Skip to content
Permalink
Browse files

Adds 'extern "C"' to headers if included from cpp code, prefixes sock…

…et functions with wiz_
  • Loading branch information...
avtolstoy committed Jul 2, 2018
1 parent 2166370 commit 53401b1d55b63641f60577e40e6996da59d71fd5
Showing with 56 additions and 31 deletions.
  1. +9 −0 Ethernet/W5500/w5500.h
  2. +19 −19 Ethernet/socket.c
  3. +20 −12 Ethernet/socket.h
  4. +8 −0 Ethernet/wizchip_conf.h
@@ -55,6 +55,10 @@
#if (_WIZCHIP_ == 5500)
/// @endcond

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define _W5500_IO_BASE_ 0x00000000

#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase
@@ -2148,8 +2152,13 @@ void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
*/
void wiz_recv_ignore(uint8_t sn, uint16_t len);

#ifdef __cplusplus
}
#endif /* __cplusplus */

/// @cond DOXY_APPLY_CODE
#endif
/// @endcond


#endif // _W5500_H_
@@ -102,7 +102,7 @@ uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,};



int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
int8_t wiz_socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
{
CHECK_SOCKNUM();
switch(protocol)
@@ -165,7 +165,7 @@ int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
break;
}
}
close(sn);
wiz_close(sn);
//M20150601
#if _WIZCHIP_ == 5300
setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) );
@@ -194,7 +194,7 @@ int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
return (int8_t)sn;
}

int8_t close(uint8_t sn)
int8_t wiz_close(uint8_t sn)
{
CHECK_SOCKNUM();
//A20160426 : Applied the erratum 1 of W5300
@@ -237,7 +237,7 @@ int8_t close(uint8_t sn)
return SOCK_OK;
}

int8_t listen(uint8_t sn)
int8_t wiz_listen(uint8_t sn)
{
CHECK_SOCKNUM();
CHECK_SOCKMODE(Sn_MR_TCP);
@@ -246,14 +246,14 @@ int8_t listen(uint8_t sn)
while(getSn_CR(sn));
while(getSn_SR(sn) != SOCK_LISTEN)
{
close(sn);
wiz_close(sn);
return SOCKERR_SOCKCLOSED;
}
return SOCK_OK;
}


int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port)
int8_t wiz_connect(uint8_t sn, uint8_t * addr, uint16_t port)
{
CHECK_SOCKNUM();
CHECK_SOCKMODE(Sn_MR_TCP);
@@ -293,7 +293,7 @@ int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port)
return SOCK_OK;
}

int8_t disconnect(uint8_t sn)
int8_t wiz_disconnect(uint8_t sn)
{
CHECK_SOCKNUM();
CHECK_SOCKMODE(Sn_MR_TCP);
@@ -306,14 +306,14 @@ int8_t disconnect(uint8_t sn)
{
if(getSn_IR(sn) & Sn_IR_TIMEOUT)
{
close(sn);
wiz_close(sn);
return SOCKERR_TIMEOUT;
}
}
return SOCK_OK;
}

int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
int32_t wiz_send(uint8_t sn, uint8_t * buf, uint16_t len)
{
uint8_t tmp=0;
uint16_t freesize=0;
@@ -343,7 +343,7 @@ int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
}
else if(tmp & Sn_IR_TIMEOUT)
{
close(sn);
wiz_close(sn);
return SOCKERR_TIMEOUT;
}
else return SOCK_BUSY;
@@ -356,7 +356,7 @@ int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
tmp = getSn_SR(sn);
if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT))
{
close(sn);
wiz_close(sn);
return SOCKERR_SOCKSTATUS;
}
if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
@@ -381,7 +381,7 @@ int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
}


int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len)
int32_t wiz_recv(uint8_t sn, uint8_t * buf, uint16_t len)
{
uint8_t tmp = 0;
uint16_t recvsize = 0;
@@ -416,13 +416,13 @@ int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len)
if(recvsize != 0) break;
else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn))
{
close(sn);
wiz_close(sn);
return SOCKERR_SOCKSTATUS;
}
}
else
{
close(sn);
wiz_close(sn);
return SOCKERR_SOCKSTATUS;
}
}
@@ -486,7 +486,7 @@ int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len)
return (int32_t)len;
}

int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port)
int32_t wiz_sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port)
{
uint8_t tmp = 0;
uint16_t freesize = 0;
@@ -590,7 +590,7 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t



int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port)
int32_t wiz_recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port)
{
//M20150601 : For W5300
#if _WIZCHIP_ == 5300
@@ -709,7 +709,7 @@ int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16
#endif
if(sock_remained_size[sn] > 1514)
{
close(sn);
wiz_close(sn);
return SOCKFATAL_PACKLEN;
}
sock_pack_info[sn] = PACK_FIRST;
@@ -772,7 +772,7 @@ int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16
}


