Socket APIs: Todo List

Socket APIs
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
Todo List
Member _WIZCHIP_
You should select one, 5100, 5200 ,5500 or etc.

ex> #define _WIZCHIP_ 5500
Member _WIZCHIP_IO_BASE_
Should re-define it to fit your system when BUS IF Mode (_WIZCHIP_IO_MODE_BUS_, _WIZCHIP_IO_MODE_BUS_DIR_, _WIZCHIP_IO_MODE_BUS_INDIR_).

ex> #define _WIZCHIP_IO_BASE_ 0x00008000
Member _WIZCHIP_IO_MODE_
Should select interface mode as chip.
  • _WIZCHIP_IO_MODE_SPI_
    -_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in _WIZCHIP_ == 5500
    -_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in _WIZCHIP_ == 5500
  • _WIZCHIP_IO_MODE_BUS_
    • _WIZCHIP_IO_MODE_BUS_DIR_
    • _WIZCHIP_IO_MODE_BUS_INDIR_
  • Others will be defined in future.

    ex> #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
Member reg_wizchip_bus_cbfunc (uint8_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, uint8_t wb))
Describe wizchip_bus_readbyte and wizchip_bus_writebyte function or register your functions.
Member reg_wizchip_cris_cbfunc (void(*cris_en)(void), void(*cris_ex)(void))
Describe WIZCHIP_CRITICAL_ENTER and WIZCHIP_CRITICAL_EXIT marco or register your functions.
Member reg_wizchip_cs_cbfunc (void(*cs_sel)(void), void(*cs_desel)(void))
Describe wizchip_cs_select and wizchip_cs_deselect function or register your functions.
Member reg_wizchip_spi_cbfunc (uint8_t(*spi_rb)(void), void(*spi_wb)(uint8_t wb))
Describe wizchip_spi_readbyte and wizchip_spi_writebyte function or register your functions.
Member reg_wizchip_spiburst_cbfunc (void(*spi_rb)(uint8_t *pBuf, uint16_t len), void(*spi_wb)(uint8_t *pBuf, uint16_t len))
Describe wizchip_spi_readbyte and wizchip_spi_writebyte function or register your functions.
Generated on Mon Apr 13 2015 09:40:04 for Socket APIs by doxygen 1.8.4


Socket APIs: Modules

  • Modules
  • Classes
  • Files
Modules
Here is a list of all modules:
o 1. WIZnet socket APIs | WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. But there is a little bit of difference
o 2. WIZnet Extra Functions | These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions
\ DATA TYPE |
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: 1. WIZnet socket APIs

Functions
1. WIZnet socket APIs

WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. But there is a little bit of difference. More...

Functions

int8_t | socket (uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket. More...
int8_t | close (uint8_t sn)
Close a socket. More...
int8_t | listen (uint8_t sn)
Listen to a connection request from a client. More...
int8_t | connect (uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server. More...
int8_t | disconnect (uint8_t sn)
Try to disconnect a connection socket. More...
int32_t | send (uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket. More...
int32_t | recv (uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer. More...
int32_t | sendto (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port)
Sends datagram to the peer with destination IP address and port number passed as parameter. More...
int32_t | recvfrom (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW. More...
int8_t | ctlsocket (uint8_t sn, ctlsock_type cstype, void *arg)
Control socket. More...
int8_t | setsockopt (uint8_t sn, sockopt_type sotype, void *arg)
set socket options More...
int8_t | getsockopt (uint8_t sn, sockopt_type sotype, void *arg)
get socket options More...

Detailed Description

WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. But there is a little bit of difference.

Comparison between WIZnet and Berkeley SOCKET APIs

API | WIZnet | Berkeley
socket() | O | O
bind() | X | O
listen() | O | O
connect() | O | O
accept() | X | O
recv() | O | O
send() | O | O
recvfrom() | O | O
sendto() | O | O
closesocket() | O close() & disconnect() | O

There are bind() and accept() functions in Berkeley SOCKET API but, not in WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request.
When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. When the listen SOCKET accepts a connection request from a client, it keeps listening. After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client.
Following figure shows network flow diagram by Berkeley SOCKET API.

<Berkeley SOCKET API>

But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number.
Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, it is changed in order to communicate with the client. And the changed SOCKET is not listening any more and is dedicated for communicating with the client.
If there're many listen SOCKET with same listen port number and a client requests a connection, the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET.
Following figure shows network flow diagram by WIZnet SOCKET API.

<WIZnet SOCKET API>

Function Documentation

int8_t socket | ( | uint8_t | sn,
 |  | uint8_t | protocol,
 |  | uint16_t | port,
 |  | uint8_t | flag
 | ) |  |

Open a socket.

Initializes the socket with 'sn' passed as parameter and open.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
protocol | Protocol type to operate such as TCP, UDP and MACRAW.
port | Port number to be bined.
flag Socket flags as SF_ETHER_OWN, SF_IGMP_VER2, SF_TCP_NODELAY, SF_MULTI_ENABLE, SF_IO_NONBLOCK and so on.
Valid flags only in W5500 : SF_BROAD_BLOCK, SF_MULTI_BLOCK, SF_IPv6_BLOCK, and SF_UNI_BLOCK.
See Also
Sn_MR
Returns
Success : The socket number 'sn' passed as parameter
Fail :
SOCKERR_SOCKNUM - Invalid socket number
SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on.
SOCKERR_SOCKFLAG - Invaild socket flag.

Definition at line 94 of file socket.c.

References CHECK_SOCKNUM, close(), SF_IGMP_VER2, SF_IO_NONBLOCK, SF_MULTI_ENABLE, SF_TCP_NODELAY, SF_UNI_BLOCK, SOCK_ANY_PORT_NUM, SOCKERR_SOCKFLAG, SOCKERR_SOCKINIT, and SOCKERR_SOCKMODE.

int8_t close ( uint8_t sn)

Close a socket.

It closes the socket with 'sn' passed as parameter.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
Success : SOCK_OK
Fail : SOCKERR_SOCKNUM - Invalid socket number

Definition at line 165 of file socket.c.

References CHECK_SOCKNUM, and SOCK_OK.

Referenced by disconnect(), listen(), recv(), recvfrom(), send(), and socket().

int8_t listen ( uint8_t sn)

Listen to a connection request from a client.

It is listening to a connection request from a client. If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
Success : SOCK_OK
Fail :
SOCKERR_SOCKINIT - Socket is not initialized
SOCKERR_SOCKCLOSED - Socket closed unexpectedly.

Definition at line 184 of file socket.c.

References CHECK_SOCKINIT, CHECK_SOCKMODE, CHECK_SOCKNUM, close(), SOCK_OK, and SOCKERR_SOCKCLOSED.

int8_t connect | ( | uint8_t | sn,
 |  | uint8_t * | addr,
 |  | uint16_t | port
 | ) |  |

Try to connect a server.

It requests connection to the server with destination IP address and port number passed as parameter.

Note
It is valid only in TCP client mode. In block io mode, it does not return until connection is completed. In Non-block io mode, it return SOCK_BUSY immediately.
Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
addr | Pointer variable of destination IP address. It should be allocated 4 bytes.
port | Destination port number.
Returns
Success : SOCK_OK
Fail :
SOCKERR_SOCKNUM - Invalid socket number
SOCKERR_SOCKMODE - Invalid socket mode
SOCKERR_SOCKINIT - Socket is not initialized
SOCKERR_IPINVALID - Wrong server IP address
SOCKERR_PORTZERO - Server port zero
SOCKERR_TIMEOUT - Timeout occurred during request connection
SOCK_BUSY - In non-block io mode, it returned immediately

Definition at line 203 of file socket.c.

References CHECK_SOCKINIT, CHECK_SOCKMODE, CHECK_SOCKNUM, SOCK_BUSY, SOCK_OK, SOCKERR_IPINVALID, SOCKERR_PORTZERO, SOCKERR_SOCKCLOSED, and SOCKERR_TIMEOUT.

int8_t disconnect ( uint8_t sn)

Try to disconnect a connection socket.

It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client.

Note
It is valid only in TCP server or client mode.
In block io mode, it does not return until disconnection is completed.
In Non-block io mode, it return SOCK_BUSY immediately.
Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
Success : SOCK_OK
Fail :
SOCKERR_SOCKNUM - Invalid socket number
SOCKERR_SOCKMODE - Invalid operation in the socket
SOCKERR_TIMEOUT - Timeout occurred
SOCK_BUSY - Socket is busy.

Definition at line 243 of file socket.c.

References CHECK_SOCKMODE, CHECK_SOCKNUM, close(), SOCK_BUSY, SOCK_OK, and SOCKERR_TIMEOUT.

int32_t send | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | len
 | ) |  |

Send data to the connected peer in TCP socket.

It is used to send outgoing data to the connected socket.

Note
It is valid only in TCP server or client mode. It can't send data greater than socket buffer size.
In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data.
In non-block io mode, It return SOCK_BUSY immediately when socket buffer is not enough.
Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
buf | Pointer buffer containing data to be sent.
len | The byte length of data in buf.
Returns
Success : The sent data size
Fail :
SOCKERR_SOCKSTATUS - Invalid socket status for socket operation
SOCKERR_TIMEOUT - Timeout occurred
SOCKERR_SOCKMODE - Invalid operation in the socket
SOCKERR_SOCKNUM - Invalid socket number
SOCKERR_DATALEN - zero data length
SOCK_BUSY - Socket is busy.

Definition at line 263 of file socket.c.

References CHECK_SOCKDATA, CHECK_SOCKMODE, CHECK_SOCKNUM, close(), SOCK_BUSY, SOCKERR_SOCKSTATUS, and SOCKERR_TIMEOUT.

int32_t recv | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | len
 | ) |  |

Receive data from the connected peer.

It is used to read incoming data from the connected socket.
It waits for data as much as the application wants to receive.

Note
It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size.
In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer.
In non-block io mode, it return SOCK_BUSY immediately when len is greater than data size in socket buffer.
Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
buf | Pointer buffer to read incoming data.
len | The max data length of data in buf.
Returns
Success : The real received data size
Fail :
SOCKERR_SOCKSTATUS - Invalid socket status for socket operation
SOCKERR_SOCKMODE - Invalid operation in the socket
SOCKERR_SOCKNUM - Invalid socket number
SOCKERR_DATALEN - zero data length
SOCK_BUSY - Socket is busy.

Definition at line 326 of file socket.c.

References CHECK_SOCKDATA, CHECK_SOCKMODE, CHECK_SOCKNUM, close(), SOCK_BUSY, and SOCKERR_SOCKSTATUS.

int32_t sendto | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | len,
 |  | uint8_t * | addr,
 |  | uint16_t | port
 | ) |  |

Sends datagram to the peer with destination IP address and port number passed as parameter.

It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.
Even if the connectionless socket has been previously connected to a specific address, the address and port number parameters override the destination address for that particular datagram only.

Note
In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. In non-block io mode, It return SOCK_BUSY immediately when socket buffer is not enough.
Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
buf | Pointer buffer to send outgoing data.
len | The byte length of data in buf.
addr | Pointer variable of destination IP address. It should be allocated 4 bytes.
port | Destination port number.
Returns
Success : The sent data size
Fail :
SOCKERR_SOCKNUM - Invalid socket number
SOCKERR_SOCKMODE - Invalid operation in the socket
SOCKERR_SOCKSTATUS - Invalid socket status for socket operation
SOCKERR_DATALEN - zero data length
SOCKERR_IPINVALID - Wrong server IP address
SOCKERR_PORTZERO - Server port zero
SOCKERR_SOCKCLOSED - Socket unexpectedly closed
SOCKERR_TIMEOUT - Timeout occurred
SOCK_BUSY - Socket is busy.

Definition at line 369 of file socket.c.

References CHECK_SOCKDATA, CHECK_SOCKNUM, SOCK_BUSY, SOCKERR_IPINVALID, SOCKERR_PORTZERO, SOCKERR_SOCKCLOSED, SOCKERR_SOCKMODE, SOCKERR_SOCKSTATUS, and SOCKERR_TIMEOUT.

int32_t recvfrom | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | len,
 |  | uint8_t * | addr,
 |  | uint16_t * | port
 | ) |  |

Receive datagram of UDP or MACRAW.

This function is an application I/F function which is used to receive the data in other then TCP mode.
This function is used to receive UDP and MAC_RAW mode, and handle the header as well. This function can divide to received the packet data. On the MACRAW SOCKET, the addr and port parameters are ignored.

Note
In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer In non-block io mode, it return SOCK_BUSY immediately when len is greater than data size in socket buffer.
Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
buf | Pointer buffer to read incoming data.
len | The max data length of data in buf. When the received packet size <= len, receives data as packet sized. When others, receives data as len.
addr | Pointer variable of destination IP address. It should be allocated 4 bytes. It is valid only when the first call recvfrom for receiving the packet. When it is valid, packinfo[7] should be set as '1' after call getsockopt(sn, SO_PACKINFO, &packinfo).
port | Pointer variable of destination port number. It is valid only when the first call recvform for receiving the packet. When it is valid, packinfo[7] should be set as '1' after call getsockopt(sn, SO_PACKINFO, &packinfo).
Returns
Success : This function return real received data size for success.
Fail : SOCKERR_DATALEN - zero data length
SOCKERR_SOCKMODE - Invalid operation in the socket
SOCKERR_SOCKNUM - Invalid socket number
SOCKBUSY - Socket is busy.

Definition at line 460 of file socket.c.

References CHECK_SOCKDATA, CHECK_SOCKNUM, close(), PACK_COMPLETED, PACK_FIRST, PACK_REMAINED, SOCK_BUSY, SOCKERR_SOCKCLOSED, SOCKERR_SOCKMODE, and SOCKFATAL_PACKLEN.

int8_t ctlsocket | ( | uint8_t | sn,
 |  | ctlsock_type | cstype,
 |  | void * | arg
 | ) |  |

Control socket.

Control IO mode, Interrupt & Mask of socket and get the socket buffer information. Refer to ctlsock_type.

Parameters
sn | socket number
cstype | type of control socket. refer to ctlsock_type.
arg Data type and value is determined according to ctlsock_type.
cstype data type value
CS_SET_IOMODE
CS_GET_IOMODE 		uint8_t SOCK_IO_BLOCK SOCK_IO_NONBLOCK
CS_GET_MAXTXBUF
CS_GET_MAXRXBUF 		uint16_t 0 ~ 16K
CS_CLR_INTERRUPT
CS_GET_INTERRUPT
CS_SET_INTMASK
CS_GET_INTMASK 		sockint_kind SIK_CONNECTED, etc.
Returns
Success SOCK_OK
fail SOCKERR_ARG - Invalid argument

Definition at line 583 of file socket.c.

References CHECK_SOCKNUM, CS_CLR_INTERRUPT, CS_GET_INTERRUPT, CS_GET_INTMASK, CS_GET_IOMODE, CS_GET_MAXRXBUF, CS_GET_MAXTXBUF, CS_SET_INTMASK, CS_SET_IOMODE, SIK_ALL, SOCK_IO_BLOCK, SOCK_IO_NONBLOCK, SOCK_OK, and SOCKERR_ARG.

int8_t setsockopt | ( | uint8_t | sn,
 |  | sockopt_type | sotype,
 |  | void * | arg
 | ) |  |

set socket options

Set socket option like as TTL, MSS, TOS, and so on. Refer to sockopt_type.

Parameters
sn | socket number
sotype | socket option type. refer to sockopt_type
arg Data type and value is determined according to sotype.
sotype | data type | value
SO_TTL | uint8_t | 0 ~ 255
SO_TOS | uint8_t | 0 ~ 255
SO_MSS | uint16_t | 0 ~ 65535
SO_DESTIP | uint8_t[4]
SO_DESTPORT | uint16_t | 0 ~ 65535
SO_KEEPALIVESEND | null | null
SO_KEEPALIVEAUTO | uint8_t | 0 ~ 255
Returns
  • Success : SOCK_OK
  • Fail
    • SOCKERR_SOCKNUM - Invalid Socket number
    • SOCKERR_SOCKMODE - Invalid socket mode
    • SOCKERR_SOCKOPT - Invalid socket option or its value
    • SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet

Definition at line 629 of file socket.c.

References CHECK_SOCKMODE, CHECK_SOCKNUM, SO_DESTIP, SO_DESTPORT, SO_KEEPALIVEAUTO, SO_KEEPALIVESEND, SO_MSS, SO_TOS, SO_TTL, SOCK_OK, SOCKERR_ARG, SOCKERR_SOCKOPT, and SOCKERR_TIMEOUT.

int8_t getsockopt | ( | uint8_t | sn,
 |  | sockopt_type | sotype,
 |  | void * | arg
 | ) |  |

get socket options

Get socket option like as FLAG, TTL, MSS, and so on. Refer to sockopt_type

Parameters
sn | socket number
sotype | socket option type. refer to sockopt_type
arg Data type and value is determined according to sotype.
sotype | data type | value
SO_FLAG | uint8_t | SF_ETHER_OWN, etc...
SO_TOS | uint8_t | 0 ~ 255
SO_MSS | uint16_t | 0 ~ 65535
SO_DESTIP | uint8_t[4]
SO_DESTPORT | uint16_t
SO_KEEPALIVEAUTO | uint8_t | 0 ~ 255
SO_SENDBUF | uint16_t | 0 ~ 65535
SO_RECVBUF | uint16_t | 0 ~ 65535
SO_STATUS | uint8_t | SOCK_ESTABLISHED, etc..
SO_REMAINSIZE | uint16_t | 0~ 65535
SO_PACKINFO | uint8_t | PACK_FIRST, etc...
Returns
  • Success : SOCK_OK
  • Fail
    • SOCKERR_SOCKNUM - Invalid Socket number
    • SOCKERR_SOCKOPT - Invalid socket option or its value
    • SOCKERR_SOCKMODE - Invalid socket mode
Note
The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call recvfrom().
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.

Definition at line 682 of file socket.c.

References CHECK_SOCKMODE, CHECK_SOCKNUM, SO_DESTIP, SO_DESTPORT, SO_FLAG, SO_KEEPALIVEAUTO, SO_MSS, SO_PACKINFO, SO_RECVBUF, SO_REMAINSIZE, SO_SENDBUF, SO_STATUS, SO_TOS, SO_TTL, SOCK_OK, and SOCKERR_SOCKOPT.


Socket APIs: 2. WIZnet Extra Functions

Functions
2. WIZnet Extra Functions

These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. More...

Functions

int8_t | ctlwizchip (ctlwizchip_type cwtype, void *arg)
Controls to the WIZCHIP. More...
int8_t | ctlnetwork (ctlnetwork_type cntype, void *arg)
Controls to network. More...
void | wizchip_sw_reset (void)
Reset WIZCHIP by softly. More...
int8_t | wizchip_init (uint8_t *txsize, uint8_t *rxsize)
Initializes WIZCHIP with socket buffer size. More...
void | wizchip_clrinterrupt (intr_kind intr)
Clear Interrupt of WIZCHIP. More...
intr_kind | wizchip_getinterrupt (void)
Get Interrupt of WIZCHIP. More...
void | wizchip_setinterruptmask (intr_kind intr)
Mask or Unmask Interrupt of WIZCHIP. More...
intr_kind | wizchip_getinterruptmask (void)
Get Interrupt mask of WIZCHIP. More...
void | wizphy_setphyconf (wiz_PhyConf *phyconf)
Set the phy information for WIZCHIP without power mode. More...
void | wizphy_getphyconf (wiz_PhyConf *phyconf)
Get phy configuration information. More...
void | wizphy_getphystat (wiz_PhyConf *phyconf)
Get phy status. More...
int8_t | wizphy_setphypmode (uint8_t pmode)
set the power mode of phy inside WIZCHIP. Refer to PHYCFGR in W5500, PHYSTATUS in W5200 More...
void | wizchip_setnetinfo (wiz_NetInfo *pnetinfo)
Set the network information for WIZCHIP. More...
void | wizchip_getnetinfo (wiz_NetInfo *pnetinfo)
Get the network information for WIZCHIP. More...
int8_t | wizchip_setnetmode (netmode_type netmode)
Set the network mode such WOL, PPPoE, Ping Block, and etc. More...
netmode_type | wizchip_getnetmode (void)
Get the network mode such WOL, PPPoE, Ping Block, and etc. More...
void | wizchip_settimeout (wiz_NetTimeout *nettime)
Set retry time value(RTR) and retry count(RCR). More...
void | wizchip_gettimeout (wiz_NetTimeout *nettime)
Get retry time value(RTR) and retry count(RCR). More...

Detailed Description

These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions.

There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer.

Function Documentation

int8_t ctlwizchip | ( | ctlwizchip_type | cwtype,
 |  | void * | arg
 | ) |  |

Controls to the WIZCHIP.

Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), controls interrupt & mask and so on.

Parameters
cwtype | : Decides to the control type
arg | : arg type is dependent on cwtype.
Returns
0 : Success
-1 : Fail because of invalid ctlwizchip_type or unsupported ctlwizchip_type in WIZCHIP

Definition at line 263 of file wizchip_conf.c.

References _WIZCHIP_SOCK_NUM_, CW_CLR_INTERRUPT, CW_GET_ID, CW_GET_INTERRUPT, CW_GET_INTRMASK, CW_GET_INTRTIME, CW_GET_PHYCONF, CW_GET_PHYLINK, CW_GET_PHYPOWMODE, CW_GET_PHYSTATUS, CW_INIT_WIZCHIP, CW_RESET_PHY, CW_RESET_WIZCHIP, CW_SET_INTRMASK, CW_SET_INTRTIME, CW_SET_PHYCONF, CW_SET_PHYPOWMODE, __WIZCHIP::id, wizchip_clrinterrupt(), wizchip_getinterrupt(), wizchip_getinterruptmask(), wizchip_init(), wizchip_setinterruptmask(), wizchip_sw_reset(), wizphy_getphyconf(), wizphy_getphylink(), wizphy_getphypmode(), wizphy_reset(), wizphy_setphyconf(), and wizphy_setphypmode().

int8_t ctlnetwork | ( | ctlnetwork_type | cntype,
 |  | void * | arg
 | ) |  |

Controls to network.

Controls to network environment, mode, timeout and so on.

Parameters
cntype | : Input. Decides to the control type
arg | : Inout. arg type is dependent on cntype.
Returns
-1 : Fail because of invalid ctlnetwork_type or unsupported ctlnetwork_type in WIZCHIP
0 : Success

Definition at line 343 of file wizchip_conf.c.

References CN_GET_NETINFO, CN_GET_NETMODE, CN_GET_TIMEOUT, CN_SET_NETINFO, CN_SET_NETMODE, CN_SET_TIMEOUT, wizchip_getnetinfo(), wizchip_getnetmode(), wizchip_gettimeout(), wizchip_setnetinfo(), wizchip_setnetmode(), and wizchip_settimeout().

void wizchip_sw_reset ( void )

Reset WIZCHIP by softly.

Definition at line 371 of file wizchip_conf.c.

Referenced by ctlwizchip(), and wizchip_init().

int8_t wizchip_init | ( | uint8_t * | txsize,
 |  | uint8_t * | rxsize
 | ) |  |

Initializes WIZCHIP with socket buffer size.

Parameters
txsize | Socket tx buffer sizes. If null, initialized the default size 2KB.
rxsize | Socket rx buffer sizes. If null, initialized the default size 2KB.
Returns
0 : succcess
-1 : fail. Invalid buffer size

Definition at line 385 of file wizchip_conf.c.

References _WIZCHIP_SOCK_NUM_, and wizchip_sw_reset().

Referenced by ctlwizchip().

void wizchip_clrinterrupt ( intr_kind intr)

Clear Interrupt of WIZCHIP.

Parameters
intr : intr_kind value operated OR. It can type-cast to uint16_t.

Definition at line 411 of file wizchip_conf.c.

Referenced by ctlwizchip().

intr_kind wizchip_getinterrupt ( void )

Get Interrupt of WIZCHIP.

Returns
intr_kind value operated OR. It can type-cast to uint16_t.

Definition at line 435 of file wizchip_conf.c.

Referenced by ctlwizchip().

void wizchip_setinterruptmask ( intr_kind intr)

Mask or Unmask Interrupt of WIZCHIP.

Parameters
intr : intr_kind value operated OR. It can type-cast to uint16_t.

Definition at line 459 of file wizchip_conf.c.

Referenced by ctlwizchip().

intr_kind wizchip_getinterruptmask ( void )

Get Interrupt mask of WIZCHIP.

Returns
: The operated OR vaule of intr_kind. It can type-cast to uint16_t.

Definition at line 480 of file wizchip_conf.c.

Referenced by ctlwizchip().

void wizphy_setphyconf ( wiz_PhyConf * phyconf)

Set the phy information for WIZCHIP without power mode.

Parameters
phyconf : wiz_PhyConf

Definition at line 556 of file wizchip_conf.c.

References wiz_PhyConf_t::by, wiz_PhyConf_t::duplex, wiz_PhyConf_t::mode, PHY_CONFBY_SW, PHY_DUPLEX_FULL, PHY_MODE_AUTONEGO, PHY_SPEED_100, wiz_PhyConf_t::speed, and wizphy_reset().

Referenced by ctlwizchip().

void wizphy_getphyconf ( wiz_PhyConf * phyconf)

Get phy configuration information.

Parameters
phyconf : wiz_PhyConf

Definition at line 586 of file wizchip_conf.c.

References wiz_PhyConf_t::by, wiz_PhyConf_t::duplex, wiz_PhyConf_t::mode, PHY_CONFBY_HW, PHY_CONFBY_SW, PHY_DUPLEX_FULL, PHY_DUPLEX_HALF, PHY_MODE_AUTONEGO, PHY_MODE_MANUAL, PHY_SPEED_10, PHY_SPEED_100, and wiz_PhyConf_t::speed.

Referenced by ctlwizchip().

void wizphy_getphystat ( wiz_PhyConf * phyconf)

Get phy status.

Parameters
phyconf : wiz_PhyConf

Definition at line 625 of file wizchip_conf.c.

References wiz_PhyConf_t::duplex, PHY_DUPLEX_FULL, PHY_DUPLEX_HALF, PHY_SPEED_10, PHY_SPEED_100, and wiz_PhyConf_t::speed.

int8_t wizphy_setphypmode ( uint8_t pmode)

set the power mode of phy inside WIZCHIP. Refer to PHYCFGR in W5500, PHYSTATUS in W5200

Parameters
pmode Settig value of power down mode.

Definition at line 632 of file wizchip_conf.c.

References PHY_POWER_DOWN, and wizphy_reset().

Referenced by ctlwizchip().

void wizchip_setnetinfo ( wiz_NetInfo * pnetinfo)

Set the network information for WIZCHIP.

Parameters
pnetinfo : wizNetInfo

Definition at line 658 of file wizchip_conf.c.

References wiz_NetInfo_t::dhcp, wiz_NetInfo_t::dns, wiz_NetInfo_t::gw, wiz_NetInfo_t::ip, wiz_NetInfo_t::mac, and wiz_NetInfo_t::sn.

Referenced by ctlnetwork().

void wizchip_getnetinfo ( wiz_NetInfo * pnetinfo)

Get the network information for WIZCHIP.

Parameters
pnetinfo : wizNetInfo

Definition at line 671 of file wizchip_conf.c.

References wiz_NetInfo_t::dhcp, wiz_NetInfo_t::dns, wiz_NetInfo_t::gw, wiz_NetInfo_t::ip, wiz_NetInfo_t::mac, and wiz_NetInfo_t::sn.

Referenced by ctlnetwork().

int8_t wizchip_setnetmode ( netmode_type netmode)

Set the network mode such WOL, PPPoE, Ping Block, and etc.

Parameters
pnetinfo Value of network mode. Refer to netmode_type.

Definition at line 684 of file wizchip_conf.c.

References NM_FORCEARP, NM_PINGBLOCK, NM_PPPOE, and NM_WAKEONLAN.

Referenced by ctlnetwork().

netmode_type wizchip_getnetmode ( void )

Get the network mode such WOL, PPPoE, Ping Block, and etc.

Returns
Value of network mode. Refer to netmode_type.

Definition at line 698 of file wizchip_conf.c.

Referenced by ctlnetwork().

void wizchip_settimeout ( wiz_NetTimeout * nettime)

Set retry time value(RTR) and retry count(RCR).

RTR configures the retransmission timeout period and RCR configures the number of time of retransmission.

Parameters
nettime RTR value and RCR value. Refer to wiz_NetTimeout.

Definition at line 703 of file wizchip_conf.c.

References wiz_NetTimeout_t::retry_cnt, and wiz_NetTimeout_t::time_100us.

Referenced by ctlnetwork().

void wizchip_gettimeout ( wiz_NetTimeout * nettime)

Get retry time value(RTR) and retry count(RCR).

RTR configures the retransmission timeout period and RCR configures the number of time of retransmission.

Parameters
nettime RTR value and RCR value. Refer to wiz_NetTimeout.

Definition at line 709 of file wizchip_conf.c.

References wiz_NetTimeout_t::retry_cnt, and wiz_NetTimeout_t::time_100us.

Referenced by ctlnetwork().


Socket APIs: DATA TYPE

Classes | Typedefs | Enumerations
DATA TYPE

Classes

struct | __WIZCHIP
The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200. More...
struct | wiz_PhyConf_t
struct | wiz_NetInfo_t
struct | wiz_NetTimeout_t

Typedefs

typedef struct __WIZCHIP | _WIZCHIP
The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200. More...
typedef struct wiz_PhyConf_t | wiz_PhyConf
typedef struct wiz_NetInfo_t | wiz_NetInfo
typedef struct wiz_NetTimeout_t | wiz_NetTimeout

Enumerations

enum sockint_kind {
SIK_CONNECTED = (1 << 0), SIK_DISCONNECTED = (1 << 1), SIK_RECEIVED = (1 << 2), SIK_TIMEOUT = (1 << 3),
SIK_SENT = (1 << 4), SIK_ALL = 0x1F
}
The kind of Socket Interrupt. More...
enum ctlsock_type {
CS_SET_IOMODE, CS_GET_IOMODE, CS_GET_MAXTXBUF, CS_GET_MAXRXBUF,
CS_CLR_INTERRUPT, CS_GET_INTERRUPT, CS_SET_INTMASK, CS_GET_INTMASK
}
The type of ctlsocket(). More...
enum sockopt_type {
SO_FLAG, SO_TTL, SO_TOS, SO_MSS,
SO_DESTIP, SO_DESTPORT, SO_KEEPALIVESEND, SO_KEEPALIVEAUTO,
SO_SENDBUF, SO_RECVBUF, SO_STATUS, SO_REMAINSIZE,
SO_PACKINFO
}
The type of socket option in setsockopt() or getsockopt() More...
enum ctlwizchip_type {
CW_RESET_WIZCHIP, CW_INIT_WIZCHIP, CW_GET_INTERRUPT, CW_CLR_INTERRUPT,
CW_SET_INTRMASK, CW_GET_INTRMASK, CW_SET_INTRTIME, CW_GET_INTRTIME,
CW_GET_ID, CW_RESET_PHY, CW_SET_PHYCONF, CW_GET_PHYCONF,
CW_GET_PHYSTATUS, CW_SET_PHYPOWMODE, CW_GET_PHYPOWMODE, CW_GET_PHYLINK
}
enum ctlnetwork_type {
CN_SET_NETINFO, CN_GET_NETINFO, CN_SET_NETMODE, CN_GET_NETMODE,
CN_SET_TIMEOUT, CN_GET_TIMEOUT
}
enum intr_kind {
IK_WOL = (1 << 4), IK_PPPOE_TERMINATED = (1 << 5), IK_DEST_UNREACH = (1 << 6), IK_IP_CONFLICT = (1 << 7),
IK_SOCK_0 = (1 << 8), IK_SOCK_1 = (1 << 9), IK_SOCK_2 = (1 << 10), IK_SOCK_3 = (1 << 11),
IK_SOCK_4 = (1 << 12), IK_SOCK_5 = (1 << 13), IK_SOCK_6 = (1 << 14), IK_SOCK_7 = (1 << 15),
IK_SOCK_ALL = (0xFF << 8)
}
enum | dhcp_mode { NETINFO_STATIC = 1, NETINFO_DHCP }
enum | netmode_type { NM_FORCEARP = (1<<1), NM_WAKEONLAN = (1<<5), NM_PINGBLOCK = (1<<4), NM_PPPOE = (1<<3) }

Detailed Description

Typedef Documentation

typedef struct __WIZCHIP _WIZCHIP

The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200.

typedef struct wiz_PhyConf_t wiz_PhyConf

It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, and it indicates the real PHY status configured by HW or SW in all WIZCHIP.
Valid only in W5500.

typedef struct wiz_NetInfo_t wiz_NetInfo

Network Information for WIZCHIP

typedef struct wiz_NetTimeout_t wiz_NetTimeout

Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of ctlwizchip() for timeout configruation.

Enumeration Type Documentation

enum sockint_kind

The kind of Socket Interrupt.

See Also
Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR()
Enumerator
SIK_CONNECTED | connected
SIK_DISCONNECTED | disconnected
SIK_RECEIVED | data received
SIK_TIMEOUT | timeout occurred
SIK_SENT | send ok
SIK_ALL | all interrupt

Definition at line 337 of file socket.h.

enum ctlsock_type

The type of ctlsocket().

Enumerator
CS_SET_IOMODE | set socket IO mode with SOCK_IO_BLOCK or SOCK_IO_NONBLOCK
CS_GET_IOMODE | get socket IO mode
CS_GET_MAXTXBUF | get the size of socket buffer allocated in TX memory
CS_GET_MAXRXBUF | get the size of socket buffer allocated in RX memory
CS_CLR_INTERRUPT | clear the interrupt of socket with sockint_kind
CS_GET_INTERRUPT | get the socket interrupt. refer to sockint_kind
CS_SET_INTMASK | set the interrupt mask of socket with sockint_kind, Not supported in W5100
CS_GET_INTMASK | get the masked interrupt of socket. refer to sockint_kind, Not supported in W5100

Definition at line 353 of file socket.h.

enum sockopt_type

The type of socket option in setsockopt() or getsockopt()

Enumerator
SO_FLAG | Valid only in getsockopt(), For set flag of socket refer to flag in socket().
SO_TTL | Set/Get TTL. Sn_TTL ( setSn_TTL(), getSn_TTL() )
SO_TOS | Set/Get TOS. Sn_TOS ( setSn_TOS(), getSn_TOS() )
SO_MSS | Set/Get MSS. Sn_MSSR ( setSn_MSSR(), getSn_MSSR() )
SO_DESTIP | Set/Get the destination IP address. Sn_DIPR ( setSn_DIPR(), getSn_DIPR() )
SO_DESTPORT | Set/Get the destination Port number. Sn_DPORT ( setSn_DPORT(), getSn_DPORT() )
SO_KEEPALIVESEND | Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100.
SO_KEEPALIVEAUTO | Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200.
SO_SENDBUF | Valid only in getsockopt. Get the free data size of Socekt TX buffer. Sn_TX_FSR, getSn_TX_FSR()
SO_RECVBUF | Valid only in getsockopt. Get the received data size in socket RX buffer. Sn_RX_RSR, getSn_RX_RSR()
SO_STATUS | Valid only in getsockopt. Get the socket status. Sn_SR, getSn_SR()
SO_REMAINSIZE | Valid only in getsockopt. Get the remained packet size in other then TCP mode.
SO_PACKINFO | Valid only in getsockopt. Get the packet information as PACK_FIRST, PACK_REMAINED, and PACK_COMPLETED in other then TCP mode.

Definition at line 372 of file socket.h.

enum ctlwizchip_type

WIZCHIP control type enumration used in ctlwizchip().

Enumerator
CW_RESET_WIZCHIP | Resets WIZCHIP by softly.
CW_INIT_WIZCHIP | Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t.
CW_GET_INTERRUPT | Get Interrupt status of WIZCHIP.
CW_CLR_INTERRUPT | Clears interrupt.
CW_SET_INTRMASK | Masks interrupt.
CW_GET_INTRMASK | Get interrupt mask.
CW_SET_INTRTIME | Set interval time between the current and next interrupt.
CW_GET_INTRTIME | Set interval time between the current and next interrupt.
CW_GET_ID | Gets WIZCHIP name.
CW_RESET_PHY | Resets internal PHY. Valid Only W5500.
CW_SET_PHYCONF | When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000.
CW_GET_PHYCONF | Get PHY operation mode in internal register. Valid Only W5500.
CW_GET_PHYSTATUS | Get real PHY status on operating. Valid Only W5500.
CW_SET_PHYPOWMODE | Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500.
CW_GET_PHYPOWMODE | Get PHY Power mode as down or normal, Valid Only W5100, W5200.
CW_GET_PHYLINK | Get PHY Link status, Valid Only W5100, W5200.

Definition at line 213 of file wizchip_conf.h.

enum ctlnetwork_type

Network control type enumration used in ctlnetwork().

Enumerator
CN_SET_NETINFO | Set Network with wiz_NetInfo.
CN_GET_NETINFO | Get Network with wiz_NetInfo.
CN_SET_NETMODE | Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
CN_GET_NETMODE | Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
CN_SET_TIMEOUT | Set network timeout as retry count and time.
CN_GET_TIMEOUT | Get network timeout as retry count and time.

Definition at line 242 of file wizchip_conf.h.

enum intr_kind

Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK and CW_GET_INTRMASK is used in ctlnetwork(). It can be used with OR operation.

Enumerator
IK_WOL | Wake On Lan by receiving the magic packet. Valid in W500.
IK_PPPOE_TERMINATED | PPPoE Disconnected.
IK_DEST_UNREACH | Destination IP & Port Unreachable, No use in W5200.
IK_IP_CONFLICT | IP conflict occurred.
IK_SOCK_0 | Socket 0 interrupt.
IK_SOCK_1 | Socket 1 interrupt.
IK_SOCK_2 | Socket 2 interrupt.
IK_SOCK_3 | Socket 3 interrupt.
IK_SOCK_4 | Socket 4 interrupt, No use in 5100.
IK_SOCK_5 | Socket 5 interrupt, No use in 5100.
IK_SOCK_6 | Socket 6 interrupt, No use in 5100.
IK_SOCK_7 | Socket 7 interrupt, No use in 5100.
IK_SOCK_ALL | All Socket interrupt.

Definition at line 258 of file wizchip_conf.h.

enum dhcp_mode

It used in setting dhcp_mode of wiz_NetInfo.

Enumerator
NETINFO_STATIC | Static IP configuration by manually.
NETINFO_DHCP | Dynamic IP configruation from a DHCP sever.

Definition at line 328 of file wizchip_conf.h.

enum netmode_type

Network mode

Enumerator
NM_FORCEARP | Force to APP send whenever udp data is sent. Valid only in W5500.
NM_WAKEONLAN | Wake On Lan.
NM_PINGBLOCK | Block ping-request.
NM_PPPOE | PPPoE mode.

Definition at line 352 of file wizchip_conf.h.


Socket APIs: __WIZCHIP Struct Reference

  • Class List
  • Class Index
  • Class Members
Classes | Public Attributes | List of all members
__WIZCHIP Struct Reference
DATA TYPE

The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200. More...

#include <wizchip_conf.h>

Collaboration diagram for __WIZCHIP:
[legend]

Classes

struct | _CRIS
struct | _CS
union | _IF

Public Attributes

uint16_t | if_mode
host interface mode More...
uint8_t | id [6]
WIZCHIP ID such as 5100, 5200, 5500, and so on. More...
struct __WIZCHIP::_CRIS | CRIS
struct __WIZCHIP::_CS | CS
union __WIZCHIP::_IF | IF

Detailed Description

The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200.

Definition at line 159 of file wizchip_conf.h.

Member Data Documentation

uint16_t __WIZCHIP::if_mode

host interface mode

Definition at line 161 of file wizchip_conf.h.

Referenced by reg_wizchip_bus_cbfunc(), reg_wizchip_spi_cbfunc(), and reg_wizchip_spiburst_cbfunc().

uint8_t __WIZCHIP::id[6]

WIZCHIP ID such as 5100, 5200, 5500, and so on.

Definition at line 162 of file wizchip_conf.h.

Referenced by ctlwizchip().

struct __WIZCHIP::_CRIS __WIZCHIP::CRIS

Referenced by reg_wizchip_cris_cbfunc().

struct __WIZCHIP::_CS __WIZCHIP::CS

Referenced by reg_wizchip_cs_cbfunc().

union __WIZCHIP::_IF __WIZCHIP::IF

Referenced by reg_wizchip_bus_cbfunc(), reg_wizchip_spi_cbfunc(), and reg_wizchip_spiburst_cbfunc().

The documentation for this struct was generated from the following file:
  • Ethernet/wizchip_conf.h


Socket APIs: __WIZCHIP::_CRIS Struct Reference

  • Class List
  • Class Index
  • Class Members
  • __WIZCHIP
  • _CRIS
Public Attributes | List of all members
__WIZCHIP::_CRIS Struct Reference

#include <wizchip_conf.h>

Public Attributes

void(* | _enter )(void)
crtical section enter More...
void(* | _exit )(void)
critial section exit More...

Detailed Description

The set of critical section callback func.

Definition at line 166 of file wizchip_conf.h.

Member Data Documentation

void(* __WIZCHIP::_CRIS::_enter)(void)

crtical section enter

Definition at line 168 of file wizchip_conf.h.

Referenced by reg_wizchip_cris_cbfunc().

void(* __WIZCHIP::_CRIS::_exit)(void)

critial section exit

Definition at line 169 of file wizchip_conf.h.

Referenced by reg_wizchip_cris_cbfunc().

The documentation for this struct was generated from the following file:
  • Ethernet/wizchip_conf.h


Socket APIs: __WIZCHIP::_CS Struct Reference

  • Class List
  • Class Index
  • Class Members
  • __WIZCHIP
  • _CS
Public Attributes | List of all members
__WIZCHIP::_CS Struct Reference

#include <wizchip_conf.h>

Public Attributes

void(* | _select )(void)
_WIZCHIP_ selected More...
void(* | _deselect )(void)
_WIZCHIP_ deselected More...

Detailed Description

The set of select control callback func.

Definition at line 174 of file wizchip_conf.h.

Member Data Documentation

void(* __WIZCHIP::_CS::_select)(void)

_WIZCHIP_ selected

Definition at line 176 of file wizchip_conf.h.

Referenced by reg_wizchip_cs_cbfunc().

void(* __WIZCHIP::_CS::_deselect)(void)

_WIZCHIP_ deselected

Definition at line 177 of file wizchip_conf.h.

Referenced by reg_wizchip_cs_cbfunc().

The documentation for this struct was generated from the following file:
  • Ethernet/wizchip_conf.h


Socket APIs: __WIZCHIP::_IF Union Reference

  • Class List
  • Class Index
  • Class Members
  • __WIZCHIP
  • _IF
Public Attributes | List of all members
__WIZCHIP::_IF Union Reference

#include <wizchip_conf.h>

Public Attributes

struct {
uint8_t(* _read_byte )(uint32_t AddrSel)
void(* _write_byte )(uint32_t AddrSel, uint8_t wb)
} BUS
struct {
uint8_t(* _read_byte )(void)
void(* _write_byte )(uint8_t wb)
void(* _read_burst )(uint8_t *pBuf, uint16_t len)
void(* _write_burst )(uint8_t *pBuf, uint16_t len)
} SPI

Detailed Description

The set of interface IO callback func.

Definition at line 182 of file wizchip_conf.h.

Member Data Documentation

uint8_t(* __WIZCHIP::_IF::_read_byte)(void)

Definition at line 189 of file wizchip_conf.h.

Referenced by reg_wizchip_bus_cbfunc(), and reg_wizchip_spi_cbfunc().

void(* __WIZCHIP::_IF::_write_byte)(uint8_t wb)

Definition at line 190 of file wizchip_conf.h.

Referenced by reg_wizchip_bus_cbfunc(), and reg_wizchip_spi_cbfunc().

struct { ... } __WIZCHIP::_IF::BUS

For BUS interface IO

Referenced by reg_wizchip_bus_cbfunc().

void(* __WIZCHIP::_IF::_read_burst)(uint8_t *pBuf, uint16_t len)

Definition at line 199 of file wizchip_conf.h.

Referenced by reg_wizchip_spiburst_cbfunc().

void(* __WIZCHIP::_IF::_write_burst)(uint8_t *pBuf, uint16_t len)

Definition at line 200 of file wizchip_conf.h.

Referenced by reg_wizchip_spiburst_cbfunc().

struct { ... } __WIZCHIP::_IF::SPI

For SPI interface IO

Referenced by reg_wizchip_spi_cbfunc(), and reg_wizchip_spiburst_cbfunc().

The documentation for this union was generated from the following file:
  • Ethernet/wizchip_conf.h


Socket APIs: wiz_PhyConf_t Struct Reference

  • Class List
  • Class Index
  • Class Members
Public Attributes | List of all members
wiz_PhyConf_t Struct Reference
DATA TYPE

#include <wizchip_conf.h>

Public Attributes

uint8_t | by
set by PHY_CONFBY_HW or PHY_CONFBY_SW More...
uint8_t | mode
set by PHY_MODE_MANUAL or PHY_MODE_AUTONEGO More...
uint8_t | speed
set by PHY_SPEED_10 or PHY_SPEED_100 More...
uint8_t | duplex
set by PHY_DUPLEX_HALF PHY_DUPLEX_FULL More...

Detailed Description

It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, and it indicates the real PHY status configured by HW or SW in all WIZCHIP.
Valid only in W5500.

Definition at line 313 of file wizchip_conf.h.

Member Data Documentation

uint8_t wiz_PhyConf_t::by

set by PHY_CONFBY_HW or PHY_CONFBY_SW

Definition at line 315 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), and wizphy_setphyconf().

uint8_t wiz_PhyConf_t::mode

set by PHY_MODE_MANUAL or PHY_MODE_AUTONEGO

Definition at line 316 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), and wizphy_setphyconf().

uint8_t wiz_PhyConf_t::speed

set by PHY_SPEED_10 or PHY_SPEED_100

Definition at line 317 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), wizphy_getphystat(), and wizphy_setphyconf().

uint8_t wiz_PhyConf_t::duplex

set by PHY_DUPLEX_HALF PHY_DUPLEX_FULL

Definition at line 318 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), wizphy_getphystat(), and wizphy_setphyconf().

The documentation for this struct was generated from the following file:
  • Ethernet/wizchip_conf.h


Socket APIs: wiz_NetInfo_t Struct Reference

  • Class List
  • Class Index
  • Class Members
Public Attributes | List of all members
wiz_NetInfo_t Struct Reference
DATA TYPE

#include <wizchip_conf.h>

Public Attributes

uint8_t | mac [6]
Source Mac Address. More...
uint8_t | ip [4]
Source IP Address. More...
uint8_t | sn [4]
Subnet Mask. More...
uint8_t | gw [4]
Gateway IP Address. More...
uint8_t | dns [4]
DNS server IP Address. More...
dhcp_mode dhcp
1 - Static, 2 - DHCP More...

Detailed Description

Network Information for WIZCHIP

Definition at line 338 of file wizchip_conf.h.

Member Data Documentation

uint8_t wiz_NetInfo_t::mac[6]

Source Mac Address.

Definition at line 340 of file wizchip_conf.h.

Referenced by wizchip_getnetinfo(), and wizchip_setnetinfo().

uint8_t wiz_NetInfo_t::ip[4]

Source IP Address.

Definition at line 341 of file wizchip_conf.h.

Referenced by wizchip_getnetinfo(), and wizchip_setnetinfo().

uint8_t wiz_NetInfo_t::sn[4]

Subnet Mask.

Definition at line 342 of file wizchip_conf.h.

Referenced by wizchip_getnetinfo(), and wizchip_setnetinfo().

uint8_t wiz_NetInfo_t::gw[4]

Gateway IP Address.

Definition at line 343 of file wizchip_conf.h.

Referenced by wizchip_getnetinfo(), and wizchip_setnetinfo().

uint8_t wiz_NetInfo_t::dns[4]

DNS server IP Address.

Definition at line 344 of file wizchip_conf.h.

Referenced by wizchip_getnetinfo(), and wizchip_setnetinfo().

dhcp_mode wiz_NetInfo_t::dhcp

1 - Static, 2 - DHCP

Definition at line 345 of file wizchip_conf.h.

Referenced by wizchip_getnetinfo(), and wizchip_setnetinfo().

The documentation for this struct was generated from the following file:
  • Ethernet/wizchip_conf.h


Socket APIs: wiz_NetTimeout_t Struct Reference

  • Class List
  • Class Index
  • Class Members
Public Attributes | List of all members
wiz_NetTimeout_t Struct Reference
DATA TYPE

#include <wizchip_conf.h>

Public Attributes

uint8_t | retry_cnt
retry count More...
uint16_t | time_100us
time unit 100us More...

Detailed Description

Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of ctlwizchip() for timeout configruation.

Definition at line 366 of file wizchip_conf.h.

Member Data Documentation

uint8_t wiz_NetTimeout_t::retry_cnt

retry count

Definition at line 368 of file wizchip_conf.h.

Referenced by wizchip_gettimeout(), and wizchip_settimeout().

uint16_t wiz_NetTimeout_t::time_100us

time unit 100us

Definition at line 369 of file wizchip_conf.h.

Referenced by wizchip_gettimeout(), and wizchip_settimeout().

The documentation for this struct was generated from the following file:
  • Ethernet/wizchip_conf.h


Socket APIs: Class List

  • Class List
  • Class Index
  • Class Members
Class List
Here are the classes, structs, unions and interfaces with brief descriptions:
[detail level 12]
o C __WIZCHIP | The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200
| o C _CRIS |
| o C _CS |
| \ C _IF |
o C wiz_NetInfo_t |
o C wiz_NetTimeout_t |
\ C wiz_PhyConf_t |
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: Class Index

  • Class List
  • Class Index
  • Class Members
Class Index
W | _
W
wiz_NetTimeout_t __WIZCHIP::_CRIS
wiz_PhyConf_t __WIZCHIP::_CS
wiz_NetInfo_t
_
__WIZCHIP::_IF
__WIZCHIP
W | _
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: Class Members

  • Class List
  • Class Index
  • Class Members
  • All
  • Variables
Here is a list of all class members with links to the classes they belong to:
  • _deselect : __WIZCHIP::_CS
  • _enter : __WIZCHIP::_CRIS
  • _exit : __WIZCHIP::_CRIS
  • _read_burst : __WIZCHIP::_IF
  • _read_byte : __WIZCHIP::_IF
  • _select : __WIZCHIP::_CS
  • _write_burst : __WIZCHIP::_IF
  • _write_byte : __WIZCHIP::_IF
  • BUS : __WIZCHIP::_IF
  • by : wiz_PhyConf_t
  • CRIS : __WIZCHIP
  • CS : __WIZCHIP
  • dhcp : wiz_NetInfo_t
  • dns : wiz_NetInfo_t
  • duplex : wiz_PhyConf_t
  • gw : wiz_NetInfo_t
  • id : __WIZCHIP
  • IF : __WIZCHIP
  • if_mode : __WIZCHIP
  • ip : wiz_NetInfo_t
  • mac : wiz_NetInfo_t
  • mode : wiz_PhyConf_t
  • retry_cnt : wiz_NetTimeout_t
  • sn : wiz_NetInfo_t
  • speed : wiz_PhyConf_t
  • SPI : __WIZCHIP::_IF
  • time_100us : wiz_NetTimeout_t
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: Class Members - Variables

  • Class List
  • Class Index
  • Class Members
  • All
  • Variables
  • _deselect : __WIZCHIP::_CS
  • _enter : __WIZCHIP::_CRIS
  • _exit : __WIZCHIP::_CRIS
  • _read_burst : __WIZCHIP::_IF
  • _read_byte : __WIZCHIP::_IF
  • _select : __WIZCHIP::_CS
  • _write_burst : __WIZCHIP::_IF
  • _write_byte : __WIZCHIP::_IF
  • BUS : __WIZCHIP::_IF
  • by : wiz_PhyConf_t
  • CRIS : __WIZCHIP
  • CS : __WIZCHIP
  • dhcp : wiz_NetInfo_t
  • dns : wiz_NetInfo_t
  • duplex : wiz_PhyConf_t
  • gw : wiz_NetInfo_t
  • id : __WIZCHIP
  • IF : __WIZCHIP
  • if_mode : __WIZCHIP
  • ip : wiz_NetInfo_t
  • mac : wiz_NetInfo_t
  • mode : wiz_PhyConf_t
  • retry_cnt : wiz_NetTimeout_t
  • sn : wiz_NetInfo_t
  • speed : wiz_PhyConf_t
  • SPI : __WIZCHIP::_IF
  • time_100us : wiz_NetTimeout_t
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File List

  • File List
  • File Members
File List
Here is a list of all files with brief descriptions:
[detail level 123]
\ - Ethernet |
o - W5100 |
| o * w5100.c |
| \ * w5100.h | W5100 HAL Header File
o - W5200 |
| o * w5200.c | W5200 HAL Interface
| \ * w5200.h | W5200 HAL Header File
o - W5500 |
| o * w5500.c | W5500 HAL Interface
| \ * w5500.h | W5500 HAL Header File
o * socket.c | SOCKET APIs Implements file
o * socket.h | SOCKET APIs Header file
o * wizchip_conf.c | WIZCHIP Config Header File
\ * wizchip_conf.h | WIZCHIP Config Header File
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet Directory Reference

  • Ethernet
Ethernet Directory Reference

Directories

directory | W5100
directory | W5200
directory | W5500

Files

file | socket.c [code]
SOCKET APIs Implements file.
file | socket.h [code]
SOCKET APIs Header file.
file | wizchip_conf.c [code]
WIZCHIP Config Header File.
file | wizchip_conf.h [code]
WIZCHIP Config Header File.


Socket APIs: Ethernet/W5100 Directory Reference

  • Ethernet
  • W5100
W5100 Directory Reference

Files

file | w5100.c [code]
file | w5100.h [code]
W5100 HAL Header File.


Socket APIs: Ethernet/W5100/w5100.c File Reference

  • Ethernet
  • W5100
w5100.c File Reference
#include "w5100.h"
Include dependency graph for w5100.c:

Go to the source code of this file.


Socket APIs: Ethernet/W5100/w5100.h File Reference

  • Ethernet
  • W5100
w5100.h File Reference

W5100 HAL Header File. More...

#include <stdint.h>
#include "wizchip_conf.h"
Include dependency graph for w5100.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

W5100 HAL Header File.

Version
1.0.0
Date
2013/10/21
Revision history
<2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file w5100.h.


Socket APIs: Ethernet/W5200 Directory Reference

  • Ethernet
  • W5200
W5200 Directory Reference

Files

file | w5200.c [code]
W5200 HAL Interface.
file | w5200.h [code]
W5200 HAL Header File.


Socket APIs: Ethernet/W5200/w5200.c File Reference

  • Ethernet
  • W5200
w5200.c File Reference

W5200 HAL Interface. More...

#include "w5200.h"
Include dependency graph for w5200.c:

Go to the source code of this file.

Detailed Description

W5200 HAL Interface.

Version
1.0.0
Date
2013/10/21
Revision history
<2013/10/21> 1st Release
Author
MidnightCow

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file w5200.c.


Socket APIs: Ethernet/W5200/w5200.h File Reference

  • Ethernet
  • W5200
w5200.h File Reference

W5200 HAL Header File. More...

#include <stdint.h>
#include "wizchip_conf.h"
Include dependency graph for w5200.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

W5200 HAL Header File.

Version
1.0.0
Date
2015/03/23
Revision history
<2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file w5200.h.


Socket APIs: Ethernet/W5500 Directory Reference

  • Ethernet
  • W5500
W5500 Directory Reference

Files

file | w5500.c [code]
W5500 HAL Interface.
file | w5500.h [code]
W5500 HAL Header File.


Socket APIs: Ethernet/W5500/w5500.c File Reference

  • Ethernet
  • W5500
Macros
w5500.c File Reference

W5500 HAL Interface. More...

#include "w5500.h"
Include dependency graph for w5500.c:

Go to the source code of this file.

Macros

#define | _W5500_SPI_VDM_OP_ 0x00
#define | _W5500_SPI_FDM_OP_LEN1_ 0x01
#define | _W5500_SPI_FDM_OP_LEN2_ 0x02
#define | _W5500_SPI_FDM_OP_LEN4_ 0x03

Detailed Description

W5500 HAL Interface.

Version
1.0.2
Date
2013/10/21
Revision history
<2015/02/05> Notice The version history is not updated after this point. Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. >> https://github.com/Wiznet/ioLibrary_Driver <2014/05/01> V1.0.2
  1. Implicit type casting -> Explicit type casting. Refer to M20140501 Fixed the problem on porting into under 32bit MCU Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh Thank for your interesting and serious advices. <2013/12/20> V1.0.1
  1. Remove warning
  2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case WIZCHIP_IO_MODE_SPI_FDM for loop optimized(removed). refer to M20131220 <2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file w5500.c.

Macro Definition Documentation

#define _W5500_SPI_VDM_OP_ 0x00

Definition at line 57 of file w5500.c.

#define _W5500_SPI_FDM_OP_LEN1_ 0x01

Definition at line 58 of file w5500.c.

#define _W5500_SPI_FDM_OP_LEN2_ 0x02

Definition at line 59 of file w5500.c.

#define _W5500_SPI_FDM_OP_LEN4_ 0x03

Definition at line 60 of file w5500.c.


Socket APIs: Ethernet/W5500/w5500.h File Reference

  • Ethernet
  • W5500
w5500.h File Reference

W5500 HAL Header File. More...

#include <stdint.h>
#include "wizchip_conf.h"
Include dependency graph for w5500.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

W5500 HAL Header File.

Version
1.0.0
Date
2013/10/21
Revision history
<2015/02/05> Notice The version history is not updated after this point. Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. >> https://github.com/Wiznet/ioLibrary_Driver <2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file w5500.h.


Socket APIs: Ethernet/socket.c File Reference

  • Ethernet
Macros | Functions
socket.c File Reference

SOCKET APIs Implements file. More...

#include "socket.h"
Include dependency graph for socket.c:

Go to the source code of this file.

Macros

#define | SOCK_ANY_PORT_NUM 0xC000
#define | CHECK_SOCKNUM()
#define | CHECK_SOCKMODE(mode)
#define | CHECK_SOCKINIT()
#define | CHECK_SOCKDATA()

Functions

int8_t | socket (uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket. More...
int8_t | close (uint8_t sn)
Close a socket. More...
int8_t | listen (uint8_t sn)
Listen to a connection request from a client. More...
int8_t | connect (uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server. More...
int8_t | disconnect (uint8_t sn)
Try to disconnect a connection socket. More...
int32_t | send (uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket. More...
int32_t | recv (uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer. More...
int32_t | sendto (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port)
Sends datagram to the peer with destination IP address and port number passed as parameter. More...
int32_t | recvfrom (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW. More...
int8_t | ctlsocket (uint8_t sn, ctlsock_type cstype, void *arg)
Control socket. More...
int8_t | setsockopt (uint8_t sn, sockopt_type sotype, void *arg)
set socket options More...
int8_t | getsockopt (uint8_t sn, sockopt_type sotype, void *arg)
get socket options More...

Detailed Description

SOCKET APIs Implements file.

SOCKET APIs like as Berkeley Socket APIs.

Version
1.0.3
Date
2013/10/21
Revision history
<2015/02/05> Notice The version history is not updated after this point. Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. >> https://github.com/Wiznet/ioLibrary_Driver <2014/05/01> V1.0.3. Refer to M20140501
  1. Implicit type casting -> Explicit type casting.
  2. replace 0x01 with PACK_REMAINED in recvfrom()
  3. Validation a destination ip in connect() & sendto(): It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. Copy 4 byte addr value into temporary uint32 variable and then compares it. <2013/12/20> V1.0.2 Refer to M20131220 Remove Warning. <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) <2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file socket.c.

Macro Definition Documentation

#define SOCK_ANY_PORT_NUM 0xC000

Definition at line 60 of file socket.c.

Referenced by socket().

#define CHECK_SOCKNUM ( )
Value:
do{ \
if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \
}while(0); \

Definition at line 72 of file socket.c.

Referenced by close(), connect(), ctlsocket(), disconnect(), getsockopt(), listen(), recv(), recvfrom(), send(), sendto(), setsockopt(), and socket().

#define CHECK_SOCKMODE ( mode)
Value:
do{ \
if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \
}while(0); \

Definition at line 77 of file socket.c.

Referenced by connect(), disconnect(), getsockopt(), listen(), recv(), send(), and setsockopt().

#define CHECK_SOCKINIT ( )
Value:
do{ \
if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \
}while(0); \

Definition at line 82 of file socket.c.

Referenced by connect(), and listen().

#define CHECK_SOCKDATA ( )
Value:
do{ \
if(len == 0) return SOCKERR_DATALEN; \
}while(0); \

Definition at line 87 of file socket.c.

Referenced by recv(), recvfrom(), send(), and sendto().


Socket APIs: Ethernet/socket.h File Reference

  • Ethernet
Macros | Enumerations | Functions
socket.h File Reference

SOCKET APIs Header file. More...

#include "wizchip_conf.h"
Include dependency graph for socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | SOCKET uint8_t
SOCKET type define for legacy driver. More...
#define | SOCK_OK 1
Result is OK about socket process. More...
#define | SOCK_BUSY 0
Socket is busy on processing the operation. Valid only Non-block IO Mode. More...
#define | SOCK_FATAL -1000
Result is fatal error about socket process. More...
#define | SOCK_ERROR 0
#define | SOCKERR_SOCKNUM (SOCK_ERROR - 1)
Invalid socket number. More...
#define | SOCKERR_SOCKOPT (SOCK_ERROR - 2)
Invalid socket option. More...
#define | SOCKERR_SOCKINIT (SOCK_ERROR - 3)
Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP. More...
#define | SOCKERR_SOCKCLOSED (SOCK_ERROR - 4)
Socket unexpectedly closed. More...
#define | SOCKERR_SOCKMODE (SOCK_ERROR - 5)
Invalid socket mode for socket operation. More...
#define | SOCKERR_SOCKFLAG (SOCK_ERROR - 6)
Invalid socket flag. More...
#define | SOCKERR_SOCKSTATUS (SOCK_ERROR - 7)
Invalid socket status for socket operation. More...
#define | SOCKERR_ARG (SOCK_ERROR - 10)
Invalid argument. More...
#define | SOCKERR_PORTZERO (SOCK_ERROR - 11)
Port number is zero. More...
#define | SOCKERR_IPINVALID (SOCK_ERROR - 12)
Invalid IP address. More...
#define | SOCKERR_TIMEOUT (SOCK_ERROR - 13)
Timeout occurred. More...
#define | SOCKERR_DATALEN (SOCK_ERROR - 14)
Data length is zero or greater than buffer max size. More...
#define | SOCKERR_BUFFER (SOCK_ERROR - 15)
Socket buffer is not enough for data communication. More...
#define | SOCKFATAL_PACKLEN (SOCK_FATAL - 1)
Invalid packet length. Fatal Error. More...
#define | SF_ETHER_OWN (Sn_MR_MFEN)
In Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet. More...
#define | SF_IGMP_VER2 (Sn_MR_MC)
In Sn_MR_UDP with SF_MULTI_ENABLE, Select IGMP version 2. More...
#define | SF_TCP_NODELAY (Sn_MR_ND)
In Sn_MR_TCP, Use to nodelayed ack. More...
#define | SF_MULTI_ENABLE (Sn_MR_MULTI)
In Sn_MR_UDP, Enable multicast mode. More...
#define | SF_BROAD_BLOCK (Sn_MR_BCASTB)
In Sn_MR_UDP or Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500. More...
#define | SF_MULTI_BLOCK (Sn_MR_MMB)
In Sn_MR_MACRAW, Block multicast packet. Valid only in W5500. More...
#define | SF_IPv6_BLOCK (Sn_MR_MIP6B)
In Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500. More...
#define | SF_UNI_BLOCK (Sn_MR_UCASTB)
In Sn_MR_UDP with SF_MULTI_ENABLE. Valid only in W5500. More...
#define | SF_IO_NONBLOCK 0x01
Socket nonblock io mode. It used parameter in socket(). More...
#define | PACK_FIRST 0x80
In Non-TCP packet, It indicates to start receiving a packet. More...
#define | PACK_REMAINED 0x01
In Non-TCP packet, It indicates to remain a packet to be received. More...
#define | PACK_COMPLETED 0x00
In Non-TCP packet, It indicates to complete to receive a packet. More...
#define | SOCK_IO_BLOCK 0
Socket Block IO Mode in setsockopt(). More...
#define | SOCK_IO_NONBLOCK 1
Socket Non-block IO Mode in setsockopt(). More...

Enumerations

enum sockint_kind {
SIK_CONNECTED = (1 << 0), SIK_DISCONNECTED = (1 << 1), SIK_RECEIVED = (1 << 2), SIK_TIMEOUT = (1 << 3),
SIK_SENT = (1 << 4), SIK_ALL = 0x1F
}
The kind of Socket Interrupt. More...
enum ctlsock_type {
CS_SET_IOMODE, CS_GET_IOMODE, CS_GET_MAXTXBUF, CS_GET_MAXRXBUF,
CS_CLR_INTERRUPT, CS_GET_INTERRUPT, CS_SET_INTMASK, CS_GET_INTMASK
}
The type of ctlsocket(). More...
enum sockopt_type {
SO_FLAG, SO_TTL, SO_TOS, SO_MSS,
SO_DESTIP, SO_DESTPORT, SO_KEEPALIVESEND, SO_KEEPALIVEAUTO,
SO_SENDBUF, SO_RECVBUF, SO_STATUS, SO_REMAINSIZE,
SO_PACKINFO
}
The type of socket option in setsockopt() or getsockopt() More...

Functions

int8_t | socket (uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket. More...
int8_t | close (uint8_t sn)
Close a socket. More...
int8_t | listen (uint8_t sn)
Listen to a connection request from a client. More...
int8_t | connect (uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server. More...
int8_t | disconnect (uint8_t sn)
Try to disconnect a connection socket. More...
int32_t | send (uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket. More...
int32_t | recv (uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer. More...
int32_t | sendto (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port)
Sends datagram to the peer with destination IP address and port number passed as parameter. More...
int32_t | recvfrom (uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW. More...
int8_t | ctlsocket (uint8_t sn, ctlsock_type cstype, void *arg)
Control socket. More...
int8_t | setsockopt (uint8_t sn, sockopt_type sotype, void *arg)
set socket options More...
int8_t | getsockopt (uint8_t sn, sockopt_type sotype, void *arg)
get socket options More...

Detailed Description

SOCKET APIs Header file.

SOCKET APIs like as berkeley socket api.

Version
1.0.2
Date
2013/10/21
Revision history
<2015/02/05> Notice The version history is not updated after this point. Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. >> https://github.com/Wiznet/ioLibrary_Driver <2014/05/01> V1.0.2. Refer to M20140501
  1. Modify the comment : SO_REMAINED -> PACK_REMAINED
  2. Add the comment as zero byte udp data reception in getsockopt(). <2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file socket.h.

Macro Definition Documentation

#define SOCKET uint8_t

SOCKET type define for legacy driver.

Definition at line 90 of file socket.h.

#define SOCK_OK 1

Result is OK about socket process.

Definition at line 92 of file socket.h.

Referenced by close(), connect(), ctlsocket(), disconnect(), getsockopt(), listen(), and setsockopt().

#define SOCK_BUSY 0

Socket is busy on processing the operation. Valid only Non-block IO Mode.

Definition at line 93 of file socket.h.

Referenced by connect(), disconnect(), recv(), recvfrom(), send(), and sendto().

#define SOCK_FATAL -1000

Result is fatal error about socket process.

Definition at line 94 of file socket.h.

#define SOCK_ERROR 0

Definition at line 96 of file socket.h.

#define SOCKERR_SOCKNUM (SOCK_ERROR - 1)

Invalid socket number.

Definition at line 97 of file socket.h.

#define SOCKERR_SOCKOPT (SOCK_ERROR - 2)

Invalid socket option.

Definition at line 98 of file socket.h.

Referenced by getsockopt(), and setsockopt().

#define SOCKERR_SOCKINIT (SOCK_ERROR - 3)

Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP.

Definition at line 99 of file socket.h.

Referenced by socket().

#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4)

Socket unexpectedly closed.

Definition at line 100 of file socket.h.

Referenced by connect(), listen(), recvfrom(), and sendto().

#define SOCKERR_SOCKMODE (SOCK_ERROR - 5)

Invalid socket mode for socket operation.

Definition at line 101 of file socket.h.

Referenced by recvfrom(), sendto(), and socket().

#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6)

Invalid socket flag.

Definition at line 102 of file socket.h.

Referenced by socket().

#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7)

Invalid socket status for socket operation.

Definition at line 103 of file socket.h.

Referenced by recv(), send(), and sendto().

#define SOCKERR_ARG (SOCK_ERROR - 10)

Invalid argument.

Definition at line 104 of file socket.h.

Referenced by ctlsocket(), and setsockopt().

#define SOCKERR_PORTZERO (SOCK_ERROR - 11)

Port number is zero.

Definition at line 105 of file socket.h.

Referenced by connect(), and sendto().

#define SOCKERR_IPINVALID (SOCK_ERROR - 12)

Invalid IP address.

Definition at line 106 of file socket.h.

Referenced by connect(), and sendto().

#define SOCKERR_TIMEOUT (SOCK_ERROR - 13)

Timeout occurred.

Definition at line 107 of file socket.h.

Referenced by connect(), disconnect(), send(), sendto(), and setsockopt().

#define SOCKERR_DATALEN (SOCK_ERROR - 14)

Data length is zero or greater than buffer max size.

Definition at line 108 of file socket.h.

#define SOCKERR_BUFFER (SOCK_ERROR - 15)

Socket buffer is not enough for data communication.

Definition at line 109 of file socket.h.

#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1)

Invalid packet length. Fatal Error.

Definition at line 111 of file socket.h.

Referenced by recvfrom().

#define SF_ETHER_OWN (Sn_MR_MFEN)

In Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet.

Definition at line 116 of file socket.h.

#define SF_IGMP_VER2 (Sn_MR_MC)

In Sn_MR_UDP with SF_MULTI_ENABLE, Select IGMP version 2.

Definition at line 117 of file socket.h.

Referenced by socket().

#define SF_TCP_NODELAY (Sn_MR_ND)

In Sn_MR_TCP, Use to nodelayed ack.

Definition at line 118 of file socket.h.

Referenced by socket().

#define SF_MULTI_ENABLE (Sn_MR_MULTI)

In Sn_MR_UDP, Enable multicast mode.

Definition at line 119 of file socket.h.

Referenced by socket().

#define SF_BROAD_BLOCK (Sn_MR_BCASTB)

In Sn_MR_UDP or Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500.

Definition at line 122 of file socket.h.

#define SF_MULTI_BLOCK (Sn_MR_MMB)

In Sn_MR_MACRAW, Block multicast packet. Valid only in W5500.

Definition at line 123 of file socket.h.

#define SF_IPv6_BLOCK (Sn_MR_MIP6B)

In Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500.

Definition at line 124 of file socket.h.

#define SF_UNI_BLOCK (Sn_MR_UCASTB)

In Sn_MR_UDP with SF_MULTI_ENABLE. Valid only in W5500.

Definition at line 125 of file socket.h.

Referenced by socket().

#define SF_IO_NONBLOCK 0x01

Socket nonblock io mode. It used parameter in socket().

Definition at line 128 of file socket.h.

Referenced by socket().

#define PACK_FIRST 0x80

In Non-TCP packet, It indicates to start receiving a packet.

Definition at line 133 of file socket.h.

Referenced by recvfrom().

#define PACK_REMAINED 0x01

In Non-TCP packet, It indicates to remain a packet to be received.

Definition at line 134 of file socket.h.

Referenced by recvfrom().

#define PACK_COMPLETED 0x00

In Non-TCP packet, It indicates to complete to receive a packet.

Definition at line 135 of file socket.h.

Referenced by recvfrom().

#define SOCK_IO_BLOCK 0

Socket Block IO Mode in setsockopt().

Definition at line 325 of file socket.h.

Referenced by ctlsocket().

#define SOCK_IO_NONBLOCK 1

Socket Non-block IO Mode in setsockopt().

Definition at line 326 of file socket.h.

Referenced by ctlsocket().


Socket APIs: Ethernet/wizchip_conf.c File Reference

  • Ethernet
Functions | Variables
wizchip_conf.c File Reference

WIZCHIP Config Header File. More...

#include <stddef.h>
#include "wizchip_conf.h"
Include dependency graph for wizchip_conf.c:

Go to the source code of this file.

Functions

void | wizchip_cris_enter (void)
Default function to enable interrupt. More...
void | wizchip_cris_exit (void)
Default function to disable interrupt. More...
void | wizchip_cs_select (void)
Default function to select chip. More...
void | wizchip_cs_deselect (void)
Default function to deselect chip. More...
uint8_t | wizchip_bus_readbyte (uint32_t AddrSel)
Default function to read in direct or indirect interface. More...
void | wizchip_bus_writebyte (uint32_t AddrSel, uint8_t wb)
Default function to write in direct or indirect interface. More...
uint8_t | wizchip_spi_readbyte (void)
Default function to read in SPI interface. More...
void | wizchip_spi_writebyte (uint8_t wb)
Default function to write in SPI interface. More...
void | wizchip_spi_readburst (uint8_t *pBuf, uint16_t len)
Default function to burst read in SPI interface. More...
void | wizchip_spi_writeburst (uint8_t *pBuf, uint16_t len)
Default function to burst write in SPI interface. More...
void | reg_wizchip_cris_cbfunc (void(*cris_en)(void), void(*cris_ex)(void))
Registers call back function for critical section of I/O functions such as WIZCHIP_READ, WIZCHIP_WRITE, WIZCHIP_READ_BUF and WIZCHIP_WRITE_BUF. More...
void | reg_wizchip_cs_cbfunc (void(*cs_sel)(void), void(*cs_desel)(void))
Registers call back function for WIZCHIP select & deselect. More...
void | reg_wizchip_bus_cbfunc (uint8_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, uint8_t wb))
Registers call back function for bus interface. More...
void | reg_wizchip_spi_cbfunc (uint8_t(*spi_rb)(void), void(*spi_wb)(uint8_t wb))
Registers call back function for SPI interface. More...
void | reg_wizchip_spiburst_cbfunc (void(*spi_rb)(uint8_t *pBuf, uint16_t len), void(*spi_wb)(uint8_t *pBuf, uint16_t len))
Registers call back function for SPI interface. More...
int8_t | ctlwizchip (ctlwizchip_type cwtype, void *arg)
Controls to the WIZCHIP. More...
int8_t | ctlnetwork (ctlnetwork_type cntype, void *arg)
Controls to network. More...
void | wizchip_sw_reset (void)
Reset WIZCHIP by softly. More...
int8_t | wizchip_init (uint8_t *txsize, uint8_t *rxsize)
Initializes WIZCHIP with socket buffer size. More...
void | wizchip_clrinterrupt (intr_kind intr)
Clear Interrupt of WIZCHIP. More...
intr_kind | wizchip_getinterrupt (void)
Get Interrupt of WIZCHIP. More...
void | wizchip_setinterruptmask (intr_kind intr)
Mask or Unmask Interrupt of WIZCHIP. More...
intr_kind | wizchip_getinterruptmask (void)
Get Interrupt mask of WIZCHIP. More...
int8_t | wizphy_getphylink (void)
get the link status of phy in WIZCHIP. No use in W5100 More...
int8_t | wizphy_getphypmode (void)
get the power mode of PHY in WIZCHIP. No use in W5100 More...
void | wizphy_reset (void)
Reset phy. Vailid only in W5500. More...
void | wizphy_setphyconf (wiz_PhyConf *phyconf)
Set the phy information for WIZCHIP without power mode. More...
void | wizphy_getphyconf (wiz_PhyConf *phyconf)
Get phy configuration information. More...
void | wizphy_getphystat (wiz_PhyConf *phyconf)
Get phy status. More...
int8_t | wizphy_setphypmode (uint8_t pmode)
set the power mode of phy inside WIZCHIP. Refer to PHYCFGR in W5500, PHYSTATUS in W5200 More...
void | wizchip_setnetinfo (wiz_NetInfo *pnetinfo)
Set the network information for WIZCHIP. More...
void | wizchip_getnetinfo (wiz_NetInfo *pnetinfo)
Get the network information for WIZCHIP. More...
int8_t | wizchip_setnetmode (netmode_type netmode)
Set the network mode such WOL, PPPoE, Ping Block, and etc. More...
netmode_type | wizchip_getnetmode (void)
Get the network mode such WOL, PPPoE, Ping Block, and etc. More...
void | wizchip_settimeout (wiz_NetTimeout *nettime)
Set retry time value(RTR) and retry count(RCR). More...
void | wizchip_gettimeout (wiz_NetTimeout *nettime)
Get retry time value(RTR) and retry count(RCR). More...

Variables

_WIZCHIP WIZCHIP

Detailed Description

WIZCHIP Config Header File.

Version
1.0.1
Date
2013/10/21
Revision history
<2015/02/05> Notice The version history is not updated after this point. Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. >> https://github.com/Wiznet/ioLibrary_Driver <2014/05/01> V1.0.1 Refer to M20140501
  1. Explicit type casting in wizchip_bus_readbyte() & wizchip_bus_writebyte()

Definition in file wizchip_conf.c.

Function Documentation

void wizchip_cris_enter ( void )

Default function to enable interrupt.

      uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t*
      For remove the warning when pointer type size is not 32bit.
      If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type.
  <2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 67 of file wizchip_conf.c.

Referenced by reg_wizchip_cris_cbfunc().

void wizchip_cris_exit ( void )

Default function to disable interrupt.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 75 of file wizchip_conf.c.

Referenced by reg_wizchip_cris_cbfunc().

void wizchip_cs_select ( void )

Default function to select chip.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 83 of file wizchip_conf.c.

Referenced by reg_wizchip_cs_cbfunc().

void wizchip_cs_deselect ( void )

Default function to deselect chip.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 91 of file wizchip_conf.c.

Referenced by reg_wizchip_cs_cbfunc().

uint8_t wizchip_bus_readbyte ( uint32_t AddrSel)

Default function to read in direct or indirect interface.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 101 of file wizchip_conf.c.

Referenced by reg_wizchip_bus_cbfunc().

void wizchip_bus_writebyte | ( | uint32_t | AddrSel,
 |  | uint8_t | wb
 | ) |  |

Default function to write in direct or indirect interface.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 112 of file wizchip_conf.c.

Referenced by reg_wizchip_bus_cbfunc().

uint8_t wizchip_spi_readbyte ( void )

Default function to read in SPI interface.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 120 of file wizchip_conf.c.

Referenced by reg_wizchip_spi_cbfunc().

void wizchip_spi_writebyte ( uint8_t wb)

Default function to write in SPI interface.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 128 of file wizchip_conf.c.

Referenced by reg_wizchip_spi_cbfunc().

void wizchip_spi_readburst | ( | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

Default function to burst read in SPI interface.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 136 of file wizchip_conf.c.

Referenced by reg_wizchip_spiburst_cbfunc().

void wizchip_spi_writeburst | ( | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

Default function to burst write in SPI interface.

Note
This function help not to access wrong address. If you do not describe this function or register any functions, null function is called.

Definition at line 144 of file wizchip_conf.c.

Referenced by reg_wizchip_spiburst_cbfunc().

void reg_wizchip_cris_cbfunc | ( | void(*)(void) | cris_en,
 |  | void(*)(void) | cris_ex
 | ) |  |

Registers call back function for critical section of I/O functions such as WIZCHIP_READ, WIZCHIP_WRITE, WIZCHIP_READ_BUF and WIZCHIP_WRITE_BUF.

Parameters
cris_en | : callback function for critical section enter.
cris_ex | : callback function for critical section exit.
Todo:
Describe WIZCHIP_CRITICAL_ENTER and WIZCHIP_CRITICAL_EXIT marco or register your functions.
Note
If you do not describe or register, default functions(wizchip_cris_enter & wizchip_cris_exit) is called.

Definition at line 186 of file wizchip_conf.c.

References __WIZCHIP::_CRIS::_enter, __WIZCHIP::_CRIS::_exit, __WIZCHIP::CRIS, wizchip_cris_enter(), and wizchip_cris_exit().

void reg_wizchip_cs_cbfunc | ( | void(*)(void) | cs_sel,
 |  | void(*)(void) | cs_desel
 | ) |  |

Registers call back function for WIZCHIP select & deselect.

Parameters
cs_sel | : callback function for WIZCHIP select
cs_desel | : callback fucntion for WIZCHIP deselect
Todo:
Describe wizchip_cs_select and wizchip_cs_deselect function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 200 of file wizchip_conf.c.

References __WIZCHIP::_CS::_deselect, __WIZCHIP::_CS::_select, __WIZCHIP::CS, wizchip_cs_deselect(), and wizchip_cs_select().

void reg_wizchip_bus_cbfunc | ( | uint8_t(*)(uint32_t addr) | bus_rb,
 |  | void(*)(uint32_t addr, uint8_t wb) | bus_wb
 | ) |  |

Registers call back function for bus interface.

Parameters
bus_rb | : callback function to read byte data using system bus
bus_wb | : callback function to write byte data using system bus
Todo:
Describe wizchip_bus_readbyte and wizchip_bus_writebyte function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 214 of file wizchip_conf.c.

References __WIZCHIP::_IF::_read_byte, _WIZCHIP_IO_MODE_BUS_, __WIZCHIP::_IF::_write_byte, __WIZCHIP::_IF::BUS, __WIZCHIP::IF, __WIZCHIP::if_mode, wizchip_bus_readbyte(), and wizchip_bus_writebyte().

void reg_wizchip_spi_cbfunc | ( | uint8_t(*)(void) | spi_rb,
 |  | void(*)(uint8_t wb) | spi_wb
 | ) |  |

Registers call back function for SPI interface.

Parameters
spi_rb | : callback function to read byte using SPI
spi_wb | : callback function to write byte using SPI
Todo:
Describe wizchip_spi_readbyte and wizchip_spi_writebyte function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 230 of file wizchip_conf.c.

References __WIZCHIP::_IF::_read_byte, _WIZCHIP_IO_MODE_SPI_, __WIZCHIP::_IF::_write_byte, __WIZCHIP::IF, __WIZCHIP::if_mode, __WIZCHIP::_IF::SPI, wizchip_spi_readbyte(), and wizchip_spi_writebyte().

void reg_wizchip_spiburst_cbfunc | ( | void(*)(uint8_t *pBuf, uint16_t len) | spi_rb,
 |  | void(*)(uint8_t *pBuf, uint16_t len) | spi_wb
 | ) |  |

Registers call back function for SPI interface.

Parameters
spi_rb | : callback function to burst read using SPI
spi_wb | : callback function to burst write using SPI
Todo:
Describe wizchip_spi_readbyte and wizchip_spi_writebyte function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 247 of file wizchip_conf.c.

References __WIZCHIP::_IF::_read_burst, _WIZCHIP_IO_MODE_SPI_, __WIZCHIP::_IF::_write_burst, __WIZCHIP::IF, __WIZCHIP::if_mode, __WIZCHIP::_IF::SPI, wizchip_spi_readburst(), and wizchip_spi_writeburst().

int8_t wizphy_getphylink ( void )

get the link status of phy in WIZCHIP. No use in W5100

Definition at line 504 of file wizchip_conf.c.

References PHY_LINK_OFF, and PHY_LINK_ON.

Referenced by ctlwizchip().

int8_t wizphy_getphypmode ( void )

get the power mode of PHY in WIZCHIP. No use in W5100

Definition at line 525 of file wizchip_conf.c.

References PHY_POWER_DOWN, and PHY_POWER_NORM.

Referenced by ctlwizchip().

void wizphy_reset ( void )

Reset phy. Vailid only in W5500.

Definition at line 546 of file wizchip_conf.c.

Referenced by ctlwizchip(), wizphy_setphyconf(), and wizphy_setphypmode().

Variable Documentation

_WIZCHIP WIZCHIP
Initial value:
=
{
_WIZCHIP_IO_MODE_,
_WIZCHIP_ID_ ,
wizchip_cris_enter,
wizchip_cris_exit,
wizchip_cs_select,
wizchip_cs_deselect,
wizchip_bus_readbyte,
wizchip_bus_writebyte
}

\ref _WIZCHIP instance

Definition at line 168 of file wizchip_conf.c.


Socket APIs: Ethernet/wizchip_conf.h File Reference

  • Ethernet
Classes | Macros | Typedefs | Enumerations | Functions | Variables
wizchip_conf.h File Reference

WIZCHIP Config Header File. More...

#include <stdint.h>
#include "W5500/w5500.h"
Include dependency graph for wizchip_conf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct | __WIZCHIP
The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200. More...
struct | __WIZCHIP::_CRIS
struct | __WIZCHIP::_CS
union | __WIZCHIP::_IF
struct | wiz_PhyConf_t
struct | wiz_NetInfo_t
struct | wiz_NetTimeout_t

Macros

#define | _WIZCHIP_ 5500
Select WIZCHIP. More...
#define | _WIZCHIP_IO_MODE_NONE_ 0x0000
#define | _WIZCHIP_IO_MODE_BUS_ 0x0100
#define | _WIZCHIP_IO_MODE_SPI_ 0x0200
#define | _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1)
#define | _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2)
#define | _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1)
#define | _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2)
#define | _WIZCHIP_ID_ "W5500\0"
#define | _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
Define interface mode.
. More...
#define | _WIZCHIP_IO_BASE_ 0x00000000
Define I/O base address when BUS IF mode. More...
#define | _WIZCHIP_SOCK_NUM_ 8
The count of independant socket of WIZCHIP. More...
#define | PHY_CONFBY_HW 0
Configured PHY operation mode by HW pin. More...
#define | PHY_CONFBY_SW 1
Configured PHY operation mode by SW register. More...
#define | PHY_MODE_MANUAL 0
Configured PHY operation mode with user setting. More...
#define | PHY_MODE_AUTONEGO 1
Configured PHY operation mode with auto-negotiation. More...
#define | PHY_SPEED_10 0
Link Speed 10. More...
#define | PHY_SPEED_100 1
Link Speed 100. More...
#define | PHY_DUPLEX_HALF 0
Link Half-Duplex. More...
#define | PHY_DUPLEX_FULL 1
Link Full-Duplex. More...
#define | PHY_LINK_OFF 0
Link Off. More...
#define | PHY_LINK_ON 1
Link On. More...
#define | PHY_POWER_NORM 0
PHY power normal mode. More...
#define | PHY_POWER_DOWN 1
PHY power down mode. More...

Typedefs

typedef struct __WIZCHIP | _WIZCHIP
The set of callback functions for W5500:WIZCHIP_IO_Functions W5200:WIZCHIP_IO_Functions_W5200. More...
typedef struct wiz_PhyConf_t | wiz_PhyConf
typedef struct wiz_NetInfo_t | wiz_NetInfo
typedef struct wiz_NetTimeout_t | wiz_NetTimeout

Enumerations

enum ctlwizchip_type {
CW_RESET_WIZCHIP, CW_INIT_WIZCHIP, CW_GET_INTERRUPT, CW_CLR_INTERRUPT,
CW_SET_INTRMASK, CW_GET_INTRMASK, CW_SET_INTRTIME, CW_GET_INTRTIME,
CW_GET_ID, CW_RESET_PHY, CW_SET_PHYCONF, CW_GET_PHYCONF,
CW_GET_PHYSTATUS, CW_SET_PHYPOWMODE, CW_GET_PHYPOWMODE, CW_GET_PHYLINK
}
enum ctlnetwork_type {
CN_SET_NETINFO, CN_GET_NETINFO, CN_SET_NETMODE, CN_GET_NETMODE,
CN_SET_TIMEOUT, CN_GET_TIMEOUT
}
enum intr_kind {
IK_WOL = (1 << 4), IK_PPPOE_TERMINATED = (1 << 5), IK_DEST_UNREACH = (1 << 6), IK_IP_CONFLICT = (1 << 7),
IK_SOCK_0 = (1 << 8), IK_SOCK_1 = (1 << 9), IK_SOCK_2 = (1 << 10), IK_SOCK_3 = (1 << 11),
IK_SOCK_4 = (1 << 12), IK_SOCK_5 = (1 << 13), IK_SOCK_6 = (1 << 14), IK_SOCK_7 = (1 << 15),
IK_SOCK_ALL = (0xFF << 8)
}
enum | dhcp_mode { NETINFO_STATIC = 1, NETINFO_DHCP }
enum | netmode_type { NM_FORCEARP = (1<<1), NM_WAKEONLAN = (1<<5), NM_PINGBLOCK = (1<<4), NM_PPPOE = (1<<3) }

Functions

void | reg_wizchip_cris_cbfunc (void(*cris_en)(void), void(*cris_ex)(void))
Registers call back function for critical section of I/O functions such as WIZCHIP_READ, WIZCHIP_WRITE, WIZCHIP_READ_BUF and WIZCHIP_WRITE_BUF. More...
void | reg_wizchip_cs_cbfunc (void(*cs_sel)(void), void(*cs_desel)(void))
Registers call back function for WIZCHIP select & deselect. More...
void | reg_wizchip_bus_cbfunc (uint8_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, uint8_t wb))
Registers call back function for bus interface. More...
void | reg_wizchip_spi_cbfunc (uint8_t(*spi_rb)(void), void(*spi_wb)(uint8_t wb))
Registers call back function for SPI interface. More...
void | reg_wizchip_spiburst_cbfunc (void(*spi_rb)(uint8_t *pBuf, uint16_t len), void(*spi_wb)(uint8_t *pBuf, uint16_t len))
Registers call back function for SPI interface. More...
int8_t | ctlwizchip (ctlwizchip_type cwtype, void *arg)
Controls to the WIZCHIP. More...
int8_t | ctlnetwork (ctlnetwork_type cntype, void *arg)
Controls to network. More...
void | wizchip_sw_reset (void)
Reset WIZCHIP by softly. More...
int8_t | wizchip_init (uint8_t *txsize, uint8_t *rxsize)
Initializes WIZCHIP with socket buffer size. More...
void | wizchip_clrinterrupt (intr_kind intr)
Clear Interrupt of WIZCHIP. More...
intr_kind | wizchip_getinterrupt (void)
Get Interrupt of WIZCHIP. More...
void | wizchip_setinterruptmask (intr_kind intr)
Mask or Unmask Interrupt of WIZCHIP. More...
intr_kind | wizchip_getinterruptmask (void)
Get Interrupt mask of WIZCHIP. More...
int8_t | wizphy_getphylink (void)
get the link status of phy in WIZCHIP. No use in W5100 More...
int8_t | wizphy_getphypmode (void)
get the power mode of PHY in WIZCHIP. No use in W5100 More...
void | wizphy_reset (void)
Reset phy. Vailid only in W5500. More...
void | wizphy_setphyconf (wiz_PhyConf *phyconf)
Set the phy information for WIZCHIP without power mode. More...
void | wizphy_getphyconf (wiz_PhyConf *phyconf)
Get phy configuration information. More...
void | wizphy_getphystat (wiz_PhyConf *phyconf)
Get phy status. More...
int8_t | wizphy_setphypmode (uint8_t pmode)
set the power mode of phy inside WIZCHIP. Refer to PHYCFGR in W5500, PHYSTATUS in W5200 More...
void | wizchip_setnetinfo (wiz_NetInfo *pnetinfo)
Set the network information for WIZCHIP. More...
void | wizchip_getnetinfo (wiz_NetInfo *pnetinfo)
Get the network information for WIZCHIP. More...
int8_t | wizchip_setnetmode (netmode_type netmode)
Set the network mode such WOL, PPPoE, Ping Block, and etc. More...
netmode_type | wizchip_getnetmode (void)
Get the network mode such WOL, PPPoE, Ping Block, and etc. More...
void | wizchip_settimeout (wiz_NetTimeout *nettime)
Set retry time value(RTR) and retry count(RCR). More...
void | wizchip_gettimeout (wiz_NetTimeout *nettime)
Get retry time value(RTR) and retry count(RCR). More...

Variables

_WIZCHIP WIZCHIP

Detailed Description

WIZCHIP Config Header File.

Version
1.0.0
Date
2013/10/21
Revision history
<2015/02/05> Notice The version history is not updated after this point. Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. >> https://github.com/Wiznet/ioLibrary_Driver <2013/10/21> 1st Release
Author
MidnightCow
Copyright

Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file wizchip_conf.h.

Macro Definition Documentation

#define _WIZCHIP_ 5500

Select WIZCHIP.

Todo:
You should select one, 5100, 5200 ,5500 or etc.

ex> #define _WIZCHIP_ 5500

Definition at line 63 of file wizchip_conf.h.

#define _WIZCHIP_IO_MODE_NONE_ 0x0000

Definition at line 65 of file wizchip_conf.h.

#define _WIZCHIP_IO_MODE_BUS_ 0x0100

Bus interface mode

Definition at line 66 of file wizchip_conf.h.

Referenced by reg_wizchip_bus_cbfunc().

#define _WIZCHIP_IO_MODE_SPI_ 0x0200

SPI interface mode

Definition at line 67 of file wizchip_conf.h.

Referenced by reg_wizchip_spi_cbfunc(), and reg_wizchip_spiburst_cbfunc().

#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1)

BUS interface mode for direct

Definition at line 73 of file wizchip_conf.h.

#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2)

BUS interface mode for indirect

Definition at line 74 of file wizchip_conf.h.

#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1)

SPI interface mode for variable length data

Definition at line 76 of file wizchip_conf.h.

#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2)

SPI interface mode for fixed length data mode

Definition at line 77 of file wizchip_conf.h.

#define _WIZCHIP_ID_ "W5500\0"

Definition at line 103 of file wizchip_conf.h.

#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_

Define interface mode.
.

Todo:
Should select interface mode as chip.
  • _WIZCHIP_IO_MODE_SPI_
    -_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in _WIZCHIP_ == 5500
    -_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in _WIZCHIP_ == 5500
  • _WIZCHIP_IO_MODE_BUS_
    • _WIZCHIP_IO_MODE_BUS_DIR_
    • _WIZCHIP_IO_MODE_BUS_INDIR_
  • Others will be defined in future.

    ex> #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_

Definition at line 119 of file wizchip_conf.h.

#define _WIZCHIP_IO_BASE_ 0x00000000

Define I/O base address when BUS IF mode.

Todo:
Should re-define it to fit your system when BUS IF Mode (_WIZCHIP_IO_MODE_BUS_, _WIZCHIP_IO_MODE_BUS_DIR_, _WIZCHIP_IO_MODE_BUS_INDIR_).

ex> #define _WIZCHIP_IO_BASE_ 0x00008000

Definition at line 135 of file wizchip_conf.h.

#define _WIZCHIP_SOCK_NUM_ 8

The count of independant socket of WIZCHIP.

Definition at line 146 of file wizchip_conf.h.

Referenced by ctlwizchip(), and wizchip_init().

#define PHY_CONFBY_HW 0

Configured PHY operation mode by HW pin.

Definition at line 292 of file wizchip_conf.h.

Referenced by wizphy_getphyconf().

#define PHY_CONFBY_SW 1

Configured PHY operation mode by SW register.

Definition at line 293 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), and wizphy_setphyconf().

#define PHY_MODE_MANUAL 0

Configured PHY operation mode with user setting.

Definition at line 294 of file wizchip_conf.h.

Referenced by wizphy_getphyconf().

#define PHY_MODE_AUTONEGO 1

Configured PHY operation mode with auto-negotiation.

Definition at line 295 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), and wizphy_setphyconf().

#define PHY_SPEED_10 0

Link Speed 10.

Definition at line 296 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), and wizphy_getphystat().

#define PHY_SPEED_100 1

Link Speed 100.

Definition at line 297 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), wizphy_getphystat(), and wizphy_setphyconf().

#define PHY_DUPLEX_HALF 0

Link Half-Duplex.

Definition at line 298 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), and wizphy_getphystat().

#define PHY_DUPLEX_FULL 1

Link Full-Duplex.

Definition at line 299 of file wizchip_conf.h.

Referenced by wizphy_getphyconf(), wizphy_getphystat(), and wizphy_setphyconf().

#define PHY_LINK_OFF 0

Link Off.

Definition at line 300 of file wizchip_conf.h.

Referenced by wizphy_getphylink().

#define PHY_LINK_ON 1

Link On.

Definition at line 301 of file wizchip_conf.h.

Referenced by wizphy_getphylink().

#define PHY_POWER_NORM 0

PHY power normal mode.

Definition at line 302 of file wizchip_conf.h.

Referenced by wizphy_getphypmode().

#define PHY_POWER_DOWN 1

PHY power down mode.

Definition at line 303 of file wizchip_conf.h.

Referenced by wizphy_getphypmode(), and wizphy_setphypmode().

Function Documentation

void reg_wizchip_cris_cbfunc | ( | void(*)(void) | cris_en,
 |  | void(*)(void) | cris_ex
 | ) |  |

Registers call back function for critical section of I/O functions such as WIZCHIP_READ, WIZCHIP_WRITE, WIZCHIP_READ_BUF and WIZCHIP_WRITE_BUF.

Parameters
cris_en | : callback function for critical section enter.
cris_ex | : callback function for critical section exit.
Todo:
Describe WIZCHIP_CRITICAL_ENTER and WIZCHIP_CRITICAL_EXIT marco or register your functions.
Note
If you do not describe or register, default functions(wizchip_cris_enter & wizchip_cris_exit) is called.

Definition at line 186 of file wizchip_conf.c.

References __WIZCHIP::_CRIS::_enter, __WIZCHIP::_CRIS::_exit, __WIZCHIP::CRIS, wizchip_cris_enter(), and wizchip_cris_exit().

void reg_wizchip_cs_cbfunc | ( | void(*)(void) | cs_sel,
 |  | void(*)(void) | cs_desel
 | ) |  |

Registers call back function for WIZCHIP select & deselect.

Parameters
cs_sel | : callback function for WIZCHIP select
cs_desel | : callback fucntion for WIZCHIP deselect
Todo:
Describe wizchip_cs_select and wizchip_cs_deselect function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 200 of file wizchip_conf.c.

References __WIZCHIP::_CS::_deselect, __WIZCHIP::_CS::_select, __WIZCHIP::CS, wizchip_cs_deselect(), and wizchip_cs_select().

void reg_wizchip_bus_cbfunc | ( | uint8_t(*)(uint32_t addr) | bus_rb,
 |  | void(*)(uint32_t addr, uint8_t wb) | bus_wb
 | ) |  |

Registers call back function for bus interface.

Parameters
bus_rb | : callback function to read byte data using system bus
bus_wb | : callback function to write byte data using system bus
Todo:
Describe wizchip_bus_readbyte and wizchip_bus_writebyte function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 214 of file wizchip_conf.c.

References __WIZCHIP::_IF::_read_byte, _WIZCHIP_IO_MODE_BUS_, __WIZCHIP::_IF::_write_byte, __WIZCHIP::_IF::BUS, __WIZCHIP::IF, __WIZCHIP::if_mode, wizchip_bus_readbyte(), and wizchip_bus_writebyte().

void reg_wizchip_spi_cbfunc | ( | uint8_t(*)(void) | spi_rb,
 |  | void(*)(uint8_t wb) | spi_wb
 | ) |  |

Registers call back function for SPI interface.

Parameters
spi_rb | : callback function to read byte using SPI
spi_wb | : callback function to write byte using SPI
Todo:
Describe wizchip_spi_readbyte and wizchip_spi_writebyte function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 230 of file wizchip_conf.c.

References __WIZCHIP::_IF::_read_byte, _WIZCHIP_IO_MODE_SPI_, __WIZCHIP::_IF::_write_byte, __WIZCHIP::IF, __WIZCHIP::if_mode, __WIZCHIP::_IF::SPI, wizchip_spi_readbyte(), and wizchip_spi_writebyte().

void reg_wizchip_spiburst_cbfunc | ( | void(*)(uint8_t *pBuf, uint16_t len) | spi_rb,
 |  | void(*)(uint8_t *pBuf, uint16_t len) | spi_wb
 | ) |  |

Registers call back function for SPI interface.

Parameters
spi_rb | : callback function to burst read using SPI
spi_wb | : callback function to burst write using SPI
Todo:
Describe wizchip_spi_readbyte and wizchip_spi_writebyte function or register your functions.
Note
If you do not describe or register, null function is called.

Definition at line 247 of file wizchip_conf.c.

References __WIZCHIP::_IF::_read_burst, _WIZCHIP_IO_MODE_SPI_, __WIZCHIP::_IF::_write_burst, __WIZCHIP::IF, __WIZCHIP::if_mode, __WIZCHIP::_IF::SPI, wizchip_spi_readburst(), and wizchip_spi_writeburst().

int8_t wizphy_getphylink ( void )

get the link status of phy in WIZCHIP. No use in W5100

Definition at line 504 of file wizchip_conf.c.

References PHY_LINK_OFF, and PHY_LINK_ON.

Referenced by ctlwizchip().

int8_t wizphy_getphypmode ( void )

get the power mode of PHY in WIZCHIP. No use in W5100

Definition at line 525 of file wizchip_conf.c.

References PHY_POWER_DOWN, and PHY_POWER_NORM.

Referenced by ctlwizchip().

void wizphy_reset ( void )

Reset phy. Vailid only in W5500.

Definition at line 546 of file wizchip_conf.c.

Referenced by ctlwizchip(), wizphy_setphyconf(), and wizphy_setphypmode().

Variable Documentation

_WIZCHIP WIZCHIP

\ref _WIZCHIP instance

Definition at line 168 of file wizchip_conf.c.


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- _ -

  • _W5500_SPI_FDM_OP_LEN1_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN2_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN4_ : w5500.c
  • _W5500_SPI_VDM_OP_ : w5500.c
  • _WIZCHIP : wizchip_conf.h
  • _WIZCHIP_ : wizchip_conf.h
  • _WIZCHIP_ID_ : wizchip_conf.h
  • _WIZCHIP_IO_BASE_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_BUS_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_BUS_DIR_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_BUS_INDIR_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_NONE_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_FDM_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_VDM_ : wizchip_conf.h
  • _WIZCHIP_SOCK_NUM_ : wizchip_conf.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- c -

  • CHECK_SOCKDATA : socket.c
  • CHECK_SOCKINIT : socket.c
  • CHECK_SOCKMODE : socket.c
  • CHECK_SOCKNUM : socket.c
  • close() : socket.c , socket.h
  • CN_GET_NETINFO : wizchip_conf.h
  • CN_GET_NETMODE : wizchip_conf.h
  • CN_GET_TIMEOUT : wizchip_conf.h
  • CN_SET_NETINFO : wizchip_conf.h
  • CN_SET_NETMODE : wizchip_conf.h
  • CN_SET_TIMEOUT : wizchip_conf.h
  • connect() : socket.c , socket.h
  • CS_CLR_INTERRUPT : socket.h
  • CS_GET_INTERRUPT : socket.h
  • CS_GET_INTMASK : socket.h
  • CS_GET_IOMODE : socket.h
  • CS_GET_MAXRXBUF : socket.h
  • CS_GET_MAXTXBUF : socket.h
  • CS_SET_INTMASK : socket.h
  • CS_SET_IOMODE : socket.h
  • ctlnetwork() : wizchip_conf.c , wizchip_conf.h
  • ctlnetwork_type : wizchip_conf.h
  • ctlsock_type : socket.h
  • ctlsocket() : socket.c , socket.h
  • ctlwizchip() : wizchip_conf.c , wizchip_conf.h
  • ctlwizchip_type : wizchip_conf.h
  • CW_CLR_INTERRUPT : wizchip_conf.h
  • CW_GET_ID : wizchip_conf.h
  • CW_GET_INTERRUPT : wizchip_conf.h
  • CW_GET_INTRMASK : wizchip_conf.h
  • CW_GET_INTRTIME : wizchip_conf.h
  • CW_GET_PHYCONF : wizchip_conf.h
  • CW_GET_PHYLINK : wizchip_conf.h
  • CW_GET_PHYPOWMODE : wizchip_conf.h
  • CW_GET_PHYSTATUS : wizchip_conf.h
  • CW_INIT_WIZCHIP : wizchip_conf.h
  • CW_RESET_PHY : wizchip_conf.h
  • CW_RESET_WIZCHIP : wizchip_conf.h
  • CW_SET_INTRMASK : wizchip_conf.h
  • CW_SET_INTRTIME : wizchip_conf.h
  • CW_SET_PHYCONF : wizchip_conf.h
  • CW_SET_PHYPOWMODE : wizchip_conf.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- d -

  • dhcp_mode : wizchip_conf.h
  • disconnect() : socket.h , socket.c
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- g -

  • getsockopt() : socket.c , socket.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- i -

  • IK_DEST_UNREACH : wizchip_conf.h
  • IK_IP_CONFLICT : wizchip_conf.h
  • IK_PPPOE_TERMINATED : wizchip_conf.h
  • IK_SOCK_0 : wizchip_conf.h
  • IK_SOCK_1 : wizchip_conf.h
  • IK_SOCK_2 : wizchip_conf.h
  • IK_SOCK_3 : wizchip_conf.h
  • IK_SOCK_4 : wizchip_conf.h
  • IK_SOCK_5 : wizchip_conf.h
  • IK_SOCK_6 : wizchip_conf.h
  • IK_SOCK_7 : wizchip_conf.h
  • IK_SOCK_ALL : wizchip_conf.h
  • IK_WOL : wizchip_conf.h
  • intr_kind : wizchip_conf.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- l -

  • listen() : socket.c , socket.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- n -

  • NETINFO_DHCP : wizchip_conf.h
  • NETINFO_STATIC : wizchip_conf.h
  • netmode_type : wizchip_conf.h
  • NM_FORCEARP : wizchip_conf.h
  • NM_PINGBLOCK : wizchip_conf.h
  • NM_PPPOE : wizchip_conf.h
  • NM_WAKEONLAN : wizchip_conf.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- p -

  • PACK_COMPLETED : socket.h
  • PACK_FIRST : socket.h
  • PACK_REMAINED : socket.h
  • PHY_CONFBY_HW : wizchip_conf.h
  • PHY_CONFBY_SW : wizchip_conf.h
  • PHY_DUPLEX_FULL : wizchip_conf.h
  • PHY_DUPLEX_HALF : wizchip_conf.h
  • PHY_LINK_OFF : wizchip_conf.h
  • PHY_LINK_ON : wizchip_conf.h
  • PHY_MODE_AUTONEGO : wizchip_conf.h
  • PHY_MODE_MANUAL : wizchip_conf.h
  • PHY_POWER_DOWN : wizchip_conf.h
  • PHY_POWER_NORM : wizchip_conf.h
  • PHY_SPEED_10 : wizchip_conf.h
  • PHY_SPEED_100 : wizchip_conf.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- r -

  • recv() : socket.c , socket.h
  • recvfrom() : socket.h , socket.c
  • reg_wizchip_bus_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_cris_cbfunc() : wizchip_conf.h , wizchip_conf.c
  • reg_wizchip_cs_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_spi_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_spiburst_cbfunc() : wizchip_conf.h , wizchip_conf.c
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- s -

  • send() : socket.c , socket.h
  • sendto() : socket.h , socket.c
  • setsockopt() : socket.c , socket.h
  • SF_BROAD_BLOCK : socket.h
  • SF_ETHER_OWN : socket.h
  • SF_IGMP_VER2 : socket.h
  • SF_IO_NONBLOCK : socket.h
  • SF_IPv6_BLOCK : socket.h
  • SF_MULTI_BLOCK : socket.h
  • SF_MULTI_ENABLE : socket.h
  • SF_TCP_NODELAY : socket.h
  • SF_UNI_BLOCK : socket.h
  • SIK_ALL : socket.h
  • SIK_CONNECTED : socket.h
  • SIK_DISCONNECTED : socket.h
  • SIK_RECEIVED : socket.h
  • SIK_SENT : socket.h
  • SIK_TIMEOUT : socket.h
  • SO_DESTIP : socket.h
  • SO_DESTPORT : socket.h
  • SO_FLAG : socket.h
  • SO_KEEPALIVEAUTO : socket.h
  • SO_KEEPALIVESEND : socket.h
  • SO_MSS : socket.h
  • SO_PACKINFO : socket.h
  • SO_RECVBUF : socket.h
  • SO_REMAINSIZE : socket.h
  • SO_SENDBUF : socket.h
  • SO_STATUS : socket.h
  • SO_TOS : socket.h
  • SO_TTL : socket.h
  • SOCK_ANY_PORT_NUM : socket.c
  • SOCK_BUSY : socket.h
  • SOCK_ERROR : socket.h
  • SOCK_FATAL : socket.h
  • SOCK_IO_BLOCK : socket.h
  • SOCK_IO_NONBLOCK : socket.h
  • SOCK_OK : socket.h
  • SOCKERR_ARG : socket.h
  • SOCKERR_BUFFER : socket.h
  • SOCKERR_DATALEN : socket.h
  • SOCKERR_IPINVALID : socket.h
  • SOCKERR_PORTZERO : socket.h
  • SOCKERR_SOCKCLOSED : socket.h
  • SOCKERR_SOCKFLAG : socket.h
  • SOCKERR_SOCKINIT : socket.h
  • SOCKERR_SOCKMODE : socket.h
  • SOCKERR_SOCKNUM : socket.h
  • SOCKERR_SOCKOPT : socket.h
  • SOCKERR_SOCKSTATUS : socket.h
  • SOCKERR_TIMEOUT : socket.h
  • socket() : socket.c , socket.h
  • SOCKET : socket.h
  • SOCKFATAL_PACKLEN : socket.h
  • sockint_kind : socket.h
  • sockopt_type : socket.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • d
  • g
  • i
  • l
  • n
  • p
  • r
  • s
  • w
Here is a list of all file members with links to the files they belong to:

- w -

  • wiz_NetInfo : wizchip_conf.h
  • wiz_NetTimeout : wizchip_conf.h
  • wiz_PhyConf : wizchip_conf.h
  • WIZCHIP : wizchip_conf.c , wizchip_conf.h
  • wizchip_bus_readbyte() : wizchip_conf.c
  • wizchip_bus_writebyte() : wizchip_conf.c
  • wizchip_clrinterrupt() : wizchip_conf.c , wizchip_conf.h
  • wizchip_cris_enter() : wizchip_conf.c
  • wizchip_cris_exit() : wizchip_conf.c
  • wizchip_cs_deselect() : wizchip_conf.c
  • wizchip_cs_select() : wizchip_conf.c
  • wizchip_getinterrupt() : wizchip_conf.c , wizchip_conf.h
  • wizchip_getinterruptmask() : wizchip_conf.c , wizchip_conf.h
  • wizchip_getnetinfo() : wizchip_conf.c , wizchip_conf.h
  • wizchip_getnetmode() : wizchip_conf.c , wizchip_conf.h
  • wizchip_gettimeout() : wizchip_conf.c , wizchip_conf.h
  • wizchip_init() : wizchip_conf.c , wizchip_conf.h
  • wizchip_setinterruptmask() : wizchip_conf.c , wizchip_conf.h
  • wizchip_setnetinfo() : wizchip_conf.c , wizchip_conf.h
  • wizchip_setnetmode() : wizchip_conf.h , wizchip_conf.c
  • wizchip_settimeout() : wizchip_conf.c , wizchip_conf.h
  • wizchip_spi_readburst() : wizchip_conf.c
  • wizchip_spi_readbyte() : wizchip_conf.c
  • wizchip_spi_writeburst() : wizchip_conf.c
  • wizchip_spi_writebyte() : wizchip_conf.c
  • wizchip_sw_reset() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphyconf() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphylink() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphypmode() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphystat() : wizchip_conf.h , wizchip_conf.c
  • wizphy_reset() : wizchip_conf.c , wizchip_conf.h
  • wizphy_setphyconf() : wizchip_conf.h , wizchip_conf.c
  • wizphy_setphypmode() : wizchip_conf.h , wizchip_conf.c
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • c
  • d
  • g
  • l
  • r
  • s
  • w

- c -

  • close() : socket.c , socket.h
  • connect() : socket.h , socket.c
  • ctlnetwork() : wizchip_conf.c , wizchip_conf.h
  • ctlsocket() : socket.c , socket.h
  • ctlwizchip() : wizchip_conf.h , wizchip_conf.c

- d -

  • disconnect() : socket.c , socket.h

- g -

  • getsockopt() : socket.c , socket.h

- l -

  • listen() : socket.c , socket.h

- r -

  • recv() : socket.c , socket.h
  • recvfrom() : socket.h , socket.c
  • reg_wizchip_bus_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_cris_cbfunc() : wizchip_conf.h , wizchip_conf.c
  • reg_wizchip_cs_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_spi_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_spiburst_cbfunc() : wizchip_conf.h , wizchip_conf.c

- s -

  • send() : socket.c , socket.h
  • sendto() : socket.h , socket.c
  • setsockopt() : socket.c , socket.h
  • socket() : socket.h , socket.c

- w -

  • wizchip_bus_readbyte() : wizchip_conf.c
  • wizchip_bus_writebyte() : wizchip_conf.c
  • wizchip_clrinterrupt() : wizchip_conf.h , wizchip_conf.c
  • wizchip_cris_enter() : wizchip_conf.c
  • wizchip_cris_exit() : wizchip_conf.c
  • wizchip_cs_deselect() : wizchip_conf.c
  • wizchip_cs_select() : wizchip_conf.c
  • wizchip_getinterrupt() : wizchip_conf.c , wizchip_conf.h
  • wizchip_getinterruptmask() : wizchip_conf.c , wizchip_conf.h
  • wizchip_getnetinfo() : wizchip_conf.c , wizchip_conf.h
  • wizchip_getnetmode() : wizchip_conf.h , wizchip_conf.c
  • wizchip_gettimeout() : wizchip_conf.c , wizchip_conf.h
  • wizchip_init() : wizchip_conf.c , wizchip_conf.h
  • wizchip_setinterruptmask() : wizchip_conf.c , wizchip_conf.h
  • wizchip_setnetinfo() : wizchip_conf.c , wizchip_conf.h
  • wizchip_setnetmode() : wizchip_conf.c , wizchip_conf.h
  • wizchip_settimeout() : wizchip_conf.c , wizchip_conf.h
  • wizchip_spi_readburst() : wizchip_conf.c
  • wizchip_spi_readbyte() : wizchip_conf.c
  • wizchip_spi_writeburst() : wizchip_conf.c
  • wizchip_spi_writebyte() : wizchip_conf.c
  • wizchip_sw_reset() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphyconf() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphylink() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphypmode() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphystat() : wizchip_conf.c , wizchip_conf.h
  • wizphy_reset() : wizchip_conf.c , wizchip_conf.h
  • wizphy_setphyconf() : wizchip_conf.h , wizchip_conf.c
  • wizphy_setphypmode() : wizchip_conf.h , wizchip_conf.c
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • WIZCHIP : wizchip_conf.c , wizchip_conf.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _WIZCHIP : wizchip_conf.h
  • wiz_NetInfo : wizchip_conf.h
  • wiz_NetTimeout : wizchip_conf.h
  • wiz_PhyConf : wizchip_conf.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • ctlnetwork_type : wizchip_conf.h
  • ctlsock_type : socket.h
  • ctlwizchip_type : wizchip_conf.h
  • dhcp_mode : wizchip_conf.h
  • intr_kind : wizchip_conf.h
  • netmode_type : wizchip_conf.h
  • sockint_kind : socket.h
  • sockopt_type : socket.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • c
  • i
  • n
  • s

- c -

  • CN_GET_NETINFO : wizchip_conf.h
  • CN_GET_NETMODE : wizchip_conf.h
  • CN_GET_TIMEOUT : wizchip_conf.h
  • CN_SET_NETINFO : wizchip_conf.h
  • CN_SET_NETMODE : wizchip_conf.h
  • CN_SET_TIMEOUT : wizchip_conf.h
  • CS_CLR_INTERRUPT : socket.h
  • CS_GET_INTERRUPT : socket.h
  • CS_GET_INTMASK : socket.h
  • CS_GET_IOMODE : socket.h
  • CS_GET_MAXRXBUF : socket.h
  • CS_GET_MAXTXBUF : socket.h
  • CS_SET_INTMASK : socket.h
  • CS_SET_IOMODE : socket.h
  • CW_CLR_INTERRUPT : wizchip_conf.h
  • CW_GET_ID : wizchip_conf.h
  • CW_GET_INTERRUPT : wizchip_conf.h
  • CW_GET_INTRMASK : wizchip_conf.h
  • CW_GET_INTRTIME : wizchip_conf.h
  • CW_GET_PHYCONF : wizchip_conf.h
  • CW_GET_PHYLINK : wizchip_conf.h
  • CW_GET_PHYPOWMODE : wizchip_conf.h
  • CW_GET_PHYSTATUS : wizchip_conf.h
  • CW_INIT_WIZCHIP : wizchip_conf.h
  • CW_RESET_PHY : wizchip_conf.h
  • CW_RESET_WIZCHIP : wizchip_conf.h
  • CW_SET_INTRMASK : wizchip_conf.h
  • CW_SET_INTRTIME : wizchip_conf.h
  • CW_SET_PHYCONF : wizchip_conf.h
  • CW_SET_PHYPOWMODE : wizchip_conf.h

- i -

  • IK_DEST_UNREACH : wizchip_conf.h
  • IK_IP_CONFLICT : wizchip_conf.h
  • IK_PPPOE_TERMINATED : wizchip_conf.h
  • IK_SOCK_0 : wizchip_conf.h
  • IK_SOCK_1 : wizchip_conf.h
  • IK_SOCK_2 : wizchip_conf.h
  • IK_SOCK_3 : wizchip_conf.h
  • IK_SOCK_4 : wizchip_conf.h
  • IK_SOCK_5 : wizchip_conf.h
  • IK_SOCK_6 : wizchip_conf.h
  • IK_SOCK_7 : wizchip_conf.h
  • IK_SOCK_ALL : wizchip_conf.h
  • IK_WOL : wizchip_conf.h

- n -

  • NETINFO_DHCP : wizchip_conf.h
  • NETINFO_STATIC : wizchip_conf.h
  • NM_FORCEARP : wizchip_conf.h
  • NM_PINGBLOCK : wizchip_conf.h
  • NM_PPPOE : wizchip_conf.h
  • NM_WAKEONLAN : wizchip_conf.h

- s -

  • SIK_ALL : socket.h
  • SIK_CONNECTED : socket.h
  • SIK_DISCONNECTED : socket.h
  • SIK_RECEIVED : socket.h
  • SIK_SENT : socket.h
  • SIK_TIMEOUT : socket.h
  • SO_DESTIP : socket.h
  • SO_DESTPORT : socket.h
  • SO_FLAG : socket.h
  • SO_KEEPALIVEAUTO : socket.h
  • SO_KEEPALIVESEND : socket.h
  • SO_MSS : socket.h
  • SO_PACKINFO : socket.h
  • SO_RECVBUF : socket.h
  • SO_REMAINSIZE : socket.h
  • SO_SENDBUF : socket.h
  • SO_STATUS : socket.h
  • SO_TOS : socket.h
  • SO_TTL : socket.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: File Members

  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • _
  • c
  • p
  • s

- _ -

  • _W5500_SPI_FDM_OP_LEN1_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN2_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN4_ : w5500.c
  • _W5500_SPI_VDM_OP_ : w5500.c
  • _WIZCHIP_ : wizchip_conf.h
  • _WIZCHIP_ID_ : wizchip_conf.h
  • _WIZCHIP_IO_BASE_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_BUS_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_BUS_DIR_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_BUS_INDIR_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_NONE_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_FDM_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_VDM_ : wizchip_conf.h
  • _WIZCHIP_SOCK_NUM_ : wizchip_conf.h

- c -

  • CHECK_SOCKDATA : socket.c
  • CHECK_SOCKINIT : socket.c
  • CHECK_SOCKMODE : socket.c
  • CHECK_SOCKNUM : socket.c

- p -

  • PACK_COMPLETED : socket.h
  • PACK_FIRST : socket.h
  • PACK_REMAINED : socket.h
  • PHY_CONFBY_HW : wizchip_conf.h
  • PHY_CONFBY_SW : wizchip_conf.h
  • PHY_DUPLEX_FULL : wizchip_conf.h
  • PHY_DUPLEX_HALF : wizchip_conf.h
  • PHY_LINK_OFF : wizchip_conf.h
  • PHY_LINK_ON : wizchip_conf.h
  • PHY_MODE_AUTONEGO : wizchip_conf.h
  • PHY_MODE_MANUAL : wizchip_conf.h
  • PHY_POWER_DOWN : wizchip_conf.h
  • PHY_POWER_NORM : wizchip_conf.h
  • PHY_SPEED_10 : wizchip_conf.h
  • PHY_SPEED_100 : wizchip_conf.h

- s -

  • SF_BROAD_BLOCK : socket.h
  • SF_ETHER_OWN : socket.h
  • SF_IGMP_VER2 : socket.h
  • SF_IO_NONBLOCK : socket.h
  • SF_IPv6_BLOCK : socket.h
  • SF_MULTI_BLOCK : socket.h
  • SF_MULTI_ENABLE : socket.h
  • SF_TCP_NODELAY : socket.h
  • SF_UNI_BLOCK : socket.h
  • SOCK_ANY_PORT_NUM : socket.c
  • SOCK_BUSY : socket.h
  • SOCK_ERROR : socket.h
  • SOCK_FATAL : socket.h
  • SOCK_IO_BLOCK : socket.h
  • SOCK_IO_NONBLOCK : socket.h
  • SOCK_OK : socket.h
  • SOCKERR_ARG : socket.h
  • SOCKERR_BUFFER : socket.h
  • SOCKERR_DATALEN : socket.h
  • SOCKERR_IPINVALID : socket.h
  • SOCKERR_PORTZERO : socket.h
  • SOCKERR_SOCKCLOSED : socket.h
  • SOCKERR_SOCKFLAG : socket.h
  • SOCKERR_SOCKINIT : socket.h
  • SOCKERR_SOCKMODE : socket.h
  • SOCKERR_SOCKNUM : socket.h
  • SOCKERR_SOCKOPT : socket.h
  • SOCKERR_SOCKSTATUS : socket.h
  • SOCKERR_TIMEOUT : socket.h
  • SOCKET : socket.h
  • SOCKFATAL_PACKLEN : socket.h
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: Doxygen/Doxyfile.dox File Reference

Doxygen/Doxyfile.dox File Reference
Generated on Mon Apr 13 2015 09:40:04 for Socket APIs by doxygen 1.8.4


Socket APIs: Doxygen/Main_page.txt File Reference

Doxygen/Main_page.txt File Reference
Generated on Mon Apr 13 2015 09:40:04 for Socket APIs by doxygen 1.8.4


Socket APIs: Graph Legend

Graph Legend

This page explains how to interpret the graphs that are generated by doxygen.

Consider the following example:

/*! Invisible class because of truncation */
class Invisible { };
/*! Truncated class, inheritance relation is hidden */
class Truncated : public Invisible { };
/* Class not documented with doxygen comments */
class Undocumented { };
/*! Class that is inherited using public inheritance */
class PublicBase : public Truncated { };
/*! A template class */
template<class T> class Templ { };
/*! Class that is inherited using protected inheritance */
class ProtectedBase { };
/*! Class that is inherited using private inheritance */
class PrivateBase { };
/*! Class that is used by the Inherited class */
class Used { };
/*! Super class that inherits a number of other classes */
class Inherited : public PublicBase,
protected ProtectedBase,
private PrivateBase,
public Undocumented,
public Templ<int>
{
private:
Used *m_usedClass;
};

This will result in the following graph:

The boxes in the above graph have the following meaning:

  • A filled gray box represents the struct or class for which the graph is generated.
  • A box with a black border denotes a documented struct or class.
  • A box with a grey border denotes an undocumented struct or class.
  • A box with a red border denotes a documented struct or class forwhich not all inheritance/containment relations are shown. A graph is truncated if it does not fit within the specified boundaries.

The arrows have the following meaning:

  • A dark blue arrow is used to visualize a public inheritance relation between two classes.
  • A dark green arrow is used for protected inheritance.
  • A dark red arrow is used for private inheritance.
  • A purple dashed arrow is used if a class is contained or used by another class. The arrow is labeled with the variable(s) through which the pointed class or struct is accessible.
  • A yellow dashed arrow denotes a relation between a template instance and the template class it was instantiated from. The arrow is labeled with the template parameters of the instance.


Socket APIs: Socket APIs

Socket APIs

This Socket APIs provide guides to WIZnet Hardwired TCP/IP Chips (WIZCHIP) user.
It contains not olny Socket APIs but also accessing registers, configuration and interface to WIZCHIP.
It proposes to integrate for user application program. It is easy to change the enhanced WIZCHIP and migrate user application.

Available WIZCHIP product
  • W5500
  • W5200
  • W5100
  • Available soon
    • W5300
Version 2.0.0
Release Notes
  • 2013/10/01
    • First Released V1.0.0
  • 2015/04/01
    • Second Released V2.0.0
    • Add W5100 & W5200 to ioLibrary
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: Related Pages

Related Pages
Here is a list of all related documentation pages:
\ Todo List
Generated on Mon Apr 13 2015 09:40:05 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/socket.c Source File

  • Ethernet
socket.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
54 //
55 //*****************************************************************************
56 #include "socket.h"
57
58 //M20150401 : Typing Error
59 //#define SOCK_ANY_PORT_NUM 0xC000;
60 #define SOCK_ANY_PORT_NUM 0xC000
61
62 static uint16_t sock_any_port = SOCK_ANY_PORT_NUM;
63 static uint16_t sock_io_mode = 0;
64 static uint16_t sock_is_sending = 0;
65 static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,};
66 static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,};
67
68 #if _WIZCHIP_ == 5200
69 static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,};
70 #endif
71
72 #define CHECK_SOCKNUM() \
73 do{ \
74 if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \
75 }while(0); \
76
77 #define CHECK_SOCKMODE(mode) \
78 do{ \
79 if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \
80 }while(0); \
81
82 #define CHECK_SOCKINIT() \
83 do{ \
84 if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \
85 }while(0); \
86
87 #define CHECK_SOCKDATA() \
88 do{ \
89 if(len == 0) return SOCKERR_DATALEN; \
90 }while(0); \
91
92
93
94 int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
95 {
96 CHECK_SOCKNUM();
97 switch(protocol)
98 {
99 case Sn_MR_TCP :
100 {
101 uint8_t taddr[4];
102 getSIPR(taddr);
103 if(taddr == 0) return SOCKERR_SOCKINIT;
104 }
105 case Sn_MR_UDP :
106 case Sn_MR_MACRAW :
107 break;
108 #if ( _WIZCHIP_ < 5200 )
109 case Sn_MR_IPRAW :
110 case Sn_MR_PPPoE :
111 break;
112 #endif
113 default :
114 return SOCKERR_SOCKMODE;
115 }
116 if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG;
117 #if _WIZCHIP_ == 5200
118 if(flag & 0x10) return SOCKERR_SOCKFLAG;
119 #endif
120
121 if(flag != 0)
122 {
123 switch(protocol)
124 {
125 case Sn_MR_TCP:
126 if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG;
127 break;
128 case Sn_MR_UDP:
129 if(flag & SF_IGMP_VER2)
130 {
131 if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG;
132 }
133 #if _WIZCHIP_ == 5500
134 if(flag & SF_UNI_BLOCK)
135 {
136 if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG;
137 }
138 #endif
139 break;
140 default:
141 break;
142 }
143 }
144 close(sn);
145 setSn_MR(sn, (protocol | (flag & 0xF0)));
146 if(!port)
147 {
148 port = sock_any_port++;
149 if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM;
150 }
151 setSn_PORT(sn,port);
152 setSn_CR(sn,Sn_CR_OPEN);
153 while(getSn_CR(sn));
154 //A20150401 : For release the previous sock_io_mode
155 sock_io_mode &= ~(1 <<sn);
156 //
157 sock_io_mode |= ((flag & SF_IO_NONBLOCK) << sn);
158 sock_is_sending &= ~(1<<sn);
159 sock_remained_size[sn] = 0;
160 sock_pack_info[sn] = 0;
161 while(getSn_SR(sn) == SOCK_CLOSED);
162 return (int8_t)sn;
163 }
164
165 int8_t close(uint8_t sn)
166 {
167 CHECK_SOCKNUM();
168
169 setSn_CR(sn,Sn_CR_CLOSE);
170 /* wait to process the command... */
171 while( getSn_CR(sn) );
172 /* clear all interrupt of the socket. */
173 setSn_IR(sn, 0xFF);
174 //A20150401 : Release the sock_io_mode of socket n.
175 sock_io_mode &= ~(1<<sn);
176 //
177 sock_is_sending &= ~(1<<sn);
178 sock_remained_size[sn] = 0;
179 sock_pack_info[sn] = 0;
180 while(getSn_SR(sn) != SOCK_CLOSED);
181 return SOCK_OK;
182 }
183
184 int8_t listen(uint8_t sn)
185 {
186 CHECK_SOCKNUM();
187 CHECK_SOCKMODE(Sn_MR_TCP);
188 CHECK_SOCKINIT();
189 setSn_CR(sn,Sn_CR_LISTEN);
190 while(getSn_CR(sn));
191 while(getSn_SR(sn) != SOCK_LISTEN)
192 {
193 if(getSn_CR(sn) == SOCK_CLOSED)
194 {
195 close(sn);
196 return SOCKERR_SOCKCLOSED;
197 }
198 }
199 return SOCK_OK;
200 }
201
202
203 int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port)
204 {
205 CHECK_SOCKNUM();
206 CHECK_SOCKMODE(Sn_MR_TCP);
207 CHECK_SOCKINIT();
208 //M20140501 : For avoiding fatal error on memory align mismatched
209 //if( *((uint32_t*)addr) == 0xFFFFFFFF || *((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
210 {
211 uint32_t taddr;
212 taddr = ((uint32_t)addr[0] & 0x000000FF);
213 taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF);
214 taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF);
215 taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF);
216 if( taddr == 0xFFFFFFFF || taddr == 0) return SOCKERR_IPINVALID;
217 }
218 //
219
220 if(port == 0) return SOCKERR_PORTZERO;
221 setSn_DIPR(sn,addr);
222 setSn_DPORT(sn,port);
223 setSn_CR(sn,Sn_CR_CONNECT);
224 while(getSn_CR(sn));
225 if(sock_io_mode & (1<<sn)) return SOCK_BUSY;
226 while(getSn_SR(sn) != SOCK_ESTABLISHED)
227 {
228 if (getSn_IR(sn) & Sn_IR_TIMEOUT)
229 {
230 setSn_IR(sn, Sn_IR_TIMEOUT);
231 return SOCKERR_TIMEOUT;
232 }
233
234 if (getSn_SR(sn) == SOCK_CLOSED)
235 {
236 return SOCKERR_SOCKCLOSED;
237 }
238 }
239
240 return SOCK_OK;
241 }
242
243 int8_t disconnect(uint8_t sn)
244 {
245 CHECK_SOCKNUM();
246 CHECK_SOCKMODE(Sn_MR_TCP);
247 setSn_CR(sn,Sn_CR_DISCON);
248 /* wait to process the command... */
249 while(getSn_CR(sn));
250 sock_is_sending &= ~(1<<sn);
251 if(sock_io_mode & (1<<sn)) return SOCK_BUSY;
252 while(getSn_SR(sn) != SOCK_CLOSED)
253 {
254 if(getSn_IR(sn) & Sn_IR_TIMEOUT)
255 {
256 close(sn);
257 return SOCKERR_TIMEOUT;
258 }
259 }
260 return SOCK_OK;
261 }
262
263 int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
264 {
265 uint8_t tmp=0;
266 uint16_t freesize=0;
267
268 CHECK_SOCKNUM();
269 CHECK_SOCKMODE(Sn_MR_TCP);
270 CHECK_SOCKDATA();
271 tmp = getSn_SR(sn);
272 if(tmp != SOCK_ESTABLISHED && tmp != SOCK_CLOSE_WAIT) return SOCKERR_SOCKSTATUS;
273 if( sock_is_sending & (1<<sn) )
274 {
275 tmp = getSn_IR(sn);
276 if(tmp & Sn_IR_SENDOK)
277 {
278 setSn_IR(sn, Sn_IR_SENDOK);
279 //M20150401 : Typing Error
280 //#if _WZICHIP_ == 5200
281 #if _WIZCHIP_ == 5200
282 if(getSn_TX_RD(sn) != sock_next_rd[sn])
283 {
284 setSn_CR(sn,Sn_CR_SEND);
285 while(getSn_CR(sn));
286 return SOCK_BUSY;
287 }
288 #endif
289 sock_is_sending &= ~(1<<sn);
290 }
291 else if(tmp & Sn_IR_TIMEOUT)
292 {
293 close(sn);
294 return SOCKERR_TIMEOUT;
295 }
296 else return SOCK_BUSY;
297 }
298 freesize = getSn_TxMAX(sn);
299 if (len > freesize) len = freesize; // check size not to exceed MAX size.
300 while(1)
301 {
302 freesize = getSn_TX_FSR(sn);
303 tmp = getSn_SR(sn);
304 if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT))
305 {
306 close(sn);
307 return SOCKERR_SOCKSTATUS;
308 }
309 if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
310 if(len <= freesize) break;
311 }
312 wiz_send_data(sn, buf, len);
313 #if _WIZCHIP_ == 5200
314 sock_next_rd[sn] = getSn_TX_RD(sn) + len;
315 #endif
316 setSn_CR(sn,Sn_CR_SEND);
317 /* wait to process the command... */
318 while(getSn_CR(sn));
319 sock_is_sending |= (1 << sn);
320 //M20150409 : Explicit Type Casting
321 //return len;
322 return (int32_t)len;
323 }
324
325
326 int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len)
327 {
328 uint8_t tmp = 0;
329 uint16_t recvsize = 0;
330 CHECK_SOCKNUM();
331 CHECK_SOCKMODE(Sn_MR_TCP);
332 CHECK_SOCKDATA();
333
334 recvsize = getSn_RxMAX(sn);
335 if(recvsize < len) len = recvsize;
336 while(1)
337 {
338 recvsize = getSn_RX_RSR(sn);
339 tmp = getSn_SR(sn);
340 if (tmp != SOCK_ESTABLISHED)
341 {
342 if(tmp == SOCK_CLOSE_WAIT)
343 {
344 if(recvsize != 0) break;
345 else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn))
346 {
347 close(sn);
348 return SOCKERR_SOCKSTATUS;
349 }
350 }
351 else
352 {
353 close(sn);
354 return SOCKERR_SOCKSTATUS;
355 }
356 }
357 if((sock_io_mode & (1<<sn)) && (recvsize == 0)) return SOCK_BUSY;
358 if(recvsize != 0) break;
359 };
360 if(recvsize < len) len = recvsize;
361 wiz_recv_data(sn, buf, len);
362 setSn_CR(sn,Sn_CR_RECV);
363 while(getSn_CR(sn));
364 //M20150409 : Explicit Type Casting
365 //return len;
366 return (int32_t)len;
367 }
368
369 int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port)
370 {
371 uint8_t tmp = 0;
372 uint16_t freesize = 0;
373 uint32_t taddr;
374
375 CHECK_SOCKNUM();
376 switch(getSn_MR(sn) & 0x0F)
377 {
378 case Sn_MR_UDP:
379 case Sn_MR_MACRAW:
380 break;
381 default:
382 return SOCKERR_SOCKMODE;
383 }
384 CHECK_SOCKDATA();
385 //M20140501 : For avoiding fatal error on memory align mismatched
386 //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
387 //{
388 //uint32_t taddr;
389 taddr = ((uint32_t)addr[0]) & 0x000000FF;
390 taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF);
391 taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF);
392 taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF);
393 //}
394 //
395 //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
396 if(taddr == 0) return SOCKERR_IPINVALID;
397 if(port == 0) return SOCKERR_PORTZERO;
398 tmp = getSn_SR(sn);
399 if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS;
400
401 setSn_DIPR(sn,addr);
402 setSn_DPORT(sn,port);
403 freesize = getSn_TxMAX(sn);
404 if (len > freesize) len = freesize; // check size not to exceed MAX size.
405 while(1)
406 {
407 freesize = getSn_TX_FSR(sn);
408 if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED;
409 if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
410 if(len <= freesize) break;
411 };
412 wiz_send_data(sn, buf, len);
413
414 #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata)
415 getSIPR((uint8_t*)&taddr);
416 if(taddr == 0)
417 {
418 getSUBR((uint8_t*)&taddr);
419 setSUBR((uint8_t*)"\x00\x00\x00\x00");
420 }
421 else taddr = 0;
422 #endif
423
424 setSn_CR(sn,Sn_CR_SEND);
425 /* wait to process the command... */
426 while(getSn_CR(sn));
427 while(1)
428 {
429 tmp = getSn_IR(sn);
430 if(tmp & Sn_IR_SENDOK)
431 {
432 setSn_IR(sn, Sn_IR_SENDOK);
433 break;
434 }
435 //M:20131104
436 //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT;
437 else if(tmp & Sn_IR_TIMEOUT)
438 {
439 setSn_IR(sn, Sn_IR_TIMEOUT);
440 //M20150409 : Fixed the lost of sign bits by type casting.
441 //len = (uint16_t)SOCKERR_TIMEOUT;
442 //break;
443 #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata)
444 if(taddr) setSUBR((uint8_t*)&taddr);
445 #endif
446 return SOCKERR_TIMEOUT;
447 }
449 }
450 #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata)
451 if(taddr) setSUBR((uint8_t*)&taddr);
452 #endif
453 //M20150409 : Explicit Type Casting
454 //return len;
455 return (int32_t)len;
456 }
457
458
459
460 int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port)
461 {
462 uint8_t mr;
463 uint8_t head[8];
464 uint16_t pack_len=0;
465
466 CHECK_SOCKNUM();
467 //CHECK_SOCKMODE(Sn_MR_UDP);
468 switch((mr=getSn_MR(sn)) & 0x0F)
469 {
470 case Sn_MR_UDP:
471 case Sn_MR_MACRAW:
472 break;
473 #if ( _WIZCHIP_ < 5200 )
474 case Sn_MR_IPRAW:
475 case Sn_MR_PPPoE:
476 break;
477 #endif
478 default:
479 return SOCKERR_SOCKMODE;
480 }
481 CHECK_SOCKDATA();
482 if(sock_remained_size[sn] == 0)
483 {
484 while(1)
485 {
486 pack_len = getSn_RX_RSR(sn);
487 if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED;
488 if( (sock_io_mode & (1<<sn)) && (pack_len == 0) ) return SOCK_BUSY;
489 if(pack_len != 0) break;
490 };
491 }
492 sock_pack_info[sn] = PACK_COMPLETED;
493 switch (mr & 0x07)
494 {
495 case Sn_MR_UDP :
496 if(sock_remained_size[sn] == 0)
497 {
498 wiz_recv_data(sn, head, 8);
499 setSn_CR(sn,Sn_CR_RECV);
500 while(getSn_CR(sn));
501 // read peer's IP address, port number & packet length
502 addr[0] = head[0];
503 addr[1] = head[1];
504 addr[2] = head[2];
505 addr[3] = head[3];
506 *port = head[4];
507 *port = (*port << 8) + head[5];
508 sock_remained_size[sn] = head[6];
509 sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[7];
510 sock_pack_info[sn] = PACK_FIRST;
511 }
512 if(len < sock_remained_size[sn]) pack_len = len;
513 else pack_len = sock_remained_size[sn];
514 //
515 // Need to packet length check (default 1472)
516 //
517 wiz_recv_data(sn, buf, pack_len); // data copy.
518 break;
519 case Sn_MR_MACRAW :
520 if(sock_remained_size[sn] == 0)
521 {
522 wiz_recv_data(sn, head, 2);
523 setSn_CR(sn,Sn_CR_RECV);
524 while(getSn_CR(sn));
525 // read peer's IP address, port number & packet length
526 sock_remained_size[sn] = head[0];
527 sock_remained_size[sn] = (sock_remained_size[sn] <<8) + head[1];
528 if(sock_remained_size[sn] > 1514)
529 {
530 close(sn);
531 return SOCKFATAL_PACKLEN;
532 }
533 sock_pack_info[sn] = PACK_FIRST;
534 }
535 if(len < sock_remained_size[sn]) pack_len = len;
536 else pack_len = sock_remained_size[sn];
537 wiz_recv_data(sn,buf,pack_len);
538 break;
539 #if ( _WIZCHIP_ < 5200 )
540 case Sn_MR_IPRAW:
541 if(sock_remained_size[sn] == 0)
542 {
543 wiz_recv_data(sn, head, 6);
544 setSn_CR(sn,Sn_CR_RECV);
545 while(getSn_CR(sn));
546 addr[0] = head[0];
547 addr[1] = head[1];
548 addr[2] = head[2];
549 addr[3] = head[3];
550 sock_remained_size[sn] = head[4];
551 //M20150401 : For Typing Error
552 //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5];
553 sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5];
554 sock_pack_info[sn] = PACK_FIRST;
555 }
556 //
557 // Need to packet length check
558 //
559 if(len < sock_remained_size[sn]) pack_len = len;
560 else pack_len = sock_remained_size[sn];
561 wiz_recv_data(sn, buf, pack_len); // data copy.
562 break;
563 #endif
564 default:
565 wiz_recv_ignore(sn, pack_len); // data copy.
566 sock_remained_size[sn] = pack_len;
567 break;
568 }
569 setSn_CR(sn,Sn_CR_RECV);
570 /* wait to process the command... */
571 while(getSn_CR(sn)) ;
572 sock_remained_size[sn] -= pack_len;
573 //M20140501 : replace 0x01 with PACK_REMAINED
574 //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01;
575 if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= PACK_REMAINED;
576 //
577 //M20150409 : Explicit Type Casting
578 //return pack_len;
579 return (int32_t)pack_len;
580 }
581
582
583 int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg)
584 {
585 uint8_t tmp = 0;
586 CHECK_SOCKNUM();
587 switch(cstype)
588 {
589 case CS_SET_IOMODE:
590 tmp = *((uint8_t*)arg);
591 if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1<<sn);
592 else if(tmp == SOCK_IO_BLOCK) sock_io_mode &= ~(1<<sn);
593 else return SOCKERR_ARG;
594 break;
595 case CS_GET_IOMODE:
596 //M20140501 : implict type casting -> explict type casting
597 //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001;
598 *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001);
599 //
600 break;
601 case CS_GET_MAXTXBUF:
602 *((uint16_t*)arg) = getSn_TxMAX(sn);
603 break;
604 case CS_GET_MAXRXBUF:
605 *((uint16_t*)arg) = getSn_RxMAX(sn);
606 break;
607 case CS_CLR_INTERRUPT:
608 if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG;
609 setSn_IR(sn,*(uint8_t*)arg);
610 break;
611 case CS_GET_INTERRUPT:
612 *((uint8_t*)arg) = getSn_IR(sn);
613 break;
614 #if _WIZCHIP_ != 5100
615 case CS_SET_INTMASK:
616 if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG;
617 setSn_IMR(sn,*(uint8_t*)arg);
618 break;
619 case CS_GET_INTMASK:
620 *((uint8_t*)arg) = getSn_IMR(sn);
621 break;
622 #endif
623 default:
624 return SOCKERR_ARG;
625 }
626 return SOCK_OK;
627 }
628
629 int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg)
630 {
631 // M20131220 : Remove warning
632 //uint8_t tmp;
633 CHECK_SOCKNUM();
634 switch(sotype)
635 {
636 case SO_TTL:
637 setSn_TTL(sn,*(uint8_t*)arg);
638 break;
639 case SO_TOS:
640 setSn_TOS(sn,*(uint8_t*)arg);
641 break;
642 case SO_MSS:
643 setSn_MSSR(sn,*(uint16_t*)arg);
644 break;
645 case SO_DESTIP:
646 setSn_DIPR(sn, (uint8_t*)arg);
647 break;
648 case SO_DESTPORT:
649 setSn_DPORT(sn, *(uint16_t*)arg);
650 break;
651 #if _WIZCHIP_ != 5100
652 case SO_KEEPALIVESEND:
653 CHECK_SOCKMODE(Sn_MR_TCP);
654 #if _WIZCHIP_ > 5200
655 if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT;
656 #endif
657 setSn_CR(sn,Sn_CR_SEND_KEEP);
658 while(getSn_CR(sn) != 0)
659 {
660 // M20131220
661 //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT)
662 if (getSn_IR(sn) & Sn_IR_TIMEOUT)
663 {
664 setSn_IR(sn, Sn_IR_TIMEOUT);
665 return SOCKERR_TIMEOUT;
666 }
667 }
668 break;
669 #if _WIZCHIP_ > 5200
670 case SO_KEEPALIVEAUTO:
671 CHECK_SOCKMODE(Sn_MR_TCP);
672 setSn_KPALVTR(sn,*(uint8_t*)arg);
673 break;
674 #endif
675 #endif
676 default:
677 return SOCKERR_ARG;
678 }
679 return SOCK_OK;
680 }
681
682 int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg)
683 {
684 CHECK_SOCKNUM();
685 switch(sotype)
686 {
687 case SO_FLAG:
688 *(uint8_t*)arg = getSn_MR(sn) & 0xF0;
689 break;
690 case SO_TTL:
691 *(uint8_t*) arg = getSn_TTL(sn);
692 break;
693 case SO_TOS:
694 *(uint8_t*) arg = getSn_TOS(sn);
695 break;
696 case SO_MSS:
697 *(uint8_t*) arg = getSn_MSSR(sn);
698 break;
699 case SO_DESTIP:
700 getSn_DIPR(sn, (uint8_t*)arg);
701 break;
702 case SO_DESTPORT:
703 *(uint16_t*) arg = getSn_DPORT(sn);
704 break;
705 #if _WIZCHIP_ > 5200
706 case SO_KEEPALIVEAUTO:
707 CHECK_SOCKMODE(Sn_MR_TCP);
708 *(uint16_t*) arg = getSn_KPALVTR(sn);
709 break;
710 #endif
711 case SO_SENDBUF:
712 *(uint16_t*) arg = getSn_TX_FSR(sn);
713 break;
714 case SO_RECVBUF:
715 *(uint16_t*) arg = getSn_RX_RSR(sn);
716 break;
717 case SO_STATUS:
718 *(uint8_t*) arg = getSn_SR(sn);
719 break;
720 case SO_REMAINSIZE:
721 if(getSn_MR(sn) == Sn_MR_TCP)
722 *(uint16_t*)arg = getSn_RX_RSR(sn);
723 else
724 *(uint16_t*)arg = sock_remained_size[sn];
725 break;
726 case SO_PACKINFO:
727 CHECK_SOCKMODE(Sn_MR_TCP);
728 *(uint8_t*)arg = sock_pack_info[sn];
729 break;
730 default:
731 return SOCKERR_SOCKOPT;
732 }
733 return SOCK_OK;
734 }
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/socket.h Source File

  • Ethernet
socket.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
47 //
48 //*****************************************************************************
85 #ifndef _SOCKET_H_
86 #define _SOCKET_H_
87
88 #include "wizchip_conf.h"
89
90 #define SOCKET uint8_t
91
92 #define SOCK_OK 1
93 #define SOCK_BUSY 0
94 #define SOCK_FATAL -1000
95
96 #define SOCK_ERROR 0
97 #define SOCKERR_SOCKNUM (SOCK_ERROR - 1)
98 #define SOCKERR_SOCKOPT (SOCK_ERROR - 2)
99 #define SOCKERR_SOCKINIT (SOCK_ERROR - 3)
100 #define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4)
101 #define SOCKERR_SOCKMODE (SOCK_ERROR - 5)
102 #define SOCKERR_SOCKFLAG (SOCK_ERROR - 6)
103 #define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7)
104 #define SOCKERR_ARG (SOCK_ERROR - 10)
105 #define SOCKERR_PORTZERO (SOCK_ERROR - 11)
106 #define SOCKERR_IPINVALID (SOCK_ERROR - 12)
107 #define SOCKERR_TIMEOUT (SOCK_ERROR - 13)
108 #define SOCKERR_DATALEN (SOCK_ERROR - 14)
109 #define SOCKERR_BUFFER (SOCK_ERROR - 15)
110
111 #define SOCKFATAL_PACKLEN (SOCK_FATAL - 1)
112
113 /*
114 * SOCKET FLAG
115 */
116 #define SF_ETHER_OWN (Sn_MR_MFEN)
117 #define SF_IGMP_VER2 (Sn_MR_MC)
118 #define SF_TCP_NODELAY (Sn_MR_ND)
119 #define SF_MULTI_ENABLE (Sn_MR_MULTI)
120
121 #if _WIZCHIP_ == 5500
122 #define SF_BROAD_BLOCK (Sn_MR_BCASTB)
123 #define SF_MULTI_BLOCK (Sn_MR_MMB)
124 #define SF_IPv6_BLOCK (Sn_MR_MIP6B)
125 #define SF_UNI_BLOCK (Sn_MR_UCASTB)
126 #endif
127
128 #define SF_IO_NONBLOCK 0x01
129
130 /*
131 * UDP & MACRAW Packet Infomation
132 */
133 #define PACK_FIRST 0x80
134 #define PACK_REMAINED 0x01
135 #define PACK_COMPLETED 0x00
136
137
154 int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
155
166 int8_t close(uint8_t sn);
167
179 int8_t listen(uint8_t sn);
180
202 int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port);
203
219 int8_t disconnect(uint8_t sn);
220
239 int32_t send(uint8_t sn, uint8_t * buf, uint16_t len);
240
261 int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len);
262
289 int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port);
290
319 int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port);
320
321
323 // SOCKET CONTROL & OPTION //
325 #define SOCK_IO_BLOCK 0
326 #define SOCK_IO_NONBLOCK 1
327
328
337 typedef enum
338 {
339 SIK_CONNECTED = (1 << 0),
340 SIK_DISCONNECTED = (1 << 1),
341 SIK_RECEIVED = (1 << 2),
342 SIK_TIMEOUT = (1 << 3),
343 SIK_SENT = (1 << 4),
344 //M20150410 : Remove the comma of last member
345 //SIK_ALL = 0x1F, ///< all interrupt
346 SIK_ALL = 0x1F
347 }sockint_kind;
348
353 typedef enum
354 {
355 CS_SET_IOMODE,
356 CS_GET_IOMODE,
357 CS_GET_MAXTXBUF,
358 CS_GET_MAXRXBUF,
359 CS_CLR_INTERRUPT,
360 CS_GET_INTERRUPT,
361 #if _WIZCHIP_ > 5100
362 CS_SET_INTMASK,
363 CS_GET_INTMASK
364 #endif
365 }ctlsock_type;
366
367
372 typedef enum
373 {
374 SO_FLAG,
375 SO_TTL,
376 SO_TOS,
377 SO_MSS,
378 SO_DESTIP,
379 SO_DESTPORT,
380 #if _WIZCHIP_ != 5100
381 SO_KEEPALIVESEND,
382 #if _WIZCHIP_ > 5200
383 SO_KEEPALIVEAUTO,
384 #endif
385 #endif
386 SO_SENDBUF,
387 SO_RECVBUF,
388 SO_STATUS,
389 SO_REMAINSIZE,
390 SO_PACKINFO
391 }sockopt_type;
392
410 int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg);
411
438 int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg);
439
472 int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg);
473
474 #endif // _SOCKET_H_
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Member List

  • Class List
  • Class Index
  • Class Members
__WIZCHIP Member List

This is the complete list of members for __WIZCHIP, including all inherited members.

CRIS | __WIZCHIP
CS | __WIZCHIP
id | __WIZCHIP
IF | __WIZCHIP
if_mode | __WIZCHIP


Socket APIs: Member List

  • Class List
  • Class Index
  • Class Members
  • __WIZCHIP
  • _CRIS
__WIZCHIP::_CRIS Member List

This is the complete list of members for __WIZCHIP::_CRIS, including all inherited members.

_enter | __WIZCHIP::_CRIS
_exit | __WIZCHIP::_CRIS


Socket APIs: Member List

  • Class List
  • Class Index
  • Class Members
  • __WIZCHIP
  • _CS
__WIZCHIP::_CS Member List

This is the complete list of members for __WIZCHIP::_CS, including all inherited members.

_deselect | __WIZCHIP::_CS
_select | __WIZCHIP::_CS


Socket APIs: Member List

  • Class List
  • Class Index
  • Class Members
wiz_NetInfo_t Member List

This is the complete list of members for wiz_NetInfo_t, including all inherited members.

dhcp | wiz_NetInfo_t
dns | wiz_NetInfo_t
gw | wiz_NetInfo_t
ip | wiz_NetInfo_t
mac | wiz_NetInfo_t
sn | wiz_NetInfo_t


Socket APIs: Member List

  • Class List
  • Class Index
  • Class Members
wiz_NetTimeout_t Member List

This is the complete list of members for wiz_NetTimeout_t, including all inherited members.

retry_cnt | wiz_NetTimeout_t
time_100us | wiz_NetTimeout_t


Socket APIs: Member List

  • Class List
  • Class Index
  • Class Members
wiz_PhyConf_t Member List

This is the complete list of members for wiz_PhyConf_t, including all inherited members.

by | wiz_PhyConf_t
duplex | wiz_PhyConf_t
mode | wiz_PhyConf_t
speed | wiz_PhyConf_t


Socket APIs: Member List

  • Class List
  • Class Index
  • Class Members
  • __WIZCHIP
  • _IF
__WIZCHIP::_IF Member List

This is the complete list of members for __WIZCHIP::_IF, including all inherited members.

_read_burst | __WIZCHIP::_IF
_read_byte | __WIZCHIP::_IF
_write_burst | __WIZCHIP::_IF
_write_byte | __WIZCHIP::_IF
BUS | __WIZCHIP::_IF
SPI | __WIZCHIP::_IF


Socket APIs: Ethernet/W5100/w5100.c Source File

  • Ethernet
  • W5100
w5100.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
38 //
39 //*****************************************************************************
40
41 #include "w5100.h"
42
43 #if (_WIZCHIP_ == 5100)
44
47 void WIZCHIP_WRITE(uint16_t AddrSel, uint8_t wb )
48 {
49 WIZCHIP_CRITICAL_ENTER();
50 WIZCHIP.CS._select();
51
52 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
53 WIZCHIP.IF.SPI._write_byte(0xF0);
54 WIZCHIP.IF.SPI._write_byte((AddrSel & 0xFF00) >> 8);
55 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF) >> 0);
56 WIZCHIP.IF.SPI._write_byte(wb); // Data write (write 1byte data)
57 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
58 WIZCHIP.IF.BUS._write_byte(AddrSel,wb);
59 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
60
61 //add indirect bus
62 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
63 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
64 WIZCHIP.IF.BUS._write_byte(IDM_DR,wb);
65 #else
66 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!"
67 #endif
68
69 WIZCHIP.CS._deselect();
70 WIZCHIP_CRITICAL_EXIT();
71 }
75 uint8_t WIZCHIP_READ(uint16_t AddrSel)
76 {
77 uint8_t ret;
78
79 WIZCHIP_CRITICAL_ENTER();
80 WIZCHIP.CS._select();
81
82 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
83 WIZCHIP.IF.SPI._write_byte(0x0F);
84 WIZCHIP.IF.SPI._write_byte((AddrSel & 0xFF00) >> 8);
85 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF) >> 0);
86 ret = WIZCHIP.IF.SPI._read_byte();
87 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
88 ret = WIZCHIP.IF.BUS._read_byte(AddrSel);
89 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
90
91 //add indirect bus
92 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
93 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
94 ret = WIZCHIP.IF.BUS._read_byte(IDM_DR);
95 #else
96 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!"
97 #endif
98
99 WIZCHIP.CS._deselect();
100 WIZCHIP_CRITICAL_EXIT();
101 return ret;
102 }
103
104
108 void WIZCHIP_WRITE_BUF(uint16_t AddrSel, uint8_t* pBuf, uint16_t len)
109 {
110 uint16_t i = 0;
111
112 WIZCHIP_CRITICAL_ENTER();
113
114 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
115 for(i = 0; i < len; i++)
116 {
117 WIZCHIP.CS._select();
118 WIZCHIP.IF.SPI._write_byte(0xF0);
119 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0xFF00) >> 8);
120 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0x00FF) >> 0);
121 WIZCHIP.IF.SPI._write_byte(pBuf[i]); // Data write (write 1byte data)
122 WIZCHIP.CS._deselect();
123 }
124 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
125 for(i = 0; i < len; i++)
126 WIZCHIP.IF.BUS._write_byte(AddrSel+i,pBuf[i]);
127 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
128 WIZCHIP_WRITE(MR,WIZCHIP_READ(MR) | MR_AI);
129 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
130 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
131 for(i = 0 ; i < len; i++)
132 WIZCHIP.IF.BUS._write_byte(IDM_DR,pBuf[i]);
133 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
134 #else
135 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!!"
136 #endif
137
138 WIZCHIP_CRITICAL_EXIT();
139 }
140
145 void WIZCHIP_READ_BUF (uint16_t AddrSel, uint8_t* pBuf, uint16_t len)
146 {
147 uint16_t i = 0;
148 WIZCHIP_CRITICAL_ENTER();
149
150 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
151 for(i = 0; i < len; i++)
152 {
153 WIZCHIP.CS._select();
154 WIZCHIP.IF.SPI._write_byte(0x0F);
155 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0xFF00) >> 8);
156 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0x00FF) >> 0);
157 pBuf[i] = WIZCHIP.IF.SPI._read_byte();
158 WIZCHIP.CS._deselect();
159 }
160 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
161 for(i = 0 ; i < len; i++)
162 pBuf[i] = WIZCHIP.IF.BUS._read_byte(AddrSel+i);
163 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
164 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) | MR_AI);
165 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
166 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
167 for(i = 0 ; i < len; i++)
168 pBuf[i] = WIZCHIP.IF.BUS._read_byte(IDM_DR);
169 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
170 #else
171 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!!"
172 #endif
173
174 WIZCHIP_CRITICAL_EXIT();
175 }
176
178 // Socket N regsiter IO function //
180
181 uint16_t getSn_TX_FSR(uint8_t sn)
182 {
183 uint16_t val=0,val1=0;
184 do
185 {
186 val1 = WIZCHIP_READ(Sn_TX_FSR(sn));
187 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
188 if (val1 != 0)
189 {
190 val = WIZCHIP_READ(Sn_TX_FSR(sn));
191 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
192 }
193 }while (val != val1);
194 return val;
195 }
196
197
198 uint16_t getSn_RX_RSR(uint8_t sn)
199 {
200 uint16_t val=0,val1=0;
201 do
202 {
203 val1 = WIZCHIP_READ(Sn_RX_RSR(sn));
204 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
205 if (val1 != 0)
206 {
207 val = WIZCHIP_READ(Sn_RX_RSR(sn));
208 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
209 }
210 }while (val != val1);
211 return val;
212 }
213
215 // Sn_TXBUF & Sn_RXBUF IO function //
217 uint32_t getSn_RxBASE(uint8_t sn)
218 {
219 int8_t i;
220 #if ( _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
221 uint32_t rxbase = _W5100_IO_BASE_ + _WIZCHIP_IO_RXBUF_;
222 #else
223 uint32_t rxbase = _WIZCHIP_IO_RXBUF_;
224 #endif
225 for(i = 0; i < sn; i++)
226 rxbase += getSn_RxMAX(i);
227
228 return rxbase;
229 }
230
231 uint32_t getSn_TxBASE(uint8_t sn)
232 {
233 int8_t i;
234 #if ( _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
235 uint32_t txbase = _W5100_IO_BASE_ + _WIZCHIP_IO_TXBUF_;
236 #else
237 uint32_t txbase = _WIZCHIP_IO_TXBUF_;
238 #endif
239 for(i = 0; i < sn; i++)
240 txbase += getSn_TxMAX(i);
241 return txbase;
242 }
243
255 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
256 {
257 uint16_t ptr;
258 uint16_t size;
259 uint16_t dst_mask;
260 uint16_t dst_ptr;
261
262 ptr = getSn_TX_WR(sn);
263
264 dst_mask = ptr & getSn_TxMASK(sn);
265 dst_ptr = getSn_TxBASE(sn) + dst_mask;
266
267 if (dst_mask + len > getSn_TxMAX(sn))
268 {
269 size = getSn_TxMAX(sn) - dst_mask;
270 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, size);
271 wizdata += size;
272 size = len - size;
273 dst_ptr = getSn_TxBASE(sn);
274 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, size);
275 }
276 else
277 {
278 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, len);
279 }
280
281 ptr += len;
282
283 setSn_TX_WR(sn, ptr);
284 }
285
286
297 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
298 {
299 uint16_t ptr;
300 uint16_t size;
301 uint16_t src_mask;
302 uint16_t src_ptr;
303
304 ptr = getSn_RX_RD(sn);
305
306 src_mask = (uint32_t)ptr & getSn_RxMASK(sn);
307 src_ptr = (getSn_RxBASE(sn) + src_mask);
308
309
310 if( (src_mask + len) > getSn_RxMAX(sn) )
311 {
312 size = getSn_RxMAX(sn) - src_mask;
313 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, size);
314 wizdata += size;
315 size = len - size;
316 src_ptr = getSn_RxBASE(sn);
317 WIZCHIP_READ_BUF(src_ptr, (uint8_t*)wizdata, size);
318 }
319 else
320 {
321 WIZCHIP_READ_BUF(src_ptr, (uint8_t*)wizdata, len);
322 }
323
324 ptr += len;
325
326 setSn_RX_RD(sn, ptr);
327 }
328
329 void wiz_recv_ignore(uint8_t sn, uint16_t len)
330 {
331 uint16_t ptr;
332
333 ptr = getSn_RX_RD(sn);
334
335 ptr += len;
336 setSn_RX_RD(sn,ptr);
337 }
338
339 #endif
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/W5100/w5100.h Source File

  • Ethernet
  • W5100
w5100.h
Go to the documentation of this file.
1 //* ****************************************************************************
38 //
39 //*****************************************************************************
40
41 #ifndef _W5100_H_
42 #define _W5100_H_
43 #include <stdint.h>
44 #include "wizchip_conf.h"
45
46 #if (_WIZCHIP_ == 5100)
47
48 #define _WIZCHIP_SN_BASE_ (0x0400)
49 #define _WIZCHIP_SN_SIZE_ (0x0100)
50 #define _WIZCHIP_IO_TXBUF_ (0x4000) /* Internal Tx buffer address of the iinchip */
51 #define _WIZCHIP_IO_RXBUF_ (0x6000) /* Internal Rx buffer address of the iinchip */
52
53
54 #define WIZCHIP_CREG_BLOCK 0x00
55 #define WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
56
57 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
58
59 #if (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
60 #define _W5100_IO_BASE_ _WIZCHIP_IO_BASE_
61 #elif (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_)
62 #define IDM_OR ((_WIZCHIP_IO_BASE + 0x0000))
63 #define IDM_AR0 ((_WIZCHIP_IO_BASE_ + 0x0001))
64 #define IDM_AR1 ((_WIZCHIP_IO_BASE_ + 0x0002))
65 #define IDM_DR ((_WIZCHIP_IO_BASE_ + 0x0003))
66 #define _W5100_IO_BASE_ 0x0000
67 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
68 #define _W5100_IO_BASE_ 0x0000
69 #endif
70
72 // Definition For Legacy Chip Driver //
74 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
75 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
76 #define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
77 #define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
78
79
80 //----------- defgroup --------------------------------
81
181 //-----------------------------------------------------------------------------------
182
183 //----------------------------- W5100 Common Registers IOMAP -----------------------------
199 #define MR (_W5100_IO_BASE_ + (0x0000)) // Mode
200
206 #define GAR (_W5100_IO_BASE_ + (0x0001)) // GW Address
207
213 #define SUBR (_W5100_IO_BASE_ + (0x0005)) // SN Mask Address
214
220 #define SHAR (_W5100_IO_BASE_ + (0x0009)) // Source Hardware Address
221
227 #define SIPR (_W5100_IO_BASE_ + (0x000F)) // Source IP Address
228
229 // Reserved (_W5100_IO_BASE_ + (0x0013))
230 // Reserved (_W5100_IO_BASE_ + (0x0014))
231
250 #define IR (_W5100_IO_BASE_ + (0x0015)) // Interrupt
251
258 #define _IMR_ (_W5100_IO_BASE_ + (0x0016)) // Socket Interrupt Mask
259
268 #define _RTR_ (_W5100_IO_BASE_ + (0x0017)) // Retry Time
269
276 #define _RCR_ (_W5100_IO_BASE_ + (0x0019)) // Retry Count
277 #define RMSR (_W5100_IO_BASE_ + (0x001A)) // Receicve Memory Size
278 #define TMSR (_W5100_IO_BASE_ + (0x001B)) // Trnasmit Memory Size
279
280
287 #define PATR (_W5100_IO_BASE_ + (0x001C))
288
289
295 #define PTIMER (_W5100_IO_BASE_ + (0x0028)) // PPP LCP RequestTimer
296
302 #define PMAGIC (_W5100_IO_BASE_ + (0x0029)) // PPP LCP Magic number
303
304 #define UIPR0 (_W5100_IO_BASE_ + (0x002A))
305 #define UPORT0 (_W5100_IO_BASE + (0x002E))
306
307
308
309 //----------------------------- W5100 Socket Registers -----------------------------
310
311 //--------------------------- For Backward Compatibility ---------------------------
312
346 #define Sn_MR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000)) // socket Mode register
347
374 #define Sn_CR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001)) // channel Sn_CR register
375
395 #define Sn_IR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002)) // channel interrupt register
396
418 #define Sn_SR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003)) // channel status register
419
426 #define Sn_PORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004)) // source port register
427
434 #define Sn_DHAR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006)) // Peer MAC register address
435
444 #define Sn_DIPR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C)) // Peer IP register address
445
454 #define Sn_DPORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010)) // Peer port register address
455
461 #define Sn_MSSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012)) // Maximum Segment Size(Sn_MSSR0) register address
462
469 #define Sn_PROTO(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014)) // Protocol of IP Header field register in IP raw mode
470
477 #define Sn_TOS(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015) // IP Type of Service(TOS) Register
478
485 #define Sn_TTL(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016)) // IP Time to live(TTL) Register
486
487 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0017))
488 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0018))
489 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0019))
490 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001A))
491 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001B))
492 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001C))
493 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001D))
494
504 #define Sn_TX_FSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020)) // Transmit free memory size register
505
516 #define Sn_TX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022)) // Transmit memory read pointer register address
517
530 #define Sn_TX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024)) // Transmit memory write pointer register address
531
539 #define Sn_RX_RSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026)) // Received data size register
540
552 #define Sn_RX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028)) // Read point of Receive memory
553
561 #define Sn_RX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A)) // Write point of Receive memory
562
563
564 //----------------------------- W5100 Register values -----------------------------
565
566 /* MODE register values */
571 #define MR_RST 0x80
572
573
580 #define MR_PB 0x10
581
582
588 #define MR_PPPOE 0x08
589
590
597 #define MR_AI 0x02
598
599
605 #define MR_IND 0x01
606
607 /* IR register values */
612 #define IR_CONFLICT 0x80
613
614
619 #define IR_UNREACH 0x40
620
621
625 #define IR_PPPoE 0x20
626
627 #define IR_SOCK(sn) (0x01 << sn)
628
629
630 // Sn_MR values
631 /* Sn_MR Default values */
636 #define Sn_MR_CLOSE 0x00
637
638
642 #define Sn_MR_TCP 0x01
643
644
648 #define Sn_MR_UDP 0x02
649 #define Sn_MR_IPRAW 0x03
650
651
656 #define Sn_MR_MACRAW 0x04
657
658
663 #define Sn_MR_PPPoE 0x05
664
665
673 #define Sn_MR_ND 0x20
674
675
682 #define Sn_MR_MC Sn_MR_ND
683
684
694 #define Sn_MR_MF 0x40
695 #define Sn_MR_MFEN Sn_MR_MF
696
697
698 /* Sn_MR Default values */
707 #define Sn_MR_MULTI 0x80
708
709 /* Sn_CR values */
724 #define Sn_CR_OPEN 0x01
725
726
735 #define Sn_CR_LISTEN 0x02
736
737
747 #define Sn_CR_CONNECT 0x04
748
749
760 #define Sn_CR_DISCON 0x08
761
762
766 #define Sn_CR_CLOSE 0x10
767
774 #define Sn_CR_SEND 0x20
775
784 #define Sn_CR_SEND_MAC 0x21
785
792 #define Sn_CR_SEND_KEEP 0x22
793
800 #define Sn_CR_RECV 0x40
801
806 #define Sn_CR_PCON 0x23
807
812 #define Sn_CR_PDISCON 0x24
813
818 #define Sn_CR_PCR 0x25
819
824 #define Sn_CR_PCN 0x26
825
830 #define Sn_CR_PCJ 0x27
831
832 /* Sn_IR values */
837 #define Sn_IR_PRECV 0x80
838
843 #define Sn_IR_PFAIL 0x40
844
849 #define Sn_IR_PNEXT 0x20
850
855 #define Sn_IR_SENDOK 0x10
856
857
861 #define Sn_IR_TIMEOUT 0x08
862
863
867 #define Sn_IR_RECV 0x04
868
873 #define Sn_IR_DISCON 0x02
874
879 #define Sn_IR_CON 0x01
880
881 /* Sn_SR values */
887 #define SOCK_CLOSED 0x00
888
889
895 #define SOCK_INIT 0x13
896
897
903 #define SOCK_LISTEN 0x14
904
912 #define SOCK_SYNSENT 0x15
913
920 #define SOCK_SYNRECV 0x16
921
929 #define SOCK_ESTABLISHED 0x17
930
937 #define SOCK_FIN_WAIT 0x18
938
945 #define SOCK_CLOSING 0x1A
946
953 #define SOCK_TIME_WAIT 0x1B
954
961 #define SOCK_CLOSE_WAIT 0x1C
962
968 #define SOCK_LAST_ACK 0x1D
969
976 #define SOCK_UDP 0x22
977
978
984 #define SOCK_IPRAW 0x32
985
986
992 #define SOCK_MACRAW 0x42
993
994
1001 #define SOCK_PPPOE 0x5F
1002
1003 // IP PROTOCOL
1004 #define IPPROTO_IP 0
1005 #define IPPROTO_ICMP 1
1006 #define IPPROTO_IGMP 2
1007 #define IPPROTO_GGP 3
1008 #define IPPROTO_TCP 6
1009 #define IPPROTO_PUP 12
1010 #define IPPROTO_UDP 17
1011 #define IPPROTO_IDP 22
1012 #define IPPROTO_ND 77
1013 #define IPPROTO_RAW 255
1014
1015
1026 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1027
1028 #ifdef _exit
1029 #undef _exit
1030 #endif
1031
1043 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1044
1045
1046
1048 // Basic I/O Function //
1050
1056 uint8_t WIZCHIP_READ (uint16_t AddrSel);
1057
1065 void WIZCHIP_WRITE(uint16_t AddrSel, uint8_t wb );
1066
1074 void WIZCHIP_READ_BUF (uint16_t AddrSel, uint8_t* pBuf, uint16_t len);
1075
1083 void WIZCHIP_WRITE_BUF(uint16_t AddrSel, uint8_t* pBuf, uint16_t len);
1084
1085
1087 // Common Register IO function //
1089
1096 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1097 #define setMR(mr) WIZCHIP_WRITE(MR,mr)
1098 #else
1099 #define setMR(mr) (*((uint8_t*)MR) = mr)
1100 #endif
1101
1108 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1109 #define getMR() WIZCHIP_READ(MR)
1110 #else
1111 #define getMR() (*(uint8_t*)MR)
1112 #endif
1113
1120 #define setGAR(gar) \
1121 WIZCHIP_WRITE_BUF(GAR,gar,4)
1122
1129 #define getGAR(gar) \
1130 WIZCHIP_READ_BUF(GAR,gar,4)
1131
1141 #define setSUBR(subr) \
1142 WIZCHIP_WRITE_BUF(SUBR,subr,4)
1143
1150 #define getSUBR(subr) \
1151 WIZCHIP_READ_BUF(SUBR, subr, 4)
1152
1159 #define setSHAR(shar) \
1160 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1161
1168 #define getSHAR(shar) \
1169 WIZCHIP_READ_BUF(SHAR, shar, 6)
1170
1177 #define setSIPR(sipr) \
1178 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1179
1186 #define getSIPR(sipr) \
1187 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1188
1195 #define setIR(ir) \
1196 WIZCHIP_WRITE(IR, (ir & 0xA0))
1197
1203 #define getIR() \
1204 (WIZCHIP_READ(IR) & 0xA0)
1205
1212 #define setIMR(imr) \
1213 WIZCHIP_WRITE(_IMR_, imr)
1214
1221 #define getIMR() \
1222 WIZCHIP_READ(_IMR_)
1223
1230 #define setRTR(rtr) {\
1231 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1232 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1233 }
1234
1241 #define getRTR() \
1242 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1243
1250 #define setRCR(rcr) \
1251 WIZCHIP_WRITE(_RCR_, rcr)
1252
1259 #define getRCR() \
1260 WIZCHIP_READ(_RCR_)
1261
1267 #define setRMSR(rmsr) \
1268 WIZCHIP_WRITE(RMSR) // Receicve Memory Size
1269
1276 #define getRMSR() \
1277 WIZCHIP_READ() // Receicve Memory Size
1278
1284 #define setTMSR(rmsr) \
1285 WIZCHIP_WRITE(TMSR) // Receicve Memory Size
1286
1300 #define getPATR() \
1301 (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
1302
1308 #define getPPPALGO() \
1309 WIZCHIP_READ(PPPALGO)
1310
1311
1318 #define setPTIMER(ptimer) \
1319 WIZCHIP_WRITE(PTIMER, ptimer)
1320
1327 #define getPTIMER() \
1328 WIZCHIP_READ(PTIMER)
1329
1336 #define setPMAGIC(pmagic) \
1337 WIZCHIP_WRITE(PMAGIC, pmagic)
1338
1345 #define getPMAGIC() \
1346 WIZCHIP_READ(PMAGIC)
1347
1349 // Socket N register I/O function //
1351
1358 #define setSn_MR(sn, mr) \
1359 WIZCHIP_WRITE(Sn_MR(sn),mr)
1360
1368 #define getSn_MR(sn) \
1369 WIZCHIP_READ(Sn_MR(sn))
1370
1378 #define setSn_CR(sn, cr) \
1379 WIZCHIP_WRITE(Sn_CR(sn), cr)
1380
1388 #define getSn_CR(sn) \
1389 WIZCHIP_READ(Sn_CR(sn))
1390
1398 #define setSn_IR(sn, ir) \
1399 WIZCHIP_WRITE(Sn_IR(sn), ir)
1400
1408 #define getSn_IR(sn) \
1409 WIZCHIP_READ(Sn_IR(sn))
1410
1417 #define getSn_SR(sn) \
1418 WIZCHIP_READ(Sn_SR(sn))
1419
1427 #define setSn_PORT(sn, port) { \
1428 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
1429 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
1430 }
1431
1439 #define getSn_PORT(sn) \
1440 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1441
1449 #define setSn_DHAR(sn, dhar) \
1450 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
1451
1459 #define getSn_DHAR(sn, dhar) \
1460 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
1461
1469 #define setSn_DIPR(sn, dipr) \
1470 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
1471
1479 #define getSn_DIPR(sn, dipr) \
1480 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
1481
1489 #define setSn_DPORT(sn, dport) { \
1490 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
1491 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
1492 }
1493
1501 #define getSn_DPORT(sn) \
1502 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1503
1511 #define setSn_MSSR(sn, mss) { \
1512 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
1513 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
1514 }
1515
1523 #define getSn_MSSR(sn) \
1524 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1525
1533 #define setSn_PROTO(sn, proto) \
1534 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1535
1543 #define getSn_PROTO(sn) \
1544 WIZCHIP_READ(Sn_TOS(sn))
1545
1553 #define setSn_TOS(sn, tos) \
1554 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1555
1563 #define getSn_TOS(sn) \
1564 WIZCHIP_READ(Sn_TOS(sn))
1565
1573 #define setSn_TTL(sn, ttl) \
1574 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
1575
1583 #define getSn_TTL(sn) \
1584 WIZCHIP_READ(Sn_TTL(sn))
1585
1593 #define setSn_RXMEM_SIZE(sn, rxmemsize) \
1594 WIZCHIP_WRITE(RMSR, (WIZCHIP_READ(RMSR) & ~(0x03 << (2*sn))) | (rxmemsize << (2*sn)))
1595 #define setSn_RXBUF_SIZE(sn,rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
1596
1604 #define getSn_RXMEM_SIZE(sn) \
1605 ((WIZCHIP_READ(RMSR) & (0x03 << (2*sn))) >> (2*sn))
1606 #define getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
1607
1615 #define setSn_TXMEM_SIZE(sn, txmemsize) \
1616 WIZCHIP_WRITE(TMSR, (WIZCHIP_READ(TMSR) & ~(0x03 << (2*sn))) | (txmemsize << (2*sn)))
1617 #define setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
1618
1626 #define getSn_TXMEM_SIZE(sn) \
1627 ((WIZCHIP_READ(TMSR) & (0x03 << (2*sn))) >> (2*sn))
1628 #define getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
1629
1636 uint16_t getSn_TX_FSR(uint8_t sn);
1637
1644 #define getSn_TX_RD(sn) \
1645 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1646
1654 #define setSn_TX_WR(sn, txwr) { \
1655 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
1656 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
1657 }
1658
1666 #define getSn_TX_WR(sn) \
1667 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1668
1675 uint16_t getSn_RX_RSR(uint8_t sn);
1676
1684 #define setSn_RX_RD(sn, rxrd) { \
1685 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
1686 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
1687 }
1688
1696 #define getSn_RX_RD(sn) \
1697 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
1698
1706 #define setSn_RX_WR(sn, rxwr) { \
1707 WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
1708 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
1709 }
1710
1711
1718 #define getSn_RX_WR(sn) \
1719 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
1720
1728 #define setSn_FRAG(sn, frag) { \
1729 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
1730 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
1731 }
1732
1740 #define getSn_FRAG(sn) \
1741 (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
1742
1749 #define getSn_RxMAX(sn) \
1750 ((uint16_t)(1 << getSn_RXMEM_SIZE(sn)) << 10)
1751
1752
1759 #define getSn_TxMAX(sn) \
1760 ((uint16_t)(1 << getSn_TXMEM_SIZE(sn)) << 10)
1761
1768 #define getSn_RxMASK(sn) \
1769 (getSn_RxMAX(sn) - 1)
1770
1777 #define getSn_TxMASK(sn) \
1778 (getSn_TxMAX(sn) - 1)
1779
1786 uint32_t getSn_RxBASE(uint8_t sn);
1787
1794 uint32_t getSn_TxBASE(uint8_t sn);
1795
1797 // Sn_TXBUF & Sn_RXBUF IO function //
1799
1814 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
1815
1831 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
1832
1840 void wiz_recv_ignore(uint8_t sn, uint16_t len);
1841
1842 #endif
1843
1844 #endif //_W5100_H_
1845
1846
1847
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/W5200/w5200.c Source File

  • Ethernet
  • W5200
w5200.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
38 //
39 //*****************************************************************************
40
41 #include "w5200.h"
42
43 #if (_WIZCHIP_ == 5200)
44
47 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb )
48 {
49 WIZCHIP_CRITICAL_ENTER();
50 WIZCHIP.CS._select();
51
52 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
53 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
54 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
55 WIZCHIP.IF.SPI._write_byte(_W5200_SPI_WRITE_); // Data write command and Write data length upper
56 WIZCHIP.IF.SPI._write_byte(0x01); // Write data length lower
57 WIZCHIP.IF.SPI._write_byte(wb); // Data write (write 1byte data)
58
59 #elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
60
61 //add indirect bus
62 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
63 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
64 WIZCHIP.IF.BUS._write_byte(IDM_DR,wb);
65 #else
66 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!"
67 #endif
68
69 WIZCHIP.CS._deselect();
70 WIZCHIP_CRITICAL_EXIT();
71 }
75 uint8_t WIZCHIP_READ(uint32_t AddrSel)
76 {
77 uint8_t ret;
78
79 WIZCHIP_CRITICAL_ENTER();
80 WIZCHIP.CS._select();
81
82 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
83 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
84 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
85 WIZCHIP.IF.SPI._write_byte(_W5200_SPI_READ_); // Read data length upper
86 WIZCHIP.IF.SPI._write_byte(0x01); // Data length lower
87 ret = WIZCHIP.IF.SPI._read_byte();
88
89 #elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
90
91 //add indirect bus
92 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
93 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
94 ret = WIZCHIP.IF.BUS._read_byte(IDM_DR);
95
96 #else
97 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!"
98 #endif
99
100 WIZCHIP.CS._deselect();
101 WIZCHIP_CRITICAL_EXIT();
102 return ret;
103 }
104
105
109 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
110 {
111 uint16_t i = 0;
112 WIZCHIP_CRITICAL_ENTER();
113 WIZCHIP.CS._select();
114
115 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
116 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
117 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
118 WIZCHIP.IF.SPI._write_byte(_W5200_SPI_WRITE_ | ((len & 0x7F00) >> 8)); // Write data op code and length upper
119 WIZCHIP.IF.SPI._write_byte((len & 0x00FF) >> 0); // length lower
120 for(i = 0; i < len; i++)
121 WIZCHIP.IF.SPI._write_byte(pBuf[i]);
122
123 #elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
124 WIZCHIP_WRITE(MR,WIZCHIP_READ(MR) | MR_AI);
125 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
126 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
127 for(i = 0 ; i < len; i++)
128 WIZCHIP.IF.BUS._write_byte(IDM_DR,pBuf[i]);
129 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
130 #else
131 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!!"
132 #endif
133
134 WIZCHIP.CS._deselect();
135 WIZCHIP_CRITICAL_EXIT();
136 }
137
142 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
143 {
144 uint16_t i = 0;
145 WIZCHIP_CRITICAL_ENTER();
146 WIZCHIP.CS._select();
147
148 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
149 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
150 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
151 WIZCHIP.IF.SPI._write_byte( _W5200_SPI_READ_ | ((len & 0x7F00) >> 8)); // Write data op code and length upper
152 WIZCHIP.IF.SPI._write_byte((len & 0x00FF) >> 0); // length lower
153 for(i = 0; i < len; i++)
154 pBuf[i] = WIZCHIP.IF.SPI._read_byte();
155
156 #elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
157 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) | MR_AI);
158 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
159 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
160 for(i = 0 ; i < len; i++)
161 pBuf[i] = WIZCHIP.IF.BUS._read_byte(IDM_DR);
162 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
163 #else
164 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!!"
165 #endif
166
167 WIZCHIP.CS._deselect();
168 WIZCHIP_CRITICAL_EXIT();
169 }
170
172 // Socket N regsiter IO function //
174
175 uint16_t getSn_TX_FSR(uint8_t sn)
176 {
177 uint16_t val=0,val1=0;
178 do
179 {
180 val1 = WIZCHIP_READ(Sn_TX_FSR(sn));
181 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
182 if (val1 != 0)
183 {
184 val = WIZCHIP_READ(Sn_TX_FSR(sn));
185 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
186 }
187 }while (val != val1);
188 return val;
189 }
190
191
192 uint16_t getSn_RX_RSR(uint8_t sn)
193 {
194 uint16_t val=0,val1=0;
195 do
196 {
197 val1 = WIZCHIP_READ(Sn_RX_RSR(sn));
198 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
199 if (val1 != 0)
200 {
201 val = WIZCHIP_READ(Sn_RX_RSR(sn));
202 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
203 }
204 }while (val != val1);
205 return val;
206 }
207
209 // Sn_TXBUF & Sn_RXBUF IO function //
211
212 uint16_t getSn_RxBASE(uint8_t sn)
213 {
214 int8_t i;
215 uint16_t rxbase = _WIZCHIP_IO_RXBUF_;
216 for(i = 0; i < sn; i++)
217 rxbase += getSn_RxMAX(i);
218 return rxbase;
219 }
220
221 uint16_t getSn_TxBASE(uint8_t sn)
222 {
223 int8_t i;
224 uint16_t txbase = _WIZCHIP_IO_TXBUF_;
225 for(i = 0; i < sn; i++)
226 txbase += getSn_TxMAX(i);
227 return txbase;
228 }
229
242 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
243 {
244
245 uint16_t ptr;
246 uint16_t size;
247 uint16_t dst_mask;
248 uint8_t * dst_ptr;
249
250 ptr = getSn_TX_WR(sn);
251
252
253 dst_mask = (uint32_t)ptr & getSn_TxMASK(sn);
254 dst_ptr = (uint8_t*)((uint32_t)getSn_TxBASE(sn) + dst_mask);
255
256 if (dst_mask + len > getSn_TxMAX(sn))
257 {
258 size = getSn_TxMAX(sn) - dst_mask;
259 WIZCHIP_WRITE_BUF((uint32_t)dst_ptr, wizdata, size);
260 wizdata += size;
261 size = len - size;
262 dst_ptr = (uint8_t*)((uint32_t)getSn_TxBASE(sn));
263 WIZCHIP_WRITE_BUF((uint32_t)dst_ptr, wizdata, size);
264 }
265 else
266 {
267 WIZCHIP_WRITE_BUF((uint32_t)dst_ptr, wizdata, len);
268 }
269
270 ptr += len;
271
272 setSn_TX_WR(sn, ptr);
273 }
274
275
286 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
287 {
288 uint16_t ptr;
289 uint16_t size;
290 uint16_t src_mask;
291 uint8_t * src_ptr;
292
293 ptr = getSn_RX_RD(sn);
294
295 src_mask = (uint32_t)ptr & getSn_RxMASK(sn);
296 src_ptr = (uint8_t *)((uint32_t)getSn_RxBASE(sn) + src_mask);
297
298 if( (src_mask + len) > getSn_RxMAX(sn) )
299 {
300 size = getSn_RxMAX(sn) - src_mask;
301 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, size);
302 wizdata += size;
303 size = len - size;
304 src_ptr = (uint8_t*)((uint32_t)getSn_RxBASE(sn));
305 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, size);
306 }
307 else
308 {
309 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, len);
310 }
311
312 ptr += len;
313
314 setSn_RX_RD(sn, ptr);
315 }
316
317 void wiz_recv_ignore(uint8_t sn, uint16_t len)
318 {
319 uint16_t ptr;
320
321 ptr = getSn_RX_RD(sn);
322
323 ptr += len;
324 setSn_RX_RD(sn,ptr);
325 }
326
327 #endif
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/W5200/w5200.h Source File

  • Ethernet
  • W5200
