/** @brief This Socket function initialise the channel in particular mode, and set the port and wait for W5200/W5100 to complete its state change. @return 1 for success else 0. */ uint8_t socket( SOCKET s, /**< for socket number */ uint8_t protocol, /**< for socket protocol */ uint16_t port, /**< the source port for the socket */ uint8_t flag /**< the option for the socket */ ) { uint8_t ret; #ifdef __DEF_WIZCHIP_DBG__ xSerialPrint_P(PSTR(" socket()\r\n")); #endif if ( (protocol == Sn_MR_TCP) || (protocol == Sn_MR_UDP) || (protocol == Sn_MR_IPRAW) || (protocol == Sn_MR_MACRAW) || (protocol == Sn_MR_PPPOE) ) { close(s); WIZCHIP_write(Sn_MR(s), (protocol | flag) ); if (port != 0) { WIZCHIP_write(Sn_PORT0(s), (uint8_t)((port & 0xff00) >> 8)); WIZCHIP_write(Sn_PORT1(s), (uint8_t)(port & 0x00ff)); } else {
/** @brief This Socket function initialize the channel in perticular mode, and set the port and wait for W5200 done it. @return 1 for sucess else 0. */ uint8 socket(SOCKET s, uint8 protocol, uint16 port, uint8 flag) { uint8 ret; if ( ((protocol&0x0F) == Sn_MR_TCP) || ((protocol&0x0F) == Sn_MR_UDP) || ((protocol&0x0F) == Sn_MR_IPRAW) || ((protocol&0x0F) == Sn_MR_MACRAW) || ((protocol&0x0F) == Sn_MR_PPPOE) ) { close(s); IINCHIP_WRITE(Sn_MR(s) ,protocol | flag); if (port != 0) { IINCHIP_WRITE( Sn_PORT0(s) ,(uint8)((port & 0xff00) >> 8)); IINCHIP_WRITE( Sn_PORT1(s) ,(uint8)(port & 0x00ff)); } else {