int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg)
int8_t wiz_ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg)
{
uint8_t tmp = 0;
CHECK_SOCKNUM();
@@ -871,7 +871,7 @@ int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg)
return SOCK_OK;
}

int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg)
int8_t wiz_getsockopt(uint8_t sn, sockopt_type sotype, void* arg)
{
CHECK_SOCKNUM();
switch(sotype)
@@ -87,6 +87,10 @@

#include "wizchip_conf.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define SOCKET uint8_t ///< SOCKET type define for legacy driver

#define SOCK_OK 1 ///< Result is OK about socket process.
@@ -159,7 +163,7 @@
* @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n
* @ref SOCKERR_SOCKFLAG - Invaild socket flag.
*/
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
int8_t wiz_socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);

/**
* @ingroup WIZnet_socket_APIs
@@ -171,7 +175,7 @@ int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
* @return @b Success : @ref SOCK_OK \n
* @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number
*/
int8_t close(uint8_t sn);
int8_t wiz_close(uint8_t sn);

/**
* @ingroup WIZnet_socket_APIs
@@ -184,7 +188,7 @@ int8_t close(uint8_t sn);
* @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n
* @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly.
*/
int8_t listen(uint8_t sn);
int8_t wiz_listen(uint8_t sn);

/**
* @ingroup WIZnet_socket_APIs
@@ -207,7 +211,7 @@ int8_t listen(uint8_t sn);
* @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n
* @ref SOCK_BUSY - In non-block io mode, it returned immediately\n
*/
int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port);
int8_t wiz_connect(uint8_t sn, uint8_t * addr, uint16_t port);

/**
* @ingroup WIZnet_socket_APIs
@@ -224,7 +228,7 @@ int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port);
* @ref SOCKERR_TIMEOUT - Timeout occurred \n
* @ref SOCK_BUSY - Socket is busy.
*/
int8_t disconnect(uint8_t sn);
int8_t wiz_disconnect(uint8_t sn);

/**
* @ingroup WIZnet_socket_APIs
@@ -244,7 +248,7 @@ int8_t disconnect(uint8_t sn);
* @ref SOCKERR_DATALEN - zero data length \n
* @ref SOCK_BUSY - Socket is busy.
*/
int32_t send(uint8_t sn, uint8_t * buf, uint16_t len);
int32_t wiz_send(uint8_t sn, uint8_t * buf, uint16_t len);

/**
* @ingroup WIZnet_socket_APIs
@@ -266,7 +270,7 @@ int32_t send(uint8_t sn, uint8_t * buf, uint16_t len);
* @ref SOCKERR_DATALEN - zero data length \n
* @ref SOCK_BUSY - Socket is busy.
*/
int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len);
int32_t wiz_recv(uint8_t sn, uint8_t * buf, uint16_t len);

/**
* @ingroup WIZnet_socket_APIs
@@ -294,7 +298,7 @@ int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len);
* @ref SOCKERR_TIMEOUT - Timeout occurred \n
* @ref SOCK_BUSY - Socket is busy.
*/
int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port);
int32_t wiz_sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port);

/**
* @ingroup WIZnet_socket_APIs
@@ -324,7 +328,7 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t
* @ref SOCKERR_SOCKNUM - Invalid socket number \n
* @ref SOCKBUSY - Socket is busy.
*/
int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port);
int32_t wiz_recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port);


/////////////////////////////
@@ -415,7 +419,7 @@ typedef enum
* @return @b Success @ref SOCK_OK \n
* @b fail @ref SOCKERR_ARG - Invalid argument\n
*/
int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg);
int8_t wiz_ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg);

/**
* @ingroup WIZnet_socket_APIs
@@ -443,7 +447,7 @@ int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg);
* - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n
* - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n
*/
int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg);
int8_t wiz_setsockopt(uint8_t sn, sockopt_type sotype, void* arg);

/**
* @ingroup WIZnet_socket_APIs
@@ -477,6 +481,10 @@ int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg);
* When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero,
* This means the zero byte UDP data(UDP Header only) received.
*/
int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg);
int8_t wiz_getsockopt(uint8_t sn, sockopt_type sotype, void* arg);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif // _SOCKET_H_
@@ -444,6 +444,10 @@ typedef struct wiz_NetTimeout_t
uint16_t time_100us; ///< time unit 100us
}wiz_NetTimeout;

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
*@brief Registers call back function for critical section of I/O functions such as
*\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF.
@@ -647,4 +651,8 @@ void wizchip_settimeout(wiz_NetTimeout* nettime);
*/
void wizchip_gettimeout(wiz_NetTimeout* nettime);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif // _WIZCHIP_CONF_H_

0 comments on commit 53401b1

Please sign in to comment.
You can’t perform that action at this time.