w5200.h
Go to the documentation of this file.
1 //* ****************************************************************************
38 //
39 //*****************************************************************************
40
41 #ifndef _W5200_H
42 #define _W5200_H
43 #include <stdint.h>
44 #include "wizchip_conf.h"
45
46 #if (_WIZCHIP_ == 5200)
47
48 #define _WIZCHIP_SN_BASE_ (0x4000)
49 #define _WIZCHIP_SN_SIZE_ (0x0100)
50 #define _WIZCHIP_IO_TXBUF_ (0x8000) /* Internal Tx buffer address of the iinchip */
51 #define _WIZCHIP_IO_RXBUF_ (0xC000) /* Internal Rx buffer address of the iinchip */
52
53 #define _W5200_SPI_READ_ (0x00 << 7)
54 #define _W5200_SPI_WRITE_ (0x01 << 7)
55
56 #define WIZCHIP_CREG_BLOCK 0x00
57 #define WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
58
59 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
60
61 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
62 #define IDM_AR0 ((_WIZCHIP_IO_BASE_ + 0x0001))
63 #define IDM_AR1 ((_WIZCHIP_IO_BASE_ + 0x0002))
64 #define IDM_DR ((_WIZCHIP_IO_BASE_ + 0x0003))
65 #define _W5200_IO_BASE_ 0x0000
66 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
67 #define _W5200_IO_BASE_ 0x0000
68 #endif
69
71 // Definition For Legacy Chip Driver //
73 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
74 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
75 #define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
76 #define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
77
78
79 //----------- defgroup --------------------------------
80
183 //-----------------------------------------------------------------------------------
184
185 //----------------------------- W5200 Common Registers IOMAP -----------------------------
202 #define MR (_W5200_IO_BASE_ + (0x0000)) // Mode
203
209 #define GAR (_W5200_IO_BASE_ + (0x0001)) // GW Address
210
216 #define SUBR (_W5200_IO_BASE_ + (0x0005)) // SN Mask Address
217
223 #define SHAR (_W5200_IO_BASE_ + (0x0009)) // Source Hardware Address
224
230 #define SIPR (_W5200_IO_BASE_ + (0x000F)) // Source IP Address
231
232 // Reserved (_W5200_IO_BASE_ + (0x0013))
233 // Reserved (_W5200_IO_BASE_ + (0x0014))
234
248 #define IR (_W5200_IO_BASE_ + (0x0015)) // Interrupt
249
259 #define _IMR_ (_W5200_IO_BASE_ + (0x0016)) // Socket Interrupt Mask
260
269 #define _RTR_ (_W5200_IO_BASE_ + (0x0017)) // Retry Time
270
277 #define _RCR_ (_W5200_IO_BASE_ + (0x0019)) // Retry Count
278
279 // Reserved (_W5200_IO_BASE_ + (0x001A))
280 // Reserved (_W5200_IO_BASE_ + (0x001B))
281
288 #define PATR (_W5200_IO_BASE_ + (0x001C))
289
296 #define PPPALGO (_W5200_IO_BASE_ + (0x001E)) // Authentication Algorithm in PPPoE
297
303 #define VERSIONR (_W5200_IO_BASE_ + (0x001F)) // Chip version
304
305 // Reserved (_W5200_IO_BASE_ + (0x0020))
306 // Reserved (_W5200_IO_BASE_ + (0x0021))
307 // Reserved (_W5200_IO_BASE_ + (0x0022))
308 // Reserved (_W5200_IO_BASE_ + (0x0023))
309 // Reserved (_W5200_IO_BASE_ + (0x0024))
310 // Reserved (_W5200_IO_BASE_ + (0x0025))
311 // Reserved (_W5200_IO_BASE_ + (0x0026))
312 // Reserved (_W5200_IO_BASE_ + (0x0027))
313
319 #define PTIMER (_W5200_IO_BASE_ + (0x0028)) // PPP LCP RequestTimer
320
326 #define PMAGIC (_W5200_IO_BASE_ + (0x0029)) // PPP LCP Magic number
327
328 // Reserved (_W5200_IO_BASE_ + (0x002A))
329 // Reserved (_W5200_IO_BASE_ + (0x002B))
330 // Reserved (_W5200_IO_BASE_ + (0x002C))
331 // Reserved (_W5200_IO_BASE_ + (0x002D))
332 // Reserved (_W5200_IO_BASE_ + (0x002E))
333 // Reserved (_W5200_IO_BASE_ + (0x002F))
334
340 #define INTLEVEL (_W5200_IO_BASE_ + (0x0030)) // Interrupt Low Level Timer
341
342 // Reserved (_W5200_IO_BASE_ + (0x0032))
343 // Reserved (_W5200_IO_BASE_ + (0x0033))
344
351 #define IR2 (_W5200_IO_BASE_ + (0x0034)) // Socket Interrupt
352
365 #define PHYSTATUS (_W5200_IO_BASE_ + (0x0035)) // PHY Status
366
383 #define IMR2 (_W5200_IO_BASE_ + (0x0036)) // Interrupt Mask
384
385
386 //----------------------------- W5200 Socket Registers -----------------------------
387
388 //--------------------------- For Backward Compatibility ---------------------------
389
423 #define Sn_MR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000)) // socket Mode register
424
451 #define Sn_CR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001)) // channel Sn_CR register
452
472 #define Sn_IR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002)) // channel interrupt register
473
495 #define Sn_SR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003)) // channel status register
496
503 #define Sn_PORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004)) // source port register
504
511 #define Sn_DHAR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006)) // Peer MAC register address
512
521 #define Sn_DIPR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C)) // Peer IP register address
522
531 #define Sn_DPORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010)) // Peer port register address
532
538 #define Sn_MSSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012)) // Maximum Segment Size(Sn_MSSR0) register address
539
546 #define Sn_PROTO(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014)) // Protocol of IP Header field register in IP raw mode
547
554 #define Sn_TOS(sn) (WIZCHIP_SREG_BLOCK(sn) + 0x0015) // IP Type of Service(TOS) Register
555
562 #define Sn_TTL(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016)) // IP Time to live(TTL) Register
563
564 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0017))
565 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0018))
566 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0019))
567 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001A))
568 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001B))
569 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001C))
570 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001D))
571
582 #define Sn_RXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E)) // Receive memory size reigster
583
593 #define Sn_TXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F)) // Transmit memory size reigster
594
604 #define Sn_TX_FSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020)) // Transmit free memory size register
605
616 #define Sn_TX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022)) // Transmit memory read pointer register address
617
630 #define Sn_TX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024)) // Transmit memory write pointer register address
631
639 #define Sn_RX_RSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026)) // Received data size register
640
652 #define Sn_RX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028)) // Read point of Receive memory
653
661 #define Sn_RX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A)) // Write point of Receive memory
662
671 #define Sn_IMR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C)) // socket interrupt mask register
672
678 #define Sn_FRAG(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D)) // frag field value in IP header register
679
680
681 //----------------------------- W5200 Register values -----------------------------
682
683 /* MODE register values */
688 #define MR_RST 0x80
689
690
699 #define MR_WOL 0x20
700
701
707 #define MR_PB 0x10
708
709
715 #define MR_PPPOE 0x08
716
717
724 #define MR_AI 0x02
725
726
732 #define MR_IND 0x01
733
734 /* IR register values */
739 #define IR_CONFLICT 0x80
740
741
745 #define IR_PPPoE 0x20
746
747
751 #define PHYSTATUS_LINK 0x20
752
757 #define PHYSTATUS_POWERSAVE 0x10
758
763 #define PHYSTATUS_POWERDOWN 0x08
764
765 // Sn_MR values
766 /* Sn_MR Default values */
771 #define Sn_MR_CLOSE 0x00
772
773
777 #define Sn_MR_TCP 0x01
778
779
783 #define Sn_MR_UDP 0x02
784 #define Sn_MR_IPRAW 0x03
785
786
791 #define Sn_MR_MACRAW 0x04
792
793
798 #define Sn_MR_PPPOE 0x05
799
800
808 #define Sn_MR_ND 0x20
809
810 /* Sn_MR Default values */
819 #define Sn_MR_MC Sn_MR_ND
820
821
828 #define Sn_MR_MF 0x40
829 #define Sn_MR_MFEN Sn_MR_MF
830
831 /* Sn_MR Default values */
840 #define Sn_MR_MULTI 0x80
841
842 /* Sn_CR values */
857 #define Sn_CR_OPEN 0x01
858
859
868 #define Sn_CR_LISTEN 0x02
869
870
880 #define Sn_CR_CONNECT 0x04
881
882
893 #define Sn_CR_DISCON 0x08
894
895
899 #define Sn_CR_CLOSE 0x10
900
907 #define Sn_CR_SEND 0x20
908
917 #define Sn_CR_SEND_MAC 0x21
918
925 #define Sn_CR_SEND_KEEP 0x22
926
933 #define Sn_CR_RECV 0x40
934
939 #define Sn_CR_PCON 0x23
940
945 #define Sn_CR_PDISCON 0x24
946
951 #define Sn_CR_PCR 0x25
952
957 #define Sn_CR_PCN 0x26
958
963 #define Sn_CR_PCJ 0x27
964
965 /* Sn_IR values */
970 #define Sn_IR_PRECV 0x80
971
976 #define Sn_IR_PFAIL 0x40
977
982 #define Sn_IR_PNEXT 0x20
983
988 #define Sn_IR_SENDOK 0x10
989
990
994 #define Sn_IR_TIMEOUT 0x08
995
996
1000 #define Sn_IR_RECV 0x04
1001
1006 #define Sn_IR_DISCON 0x02
1007
1012 #define Sn_IR_CON 0x01
1013
1014 /* Sn_SR values */
1020 #define SOCK_CLOSED 0x00
1021
1022
1028 #define SOCK_INIT 0x13
1029
1030
1036 #define SOCK_LISTEN 0x14
1037
1045 #define SOCK_SYNSENT 0x15
1046
1053 #define SOCK_SYNRECV 0x16
1054
1062 #define SOCK_ESTABLISHED 0x17
1063
1070 #define SOCK_FIN_WAIT 0x18
1071
1078 #define SOCK_CLOSING 0x1A
1079
1086 #define SOCK_TIME_WAIT 0x1B
1087
1094 #define SOCK_CLOSE_WAIT 0x1C
1095
1101 #define SOCK_LAST_ACK 0x1D
1102
1109 #define SOCK_UDP 0x22
1110
1111
1117 #define SOCK_IPRAW 0x32
1118
1119
1125 #define SOCK_MACRAW 0x42
1126
1127
1134 #define SOCK_PPPOE 0x5F
1135
1136 // IP PROTOCOL
1137 #define IPPROTO_IP 0
1138 #define IPPROTO_ICMP 1
1139 #define IPPROTO_IGMP 2
1140 #define IPPROTO_GGP 3
1141 #define IPPROTO_TCP 6
1142 #define IPPROTO_PUP 12
1143 #define IPPROTO_UDP 17
1144 #define IPPROTO_IDP 22
1145 #define IPPROTO_ND 77
1146 #define IPPROTO_RAW 255
1147
1148
1159 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1160
1161 #ifdef _exit
1162 #undef _exit
1163 #endif
1164
1176 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1177
1178
1179
1181 // Basic I/O Function //
1183
1189 uint8_t WIZCHIP_READ (uint32_t AddrSel);
1190
1198 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb );
1199
1207 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1208
1216 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1217
1218
1220 // Common Register IO function //
1222
1229 #define setMR(mr) \
1230 WIZCHIP_WRITE(MR,mr)
1231
1238 #define getMR() \
1239 WIZCHIP_READ(MR)
1240
1247 #define setGAR(gar) \
1248 WIZCHIP_WRITE_BUF(GAR,gar,4)
1249
1256 #define getGAR(gar) \
1257 WIZCHIP_READ_BUF(GAR,gar,4)
1258
1268 #define setSUBR(subr) \
1269 WIZCHIP_WRITE_BUF(SUBR, subr,4)
1270
1277 #define getSUBR(subr) \
1278 WIZCHIP_READ_BUF(SUBR, subr, 4)
1279
1286 #define setSHAR(shar) \
1287 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1288
1295 #define getSHAR(shar) \
1296 WIZCHIP_READ_BUF(SHAR, shar, 6)
1297
1304 #define setSIPR(sipr) \
1305 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1306
1313 #define getSIPR(sipr) \
1314 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1315
1322 #define setIR(ir) \
1323 WIZCHIP_WRITE(IR, (ir & 0xA0))
1324
1330 #define getIR() \
1331 (WIZCHIP_READ(IR) & 0xA0)
1332
1339 //M20150410 : Replace _IMR_ with IMR2 for integrating with ioLibrary
1340 /*
1341 #define setIMR(imr) \
1342 WIZCHIP_WRITE(_IMR_, imr)
1343 */
1344 #define setIMR(imr) \
1345 WIZCHIP_WRITE(IMR2, imr)
1346
1353 //M20150410 : Replace _IMR_ with IMR2 for integrating with ioLibrary
1354 /*
1355 #define getIMR() \
1356 WIZCHIP_READ(_IMR_)
1357 */
1358 #define getIMR() \
1359 WIZCHIP_READ(IMR2)
1360
1367 #define setRTR(rtr) {\
1368 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1369 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1370 }
1371
1378 #define getRTR() \
1379 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1380
1387 #define setRCR(rcr) \
1388 WIZCHIP_WRITE(_RCR_, rcr)
1389
1396 #define getRCR() \
1397 WIZCHIP_READ(_RCR_)
1398
1404 #define getPATR() \
1405 (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
1406
1412 #define getPPPALGO() \
1413 WIZCHIP_READ(PPPALGO)
1414
1415
1421 #define getVERSIONR() \
1422 WIZCHIP_READ(VERSIONR)
1423
1430 #define setPTIMER(ptimer) \
1431 WIZCHIP_WRITE(PTIMER, ptimer)
1432
1439 #define getPTIMER() \
1440 WIZCHIP_READ(PTIMER)
1441
1448 #define setPMAGIC(pmagic) \
1449 WIZCHIP_WRITE(PMAGIC, pmagic)
1450
1457 #define getPMAGIC() \
1458 WIZCHIP_READ(PMAGIC)
1459
1466 #define setINTLEVEL(intlevel) {\
1467 WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \
1468 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \
1469 }
1470
1476 #define getINTLEVEL() \
1477 (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
1478
1485 #define setIR2(ir2) \
1486 WIZCHIP_WRITE(IR2, ir2)
1487 #define setSIR(ir2) setIR2(ir2)
1488
1495 #define getIR2() \
1496 WIZCHIP_READ(IR2)
1497 #define getSIR() getIR2()
1498
1504 #define getPHYSTATUS() \
1505 WIZCHIP_READ(PHYSTATUS)
1506
1514 //M20150410 : Replace IMR2 with _IMR_ for integrating with ioLibrary
1515 /*
1516 #define setIMR2(imr2) \
1517 WIZCHIP_WRITE(IMR2, (imr2 & 0xA0))
1518 */
1519 #define setIMR2(imr2) \
1520 WIZCHIP_WRITE(_IMR_, (imr2 & 0xA0))
1521 #define setSIMR(imr2) setIMR2(imr2)
1522
1529 //M20150410 : Replace IMR2 with _IMR_ for integrating with ioLibrary
1530 /*
1531 #define getIMR2() \
1532 (WIZCHIP_READ(IMR2) & 0xA0)
1533 */
1534 #define getIMR2() \
1535 (WIZCHIP_READ(_IMR_) & 0xA0)
1536 #define getSIMR() getIMR2()
1537 // Socket N register I/O function //
1540
1547 #define setSn_MR(sn, mr) \
1548 WIZCHIP_WRITE(Sn_MR(sn),mr)
1549
1557 #define getSn_MR(sn) \
1558 WIZCHIP_READ(Sn_MR(sn))
1559
1567 #define setSn_CR(sn, cr) \
1568 WIZCHIP_WRITE(Sn_CR(sn), cr)
1569
1577 #define getSn_CR(sn) \
1578 WIZCHIP_READ(Sn_CR(sn))
1579
1587 #define setSn_IR(sn, ir) \
1588 WIZCHIP_WRITE(Sn_IR(sn), ir)
1589
1597 #define getSn_IR(sn) \
1598 WIZCHIP_READ(Sn_IR(sn))
1599
1607 #define setSn_IMR(sn, imr) \
1608 WIZCHIP_WRITE(Sn_IMR(sn), imr)
1609
1617 #define getSn_IMR(sn) \
1618 WIZCHIP_READ(Sn_IMR(sn))
1619
1626 #define getSn_SR(sn) \
1627 WIZCHIP_READ(Sn_SR(sn))
1628
1636 #define setSn_PORT(sn, port) { \
1637 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
1638 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
1639 }
1640
1648 #define getSn_PORT(sn) \
1649 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1650
1658 #define setSn_DHAR(sn, dhar) \
1659 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
1660
1668 #define getSn_DHAR(sn, dhar) \
1669 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
1670
1678 #define setSn_DIPR(sn, dipr) \
1679 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
1680
1688 #define getSn_DIPR(sn, dipr) \
1689 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
1690
1698 #define setSn_DPORT(sn, dport) { \
1699 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
1700 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
1701 }
1702
1710 #define getSn_DPORT(sn) \
1711 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1712
1720 #define setSn_MSSR(sn, mss) { \
1721 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
1722 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
1723 }
1724
1732 #define getSn_MSSR(sn) \
1733 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1734
1742 #define setSn_PROTO(sn, proto) \
1743 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1744
1752 #define getSn_PROTO(sn) \
1753 WIZCHIP_READ(Sn_TOS(sn))
1754
1762 #define setSn_TOS(sn, tos) \
1763 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1764
1772 #define getSn_TOS(sn) \
1773 WIZCHIP_READ(Sn_TOS(sn))
1774
1782 #define setSn_TTL(sn, ttl) \
1783 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
1784
1792 #define getSn_TTL(sn) \
1793 WIZCHIP_READ(Sn_TTL(sn))
1794
1802 #define setSn_RXMEM_SIZE(sn, rxmemsize) \
1803 WIZCHIP_WRITE(Sn_RXMEM_SIZE(sn),rxmemsize)
1804
1805 #define setSn_RXBUF_SIZE(sn,rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
1806
1814 #define getSn_RXMEM_SIZE(sn) \
1815 WIZCHIP_READ(Sn_RXMEM_SIZE(sn))
1816
1817 #define getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
1818
1826 #define setSn_TXMEM_SIZE(sn, txmemsize) \
1827 WIZCHIP_WRITE(Sn_TXMEM_SIZE(sn), txmemsize)
1828
1829 #define setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
1830
1838 #define getSn_TXMEM_SIZE(sn) \
1839 WIZCHIP_READ(Sn_TXMEM_SIZE(sn))
1840
1841 #define getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
1842
1849 uint16_t getSn_TX_FSR(uint8_t sn);
1850
1857 #define getSn_TX_RD(sn) \
1858 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1859
1867 #define setSn_TX_WR(sn, txwr) { \
1868 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
1869 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
1870 }
1871
1879 #define getSn_TX_WR(sn) \
1880 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1881
1888 uint16_t getSn_RX_RSR(uint8_t sn);
1889
1897 #define setSn_RX_RD(sn, rxrd) { \
1898 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
1899 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
1900 }
1901
1909 #define getSn_RX_RD(sn) \
1910 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
1911
1919 #define setSn_RX_WR(sn, rxwr) { \
1920 WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
1921 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
1922 }
1923
1924
1931 #define getSn_RX_WR(sn) \
1932 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
1933
1941 #define setSn_IMR(sn ,imr) \
1942 WIZCHIP_WRITE(Sn_IMR(sn), imr)
1943
1951 #define getSn_IMR(sn) \
1952 WIZCHIP_READ(Sn_IMR(sn))
1953
1961 #define setSn_FRAG(sn, frag) { \
1962 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
1963 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
1964 }
1965
1973 #define getSn_FRAG(sn) \
1974 (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
1975
1982 #define getSn_RxMAX(sn) \
1983 ((uint16_t)getSn_RXMEM_SIZE(sn) << 10)
1984
1991 #define getSn_TxMAX(sn) \
1992 ((uint16_t)getSn_TXMEM_SIZE(sn) << 10)
1993
2000 #define getSn_RxMASK(sn) \
2001 ((uint16_t)getSn_RxMAX(sn) - 1)
2002
2009 #define getSn_TxMASK(sn) \
2010 ((uint16_t)getSn_TxMAX(sn) - 1)
2011
2018 uint16_t getSn_RxBASE(uint8_t sn);
2019
2026 uint16_t getSn_TxBASE(uint8_t sn);
2027
2029 // Sn_TXBUF & Sn_RXBUF IO function //
2031
2046 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2047
2063 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2064
2072 void wiz_recv_ignore(uint8_t sn, uint16_t len);
2073
2074 #endif
2075
2076 #endif //_W5200_H_
2077
2078
2079
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/W5500/w5500.c Source File

  • Ethernet
  • W5500
w5500.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
52 //
53 //*****************************************************************************
54 //#include <stdio.h>
55 #include "w5500.h"
56
57 #define _W5500_SPI_VDM_OP_ 0x00
58 #define _W5500_SPI_FDM_OP_LEN1_ 0x01
59 #define _W5500_SPI_FDM_OP_LEN2_ 0x02
60 #define _W5500_SPI_FDM_OP_LEN4_ 0x03
61
62 #if (_WIZCHIP_ == 5500)
63
65 uint8_t WIZCHIP_READ(uint32_t AddrSel)
66 {
67 uint8_t ret;
68 uint8_t spi_data[3];
69
70 WIZCHIP_CRITICAL_ENTER();
71 WIZCHIP.CS._select();
72
73 AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_);
74
75 if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation
76 {
77 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
78 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
79 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
80 }
81 else // burst operation
82 {
83 spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
84 spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
85 spi_data[2] = (AddrSel & 0x000000FF) >> 0;
86 WIZCHIP.IF.SPI._write_burst(spi_data, 3);
87 }
88 ret = WIZCHIP.IF.SPI._read_byte();
89
90 WIZCHIP.CS._deselect();
91 WIZCHIP_CRITICAL_EXIT();
92 return ret;
93 }
94
95 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb )
96 {
97 uint8_t spi_data[4];
98
99 WIZCHIP_CRITICAL_ENTER();
100 WIZCHIP.CS._select();
101
102 AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_);
103
104 //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation
105 if(!WIZCHIP.IF.SPI._write_burst) // byte operation
106 {
107 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
108 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
109 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
110 WIZCHIP.IF.SPI._write_byte(wb);
111 }
112 else // burst operation
113 {
114 spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
115 spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
116 spi_data[2] = (AddrSel & 0x000000FF) >> 0;
117 spi_data[3] = wb;
118 WIZCHIP.IF.SPI._write_burst(spi_data, 4);
119 }
120
121 WIZCHIP.CS._deselect();
122 WIZCHIP_CRITICAL_EXIT();
123 }
124
125 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
126 {
127 uint8_t spi_data[3];
128 uint16_t i;
129
130 WIZCHIP_CRITICAL_ENTER();
131 WIZCHIP.CS._select();
132
133 AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_);
134
135 if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation
136 {
137 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
138 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
139 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
140 for(i = 0; i < len; i++)
141 pBuf[i] = WIZCHIP.IF.SPI._read_byte();
142 }
143 else // burst operation
144 {
145 spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
146 spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
147 spi_data[2] = (AddrSel & 0x000000FF) >> 0;
148 WIZCHIP.IF.SPI._write_burst(spi_data, 3);
149 WIZCHIP.IF.SPI._read_burst(pBuf, len);
150 }
151
152 WIZCHIP.CS._deselect();
153 WIZCHIP_CRITICAL_EXIT();
154 }
155
156 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
157 {
158 uint8_t spi_data[3];
159 uint16_t i;
160
161 WIZCHIP_CRITICAL_ENTER();
162 WIZCHIP.CS._select();
163
164 AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_);
165
166 if(!WIZCHIP.IF.SPI._write_burst) // byte operation
167 {
168 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
169 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
170 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
171 for(i = 0; i < len; i++)
172 WIZCHIP.IF.SPI._write_byte(pBuf[i]);
173 }
174 else // burst operation
175 {
176 spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
177 spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
178 spi_data[2] = (AddrSel & 0x000000FF) >> 0;
179 WIZCHIP.IF.SPI._write_burst(spi_data, 3);
180 WIZCHIP.IF.SPI._write_burst(pBuf, len);
181 }
182
183 WIZCHIP.CS._deselect();
184 WIZCHIP_CRITICAL_EXIT();
185 }
186
187
188 uint16_t getSn_TX_FSR(uint8_t sn)
189 {
190 uint16_t val=0,val1=0;
191
192 do
193 {
194 val1 = WIZCHIP_READ(Sn_TX_FSR(sn));
195 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
196 if (val1 != 0)
197 {
198 val = WIZCHIP_READ(Sn_TX_FSR(sn));
199 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
200 }
201 }while (val != val1);
202 return val;
203 }
204
205
206 uint16_t getSn_RX_RSR(uint8_t sn)
207 {
208 uint16_t val=0,val1=0;
209
210 do
211 {
212 val1 = WIZCHIP_READ(Sn_RX_RSR(sn));
213 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
214 if (val1 != 0)
215 {
216 val = WIZCHIP_READ(Sn_RX_RSR(sn));
217 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
218 }
219 }while (val != val1);
220 return val;
221 }
222
223 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
224 {
225 uint16_t ptr = 0;
226 uint32_t addrsel = 0;
227
228 if(len == 0) return;
229 ptr = getSn_TX_WR(sn);
230 //M20140501 : implict type casting -> explict type casting
231 //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3);
232 addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3);
233 //
234 WIZCHIP_WRITE_BUF(addrsel,wizdata, len);
235
236 ptr += len;
237 setSn_TX_WR(sn,ptr);
238 }
239
240 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
241 {
242 uint16_t ptr = 0;
243 uint32_t addrsel = 0;
244
245 if(len == 0) return;
246 ptr = getSn_RX_RD(sn);
247 //M20140501 : implict type casting -> explict type casting
248 //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3);
249 addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3);
250 //
251 WIZCHIP_READ_BUF(addrsel, wizdata, len);
252 ptr += len;
253
254 setSn_RX_RD(sn,ptr);
255 }
256
257
258 void wiz_recv_ignore(uint8_t sn, uint16_t len)
259 {
260 uint16_t ptr = 0;
261
262 ptr = getSn_RX_RD(sn);
263 ptr += len;
264 setSn_RX_RD(sn,ptr);
265 }
266
267 #endif
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/W5500/w5500.h Source File

  • Ethernet
  • W5500
w5500.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
43 //
44 //*****************************************************************************
45
46 //
47
48 #ifndef _W5500_H_
49 #define _W5500_H_
50
51 #include <stdint.h>
52 #include "wizchip_conf.h"
53
54 #if (_WIZCHIP_ == 5500)
55
56 #define _W5500_IO_BASE_ 0x00000000
57
58 #define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase
59 #define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase
60
61 #define WIZCHIP_CREG_BLOCK 0x00 //< Common register block
62 #define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block
63 #define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block
64 #define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block
65
66 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address
67
68
70 // Definition For Legacy Chip Driver //
72 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
73 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
74 #define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
75 #define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
76
77 //-------------------------- defgroup ---------------------------------
195 //------------------------------- defgroup end --------------------------------------------
196 //----------------------------- W5500 Common Registers IOMAP -----------------------------
212 #define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3))
213
219 #define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3))
220
226 #define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3))
227
233 #define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3))
234
240 #define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3))
241
247 #define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3))
248
264 #define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3))
265
282 //M20150401 : Rename SYMBOE ( Re-define error in a compile)
283 //#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))
284 #define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))
285
292 #define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3))
293
301 #define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))
302
311 //M20150401 : Rename SYMBOE ( Re-define error in a compile)
312 //#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))
313 #define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))
314
321 //M20150401 : Rename SYMBOE ( Re-define error in a compile)
322 //#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))
323 #define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))
324
330 #define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3))
331
337 #define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3))
338
344 #define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3))
345
351 #define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3))
352
358 #define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3))
359
367 #define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3))
368
376 #define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3))
377
383 #define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3))
384
385 // Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3))
386 // Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3))
387 // Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3))
388 // Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3))
389 // Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3))
390 // Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3))
391 // Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3))
392 // Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3))
393 // Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3))
394 // Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3))
395
401 #define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3))
402
403
404 //----------------------------- W5500 Socket Registers IOMAP -----------------------------
435 #define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
436
454 #define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
455
472 #define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
473
495 #define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
496
503 #define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
504
511 #define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
512
521 #define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
522
531 #define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
532
538 #define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
539
540 // Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
541
548 #define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
549
555 #define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
556 // Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
557 // Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
558 // Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
559 // Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
560 // Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
561 // Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
562 // Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
563
574 #define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
575
585 #define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
586
596 #define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
597
608 #define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
609
622 #define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
623
631 #define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
632
644 #define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
645
653 #define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
654
663 #define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
664
670 #define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
671
683 #define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
684
685 //#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
686
687
688 //----------------------------- W5500 Register values -----------------------------
689
690 /* MODE register values */
695 #define MR_RST 0x80
696
706 #define MR_WOL 0x20
707
714 #define MR_PB 0x10
715
722 #define MR_PPPOE 0x08
723
730 #define MR_FARP 0x02
731
732 /* IR register values */
737 #define IR_CONFLICT 0x80
738
744 #define IR_UNREACH 0x40
745
750 #define IR_PPPoE 0x20
751
756 #define IR_MP 0x10
757
758
759 /* PHYCFGR register value */
760 #define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask.
761 #define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value
762 #define PHYCFGR_OPMDC_ALLA (7<<3)
763 #define PHYCFGR_OPMDC_PDOWN (6<<3)
764 #define PHYCFGR_OPMDC_NA (5<<3)
765 #define PHYCFGR_OPMDC_100FA (4<<3)
766 #define PHYCFGR_OPMDC_100F (3<<3)
767 #define PHYCFGR_OPMDC_100H (2<<3)
768 #define PHYCFGR_OPMDC_10F (1<<3)
769 #define PHYCFGR_OPMDC_10H (0<<3)
770 #define PHYCFGR_DPX_FULL (1<<2)
771 #define PHYCFGR_DPX_HALF (0<<2)
772 #define PHYCFGR_SPD_100 (1<<1)
773 #define PHYCFGR_SPD_10 (0<<1)
774 #define PHYCFGR_LNK_ON (1<<0)
775 #define PHYCFGR_LNK_OFF (0<<0)
776
777 /* IMR register values */
783 #define IM_IR7 0x80
784
790 #define IM_IR6 0x40
791
797 #define IM_IR5 0x20
798
804 #define IM_IR4 0x10
805
806 /* Sn_MR Default values */
815 #define Sn_MR_MULTI 0x80
816
824 #define Sn_MR_BCASTB 0x40
825
834 #define Sn_MR_ND 0x20
835
842 #define Sn_MR_UCASTB 0x10
843
849 #define Sn_MR_MACRAW 0x04
850
851 //#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */
852
857 #define Sn_MR_UDP 0x02
858
863 #define Sn_MR_TCP 0x01
864
869 #define Sn_MR_CLOSE 0x00
870
871 /* Sn_MR values used with Sn_MR_MACRAW */
882 #define Sn_MR_MFEN Sn_MR_MULTI
883
891 #define Sn_MR_MMB Sn_MR_ND
892
899 #define Sn_MR_MIP6B Sn_MR_UCASTB
900
901 /* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */
908 #define Sn_MR_MC Sn_MR_ND
909
910 /* Sn_MR alternate values */
914 #define SOCK_STREAM Sn_MR_TCP
915
919 #define SOCK_DGRAM Sn_MR_UDP
920
921
922 /* Sn_CR values */
935 #define Sn_CR_OPEN 0x01
936
946 #define Sn_CR_LISTEN 0x02
947
958 #define Sn_CR_CONNECT 0x04
959
971 #define Sn_CR_DISCON 0x08
972
977 #define Sn_CR_CLOSE 0x10
978
985 #define Sn_CR_SEND 0x20
986
995 #define Sn_CR_SEND_MAC 0x21
996
1003 #define Sn_CR_SEND_KEEP 0x22
1004
1011 #define Sn_CR_RECV 0x40
1012
1013 /* Sn_IR values */
1018 #define Sn_IR_SENDOK 0x10
1019
1024 #define Sn_IR_TIMEOUT 0x08
1025
1030 #define Sn_IR_RECV 0x04
1031
1036 #define Sn_IR_DISCON 0x02
1037
1042 #define Sn_IR_CON 0x01
1043
1044 /* Sn_SR values */
1050 #define SOCK_CLOSED 0x00
1051
1058 #define SOCK_INIT 0x13
1059
1066 #define SOCK_LISTEN 0x14
1067
1075 #define SOCK_SYNSENT 0x15
1076
1083 #define SOCK_SYNRECV 0x16
1084
1092 #define SOCK_ESTABLISHED 0x17
1093
1100 #define SOCK_FIN_WAIT 0x18
1101
1108 #define SOCK_CLOSING 0x1A
1109
1116 #define SOCK_TIME_WAIT 0x1B
1117
1124 #define SOCK_CLOSE_WAIT 0x1C
1125
1131 #define SOCK_LAST_ACK 0x1D
1132
1139 #define SOCK_UDP 0x22
1140
1141 //#define SOCK_IPRAW 0x32 /**< IP raw mode socket */
1142
1149 #define SOCK_MACRAW 0x42
1150
1151 //#define SOCK_PPPOE 0x5F
1152
1153 /* IP PROTOCOL */
1154 #define IPPROTO_IP 0 //< Dummy for IP
1155 #define IPPROTO_ICMP 1 //< Control message protocol
1156 #define IPPROTO_IGMP 2 //< Internet group management protocol
1157 #define IPPROTO_GGP 3 //< Gateway^2 (deprecated)
1158 #define IPPROTO_TCP 6 //< TCP
1159 #define IPPROTO_PUP 12 //< PUP
1160 #define IPPROTO_UDP 17 //< UDP
1161 #define IPPROTO_IDP 22 //< XNS idp
1162 #define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol
1163 #define IPPROTO_RAW 255 //< Raw IP packet
1164
1165
1177 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1178
1179 #ifdef _exit
1180 #undef _exit
1181 #endif
1182
1194 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1195
1196
1198 // Basic I/O Function //
1200
1207 uint8_t WIZCHIP_READ (uint32_t AddrSel);
1208
1216 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb );
1217
1225 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1226
1234 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1235
1237 // Common Register I/O function //
1239
1245 #define setMR(mr) \
1246 WIZCHIP_WRITE(MR,mr)
1247
1248
1255 #define getMR() \
1256 WIZCHIP_READ(MR)
1257
1264 #define setGAR(gar) \
1265 WIZCHIP_WRITE_BUF(GAR,gar,4)
1266
1273 #define getGAR(gar) \
1274 WIZCHIP_READ_BUF(GAR,gar,4)
1275
1282 #define setSUBR(subr) \
1283 WIZCHIP_WRITE_BUF(SUBR, subr,4)
1284
1285
1292 #define getSUBR(subr) \
1293 WIZCHIP_READ_BUF(SUBR, subr, 4)
1294
1301 #define setSHAR(shar) \
1302 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1303
1310 #define getSHAR(shar) \
1311 WIZCHIP_READ_BUF(SHAR, shar, 6)
1312
1319 #define setSIPR(sipr) \
1320 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1321
1328 #define getSIPR(sipr) \
1329 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1330
1337 #define setINTLEVEL(intlevel) {\
1338 WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \
1339 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \
1340 }
1341
1342
1349 //M20150401 : Type explict declaration
1350 /*
1351 #define getINTLEVEL() \
1352 ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
1353 */
1354 #define getINTLEVEL() \
1355 (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
1356
1363 #define setIR(ir) \
1364 WIZCHIP_WRITE(IR, (ir & 0xF0))
1365
1372 #define getIR() \
1373 (WIZCHIP_READ(IR) & 0xF0)
1374
1380 #define setIMR(imr) \
1381 WIZCHIP_WRITE(_IMR_, imr)
1382
1389 #define getIMR() \
1390 WIZCHIP_READ(_IMR_)
1391
1398 #define setSIR(sir) \
1399 WIZCHIP_WRITE(SIR, sir)
1400
1407 #define getSIR() \
1408 WIZCHIP_READ(SIR)
1409
1415 #define setSIMR(simr) \
1416 WIZCHIP_WRITE(SIMR, simr)
1417
1424 #define getSIMR() \
1425 WIZCHIP_READ(SIMR)
1426
1433 #define setRTR(rtr) {\
1434 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1435 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1436 }
1437
1444 //M20150401 : Type explict declaration
1445 /*
1446 #define getRTR() \
1447 ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1448 */
1449 #define getRTR() \
1450 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1451
1452
1459 #define setRCR(rcr) \
1460 WIZCHIP_WRITE(_RCR_, rcr)
1461
1468 #define getRCR() \
1469 WIZCHIP_READ(_RCR_)
1470
1471 //================================================== test done ===========================================================
1472
1479 #define setPTIMER(ptimer) \
1480 WIZCHIP_WRITE(PTIMER, ptimer)
1481
1488 #define getPTIMER() \
1489 WIZCHIP_READ(PTIMER)
1490
1497 #define setPMAGIC(pmagic) \
1498 WIZCHIP_WRITE(PMAGIC, pmagic)
1499
1506 #define getPMAGIC() \
1507 WIZCHIP_READ(PMAGIC)
1508
1515 #define setPHAR(phar) \
1516 WIZCHIP_WRITE_BUF(PHAR, phar, 6)
1517
1524 #define getPHAR(phar) \
1525 WIZCHIP_READ_BUF(PHAR, phar, 6)
1526
1533 #define setPSID(psid) {\
1534 WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \
1535 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \
1536 }
1537
1544 //uint16_t getPSID(void);
1545 //M20150401 : Type explict declaration
1546 /*
1547 #define getPSID() \
1548 ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))
1549 */
1550 #define getPSID() \
1551 (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))
1552
1559 #define setPMRU(pmru) { \
1560 WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \
1561 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \
1562 }
1563
1570 //M20150401 : Type explict declaration
1571 /*
1572 #define getPMRU() \
1573 ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))
1574 */
1575 #define getPMRU() \
1576 (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))
1577
1583 //M20150401 : Size Error of UIPR (6 -> 4)
1584 /*
1585 #define getUIPR(uipr) \
1586 WIZCHIP_READ_BUF(UIPR,uipr,6)
1587 */
1588 #define getUIPR(uipr) \
1589 WIZCHIP_READ_BUF(UIPR,uipr,4)
1590
1596 //M20150401 : Type explict declaration
1597 /*
1598 #define getUPORTR() \
1599 ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))
1600 */
1601 #define getUPORTR() \
1602 (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))
1603
1610 #define setPHYCFGR(phycfgr) \
1611 WIZCHIP_WRITE(PHYCFGR, phycfgr)
1612
1619 #define getPHYCFGR() \
1620 WIZCHIP_READ(PHYCFGR)
1621
1627 #define getVERSIONR() \
1628 WIZCHIP_READ(VERSIONR)
1629
1631
1633 // Socket N register I/O function //
1635
1642 #define setSn_MR(sn, mr) \
1643 WIZCHIP_WRITE(Sn_MR(sn),mr)
1644
1652 #define getSn_MR(sn) \
1653 WIZCHIP_READ(Sn_MR(sn))
1654
1662 #define setSn_CR(sn, cr) \
1663 WIZCHIP_WRITE(Sn_CR(sn), cr)
1664
1672 #define getSn_CR(sn) \
1673 WIZCHIP_READ(Sn_CR(sn))
1674
1682 #define setSn_IR(sn, ir) \
1683 WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F))
1684
1692 #define getSn_IR(sn) \
1693 (WIZCHIP_READ(Sn_IR(sn)) & 0x1F)
1694
1702 #define setSn_IMR(sn, imr) \
1703 WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F))
1704
1712 #define getSn_IMR(sn) \
1713 (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F)
1714
1721 #define getSn_SR(sn) \
1722 WIZCHIP_READ(Sn_SR(sn))
1723
1731 #define setSn_PORT(sn, port) { \
1732 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
1733 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
1734 }
1735
1743 //M20150401 : Type explict declaration
1744 /*
1745 #define getSn_PORT(sn) \
1746 ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1747 */
1748 #define getSn_PORT(sn) \
1749 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1750
1758 #define setSn_DHAR(sn, dhar) \
1759 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
1760
1768 #define getSn_DHAR(sn, dhar) \
1769 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
1770
1778 #define setSn_DIPR(sn, dipr) \
1779 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
1780
1788 #define getSn_DIPR(sn, dipr) \
1789 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
1790
1798 #define setSn_DPORT(sn, dport) { \
1799 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
1800 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
1801 }
1802
1810 //M20150401 : Type explict declaration
1811 /*
1812 #define getSn_DPORT(sn) \
1813 ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1814 */
1815 #define getSn_DPORT(sn) \
1816 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1817
1825 #define setSn_MSSR(sn, mss) { \
1826 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
1827 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
1828 }
1829
1837 //M20150401 : Type explict declaration
1838 /*
1839 #define getSn_MSSR(sn) \
1840 ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1841 */
1842 #define getSn_MSSR(sn) \
1843 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1844
1852 #define setSn_TOS(sn, tos) \
1853 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1854
1862 #define getSn_TOS(sn) \
1863 WIZCHIP_READ(Sn_TOS(sn))
1864
1872 #define setSn_TTL(sn, ttl) \
1873 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
1874
1875
1883 #define getSn_TTL(sn) \
1884 WIZCHIP_READ(Sn_TTL(sn))
1885
1886
1894 #define setSn_RXBUF_SIZE(sn, rxbufsize) \
1895 WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize)
1896
1897
1905 #define getSn_RXBUF_SIZE(sn) \
1906 WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
1907
1915 #define setSn_TXBUF_SIZE(sn, txbufsize) \
1916 WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize)
1917
1925 #define getSn_TXBUF_SIZE(sn) \
1926 WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
1927
1934 uint16_t getSn_TX_FSR(uint8_t sn);
1935
1942 //M20150401 : Type explict declaration
1943 /*
1944 #define getSn_TX_RD(sn) \
1945 ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1946 */
1947 #define getSn_TX_RD(sn) \
1948 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1949
1957 #define setSn_TX_WR(sn, txwr) { \
1958 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
1959 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
1960 }
1961
1969 //M20150401 : Type explict declaration
1970 /*
1971 #define getSn_TX_WR(sn) \
1972 ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1973 */
1974 #define getSn_TX_WR(sn) \
1975 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1976
1977
1984 uint16_t getSn_RX_RSR(uint8_t sn);
1985
1986
1994 #define setSn_RX_RD(sn, rxrd) { \
1995 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
1996 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
1997 }
1998
2006 //M20150401 : Type explict declaration
2007 /*
2008 #define getSn_RX_RD(sn) \
2009 ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
2010 */
2011 #define getSn_RX_RD(sn) \
2012 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
2013
2020 //M20150401 : Type explict declaration
2021 /*
2022 #define getSn_RX_WR(sn) \
2023 ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
2024 */
2025 #define getSn_RX_WR(sn) \
2026 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
2027
2035 #define setSn_FRAG(sn, frag) { \
2036 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
2037 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
2038 }
2039
2047 //M20150401 : Type explict declaration
2048 /*
2049 #define getSn_FRAG(sn) \
2050 ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
2051 */
2052 #define getSn_FRAG(sn) \
2053 (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
2054
2062 #define setSn_KPALVTR(sn, kpalvt) \
2063 WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt)
2064
2072 #define getSn_KPALVTR(sn) \
2073 WIZCHIP_READ(Sn_KPALVTR(sn))
2074
2076
2078 // Sn_TXBUF & Sn_RXBUF IO function //
2080
2085 //M20150401 : Type explict declaration
2086 /*
2087 #define getSn_RxMAX(sn) \
2088 (getSn_RXBUF_SIZE(sn) << 10)
2089 */
2090 #define getSn_RxMAX(sn) \
2091 (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10)
2092
2098 //M20150401 : Type explict declaration
2099 /*
2100 #define getSn_TxMAX(sn) \
2101 (getSn_TXBUF_SIZE(sn) << 10)
2102 */
2103 #define getSn_TxMAX(sn) \
2104 (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10)
2105
2121 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2122
2138 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2139
2147 void wiz_recv_ignore(uint8_t sn, uint16_t len);
2148
2149 #endif
2150
2151 #endif // _W5500_H_
Generated on Mon Apr 13 2015 09:40:03 for Socket APIs by doxygen 1.8.4


