diff --git a/drivers/wiznet5k/ethernet/socket.c b/drivers/wiznet5k/ethernet/socket.c index 4c23481391..79e082cb51 100644 --- a/drivers/wiznet5k/ethernet/socket.c +++ b/drivers/wiznet5k/ethernet/socket.c @@ -204,13 +204,19 @@ int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port) setSn_DIPR(sn,addr); setSn_DPORT(sn,port); #if _WIZCHIP_ == 5200 // for W5200 ARP errata - setSUBR(0); + setSUBR(wizchip_getsubn()); #endif setSn_CR(sn,Sn_CR_CONNECT); while(getSn_CR(sn)); if(sock_io_mode & (1<> 8)); \ WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ @@ -1329,7 +1331,9 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); * @return uint16_t. Value of @ref INTLEVEL register. * @sa setINTLEVEL() */ -#if 0 // dpgeorge +// dpgeorge: not yet implemented +#define getINTLEVEL() (0) +#if 0 #define getINTLEVEL() \ ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) #endif @@ -1376,9 +1380,12 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); * @param (uint8_t)sir Value to set @ref SIR register. * @sa getSIR() */ +// dpgeorge: not yet implemented +#define setSIR(sir) ((void)sir) #if 0 #define setSIR(sir) \ WIZCHIP_WRITE(SIR, sir) +#endif /** * @ingroup Common_register_access_function @@ -1386,16 +1393,25 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); * @return uint8_t. Value of @ref SIR register. * @sa setSIR() */ +// dpgeorge: not yet implemented +#define getSIR() (0) +#if 0 #define getSIR() \ WIZCHIP_READ(SIR) +#endif + /** * @ingroup Common_register_access_function * @brief Set @ref SIMR register * @param (uint8_t)simr Value to set @ref SIMR register. * @sa getSIMR() */ +// dpgeorge: not yet implemented +#define setSIMR(simr) ((void)simr) +#if 0 #define setSIMR(simr) \ WIZCHIP_WRITE(SIMR, simr) +#endif /** * @ingroup Common_register_access_function @@ -1403,6 +1419,9 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); * @return uint8_t. Value of @ref SIMR register. * @sa setSIMR() */ +// dpgeorge: not yet implemented +#define getSIMR() (0) +#if 0 #define getSIMR() \ WIZCHIP_READ(SIMR) #endif @@ -1652,7 +1671,6 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); #define getSn_IR(sn) \ (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) -#if 0 // dpgeorge /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_IMR register @@ -1660,8 +1678,12 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); * @param (uint8_t)imr Value to set @ref Sn_IMR * @sa getSn_IMR() */ +// dpgeorge: not yet implemented +#define setSn_IMR(sn, imr) (void)sn; (void)imr +#if 0 #define setSn_IMR(sn, imr) \ WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) +#endif /** * @ingroup Socket_register_access_function @@ -1670,6 +1692,9 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); * @return uint8_t. Value of @ref Sn_IMR. * @sa setSn_IMR() */ +// dpgeorge: not yet implemented +#define getSn_IMR(sn) (0) +#if 0 #define getSn_IMR(sn) \ (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) #endif diff --git a/drivers/wiznet5k/ethernet/wizchip_conf.c b/drivers/wiznet5k/ethernet/wizchip_conf.c index c733cdf873..87b5427f26 100644 --- a/drivers/wiznet5k/ethernet/wizchip_conf.c +++ b/drivers/wiznet5k/ethernet/wizchip_conf.c @@ -121,6 +121,9 @@ _WIZCHIP WIZCHIP = // .IF.SPI._write_byte = wizchip_spi_writebyte }; +#if _WIZCHIP_ == 5200 // for W5200 ARP errata +static uint8_t _SUBN_[4]; // subnet +#endif static uint8_t _DNS_[4]; // DNS server ip address static dhcp_mode _DHCP_; // DHCP mode @@ -168,7 +171,7 @@ void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint } } -void reg_wizchip_spi_cbfunc((void (*spi_rb)(uint8_t *, uint32_t), void (*spi_wb)(const uint8_t *, uint32_t)) +void reg_wizchip_spi_cbfunc(void (*spi_rb)(uint8_t *, uint32_t), void (*spi_wb)(const uint8_t *, uint32_t)) { while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); @@ -584,6 +587,12 @@ void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) setGAR(pnetinfo->gw); setSUBR(pnetinfo->sn); setSIPR(pnetinfo->ip); +#if _WIZCHIP_ == 5200 // for W5200 ARP errata + _SUBN_[0] = pnetinfo->sn[0]; + _SUBN_[1] = pnetinfo->sn[1]; + _SUBN_[2] = pnetinfo->sn[2]; + _SUBN_[3] = pnetinfo->sn[3]; +#endif _DNS_[0] = pnetinfo->dns[0]; _DNS_[1] = pnetinfo->dns[1]; _DNS_[2] = pnetinfo->dns[2]; @@ -604,6 +613,12 @@ void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) pnetinfo->dhcp = _DHCP_; } +#if _WIZCHIP_ == 5200 // for W5200 ARP errata +uint8_t *wizchip_getsubn(void) { + return _SUBN_; +} +#endif + int8_t wizchip_setnetmode(netmode_type netmode) { uint8_t tmp = 0; diff --git a/drivers/wiznet5k/ethernet/wizchip_conf.h b/drivers/wiznet5k/ethernet/wizchip_conf.h index 6f4461b3f3..55c79ae0a1 100644 --- a/drivers/wiznet5k/ethernet/wizchip_conf.h +++ b/drivers/wiznet5k/ethernet/wizchip_conf.h @@ -56,7 +56,7 @@ * @todo You should select one, \b 5100, \b 5200 ,\b 5500 or etc. \n\n * ex> #define \_WIZCHIP_ 5500 */ -#define _WIZCHIP_ 5500 // 5100, 5200, 5500 +#define _WIZCHIP_ 5200 // 5100, 5200, 5500 #define _WIZCHIP_IO_MODE_NONE_ 0x0000 #define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ @@ -515,6 +515,10 @@ void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); */ void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); +#if _WIZCHIP_ == 5200 // for W5200 ARP errata +uint8_t *wizchip_getsubn(void); +#endif + /** * @ingroup extra_functions * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc.