 |
io6Library
WIZnet Dual Stack TCP/IP Ethernet Controller Driver
|
Go to the documentation of this file.
76 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
87 iodata_t
wizchip_bus_read(uint32_t AddrSel) {
return * ((
volatile iodata_t *)((ptrdiff_t) AddrSel)); }
98 void wizchip_bus_write(uint32_t AddrSel, iodata_t wb) { *((
volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; }
116 if(addrinc) addrinc =
sizeof(iodata_t);
117 for ( i = 0; i < len; i++)
120 AddrSel += (uint32_t) addrinc;
140 if(addrinc) addrinc =
sizeof(iodata_t);
141 for( i = 0; i < len ; i++)
144 AddrSel += (uint32_t)addrinc;
155 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
226 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
236 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
247 #error "Undefined _WIZCHIP_IO_MODE_. You should define it"
252 static uint8_t _DNS_[4];
253 static uint8_t _DNS6_[16];
272 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
274 void (*bus_wd)(uint32_t addr, iodata_t wb),
275 void (*bus_rbuf)(uint32_t AddrSel, uint8_t* buf, datasize_t len, uint8_t inc),
276 void (*bus_wbuf)(uint32_t AddrSel, uint8_t* buf, datasize_t len, uint8_t inc) )
293 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
295 void (*spi_wb)(uint8_t wb),
296 void (*spi_rbuf)(uint8_t* buf, datasize_t len),
297 void (*spi_wbuf)(uint8_t* buf, datasize_t len) )
315 uint8_t tmp = *(uint8_t*) arg;
317 uint8_t* ptmp[2] = {0,0};
331 *(uint8_t*)arg =
getSYSR() >> 5;
339 ptmp[0] = (uint8_t*)arg;
375 ((uint8_t*)arg)[5] = 0;
378 *(uint16_t*)arg =
getVER();
473 uint8_t gw[4], sn[4], sip[4], gw6[16], sn6[16], lla[16], gua[16];
529 uint8_t ir = (uint8_t)intr;
530 uint8_t sir = (uint8_t)((uint32_t)intr >> 8);
531 uint8_t slir = (uint8_t)((uint32_t)intr >> 16);
543 ret = (((uint32_t)
getSLIR())<<16) | (((uint32_t)
getSIR())<<8) | (((uint32_t)
getIR()));
549 uint8_t imr = (uint8_t)intr;
550 uint8_t simr = (uint8_t)((uint32_t)intr >> 8);
551 uint8_t slimr = (uint8_t)((uint32_t)intr >> 16);
566 #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_)
568 #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_)
576 #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_)
581 #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_)
589 #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_)
608 #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_)
632 #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_)
639 #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_)
661 #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_)
666 #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_)
677 #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_)
679 #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_)
697 for(i=0; i<4; i++) _DNS_[i] = pnetinfo->
dns[i];
698 for(i=0; i<16; i++) _DNS6_[i] = pnetinfo->
dns6[i];
700 _IPMODE_ = pnetinfo->
ipmode;
716 for(i=0; i<4; i++) pnetinfo->
dns[i] = _DNS_[i];
717 for(i=0; i<16; i++) pnetinfo->
dns6[i] = _DNS6_[i];
719 pnetinfo->
ipmode = _IPMODE_;
724 uint32_t tmp = (uint32_t) netmode;
771 while((tmp =
getSLIR()) == 0x00);
797 while((tmp =
getSLIR()) == 0x00);
809 while((tmp =
getSLIR()) == 0x00);
820 while((tmp =
getSLIR()) == 0x00);
839 while((tmp =
getSLIR()) == 0x00);
#define BMCR_PWDN
Ethernet PHY Power Down Mode.
#define PHY_MODE_TE
Configured PHY operation mode with 10Base-Te.
#define PHY_LINK_OFF
PHY Link Off. Refer to CW_GET_PHYLINK.
uint8_t ip[16]
Destination IP Address. IPv4 index : 0 to 3, IPv6 index : 0 to 15.
#define getSLDHAR(sldhar)
uint16_t wiz_mdio_read(uint8_t phyregaddr)
Read data from the PHY via MDC/MDIO interface.
ipconf_mode
IP Address Configuration Mode.
@ CNS_DAD
Duplicated IPv6 Address Detection.
#define setSn_TXBUF_SIZE(sn, tmsr)
ctlnetwork_type
Network control type enumeration.
uint8_t sl_retry_cnt
The retry count of SOCKET-less.
void wizchip_bus_read_buf(uint32_t AddrSel, iodata_t *buf, datasize_t len, uint8_t addrinc)
Default function to read iodata_t buffer by using BUS interface.
@ CW_SET_SYSCLK
Set the system clock with SYSCLK_100MHZ or SYSCLK_10MHZ only when SYS_CHIP_LOCK is unlock.
#define SLCR_ARP6
IPv6 ARP Command.
uint8_t duplex
set by PHY_DUPLEX_HALF PHY_DUPLEX_FULL
#define PHY_MODE_MANUAL
Configured PHY operation mode with user setting. Refer to CW_SET_PHYCONF and CW_GET_PHYCONF.
@ CN_SET_NETMODE
Set network mode with netmode_type.
void wizchip_cs_deselect(void)
Default function to de-select _WIZCHIP_.
#define SYSCLK_100MHZ
System Clock 100MHz. Refer to Refer to CW_SET_SYSCLK and CW_GET_SYSCLK.
void(* _write_byte_buf)(uint8_t *pBuf, datasize_t len)
Write byte data as many as len to _WIZCHIP_ through SPI.
@ CW_SET_PHYPOWMODE
Set PHY power mode with PHY_POWER_NORM or PHY_POWER_DOWN.
#define setSn_RXBUF_SIZE(sn, rmsr)
uint8_t lla[16]
Source Link Local Address.
uint8_t gua[16]
Source Global Unicast Address.
void wizchip_spi_read_buf(uint8_t *buf, datasize_t len)
Default function to read buffer by using SPI interface.
#define SYS_PHY_LOCK
PHY LOCK. Refer to CW_SYS_LOCK, CW_SYS_UNLOCK, and CW_GET_SYSLOCK.
@ CN_SET_PREFER
Set the preferred source IPv6 address of _SLCR_. Refer to IPV6_ADDR_AUTO, IPV6_ADDR_LLA,...
#define SLIR_TOUT
TOUT bit of _SLIR_.
uint8_t dns[4]
DNS server IPv4 Address.
#define PHY_DUPLEX_FULL
PHY Link Full-Duplex. Refer to CW_SET_PHYCONF and CW_GET_PHYCONF.
#define PHY_SPEED_10
PHY Link Speed 10. Refer to CW_SET_PHYCONF and CW_GET_PHYCONF.
#define SLCR_RS
IPv6 Auto-configuration RS Command.
@ CW_GET_INTERRUPT
Get the interrupt status with intr_kind.
void(* _d_e_s_e_l_e_c_t_)(void)
_WIZCHIP_ deselected
uint16_t if_mode
HOST Interface Mode.
void wizchip_spi_write_buf(uint8_t *buf, datasize_t len)
Default function to write buffer by using SPI interface.
Destination Information & Destination Hardware Address for CNS_ARP.
void(* _read_data_buf)(uint32_t AddrSel, iodata_t *pBuf, datasize_t len, uint8_t addrinc)
Read iodata_t as many as len from _WIZCHIP_ through BUS.
@ CN_GET_NETINFO
Get Network with wiz_NetInfo.
#define BMCR_RST
Ethernet PHY S/W Reset.
@ CW_GET_PHYPOWMODE
Get PHY Power mode with PHY_POWER_NORM or PHY_POWER_DOWN.
#define setPHYCR1(phycr1)
void(* _e_n_t_e_r_)(void)
critical section enter
@ CNS_SLAAC
Stateless Address Auto-configuration(SLAAC) with wiz_Prefix.
uint8_t dha[6]
Destination Hardware Address when ARP-reply is received from the destination.
uint8_t dns6[16]
DNS server IPv6 Address.
uint8_t mode
set by PHY_MODE_MANUAL ,PHY_MODE_AUTONEGO, or PHY_MODE_TE
#define BMCR_SPD
Ethernet PHY Speed.
void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void))
Registers call back functions for _WIZCHIP_ select & deselect.
@ CNS_PING
PING process with wiz_IPAddress.
#define setINTPTMR(intptmr)
uint8_t gw6[16]
Gateway IPv6 Address.
#define _WIZCHIP_IO_MODE_SPI_
SPI interface mode. Refer to _WIZCHIP_IO_MODE_SPI_VDM_ or _WIZCHIP_IO_MODE_SPI_FDM_.
#define PHY_DUPLEX_HALF
PHY Link Half-Duplex. Refer to CW_SET_PHYCONF and CW_GET_PHYCONF.
@ CW_GET_SYSCLK
Get the system clock with SYSCLK_100MHZ or SYSCLK_10MHZ.
netmode_type
Network mode Configuration.
_WIZCHIP_T_ WIZCHIP
_WIZCHIP_T_ instance
@ CW_SET_PHYCONF
Set PHY operation mode (Manual/Auto, 10/100, Half/Full) with wiz_PhyConf.
@ CN_GET_NETMODE
Get network mode with netmode_type.
@ CW_GET_PHYLINK
Get PHY Link status with PHY_LINK_ON or PHY_LINK_OFF.
uint8_t len
Destination IP Address Length. IPv4 : 4, IPv6 : 16.
@ CW_SET_INTRMASK
Set the interrupt mask with intr_kind.
#define SYCR1_IEN
IEN bit of _SYCR1_.
ctlwizchip_type
_WIZCHIP_ Control Type Enumeration.
#define SLIR_ARP6
ARP6 bit of _SLIR_.
ctlnetservice_type
Network Service Control Type enumeration.
@ CNS_ARP
ARP process with wiz_IPAddress.
Callback function set for _WIZCHIP_.
#define setPINGSEQR(pingseqr)
uint8_t(* _read_byte)(void)
Read 1 byte data from _WIZCHIP_ through SPI.
#define PHY_POWER_NORM
PHY power normal mode. Refer to CW_SET_PHYPOWMODE and CW_GET_PHYPOWMODE.
#define PHYSR_DPX
DPX mask bit of _PHYSR_.
#define PHY_POWER_DOWN
PHY power down mode. Refer to CW_SET_PHYPOWMODE and CW_GET_PHYPOWMODE.
#define setSLDIP4R(sldip4r)
@ CW_INIT_WIZCHIP
Initialize to SOCKETn buffer size with n byte array typed uint8_t.
#define BMCR_DPX
Ethernet PHY Duplex.
uint8_t sn6[16]
IPv6 Prefix.
@ CN_SET_TIMEOUT
Set network timeout with wiz_NetTimeout.
#define setNETMR2(netmr2)
void reg_wizchip_spi_cbfunc(uint8_t(*spi_rb)(void), void(*spi_wb)(uint8_t wb), void(*spi_rbuf)(uint8_t *buf, datasize_t len), void(*spi_wbuf)(uint8_t *buf, datasize_t len))
Registers call back functions for SPI interface.
@ CW_SYS_LOCK
Lock or Unlock _WIZCHIP_ with SYS_CHIP_LOCK, SYS_PHY_LOCK, and SYS_NET_LOCK.
#define SLIR_RS
RS bit of _SLIR_.
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Write 1 iodata_t to _WIZCHIP_ through BUS.
void wizchip_spi_write(uint8_t wb)
Default function to write one byte by using SPI interface.
#define PHYRAR_BMCR
Basic Mode Control Register of Ethernet PHY [RW][0x3100].
#define PHY_SPEED_100
PHY Link Speed 100. Refer to CW_SET_PHYCONF and CW_GET_PHYCONF.
iodata_t wizchip_bus_read(uint32_t AddrSel)
Default function to read one iodata_t data by using BUS interface.
struct __WIZCHIP_T__::_CRIS CRIS
The set of _WIZCHIP_ select control callback function.
@ CW_GET_PHYSTATUS
Get real operation mode with wiz_PhyConf when PHY is linked up.
@ CW_GET_ID
Get _WIZCHIP_ name.
@ CW_GET_INTRTIME
Get the interrupt pending time.
Network Timeout for _WIZCHIP_.
void(* _e_x_i_t_)(void)
critical section exit
uint8_t mac[6]
Source Hardware Address.
void(* _write_data_buf)(uint32_t AddrSel, iodata_t *pBuf, datasize_t len, uint8_t addrinc)
Write iodata_t data as many as len to _WIZCHIP_ through BUS.
struct __WIZCHIP_T__::_IF::_BUS BUS
The callback function of _WIZCHIP_IO_MODE_SPI_ such as _WIZCHIP_IO_MODE_SPI_VDM_ and _WIZCHIP_IO_MODE...
@ CW_GET_SYSLOCK
Get the lock status of _WIZCHIP_ with SYS_CHIP_LOCK, SYS_PHY_LOCK, and SYS_NET_LOCK.
#define SYSR_NETL
NET Lock status bit of _SYSR_.
void wizchip_bus_write(uint32_t AddrSel, iodata_t wb)
Default function to write one iodata_t data by using BUS interface.
uint8_t speed
set by PHY_SPEED_10 or PHY_SPEED_100
@ CW_GET_INTRMASK
Get the interrupt mask with intr_kind.
#define setSn_IRCLR(sn, irclr)
#define _WIZCHIP_SOCK_NUM_
Define I/O base address of _WIZCHIP_.
uint16_t s_time_100us
The retransmission time of SOCKETn (unit 100us)
union __WIZCHIP_T__::_IF IF
ipconf_mode ipmode
IP Configuration Mode.
uint8_t prefix[16]
Prefix.
uint8_t wizchip_spi_read(void)
Default function to read one byte by using SPI interface.
#define SLCR_PING4
IPv4 PING Command.
#define PHYCR0_AUTO
PHY Operation Mode - Auto Negotiation.
uint32_t preferred_lifetime
Preferred Lifetime.
#define SLCR_ARP4
IPv4 ARP Command.
void(* _write_byte)(uint8_t wb)
Write 1 byte data to _WIZCHIP_ through SPI.
uint8_t gw[4]
Gateway IPv4 Address.
@ CNS_GET_PREFIX
Get prefix information with wiz_Prefix.
void(* _s_e_l_e_c_t_)(void)
_WIZCHIP_ selected
#define setSLIRCLR(slirclr)
#define PHY_MODE_AUTONEGO
Configured PHY operation mode with auto-negotiation. Refer to CW_SET_PHYCONF and CW_GET_PHYCONF.
iodata_t(* _read_data)(uint32_t AddrSel)
Read 1 iodata_t from _WIZCHIP_ through BUS.
void(* _read_byte_buf)(uint8_t *pBuf, datasize_t len)
Read byte data as many as len from _WIZCHIP_ through SPI.
#define SYCR1_CLKSEL
System Clock select mask bit of _SYCR1_.
#define setNET4MR(net4mr)
#define SLIR_PING4
PING4 bit of _SLIR_.
struct __WIZCHIP_T__::_CS CS
The set of interface IO callback function.
void wiz_mdio_write(uint8_t phyregaddr, uint16_t var)
Write data to the PHY via MDC/MDIO interface.
@ CW_SET_INTRTIME
Set the interrupt pending time.
#define SLCR_PING6
IPv6 PING Command.
#define PHYCR1_RST
PHY function - HW Reset.
void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void))
Registers call back functions for critical section.
#define BMSR_LINK_STATUS
Ethernet PHY Link Status.
@ CW_CLR_INTERRUPT
Clear the interrupt with intr_kind.
#define PHYRAR_BMSR
Basic Mode Status Register of Ethernet PHY [RO][0x7809].
#define SYCR0_RST
RST bit of _SYCR0_.
void reg_wizchip_bus_cbfunc(iodata_t(*bus_rd)(uint32_t addr), void(*bus_wd)(uint32_t addr, iodata_t wb), void(*bus_rbuf)(uint32_t addr, iodata_t *buf, datasize_t len, uint8_t inc), void(*bus_wbuf)(uint32_t addr, iodata_t *buf, datasize_t len, uint8_t inc))
Registers call back functions for BUS interface.
#define PHY_LINK_ON
PHY Link On. Refer to CW_GET_PHYLINK.
#define SYS_CHIP_LOCK
CHIP LOCK. Refer to CW_SYS_LOCK, CW_SYS_UNLOCK, and CW_GET_SYSLOCK.
@ CN_SET_NETINFO
Set Network with wiz_NetInfo.
uint8_t ip[4]
Source IPv4 Address.
#define SLIR_PING6
PING6 bit of _SLIR_.
@ CNS_UNSOL_NA
Unsolicited Neighbor Advertisement for update _WIZCHIP_ network information to neighbors.
@ CW_SET_IEN
Set the global interrupt enable only when SYS_CHIP_LOCK is not set.
#define _WIZCHIP_IO_MODE_BUS_
Bus interface mode. Refer to _WIZCHIP_IO_MODE_BUS_DIR_ or _WIZCHIP_IO_MODE_BUS_INDIR_.
#define setNET6MR(net6mr)
uint8_t id[6]
ID of CHIP such as W6100, and so on.
@ CN_GET_TIMEOUT
Get network timeout with wiz_NetTimeout.
wiz_IPAddress destinfo
Destination IP address for ARP-request.
#define SYSCLK_25MHZ
System Clock 25MHz. Refer to Refer to CW_SET_SYSCLK and CW_GET_SYSCLK.
void wizchip_cris_enter(void)
Default function to enter the critical section for _WIZCHIP_.
#define SLIR_RA
ICMPv6 RA Received Interrupt.
#define SYS_NET_LOCK
NETWORK Information LOCK. Refer to CW_SYS_LOCK, CW_SYS_UNLOCK, and CW_GET_SYSLOCK.
Network Information for _WIZCHIP_.
void wizchip_bus_write_buf(uint32_t AddrSel, iodata_t *buf, datasize_t len, uint8_t addrinc)
Default function to write iodata_t buffer by using BUS interface.
Ethernet PHY operation mode configuration.
#define SLCR_UNA
IPv6 Unsolicited NA Command.
Destination Information & Destination Hardware Address for CNS_ARP.
#define setSLDIP6R(sldip6r)
uint8_t len
Prefix Length. It is used to set _SUB6R_ to 1 as many as len from LSB bit.
@ CW_RESET_WIZCHIP
Reset _WIZCHIP_ by software.
#define setPINGIDR(pingidr)
@ CN_GET_PREFER
Get the preferred source IPv6 address of _SLCR_. Refer to IPV6_ADDR_AUTO, IPV6_ADDR_LLA,...
@ CW_SYS_UNLOCK
Lock or Unlock _WIZCHIP_ with SYS_CHIP_LOCK, SYS_PHY_LOCK, and SYS_NET_LOCK.
uint8_t s_retry_cnt
The default retry count of SOCKETn.
@ CW_GET_PHYCONF
Get PHY operation mode (Manual/Auto, 10/100, Half/Full) with wiz_PhyConf.
uint16_t sl_time_100us
The retransmission time of SOCKET-less (unit 100us)
#define PHYSR_SPD
SPD mask bit of _PHYSR_.
uint32_t valid_lifetime
Valid Lifetime.
#define setPHYCR0(phycr0)
WIZCHIP Config Header File.
#define PHYCR1_PWDN
PHY function - Power Down.
#define PHYSR_LNK
LNK mask bit of _PHYSR_.
#define SLIR_ARP4
ARP4 bit of _SLIR_.
void wizchip_cs_select(void)
Default function to select _WIZCHIP_.
struct __WIZCHIP_T__::_IF::_SPI SPI
@ CW_GET_VER
Get the version of TCP/IP TOE engine.
#define SLCR_NS
IPv6 DAD(Duplicate Address Detection) NS Command.
uint8_t sn[4]
Subnet Mask value.
#define SYSR_CHPL
CHIP Lock staus bit of _SYSR_.
void wizchip_cris_exit(void)
Default function to exit the critical section for _WIZCHIP_.
@ CW_GET_IEN
Get the global interrupt enable.
#define PHYCR1_TE
PHY function - 10Base-TE Mode.
#define BMCR_ANE
Ethernet PHY Auto-Negotiation.