Socket APIs: Ethernet/wizchip_conf.c Source File

  • Ethernet
wizchip_conf.c
Go to the documentation of this file.
1 //****************************************************************************/
14 // Issued by Mathias ClauBen.
49 //
50 //*****************************************************************************/
51 //A20140501 : for use the type - ptrdiff_t
52 #include <stddef.h>
53 //
54
55 #include "wizchip_conf.h"
56
58 //M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc.
60
66 //void wizchip_cris_enter(void) {};
67 void wizchip_cris_enter(void) {}
68
74 //void wizchip_cris_exit(void) {};
75 void wizchip_cris_exit(void) {}
76
82 //void wizchip_cs_select(void) {};
83 void wizchip_cs_select(void) {}
84
90 //void wizchip_cs_deselect(void) {};
91 void wizchip_cs_deselect(void) {}
92
98 //M20140501 : Explict pointer type casting
99 //uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *) AddrSel); };
100 //uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); };
101 uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); }
102
109 //M20140501 : Explict pointer type casting
110 //void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*) AddrSel) = wb; };
111 //void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; };
112 void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; }
113
119 //uint8_t wizchip_spi_readbyte(void) {return 0;};
120 uint8_t wizchip_spi_readbyte(void) {return 0;}
121
127 //void wizchip_spi_writebyte(uint8_t wb) {};
128 void wizchip_spi_writebyte(uint8_t wb) {}
129
135 //void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {};
136 void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}
137
143 //void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {};
144 void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}
145
149 //
150 //M20150401 : For a compiler didnot support a member of structure
151 // Replace the assignment of struct members with the assingment of array
152 //
153 /*
154 _WIZCHIP WIZCHIP =
155 {
156 .id = _WIZCHIP_ID_,
157 .if_mode = _WIZCHIP_IO_MODE_,
158 .CRIS._enter = wizchip_cris_enter,
159 .CRIS._exit = wizchip_cris_exit,
160 .CS._select = wizchip_cs_select,
161 .CS._deselect = wizchip_cs_deselect,
162 .IF.BUS._read_byte = wizchip_bus_readbyte,
163 .IF.BUS._write_byte = wizchip_bus_writebyte
164 // .IF.SPI._read_byte = wizchip_spi_readbyte,
165 // .IF.SPI._write_byte = wizchip_spi_writebyte
166 };
167 */
168 _WIZCHIP WIZCHIP =
169 {
170 _WIZCHIP_IO_MODE_,
171 _WIZCHIP_ID_ ,
172 wizchip_cris_enter,
173 wizchip_cris_exit,
174 wizchip_cs_select,
175 wizchip_cs_deselect,
176 wizchip_bus_readbyte,
177 wizchip_bus_writebyte
178 // wizchip_spi_readbyte,
179 // wizchip_spi_writebyte
180 };
181
182
183 static uint8_t _DNS_[4]; // DNS server ip address
184 static dhcp_mode _DHCP_; // DHCP mode
185
186 void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void))
187 {
188 if(!cris_en || !cris_ex)
189 {
190 WIZCHIP.CRIS._enter = wizchip_cris_enter;
191 WIZCHIP.CRIS._exit = wizchip_cris_exit;
192 }
193 else
194 {
195 WIZCHIP.CRIS._enter = cris_en;
196 WIZCHIP.CRIS._exit = cris_ex;
197 }
198 }
199
200 void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void))
201 {
202 if(!cs_sel || !cs_desel)
203 {
204 WIZCHIP.CS._select = wizchip_cs_select;
205 WIZCHIP.CS._deselect = wizchip_cs_deselect;
206 }
207 else
208 {
209 WIZCHIP.CS._select = cs_sel;
210 WIZCHIP.CS._deselect = cs_desel;
211 }
212 }
213
214 void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb))
215 {
216 while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_));
217
218 if(!bus_rb || !bus_wb)
219 {
220 WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte;
221 WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte;
222 }
223 else
224 {
225 WIZCHIP.IF.BUS._read_byte = bus_rb;
226 WIZCHIP.IF.BUS._write_byte = bus_wb;
227 }
228 }
229
230 void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb))
231 {
232 while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_));
233
234 if(!spi_rb || !spi_wb)
235 {
236 WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte;
237 WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte;
238 }
239 else
240 {
241 WIZCHIP.IF.SPI._read_byte = spi_rb;
242 WIZCHIP.IF.SPI._write_byte = spi_wb;
243 }
244 }
245
246 // 20140626 Eric Added for SPI burst operations
247 void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len))
248 {
249 while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_));
250
251 if(!spi_rb || !spi_wb)
252 {
253 WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst;
254 WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst;
255 }
256 else
257 {
258 WIZCHIP.IF.SPI._read_burst = spi_rb;
259 WIZCHIP.IF.SPI._write_burst = spi_wb;
260 }
261 }
262
263 int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg)
264 {
265 #if _WIZCHIP_ == 5200 || _WIZCHIP_ == 5500
266 uint8_t tmp = 0;
267 #endif
268 uint8_t* ptmp[2] = {0,0};
269 switch(cwtype)
270 {
271 case CW_RESET_WIZCHIP:
272 wizchip_sw_reset();
273 break;
274 case CW_INIT_WIZCHIP:
275 if(arg != 0)
276 {
277 ptmp[0] = (uint8_t*)arg;
278 ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_;
279 }
280 return wizchip_init(ptmp[0], ptmp[1]);
281 case CW_CLR_INTERRUPT:
282 wizchip_clrinterrupt(*((intr_kind*)arg));
283 break;
284 case CW_GET_INTERRUPT:
285 *((intr_kind*)arg) = wizchip_getinterrupt();
286 break;
287 case CW_SET_INTRMASK:
288 wizchip_setinterruptmask(*((intr_kind*)arg));
289 break;
290 case CW_GET_INTRMASK:
291 *((intr_kind*)arg) = wizchip_getinterruptmask();
292 break;
293 #if _WIZCHIP_ > 5100
294 case CW_SET_INTRTIME:
295 setINTLEVEL(*(uint16_t*)arg);
296 break;
297 case CW_GET_INTRTIME:
298 *(uint16_t*)arg = getINTLEVEL();
299 break;
300 #endif
301 case CW_GET_ID:
302 ((uint8_t*)arg)[0] = WIZCHIP.id[0];
303 ((uint8_t*)arg)[1] = WIZCHIP.id[1];
304 ((uint8_t*)arg)[2] = WIZCHIP.id[2];
305 ((uint8_t*)arg)[3] = WIZCHIP.id[3];
306 ((uint8_t*)arg)[4] = WIZCHIP.id[4];
307 ((uint8_t*)arg)[5] = 0;
308 break;
309 #if _WIZCHIP_ == 5500
310 case CW_RESET_PHY:
311 wizphy_reset();
312 break;
313 case CW_SET_PHYCONF:
314 wizphy_setphyconf((wiz_PhyConf*)arg);
315 break;
316 case CW_GET_PHYCONF:
317 wizphy_getphyconf((wiz_PhyConf*)arg);
318 break;
319 case CW_GET_PHYSTATUS:
320 break;
321 case CW_SET_PHYPOWMODE:
322 return wizphy_setphypmode(*(uint8_t*)arg);
323 #endif
324 #if _WIZCHIP_ == 5200 || _WIZCHIP_ == 5500
325 case CW_GET_PHYPOWMODE:
326 tmp = wizphy_getphypmode();
327 if((int8_t)tmp == -1) return -1;
328 *(uint8_t*)arg = tmp;
329 break;
330 case CW_GET_PHYLINK:
331 tmp = wizphy_getphylink();
332 if((int8_t)tmp == -1) return -1;
333 *(uint8_t*)arg = tmp;
334 break;
335 #endif
336 default:
337 return -1;
338 }
339 return 0;
340 }
341
342
343 int8_t ctlnetwork(ctlnetwork_type cntype, void* arg)
344 {
345
346 switch(cntype)
347 {
348 case CN_SET_NETINFO:
349 wizchip_setnetinfo((wiz_NetInfo*)arg);
350 break;
351 case CN_GET_NETINFO:
352 wizchip_getnetinfo((wiz_NetInfo*)arg);
353 break;
354 case CN_SET_NETMODE:
355 return wizchip_setnetmode(*(netmode_type*)arg);
356 case CN_GET_NETMODE:
357 *(netmode_type*)arg = wizchip_getnetmode();
358 break;
359 case CN_SET_TIMEOUT:
360 wizchip_settimeout((wiz_NetTimeout*)arg);
361 break;
362 case CN_GET_TIMEOUT:
363 wizchip_gettimeout((wiz_NetTimeout*)arg);
364 break;
365 default:
366 return -1;
367 }
368 return 0;
369 }
370
371 void wizchip_sw_reset(void)
372 {
373 uint8_t gw[4], sn[4], sip[4];
374 uint8_t mac[6];
375 getSHAR(mac);
376 getGAR(gw); getSUBR(sn); getSIPR(sip);
377 setMR(MR_RST);
378 getMR(); // for delay
379 setSHAR(mac);
380 setGAR(gw);
381 setSUBR(sn);
382 setSIPR(sip);
383 }
384
385 int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize)
386 {
387 int8_t i;
388 int8_t tmp = 0;
389 wizchip_sw_reset();
390 if(txsize)
391 {
392 tmp = 0;
393 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
394 tmp += txsize[i];
395 if(tmp > 16) return -1;
396 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
397 setSn_TXBUF_SIZE(i, txsize[i]);
398 }
399 if(rxsize)
400 {
401 tmp = 0;
402 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
403 tmp += rxsize[i];
404 if(tmp > 16) return -1;
405 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
406 setSn_RXBUF_SIZE(i, rxsize[i]);
407 }
408 return 0;
409 }
410
411 void wizchip_clrinterrupt(intr_kind intr)
412 {
413 uint8_t ir = (uint8_t)intr;
414 uint8_t sir = (uint8_t)((uint16_t)intr >> 8);
415 #if _WIZCHIP_ < 5500
416 ir |= (1<<4); // IK_WOL
417 #endif
418 #if _WIZCHIP_ == 5200
419 ir |= (1 << 6);
420 #endif
421
422 #if _WIZCHIP_ < 5200
423 sir &= 0x0F;
424 #endif
425
426 #if _WIZCHIP_ == 5100
427 ir |= sir;
428 setIR(ir);
429 #else
430 setIR(ir);
431 setSIR(sir);
432 #endif
433 }
434
435 intr_kind wizchip_getinterrupt(void)
436 {
437 uint8_t ir = 0;
438 uint8_t sir = 0;
439 uint16_t ret = 0;
440 #if _WIZCHIP_ == 5100
441 ir = getIR();
442 sir = ir & 0x0F;
443 #else
444 ir = getIR();
445 sir = getSIR();
446 #endif
447
448 #if _WIZCHIP_ < 5500
449 ir &= ~(1<<4); // IK_WOL
450 #endif
451 #if _WIZCHIP_ == 5200
452 ir &= ~(1 << 6);
453 #endif
454 ret = sir;
455 ret = (ret << 8) + ir;
456 return (intr_kind)ret;
457 }
458
459 void wizchip_setinterruptmask(intr_kind intr)
460 {
461 uint8_t imr = (uint8_t)intr;
462 uint8_t simr = (uint8_t)((uint16_t)intr >> 8);
463 #if _WIZCHIP_ < 5500
464 imr &= ~(1<<4); // IK_WOL
465 #endif
466 #if _WIZCHIP_ == 5200
467 imr &= ~(1 << 6);
468 #endif
469
470 #if _WIZCHIP_ == 5100
471 simr &= 0x0F;
472 imr |= simr;
473 setIMR(imr);
474 #else
475 setIMR(imr);
476 setSIMR(simr);
477 #endif
478 }
479
480 intr_kind wizchip_getinterruptmask(void)
481 {
482 uint8_t imr = 0;
483 uint8_t simr = 0;
484 uint16_t ret = 0;
485 #if _WIZCHIP_ == 5100
486 imr = getIMR();
487 simr = imr & 0x0F;
488 #else
489 imr = getIMR();
490 simr = getSIMR();
491 #endif
492
493 #if _WIZCHIP_ < 5500
494 imr &= ~(1<<4); // IK_WOL
495 #endif
496 #if _WIZCHIP_ == 5200
497 imr &= ~(1 << 6); // IK_DEST_UNREACH
498 #endif
499 ret = simr;
500 ret = (ret << 8) + imr;
501 return (intr_kind)ret;
502 }
503
504 int8_t wizphy_getphylink(void)
505 {
506 int8_t tmp;
507 #if _WIZCHIP_ == 5200
508 if(getPHYSTATUS() & PHYSTATUS_LINK)
509 tmp = PHY_LINK_ON;
510 else
511 tmp = PHY_LINK_OFF;
512 #elif _WIZCHIP_ == 5500
513 if(getPHYCFGR() & PHYCFGR_LNK_ON)
514 tmp = PHY_LINK_ON;
515 else
516 tmp = PHY_LINK_OFF;
517 #else
518 tmp = -1;
519 #endif
520 return tmp;
521 }
522
523 #if _WIZCHIP_ > 5100
524
525 int8_t wizphy_getphypmode(void)
526 {
527 int8_t tmp = 0;
528 #if _WIZCHIP_ == 5200
529 if(getPHYSTATUS() & PHYSTATUS_POWERDOWN)
530 tmp = PHY_POWER_DOWN;
531 else
532 tmp = PHY_POWER_NORM;
533 #elif _WIZCHIP_ == 5500
534 if(getPHYCFGR() & PHYCFGR_OPMDC_PDOWN)
535 tmp = PHY_POWER_DOWN;
536 else
537 tmp = PHY_POWER_NORM;
538 #else
539 tmp = -1;
540 #endif
541 return tmp;
542 }
543 #endif
544
545 #if _WIZCHIP_ == 5500
546 void wizphy_reset(void)
547 {
548 uint8_t tmp = getPHYCFGR();
549 tmp &= PHYCFGR_RST;
550 setPHYCFGR(tmp);
551 tmp = getPHYCFGR();
552 tmp |= ~PHYCFGR_RST;
553 setPHYCFGR(tmp);
554 }
555
556 void wizphy_setphyconf(wiz_PhyConf* phyconf)
557 {
558 uint8_t tmp = 0;
559 if(phyconf->by == PHY_CONFBY_SW)
560 tmp |= PHYCFGR_OPMD;
561 else
562 tmp &= ~PHYCFGR_OPMD;
563 if(phyconf->mode == PHY_MODE_AUTONEGO)
564 tmp |= PHYCFGR_OPMDC_ALLA;
565 else
566 {
567 if(phyconf->duplex == PHY_DUPLEX_FULL)
568 {
569 if(phyconf->speed == PHY_SPEED_100)
570 tmp |= PHYCFGR_OPMDC_100F;
571 else
572 tmp |= PHYCFGR_OPMDC_10F;
573 }
574 else
575 {
576 if(phyconf->speed == PHY_SPEED_100)
577 tmp |= PHYCFGR_OPMDC_100H;
578 else
579 tmp |= PHYCFGR_OPMDC_10H;
580 }
581 }
582 setPHYCFGR(tmp);
583 wizphy_reset();
584 }
585
586 void wizphy_getphyconf(wiz_PhyConf* phyconf)
587 {
588 uint8_t tmp = 0;
589 tmp = getPHYCFGR();
590 phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW;
591 switch(tmp & PHYCFGR_OPMDC_ALLA)
592 {
593 case PHYCFGR_OPMDC_ALLA:
594 case PHYCFGR_OPMDC_100FA:
595 phyconf->mode = PHY_MODE_AUTONEGO;
596 break;
597 default:
598 phyconf->mode = PHY_MODE_MANUAL;
599 break;
600 }
601 switch(tmp & PHYCFGR_OPMDC_ALLA)
602 {
603 case PHYCFGR_OPMDC_100FA:
604 case PHYCFGR_OPMDC_100F:
605 case PHYCFGR_OPMDC_100H:
606 phyconf->speed = PHY_SPEED_100;
607 break;
608 default:
609 phyconf->speed = PHY_SPEED_10;
610 break;
611 }
612 switch(tmp & PHYCFGR_OPMDC_ALLA)
613 {
614 case PHYCFGR_OPMDC_100FA:
615 case PHYCFGR_OPMDC_100F:
616 case PHYCFGR_OPMDC_10F:
617 phyconf->duplex = PHY_DUPLEX_FULL;
618 break;
619 default:
620 phyconf->duplex = PHY_DUPLEX_HALF;
621 break;
622 }
623 }
624
625 void wizphy_getphystat(wiz_PhyConf* phyconf)
626 {
627 uint8_t tmp = getPHYCFGR();
628 phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF;
629 phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10;
630 }
631
632 int8_t wizphy_setphypmode(uint8_t pmode)
633 {
634 uint8_t tmp = 0;
635 tmp = getPHYCFGR();
636 if((tmp & PHYCFGR_OPMD)== 0) return -1;
637 tmp &= ~PHYCFGR_OPMDC_ALLA;
638 if( pmode == PHY_POWER_DOWN)
639 tmp |= PHYCFGR_OPMDC_PDOWN;
640 else
641 tmp |= PHYCFGR_OPMDC_ALLA;
642 setPHYCFGR(tmp);
643 wizphy_reset();
644 tmp = getPHYCFGR();
645 if( pmode == PHY_POWER_DOWN)
646 {
647 if(tmp & PHYCFGR_OPMDC_PDOWN) return 0;
648 }
649 else
650 {
651 if(tmp & PHYCFGR_OPMDC_ALLA) return 0;
652 }
653 return -1;
654 }
655 #endif
656
657
658 void wizchip_setnetinfo(wiz_NetInfo* pnetinfo)
659 {
660 setSHAR(pnetinfo->mac);
661 setGAR(pnetinfo->gw);
662 setSUBR(pnetinfo->sn);
663 setSIPR(pnetinfo->ip);
664 _DNS_[0] = pnetinfo->dns[0];
665 _DNS_[1] = pnetinfo->dns[1];
666 _DNS_[2] = pnetinfo->dns[2];
667 _DNS_[3] = pnetinfo->dns[3];
668 _DHCP_ = pnetinfo->dhcp;
669 }
670
671 void wizchip_getnetinfo(wiz_NetInfo* pnetinfo)
672 {
673 getSHAR(pnetinfo->mac);
674 getGAR(pnetinfo->gw);
675 getSUBR(pnetinfo->sn);
676 getSIPR(pnetinfo->ip);
677 pnetinfo->dns[0]= _DNS_[0];
678 pnetinfo->dns[1]= _DNS_[1];
679 pnetinfo->dns[2]= _DNS_[2];
680 pnetinfo->dns[3]= _DNS_[3];
681 pnetinfo->dhcp = _DHCP_;
682 }
683
684 int8_t wizchip_setnetmode(netmode_type netmode)
685 {
686 uint8_t tmp = 0;
687 #if _WIZCHIP_ != 5500
688 if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1;
689 #else
690 if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1;
691 #endif
692 tmp = getMR();
693 tmp |= (uint8_t)netmode;
694 setMR(tmp);
695 return 0;
696 }
697
698 netmode_type wizchip_getnetmode(void)
699 {
700 return (netmode_type) getMR();
701 }
702
703 void wizchip_settimeout(wiz_NetTimeout* nettime)
704 {
705 setRCR(nettime->retry_cnt);
706 setRTR(nettime->time_100us);
707 }
708
709 void wizchip_gettimeout(wiz_NetTimeout* nettime)
710 {
711 nettime->retry_cnt = getRCR();
712 nettime->time_100us = getRTR();
713 }


Socket APIs: Ethernet/wizchip_conf.h Source File

  • Ethernet
wizchip_conf.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
43 //
44 //*****************************************************************************
45
54 #ifndef _WIZCHIP_CONF_H_
55 #define _WIZCHIP_CONF_H_
56
57 #include <stdint.h>
63 #define _WIZCHIP_ 5500 // 5100, 5200, 5500
64
65 #define _WIZCHIP_IO_MODE_NONE_ 0x0000
66 #define _WIZCHIP_IO_MODE_BUS_ 0x0100
67 #define _WIZCHIP_IO_MODE_SPI_ 0x0200
68 //#define _WIZCHIP_IO_MODE_IIC_ 0x0400
69 //#define _WIZCHIP_IO_MODE_SDIO_ 0x0800
70 // Add to
71 //
72
73 #define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1)
74 #define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2)
76 #define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1)
77 #define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2)
80 #if (_WIZCHIP_ == 5100)
81 #define _WIZCHIP_ID_ "W5100\0"
82
87 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_
88 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
89 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_
90 //A20150401 : Indclude W5100.h file
91 #include "W5100/w5100.h"
92
93 #elif (_WIZCHIP_ == 5200)
94 #define _WIZCHIP_ID_ "W5200\0"
95
99 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
100 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_
101 #include "W5200/w5200.h"
102 #elif (_WIZCHIP_ == 5500)
103 #define _WIZCHIP_ID_ "W5500\0"
104
118 //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_
119 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
120 #include "W5500/w5500.h"
121 #else
122 #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!"
123 #endif
124
125 #ifndef _WIZCHIP_IO_MODE_
126 #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!"
127 #endif
128
135 #define _WIZCHIP_IO_BASE_ 0x00000000 //
136
137 //M20150401 : Typing Error
138 //#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS
139 #if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_
140 #ifndef _WIZCHIP_IO_BASE_
141 #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map."
142 #endif
143 #endif
144
145 #if _WIZCHIP_ > 5100
146 #define _WIZCHIP_SOCK_NUM_ 8
147 #else
148 #define _WIZCHIP_SOCK_NUM_ 4
149 #endif
150
151
152 /********************************************************
153 * WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC.
154 *********************************************************/
159 typedef struct __WIZCHIP
160 {
161 uint16_t if_mode;
162 uint8_t id[6];
163
166 struct _CRIS
167 {
168 void (*_enter) (void);
169 void (*_exit) (void);
170 }CRIS;
174 struct _CS
175 {
176 void (*_select) (void);
177 void (*_deselect)(void);
178 }CS;
182 union _IF
183 {
187 struct
188 {
189 uint8_t (*_read_byte) (uint32_t AddrSel);
190 void (*_write_byte) (uint32_t AddrSel, uint8_t wb);
191 }BUS;
195 struct
196 {
197 uint8_t (*_read_byte) (void);
198 void (*_write_byte) (uint8_t wb);
199 void (*_read_burst) (uint8_t* pBuf, uint16_t len);
200 void (*_write_burst) (uint8_t* pBuf, uint16_t len);
201 }SPI;
202 // To be added
203 //
204 }IF;
205 }_WIZCHIP;
206
207 extern _WIZCHIP WIZCHIP;
208
213 typedef enum
214 {
215 CW_RESET_WIZCHIP,
216 CW_INIT_WIZCHIP,
217 CW_GET_INTERRUPT,
218 CW_CLR_INTERRUPT,
219 CW_SET_INTRMASK,
220 CW_GET_INTRMASK,
221 CW_SET_INTRTIME,
222 CW_GET_INTRTIME,
223 CW_GET_ID,
224
225 #if _WIZCHIP_ == 5500
226 CW_RESET_PHY,
227 CW_SET_PHYCONF,
228 CW_GET_PHYCONF,
229 CW_GET_PHYSTATUS,
230 CW_SET_PHYPOWMODE,
231 #endif
232 #if _WIZCHIP_ == 5200 || _WIZCHIP_ == 5500
233 CW_GET_PHYPOWMODE,
234 CW_GET_PHYLINK
235 #endif
236 }ctlwizchip_type;
237
242 typedef enum
243 {
244 CN_SET_NETINFO,
245 CN_GET_NETINFO,
246 CN_SET_NETMODE,
247 CN_GET_NETMODE,
248 CN_SET_TIMEOUT,
249 CN_GET_TIMEOUT,
250 }ctlnetwork_type;
251
258 typedef enum
259 {
260 #if _WIZCHIP_ == 5500
261 IK_WOL = (1 << 4),
262 #elif _WIZCHIP_ == 5300
263 IK_FMTU = (1 << 4),
264 #endif
265
266 IK_PPPOE_TERMINATED = (1 << 5),
267
268 #if _WIZCHIP_ != 5200
269 IK_DEST_UNREACH = (1 << 6),
270 #endif
271
272 IK_IP_CONFLICT = (1 << 7),
273
274 IK_SOCK_0 = (1 << 8),
275 IK_SOCK_1 = (1 << 9),
276 IK_SOCK_2 = (1 << 10),
277 IK_SOCK_3 = (1 << 11),
278 #if _WIZCHIP_ > 5100
279 IK_SOCK_4 = (1 << 12),
280 IK_SOCK_5 = (1 << 13),
281 IK_SOCK_6 = (1 << 14),
282 IK_SOCK_7 = (1 << 15),
283 #endif
284
285 #if _WIZCHIP_ > 5100
286 IK_SOCK_ALL = (0xFF << 8)
287 #else
288 IK_SOCK_ALL = (0x0F << 8)
289 #endif
290 }intr_kind;
291
292 #define PHY_CONFBY_HW 0
293 #define PHY_CONFBY_SW 1
294 #define PHY_MODE_MANUAL 0
295 #define PHY_MODE_AUTONEGO 1
296 #define PHY_SPEED_10 0
297 #define PHY_SPEED_100 1
298 #define PHY_DUPLEX_HALF 0
299 #define PHY_DUPLEX_FULL 1
300 #define PHY_LINK_OFF 0
301 #define PHY_LINK_ON 1
302 #define PHY_POWER_NORM 0
303 #define PHY_POWER_DOWN 1
304
305
306 #if _WIZCHIP_ == 5500
307
313 typedef struct wiz_PhyConf_t
314 {
315 uint8_t by;
316 uint8_t mode;
317 uint8_t speed;
318 uint8_t duplex;
319 //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN
320 //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF
321 }wiz_PhyConf;
322 #endif
323
328 typedef enum
329 {
330 NETINFO_STATIC = 1,
331 NETINFO_DHCP
332 }dhcp_mode;
333
338 typedef struct wiz_NetInfo_t
339 {
340 uint8_t mac[6];
341 uint8_t ip[4];
342 uint8_t sn[4];
343 uint8_t gw[4];
344 uint8_t dns[4];
345 dhcp_mode dhcp;
346 }wiz_NetInfo;
347
352 typedef enum
353 {
354 #if _WIZCHIP_ == 5500
355 NM_FORCEARP = (1<<1),
356 #endif
357 NM_WAKEONLAN = (1<<5),
358 NM_PINGBLOCK = (1<<4),
359 NM_PPPOE = (1<<3),
360 }netmode_type;
361
366 typedef struct wiz_NetTimeout_t
367 {
368 uint8_t retry_cnt;
369 uint16_t time_100us;
370 }wiz_NetTimeout;
371
380 void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void));
381
382
390 void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void));
391
400 void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb));
401
410 void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb));
411
420 void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len));
421
432 int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
433
443 int8_t ctlnetwork(ctlnetwork_type cntype, void* arg);
444
445
446 /*
447 * The following functions are implemented for internal use.
448 * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork().
449 */
450
455 void wizchip_sw_reset(void);
456
465 int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize);
466
472 void wizchip_clrinterrupt(intr_kind intr);
473
479 intr_kind wizchip_getinterrupt(void);
480
486 void wizchip_setinterruptmask(intr_kind intr);
487
493 intr_kind wizchip_getinterruptmask(void);
494
495 #if _WIZCHIP_ > 5100
496 int8_t wizphy_getphylink(void);
497 int8_t wizphy_getphypmode(void);
498 #endif
499
500 #if _WIZCHIP_ == 5500
501 void wizphy_reset(void);
502
507 void wizphy_setphyconf(wiz_PhyConf* phyconf);
513 void wizphy_getphyconf(wiz_PhyConf* phyconf);
519 void wizphy_getphystat(wiz_PhyConf* phyconf);
525 int8_t wizphy_setphypmode(uint8_t pmode);
526 #endif
527
533 void wizchip_setnetinfo(wiz_NetInfo* pnetinfo);
534
540 void wizchip_getnetinfo(wiz_NetInfo* pnetinfo);
541
547 int8_t wizchip_setnetmode(netmode_type netmode);
548
554 netmode_type wizchip_getnetmode(void);
555
562 void wizchip_settimeout(wiz_NetTimeout* nettime);
563
570 void wizchip_gettimeout(wiz_NetTimeout* nettime);
571
572 #endif // _WIZCHIP_CONF_H_
Generated on Mon Apr 13 2015 09:40:04 for Socket APIs by doxygen 1.8.4