ioLibrary: ioLibrary Driver

ioLibrary 4.0
ioLibrary driver
ioLibrary Driver

The ioLibrary means “Internet Offload Library” for WIZnet chip. It includes drivers and application protocols. The driver (ioLibrary) can be used for the application design of WIZnet TCP/IP chips as W5500, W5300, W5200, W5100 W5100S.

ioLibrary

This driver provides the Berkeley Socket type APIs.

  • Directory Structure
  • Ethernet : SOCKET APIs like BSD & WIZCHIP(W5500 / W5300 / W5200 / W5100 / W5100S) Driver
  • Internet :
    • DHCP client
    • DNS client
    • FTP client
    • FTP server
    • SNMP agent/trap
    • SNTP client
    • TFTP client
    • HTTP server
    • MQTT Client
    • Others will be added.

How to add an ioLibrary in project through github site.

  • Example, refer to https://www.youtube.com/watch?v=mt815RBGdsA
  • ioLibrary Doxygen doument : Refer to TODO in this document
    • Define what chip is used in wizchip_conf.h
    • Define what Host I/F mode is used in wizchip_conf.h

Revision History

  • ioLibrary V3.2.1 Released : 29, MAR, 2018
    • New features added: Library for W5100S added.
  • ioLibrary V3.1.1 Released : 14, Dec, 2016
    • Bug fixed : In Socket.c Fixed MACraw & IPraw sendto function.
  • ioLibrary V3.1.0 Released : 05, Dec, 2016
    • Internet application protocol add to MQTT Client (using paho MQTT 3.11)
  • ioLibrary V3.0.3 Released : 03, May, 2016
    • In W5300, Fixed some compile errors in close(). Refer to M20160503
    • In close(), replace socket() with some command sequences.
  • ioLibrary V3.0.2 Released : 26, April, 2016
    • Applied the erratum #1 in close() of socket.c (Refer to A20160426)
  • ioLibrary V3.0.1 Released : 15, July, 2015
    • Bug fixed : In W5100, Fixed CS control problem in read/write buffer with SPI. Refer to M20150715.
  • ioLibrary V3.0 Released : 01, June, 2015
    • Add to W5300
    • Typing Error in comments
    • Refer to 20150601 in sources.
  • Type casting error Fixed : 09, April. 2015 In socket.c, send() : Refer to M20150409
  • ioLibrary V2.0 released : April. 2015
    • Added to W5100, W5200
    • Correct to some typing error
    • Fixed the warning of type casting.
  • Last release : Nov. 2014
Generated by doxygen 1.8.14


ioLibrary: Todo List

Todo List
Global _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
Global _WIZCHIP_IO_MODE_
Should select interface mode as chip.
  • _WIZCHIP_IO_MODE_SPI_
    -_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in _WIZCHIP_ == W5500
    -_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in _WIZCHIP_ == W5500
  • _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_
Global reg_wizchip_bus_cbfunc (iodata_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, iodata_t wb))
Describe wizchip_bus_readbyte and wizchip_bus_writebyte function or register your functions.
Global 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.
Global 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.
Global 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.
Global 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.
Global W5100
You should select one, W5100, W5100S, W5200, W5300, W5500 or etc.

ex> #define _WIZCHIP_ W5500


ioLibrary: Modules

Modules
Here is a list of all modules:
[detail level 123]
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
DATA TYPE |
▼ W5100 | WHIZCHIP register defines and I/O functions of W5100
▼ WIZCHIP register | WIZCHIP register defines register group of W5100
Common register | Common register group It set the basic for the networking It set the configuration such as interrupt, network information, ICMP, etc
Socket register | Socket register group Socket register configures and control SOCKETn which is necessary to data communication
▼ WIZCHIP I/O functions | This supports the basic I/O functions for WIZCHIP register
Basic I/O function | These are basic input/output functions to read values from register or write values to register
Common register access functions | These are functions to access common registers
Socket register access functions | These are functions to access socket registers
▼ W5100S | WHIZCHIP register defines and I/O functions of W5100S
▼ WIZCHIP register | WIZCHIP register defines register group of W5100S
Common register | Common register group It set the basic for the networking It set the configuration such as interrupt, network information, ICMP, etc
Socket register | Socket register group Socket register configures and control SOCKETn which is necessary to data communication
▼ WIZCHIP I/O functions | This supports the basic I/O functions for WIZCHIP register
Basic I/O function | These are basic input/output functions to read values from register or write values to register
Common register access functions | These are functions to access common registers
Socket register access functions | These are functions to access socket registers
Special functions | These are special functions to access to the PHY
▼ W5200 | WHIZCHIP register defines and I/O functions of W5200
▼ WIZCHIP register | WIZCHIP register defines register group of W5200
Common register | Common register group It set the basic for the networking It set the configuration such as interrupt, network information, ICMP, etc
Socket register | Socket register group Socket register configures and control SOCKETn which is necessary to data communication
▼ WIZCHIP I/O functions | This supports the basic I/O functions for WIZCHIP register
Basic I/O function | These are basic input/output functions to read values from register or write values to register
Common register access functions | These are functions to access common registers
Socket register access functions | These are functions to access socket registers
▼ W5300 | WHIZCHIP register defines and I/O functions of W5300
▼ WIZCHIP register | WHIZCHIP register defines register group of W5300
Common register | Common register group It set the basic for the networking It set the configuration such as interrupt, network information, ICMP, etc
Socket register | Socket register group. Socket register configures and control SOCKETn which is necessary to data communication
▼ WIZCHIP I/O functions | This supports the basic I/O functions for WIZCHIP register
Basic I/O function | These are basic input/output functions to read values from register or write values to register
Common register access functions | These are functions to access common registers
Socket register access functions | These are functions to access socket registers
▼ W5500 | WHIZCHIP register defines and I/O functions of W5500
▼ WIZCHIP register | WHIZCHIP register defines register group of W5500
Common register | Common register group It set the basic for the networking It set the configuration such as interrupt, network information, ICMP, etc
Socket register | Socket register group. Socket register configures and control SOCKETn which is necessary to data communication
▼ WIZCHIP I/O functions | This supports the basic I/O functions for WIZCHIP register
Basic I/O function | These are basic input/output functions to read values from register or write values to register
Common register access functions | These are functions to access common registers
Socket register access functions | These are functions to access socket registers
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.
Snmp_module |


ioLibrary: 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

◆ close()

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 197 of file socket.c.

◆ connect()

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 256 of file socket.c.

◆ ctlsocket()

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 775 of file socket.c.

◆ disconnect()

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 296 of file socket.c.

◆ getsockopt()

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 874 of file socket.c.

◆ listen()

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 240 of file socket.c.

◆ recv()

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 384 of file socket.c.

◆ recvfrom()

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 593 of file socket.c.

◆ send()

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 316 of file socket.c.

◆ sendto()

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 489 of file socket.c.

◆ setsockopt()

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 821 of file socket.c.

◆ socket()

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 105 of file socket.c.


ioLibrary: DATA TYPE

Data Structures | Typedefs | Enumerations
DATA TYPE

Data Structures

struct | __WIZCHIP
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions. 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 I/O functions W5200:WIZCHIP I/O functions. 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

◆ _WIZCHIP

typedef struct __WIZCHIP _WIZCHIP

The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions.

◆ wiz_NetInfo

typedef struct wiz_NetInfo_t wiz_NetInfo

Network Information for WIZCHIP

◆ wiz_NetTimeout

typedef struct wiz_NetTimeout_t wiz_NetTimeout

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

◆ wiz_PhyConf

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.

Enumeration Type Documentation

◆ ctlnetwork_type

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 317 of file wizchip_conf.h.

◆ ctlsock_type

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 361 of file socket.h.

◆ ctlwizchip_type

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 286 of file wizchip_conf.h.

◆ dhcp_mode

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 403 of file wizchip_conf.h.

◆ intr_kind

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 333 of file wizchip_conf.h.

◆ netmode_type

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 427 of file wizchip_conf.h.

◆ sockint_kind

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 345 of file socket.h.

◆ sockopt_type

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 TTL. Sn_TTL ( setSn_TTL(), getSn_TTL() )
SO_TOS | Set TOS. Sn_TOS ( setSn_TOS(), getSn_TOS() )
SO_MSS | Set MSS. Sn_MSSR ( setSn_MSSR(), getSn_MSSR() )
SO_DESTIP | Set the destination IP address. Sn_DIPR ( setSn_DIPR(), getSn_DIPR() )
SO_DESTPORT | Set 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 380 of file socket.h.


ioLibrary: __WIZCHIP Struct Reference

Data Structures | Data Fields
__WIZCHIP Struct Reference
DATA TYPE

The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions. More...

#include <wizchip_conf.h>

Collaboration diagram for __WIZCHIP:
[legend]

Data Structures

struct | _CRIS
struct | _CS
union | _IF

Data Fields

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 I/O functions W5200:WIZCHIP I/O functions.

Definition at line 225 of file wizchip_conf.h.

Field Documentation

◆ CRIS

struct __WIZCHIP::_CRIS CRIS

◆ CS

struct __WIZCHIP::_CS CS

◆ id

uint8_t id[6]

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

Definition at line 228 of file wizchip_conf.h.

◆ IF

union __WIZCHIP::_IF IF

◆ if_mode

uint16_t if_mode

host interface mode

Definition at line 227 of file wizchip_conf.h.

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


ioLibrary: __WIZCHIP::_CRIS Struct Reference

  • __WIZCHIP
  • _CRIS
Data Fields
__WIZCHIP::_CRIS Struct Reference

#include <wizchip_conf.h>

Data Fields

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 232 of file wizchip_conf.h.

Field Documentation

◆ _enter

void(* _enter) (void)

crtical section enter

Definition at line 234 of file wizchip_conf.h.

◆ _exit

void(* _exit) (void)

critial section exit

Definition at line 235 of file wizchip_conf.h.

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


ioLibrary: __WIZCHIP::_CS Struct Reference

  • __WIZCHIP
  • _CS
Data Fields
__WIZCHIP::_CS Struct Reference

#include <wizchip_conf.h>

Data Fields

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

Detailed Description

The set of _WIZCHIP_ select control callback func.

Definition at line 240 of file wizchip_conf.h.

Field Documentation

◆ _deselect

void(* _deselect) (void)

_WIZCHIP_ deselected

Definition at line 243 of file wizchip_conf.h.

◆ _select

void(* _select) (void)

_WIZCHIP_ selected

Definition at line 242 of file wizchip_conf.h.

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


ioLibrary: __WIZCHIP::_IF Union Reference

  • __WIZCHIP
  • _IF
Data Fields
__WIZCHIP::_IF Union Reference

#include <wizchip_conf.h>

Data Fields

struct {
iodata_t(* _read_data )(uint32_t AddrSel)
void(* _write_data )(uint32_t AddrSel, iodata_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 248 of file wizchip_conf.h.

Field Documentation

◆ _read_burst

void(* _read_burst) (uint8_t *pBuf, uint16_t len)

Definition at line 272 of file wizchip_conf.h.

◆ _read_byte

uint8_t(* _read_byte) (void)

Definition at line 270 of file wizchip_conf.h.

◆ _read_data

iodata_t(* _read_data) (uint32_t AddrSel)

Definition at line 261 of file wizchip_conf.h.

◆ _write_burst

void(* _write_burst) (uint8_t *pBuf, uint16_t len)

Definition at line 273 of file wizchip_conf.h.

◆ _write_byte

void(* _write_byte) (uint8_t wb)

Definition at line 271 of file wizchip_conf.h.

◆ _write_data

void(* _write_data) (uint32_t AddrSel, iodata_t wb)

Definition at line 262 of file wizchip_conf.h.

◆ BUS

struct { ... } BUS

For BUS interface IO

◆ SPI

struct { ... } SPI

For SPI interface IO

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


ioLibrary: wiz_PhyConf_t Struct Reference

Data Fields
wiz_PhyConf_t Struct Reference
DATA TYPE

#include <wizchip_conf.h>

Data Fields

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 388 of file wizchip_conf.h.

Field Documentation

◆ by

uint8_t by

set by PHY_CONFBY_HW or PHY_CONFBY_SW

Definition at line 390 of file wizchip_conf.h.

◆ duplex

uint8_t duplex

set by PHY_DUPLEX_HALF PHY_DUPLEX_FULL

Definition at line 393 of file wizchip_conf.h.

◆ mode

uint8_t mode

set by PHY_MODE_MANUAL or PHY_MODE_AUTONEGO

Definition at line 391 of file wizchip_conf.h.

◆ speed

uint8_t speed

set by PHY_SPEED_10 or PHY_SPEED_100

Definition at line 392 of file wizchip_conf.h.

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


ioLibrary: wiz_NetInfo_t Struct Reference

Data Fields
wiz_NetInfo_t Struct Reference
DATA TYPE

#include <wizchip_conf.h>

Data Fields

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 413 of file wizchip_conf.h.

Field Documentation

◆ dhcp

dhcp_mode dhcp

1 - Static, 2 - DHCP

Definition at line 420 of file wizchip_conf.h.

◆ dns

uint8_t dns[4]

DNS server IP Address.

Definition at line 419 of file wizchip_conf.h.

◆ gw

uint8_t gw[4]

Gateway IP Address.

Definition at line 418 of file wizchip_conf.h.

◆ ip

uint8_t ip[4]

Source IP Address.

Definition at line 416 of file wizchip_conf.h.

◆ mac

uint8_t mac[6]

Source Mac Address.

Definition at line 415 of file wizchip_conf.h.

◆ sn

uint8_t sn[4]

Subnet Mask.

Definition at line 417 of file wizchip_conf.h.

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


ioLibrary: wiz_NetTimeout_t Struct Reference

Data Fields
wiz_NetTimeout_t Struct Reference
DATA TYPE

#include <wizchip_conf.h>

Data Fields

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 441 of file wizchip_conf.h.

Field Documentation

◆ retry_cnt

uint8_t retry_cnt

retry count

Definition at line 443 of file wizchip_conf.h.

◆ time_100us

uint16_t time_100us

time unit 100us

Definition at line 444 of file wizchip_conf.h.

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


ioLibrary: W5100

Modules
W5100

WHIZCHIP register defines and I/O functions of W5100. More...

Collaboration diagram for W5100:

Modules

WIZCHIP register
WIZCHIP register defines register group of W5100 .
WIZCHIP I/O functions
This supports the basic I/O functions for WIZCHIP register.

Detailed Description

WHIZCHIP register defines and I/O functions of W5100.

  • WIZCHIP register : Common register and Socket register
  • WIZCHIP I/O functions : Basic I/O function, Common register access functions and Socket register


ioLibrary: WIZCHIP register

Modules
WIZCHIP register
W5100

WIZCHIP register defines register group of W5100 . More...

Collaboration diagram for WIZCHIP register:

Modules

Common register
Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.
Socket register
Socket register group
Socket register configures and control SOCKETn which is necessary to data communication.

Detailed Description

WIZCHIP register defines register group of W5100 .

  • Common register : Common register group W5100
  • Socket register : SOCKET n register group W5100


ioLibrary: Common register

Macros
Common register
W5100 » WIZCHIP register

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc. More...

Collaboration diagram for Common register:

Macros

#define | MR (_WIZCHIP_IO_BASE_ + (0x0000))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5100_IO_BASE_ + (0x0001))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5100_IO_BASE_ + (0x0005))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5100_IO_BASE_ + (0x0009))
Source MAC Register address(R/W) More...
#define | SIPR (_W5100_IO_BASE_ + (0x000F))
Source IP Register address(R/W) More...
#define | IR (_W5100_IO_BASE_ + (0x0015))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5100_IO_BASE_ + (0x0016))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5100_IO_BASE_ + (0x0017))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5100_IO_BASE_ + (0x0019))
Retry count register(R/W) More...
#define | PATR (_W5100_IO_BASE_ + (0x001C))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PTIMER (_W5100_IO_BASE_ + (0x0028))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PMAGIC (_W5100_IO_BASE_ + (0x0029))
PPP LCP Magic number register in PPPoE mode(R) More...

Detailed Description

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.

See also
MR : Mode register.
GAR, SUBR, SHAR, SIPR
IR, Sn_IR, IMR : Interrupt.
RTR, RCR : Data retransmission.
PTIMER, PMAGIC : PPPoE.

Macro Definition Documentation

◆ _IMR_

#define _IMR_ (_W5100_IO_BASE_ + (0x0016))

Socket Interrupt Mask Register(R/W)

Each bit of IMR corresponds to each bit of IR. When a bit of IMR is and the corresponding bit of IR is set, Interrupt will be issued.

Definition at line 264 of file w5100.h.

◆ _RCR_

#define _RCR_ (_W5100_IO_BASE_ + (0x0019))

Retry count register(R/W)

RCR configures the number of time of retransmission. When retransmission occurs as many as ref RCR+1 Timeout interrupt is issued (Sn_IR_TIMEOUT = '1').

Definition at line 282 of file w5100.h.

◆ _RTR_

#define _RTR_ (_W5100_IO_BASE_ + (0x0017))

Timeout register address( 1 is 100us )(R/W)

RTR configures the retransmission timeout period. The unit of timeout period is 100us and the default of RTR is x07D0or 000 And so the default timeout period is 200ms(100us X 2000). During the time configured by RTR, W5100 waits for the peer response to the packet that is transmitted by Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). If the peer does not respond within the RTR time, W5100 retransmits the packet or issues timeout.

Definition at line 274 of file w5100.h.

◆ GAR

#define GAR (_W5100_IO_BASE_ + (0x0001))

Gateway IP Register address(R/W)

GAR configures the default gateway address.

Definition at line 212 of file w5100.h.

◆ IR

#define IR (_W5100_IO_BASE_ + (0x0015))

Interrupt Register(R/W)

IR indicates the interrupt status. Each bit of IR will be still until the bit will be written to by the host. If IR is not equal to x00 INTn PIN is asserted to low until it is x00

Each bit of IR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
CONFLICT | UNREACH | PPPoE | Reserved | S3_INT | S2_INT | S1_INT | S0_INT
  • IR_CONFLICT : IP conflict
  • IR_UNREACH : Destination unreachable
  • IR_PPPoE : PPPoE connection close
  • IR_SOCK(3) : SOCKET 3 Interrupt
  • IR_SOCK(2) : SOCKET 2 Interrupt
  • IR_SOCK(1) : SOCKET 1 Interrupt
  • IR_SOCK(0) : SOCKET 0 Interrupt

Definition at line 256 of file w5100.h.

◆ MR

#define MR (_WIZCHIP_IO_BASE_ + (0x0000))

Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc.

Each bit of MR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
RST | Reserved | WOL | PB | PPPoE | Reserved | AI | IND
  • MR_RST : Reset
  • MR_PB : Ping block
  • MR_PPPOE : PPPoE mode
  • MR_AI : Address Auto-Increment in Indirect Bus Interface
  • MR_IND : Indirect Bus Interface mode

Definition at line 202 of file w5100.h.

◆ PATR

#define PATR (_W5100_IO_BASE_ + (0x001C))

PPP LCP Request Timer register in PPPoE mode(R)

PATR notifies authentication method that has been agreed at the connection with PPPoE Server. W5100 supports two types of Authentication method - PAP and CHAP.

Definition at line 293 of file w5100.h.

◆ PMAGIC

#define PMAGIC (_W5100_IO_BASE_ + (0x0029))

PPP LCP Magic number register in PPPoE mode(R)

PMAGIC configures the 4bytes magic number to be used in LCP negotiation.

Definition at line 308 of file w5100.h.

◆ PTIMER

#define PTIMER (_W5100_IO_BASE_ + (0x0028))

PPP LCP Request Timer register in PPPoE mode(R)

PTIMER configures the time for sending LCP echo request. The unit of time is 25ms.

Definition at line 301 of file w5100.h.

◆ SHAR

#define SHAR (_W5100_IO_BASE_ + (0x0009))

Source MAC Register address(R/W)

SHAR configures the source hardware address.

Definition at line 226 of file w5100.h.

◆ SIPR

#define SIPR (_W5100_IO_BASE_ + (0x000F))

Source IP Register address(R/W)

SIPR configures the source IP address.

Definition at line 233 of file w5100.h.

◆ SUBR

#define SUBR (_W5100_IO_BASE_ + (0x0005))

Subnet mask Register address(R/W)

SUBR configures the subnet mask address.

Definition at line 219 of file w5100.h.


ioLibrary: Socket register

Macros
Socket register
W5100 » WIZCHIP register

Socket register group
Socket register configures and control SOCKETn which is necessary to data communication. More...

Collaboration diagram for Socket register:

Macros

#define | Sn_MR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))
socket Mode register(R/W) More...
#define | Sn_CR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))
Socket command register(R/W) More...
#define | Sn_IR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))
Socket interrupt register(R) More...
#define | Sn_SR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))
Socket status register(R) More...
#define | Sn_PORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))
source port register(R/W) More...
#define | Sn_DHAR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))
Peer IP register address(R/W) More...
#define | Sn_DPORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))
Peer port register address(R/W) More...
#define | Sn_MSSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_PROTO(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOS(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_TX_FSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))
Received data size register(R) More...
#define | Sn_RX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))
Write point of Receive memory(R) More...

Detailed Description

Socket register group
Socket register configures and control SOCKETn which is necessary to data communication.

See also
Sn_MR, Sn_CR, Sn_IR : SOCKETn Control
Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information
Sn_MSSR, Sn_TOS, Sn_TTL, Sn_FRAG : Internet protocol.
Sn_RXMEM_SIZE, Sn_TXMEM_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication

Macro Definition Documentation

◆ Sn_CR

#define Sn_CR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))

Socket command register(R/W)

This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.
After W5100 accepts the command, the Sn_CR register is automatically cleared to 0x00. Even though Sn_CR is cleared to 0x00, the command is still being processed.
To check whether the command is completed or not, please check the Sn_IR or Sn_SR.

  • Sn_CR_OPEN : Initialize or open socket.
  • Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode)
  • Sn_CR_CONNECT : Send connection request in TCP mode(Client mode)
  • Sn_CR_DISCON : Send closing request in TCP mode.
  • Sn_CR_CLOSE : Close socket.
  • Sn_CR_SEND : Update TX buffer pointer and send data.
  • Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process.
  • Sn_CR_SEND_KEEP : Send keep alive message.
  • Sn_CR_RECV : Update RX buffer pointer and receive data.
  • In case of S0_MR(P3:P0) = S0_MR_PPPoE
    Value | Symbol | Description
    0x23 | PCON | PPPoE connection begins by transmitting PPPoE discovery packet
    0x24 | PDISCON | Closes PPPoE connection
    0x25 | PCR | In each phase, it transmits REQ message.
    0x26 | PCN | In each phase, it transmits NAK message.
    0x27 | PCJ | In each phase, it transmits REJECT message.

Definition at line 380 of file w5100.h.

◆ Sn_DHAR

#define Sn_DHAR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))

Peer MAC register address(R/W)

Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or it indicates that it is acquired in ARP-process by CONNECT/SEND command.

Definition at line 440 of file w5100.h.

◆ Sn_DIPR

#define Sn_DIPR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))

Peer IP register address(R/W)

Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP client mode, it configures an IP address of TCP server before CONNECT command. In TCP server mode, it indicates an IP address of TCP client after successfully establishing connection. In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command.

Definition at line 450 of file w5100.h.

◆ Sn_DPORT

#define Sn_DPORT ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))

Peer port register address(R/W)

Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP clientmode, it configures the listen port number of TCP server before CONNECT command. In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command.

Definition at line 460 of file w5100.h.

◆ Sn_IR

#define Sn_IR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))

Socket interrupt register(R)

Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).
When an interrupt occurs and the corresponding bit IR_SOCK(N) in IMR are set, IR_SOCK(N) in IR becomes '1'.
In order to clear the Sn_IR bit, the host should write the bit to

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
PRECV | PFAIL | PNEXT | SEND_OK | TIMEOUT | RECV | DISCON | CON
  • Sn_IR_PRECV : PPP Receive Interrupt
  • Sn_IR_PFAIL : PPP Fail Interrupt
  • Sn_IR_PNEXT : PPP Next Phase Interrupt
  • Sn_IR_SENDOK : SEND_OK Interrupt
  • Sn_IR_TIMEOUT : TIMEOUT Interrupt
  • Sn_IR_RECV : RECV Interrupt
  • Sn_IR_DISCON : DISCON Interrupt
  • Sn_IR_CON : CON Interrupt

Definition at line 401 of file w5100.h.

◆ Sn_MR

#define Sn_MR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))

socket Mode register(R/W)

Sn_MR configures the option or protocol type of Socket n.

Each bit of Sn_MR defined as the following.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
MULTI | MF | ND/MC | Reserved | Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0]
  • Sn_MR_MULTI : Support UDP Multicasting
  • Sn_MR_MF : Support MACRAW
  • Sn_MR_ND : No Delayed Ack(TCP) flag
  • Sn_MR_MC : IGMP version used in UDP mulitcasting
  • Protocol
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 0 | 0 | 0 | Closed
    0 | 0 | 0 | 1 | TCP
    0 | 0 | 1 | 0 | UDP
    0 | 1 | 0 | 0 | MACRAW
  • In case of Socket 0
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 1 | 0 | 0 | MACRAW
    0 | 1 | 0 | 1 | PPPoE
    • Sn_MR_MACRAW : MAC LAYER RAW SOCK

Sn_MR_UDP : UDP

  • Sn_MR_TCP : TCP
  • Sn_MR_CLOSE : Unused socket
    Note
    MACRAW mode should be only used in Socket 0.

Definition at line 352 of file w5100.h.

◆ Sn_MSSR

#define Sn_MSSR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))

Maximum Segment Size(Sn_MSSR0) register address(R/W)

Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n.

Definition at line 467 of file w5100.h.

◆ Sn_PORT

#define Sn_PORT ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))

source port register(R/W)

Sn_PORT configures the source port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered.

Definition at line 432 of file w5100.h.

◆ Sn_PROTO

#define Sn_PROTO ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))

IP Protocol(PROTO) Register(R/W)

Sn_PROTO that sets the protocol number field of the IP header at the IP layer. It is valid only in IPRAW mode, and ignored in other modes.

Definition at line 475 of file w5100.h.

◆ Sn_RX_RD

#define Sn_RX_RD ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))

Read point of Receive memory(R/W)

Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.

  1. Read the starting save address of the received data.
  2. Read data from the starting address of Socket n RX Buffer.
  3. After reading the received data, Update Sn_RX_RD to the increased value as many as the reading size. If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, update with the lower 16bits value ignored the carry bit.
  4. Order RECV command is for notifying the updated Sn_RX_RD to W5100.

Definition at line 558 of file w5100.h.

◆ Sn_RX_RSR

#define Sn_RX_RSR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))

Received data size register(R)

Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. Sn_RX_RSR does not exceed the Sn_RXMEM_SIZE and is calculated as the difference between Socket n RX Write Pointer (Sn_RX_WR)and Socket n RX Read Pointer (Sn_RX_RD)

Definition at line 545 of file w5100.h.

◆ Sn_RX_WR

#define Sn_RX_WR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))

Write point of Receive memory(R)

Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 567 of file w5100.h.

◆ Sn_SR

#define Sn_SR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))

Socket status register(R)

Sn_SR indicates the status of Socket n.
The status of Socket n is changed by Sn_CR or some special control packet as SYN, FIN packet in TCP.

Normal status
  • SOCK_CLOSED : Closed
  • SOCK_INIT : Initiate state
  • SOCK_LISTEN : Listen state
  • SOCK_ESTABLISHED : Success to connect
  • SOCK_CLOSE_WAIT : Closing state
  • SOCK_UDP : UDP socket
  • SOCK_MACRAW : MAC raw mode socket
Temporary status during changing the status of Socket n.
  • SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
  • SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
  • SOCK_FIN_WAIT : Connection state
  • SOCK_CLOSING : Closing state
  • SOCK_TIME_WAIT : Closing state
  • SOCK_LAST_ACK : Closing state

Definition at line 424 of file w5100.h.

◆ Sn_TOS

#define Sn_TOS ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015)

IP Type of Service(TOS) Register(R/W)

Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. It is set before OPEN command.

Definition at line 483 of file w5100.h.

◆ Sn_TTL

#define Sn_TTL ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))

IP Time to live(TTL) Register(R/W)

Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. It is set before OPEN command.

Definition at line 491 of file w5100.h.

◆ Sn_TX_FSR

#define Sn_TX_FSR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))

Transmit free memory size register(R)

Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by Sn_TXMEM_SIZE. Data bigger than Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, transmit the data after dividing into the checked size and saving in the Socket n TX buffer.

Definition at line 510 of file w5100.h.

◆ Sn_TX_RD

#define Sn_TX_RD ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))

Transmit memory read pointer register address(R)

Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001), it is re-initialized while connecting with TCP. After its initialization, it is auto-increased by SEND command. SEND command transmits the saved data from the current Sn_TX_RD to the Sn_TX_WR in the Socket n TX Buffer. After transmitting the saved data, the SEND command increases the Sn_TX_RD as same as the Sn_TX_WR. If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 522 of file w5100.h.

◆ Sn_TX_WR

#define Sn_TX_WR ( sn ) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))

Transmit memory write pointer register address(R/W)

Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001), it is re-initialized while connecting with TCP.
It should be read or be updated like as follows.

  1. Read the starting address for saving the transmitting data.
  2. Save the transmitting data from the starting address of Socket n TX buffer.
  3. After saving the transmitting data, update Sn_TX_WR to the increased value as many as transmitting data size. If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.
  4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command

Definition at line 536 of file w5100.h.


ioLibrary: WIZCHIP I/O functions

Modules
WIZCHIP I/O functions
W5100

This supports the basic I/O functions for WIZCHIP register. More...

Collaboration diagram for WIZCHIP I/O functions:

Modules

Basic I/O function
These are basic input/output functions to read values from register or write values to register.
Common register access functions
These are functions to access common registers.
Socket register access functions
These are functions to access socket registers.

Detailed Description

This supports the basic I/O functions for WIZCHIP register.

  • Basic I/O function
    WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()

  • Common register access functions
    1. Mode
      getMR(), setMR()
    2. Interrupt
      getIR(), setIR(), getIMR(), setIMR(),
    3. Network Information
      getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR()
    4. Retransmission
      getRCR(), setRCR(), getRTR(), setRTR()
    5. PPPoE
      getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC()
  • Socket register access functions
    1. SOCKET control
      getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IR(), setSn_IR()
    2. SOCKET information
      getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() getSn_MSSR(), setSn_MSSR()
    3. SOCKET communication
      getSn_RXMEM_SIZE(), setSn_RXMEM_SIZE(), getSn_TXMEM_SIZE(), setSn_TXMEM_SIZE()
      getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR()
      getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR()
      getSn_TX_FSR(), getSn_RX_RSR()
    4. IP header field
      getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS()
      getSn_TTL(), setSn_TTL()


ioLibrary: Basic I/O function

Functions
Basic I/O function
W5100 » WIZCHIP I/O functions

These are basic input/output functions to read values from register or write values to register. More...

Collaboration diagram for Basic I/O function:

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...

Detailed Description

These are basic input/output functions to read values from register or write values to register.

Function Documentation

◆ wiz_recv_data()

void wiz_recv_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after that, it copies the received data from internal RX memory to wizdata(pointer variable) of the length of len(variable) bytes. This function is being called by recv() also.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
wizdata | Pointer buffer to read data
len | Data length
See also
wiz_send_data()

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after copy the data from receive buffer update the Rx write pointer register. User should read upper byte first and lower byte later to get proper value. It calculate the actual physical address where one has to read the data from Receive buffer. Here also take care of the condition while it exceed the Rx memory uper-bound of socket.

Definition at line 353 of file w5100s.c.

◆ wiz_recv_ignore()

void wiz_recv_ignore | ( | uint8_t | sn,
 |  | uint16_t | len
 | ) |  |

It discard the received data in RX memory.

It discards the data of the length of len(variable) bytes in internal RX memory.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
len | Data length

Definition at line 385 of file w5100s.c.

◆ wiz_send_data()

void wiz_send_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to internal TX memory.

This function reads the Tx write pointer register and after that, it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory and updates the Tx write pointer register. This function is being called by send() and sendto() function also.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
wizdata | Pointer buffer to write data
len | Data length
See also
wiz_recv_data()

It copies data to internal TX memory.

This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer register. User should read upper byte first and lower byte later to get proper value. And this function is being used for copy the data form application buffer to Transmite buffer of the chip. It calculate the actual physical address where one has to write the data in transmite buffer. Here also take care of the condition while it exceed the Tx memory uper-bound of socket.

Definition at line 311 of file w5100s.c.

◆ WIZCHIP_READ()

uint8_t WIZCHIP_READ ( uint32_t AddrSel )

It reads 1 byte value from a register.

Parameters
AddrSel Register address
Returns
The value of register

It reads 1 byte value from a register.

Definition at line 83 of file w5100s.c.

◆ WIZCHIP_READ_BUF()

void WIZCHIP_READ_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It reads sequence data from registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to read data
len | Data length

It reads sequence data from registers.

Definition at line 181 of file w5100s.c.

◆ WIZCHIP_WRITE()

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

It writes 1 byte value to a register.

Parameters
AddrSel | Register address
wb | Write data
Returns
void

It writes 1 byte value to a register.

Definition at line 47 of file w5100s.c.

◆ WIZCHIP_WRITE_BUF()

void WIZCHIP_WRITE_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It writes sequence data to registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to write data
len | Data length

It writes sequence data to registers.

Definition at line 124 of file w5100s.c.


ioLibrary: Common register access functions

Macros
Common register access functions
W5100 » WIZCHIP I/O functions

These are functions to access common registers. More...

Collaboration diagram for Common register access functions:

Macros

#define | setMR(mr) (*((uint8_t*)MR) = mr)
Set Mode Register. More...
#define | getMR() (*(uint8_t*)MR)
Get MR. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set GAR. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get GAR. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR,subr,4)
Set SUBR. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get SUBR. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set SHAR. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get SHAR. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set SIPR. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get SIPR. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xA0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xA0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr)
Set IMR register. More...
#define | getIMR() WIZCHIP_READ(_IMR_)
Get IMR register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | setRMSR(rmsr) WIZCHIP_WRITE(RMSR)
Get RMSR register. More...
#define | getRMSR() WIZCHIP_READ()
Get RMSR register. More...
#define | setTMSR(rmsr) WIZCHIP_WRITE(TMSR)
Get TMSR register. More...
#define | getPATR() (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
Get TMSR register. More...
#define | getPPPALGO() WIZCHIP_READ(PPPALGO)
Get PPPALGO register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...

Detailed Description

These are functions to access common registers.

Macro Definition Documentation

◆ getGAR

#define getGAR ( gar ) WIZCHIP_READ_BUF(GAR,gar,4)

Get GAR.

Parameters
(uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes.
See also
setGAR()

Definition at line 1138 of file w5100.h.

◆ getIMR

#define getIMR ( ) WIZCHIP_READ(_IMR_)

Get IMR register.

Returns
uint8_t. Value of IMR register.
See also
setIMR()

Definition at line 1230 of file w5100.h.

◆ getIR

#define getIR ( ) (WIZCHIP_READ(IR) & 0xA0)

Get IR register.

Returns
uint8_t. Value of IR register.
See also
setIR()

Definition at line 1212 of file w5100.h.

◆ getMR

#define getMR ( ) (*(uint8_t*)MR)

Get MR.

Returns
uint8_t. The value of Mode register.
See also
setMR()

Definition at line 1120 of file w5100.h.

◆ getPATR

#define getPATR ( ) (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))

Get TMSR register.

Returns
uint8_t. Value of TMSR register.
See also
setTMSR()

Get PATR register

Returns
uint16_t. Value to set PATR register

Definition at line 1309 of file w5100.h.

◆ getPMAGIC

#define getPMAGIC ( ) WIZCHIP_READ(PMAGIC)

Get PMAGIC register.

Returns
uint8_t. Value of PMAGIC register.
See also
setPMAGIC()

Definition at line 1354 of file w5100.h.

◆ getPPPALGO

#define getPPPALGO ( ) WIZCHIP_READ(PPPALGO)

Get PPPALGO register.

Returns
uint8_t. Value to set PPPALGO register

Definition at line 1317 of file w5100.h.

◆ getPTIMER

#define getPTIMER ( ) WIZCHIP_READ(PTIMER)

Get PTIMER register.

Returns
uint8_t. Value of PTIMER register.
See also
setPTIMER()

Definition at line 1336 of file w5100.h.

◆ getRCR

#define getRCR ( ) WIZCHIP_READ(_RCR_)

Get RCR register.

Returns
uint8_t. Value of RCR register.
See also
setRCR()

Definition at line 1268 of file w5100.h.

◆ getRMSR

#define getRMSR ( ) WIZCHIP_READ()

Get RMSR register.

Returns
uint8_t. Value of RMSR register.
See also
setRMSR()

Definition at line 1285 of file w5100.h.

◆ getRTR

#define getRTR ( ) (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))

Get RTR register.

Returns
uint16_t. Value of RTR register.
See also
setRTR()

Definition at line 1250 of file w5100.h.

◆ getSHAR

#define getSHAR ( shar ) WIZCHIP_READ_BUF(SHAR, shar, 6)

Get SHAR.

Parameters
(uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes.
See also
setSHAR()

Definition at line 1177 of file w5100.h.

◆ getSIPR

#define getSIPR ( sipr ) WIZCHIP_READ_BUF(SIPR, sipr, 4)

Get SIPR.

Parameters
(uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes.
See also
setSIPR()

Definition at line 1195 of file w5100.h.

◆ getSUBR

#define getSUBR ( subr ) WIZCHIP_READ_BUF(SUBR, subr, 4)

Get SUBR.

Parameters
(uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes.
See also
setSUBR()

Definition at line 1159 of file w5100.h.

◆ setGAR

#define setGAR ( gar ) WIZCHIP_WRITE_BUF(GAR,gar,4)

Set GAR.

Parameters
(uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes.
See also
getGAR()

Definition at line 1129 of file w5100.h.

◆ setIMR

#define setIMR ( imr ) WIZCHIP_WRITE(_IMR_, imr)

Set IMR register.

Parameters
(uint8_t)imr Value to set IMR register.
See also
getIMR()

Definition at line 1221 of file w5100.h.

◆ setIR

#define setIR ( ir ) WIZCHIP_WRITE(IR, (ir & 0xA0))

Set IR register.

Parameters
(uint8_t)ir Value to set IR register.
See also
getIR()

Definition at line 1204 of file w5100.h.

◆ setMR

#define setMR ( mr ) (*((uint8_t*)MR) = mr)

Set Mode Register.

Parameters
(uint8_t)mr The value to be set.
See also
getMR()

Definition at line 1108 of file w5100.h.

◆ setPMAGIC

#define setPMAGIC ( pmagic ) WIZCHIP_WRITE(PMAGIC, pmagic)

Set PMAGIC register.

Parameters
(uint8_t)pmagic Value to set PMAGIC register.
See also
getPMAGIC()

Definition at line 1345 of file w5100.h.

◆ setPTIMER

#define setPTIMER ( ptimer ) WIZCHIP_WRITE(PTIMER, ptimer)

Set PTIMER register.

Parameters
(uint8_t)ptimer Value to set PTIMER register.
See also
getPTIMER()

Definition at line 1327 of file w5100.h.

◆ setRCR

#define setRCR ( rcr ) WIZCHIP_WRITE(_RCR_, rcr)

Set RCR register.

Parameters
(uint8_t)rcr Value to set RCR register.
See also
getRCR()

Definition at line 1259 of file w5100.h.

◆ setRMSR

#define setRMSR ( rmsr ) WIZCHIP_WRITE(RMSR)

Get RMSR register.

See also
getRMSR()

Definition at line 1276 of file w5100.h.

◆ setRTR

#define setRTR ( rtr )
Value:
{\
WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
_RTR_
#define _RTR_
Timeout register address( 1 is 100us )(R/W)
Definition: w5100.h:274

Set RTR register.

Parameters
(uint16_t)rtr Value to set RTR register.
See also
getRTR()

Definition at line 1239 of file w5100.h.

◆ setSHAR

#define setSHAR ( shar ) WIZCHIP_WRITE_BUF(SHAR, shar, 6)

Set SHAR.

Parameters
(uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes.
See also
getSHAR()

Definition at line 1168 of file w5100.h.

◆ setSIPR

#define setSIPR ( sipr ) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)

Set SIPR.

Parameters
(uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes.
See also
getSIPR()

Definition at line 1186 of file w5100.h.

◆ setSUBR

#define setSUBR ( subr ) WIZCHIP_WRITE_BUF(SUBR,subr,4)

Set SUBR.

Parameters
(uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes.
Note
If subr is null pointer, set the backup subnet to SUBR.
If subr is 0.0.0.0, back up SUBR and clear it.
Otherwize, set subr to SUBR
See also
getSUBR()

Definition at line 1150 of file w5100.h.

◆ setTMSR

#define setTMSR ( rmsr ) WIZCHIP_WRITE(TMSR)

Get TMSR register.

See also
getTMSR()

Definition at line 1293 of file w5100.h.


ioLibrary: Socket register access functions

Macros | Functions
Socket register access functions
W5100 » WIZCHIP I/O functions

These are functions to access socket registers. More...

Collaboration diagram for Socket register access functions:

Macros

#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ir)
Set Sn_IR register. More...
#define | getSn_IR(sn) WIZCHIP_READ(Sn_IR(sn))
Get Sn_IR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_DHAR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_PROTO(sn, proto) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_PROTO register. More...
#define | getSn_PROTO(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_PROTO register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXMEM_SIZE(sn, rxmemsize) WIZCHIP_WRITE(RMSR, (WIZCHIP_READ(RMSR) & ~(0x03 << (2*sn))) | (rxmemsize << (2*sn)))
Set Sn_RXMEM_SIZE register. More...
#define | getSn_RXMEM_SIZE(sn) ((WIZCHIP_READ(RMSR) & (0x03 << (2*sn))) >> (2*sn))
Get Sn_RXMEM_SIZE register. More...
#define | setSn_TXMEM_SIZE(sn, txmemsize) WIZCHIP_WRITE(TMSR, (WIZCHIP_READ(TMSR) & ~(0x03 << (2*sn))) | (txmemsize << (2*sn)))
Set Sn_TXMEM_SIZE register. More...
#define | getSn_TXMEM_SIZE(sn) ((WIZCHIP_READ(TMSR) & (0x03 << (2*sn))) >> (2*sn))
Get Sn_TXMEM_SIZE register. More...
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | setSn_RX_WR(sn, rxwr)
Set Sn_RX_WR register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_FRAG(sn, frag)
Set Sn_FRAG register. More...
#define | getSn_FRAG(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
Get Sn_FRAG register. More...
#define | getSn_RxMAX(sn) ((uint16_t)(1 << getSn_RXMEM_SIZE(sn)) << 10)
Get the max RX buffer size of socket sn. More...
#define | getSn_TxMAX(sn) ((uint16_t)(1 << getSn_TXMEM_SIZE(sn)) << 10)
Get the max TX buffer size of socket sn. More...
#define | getSn_RxMASK(sn) (getSn_RxMAX(sn) - 1)
Get the mask of socket sn RX buffer. More...
#define | getSn_TxMASK(sn) (getSn_TxMAX(sn) - 1)
Get the mask of socket sn TX buffer. More...

Functions

uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
uint32_t | getSn_RxBASE (uint8_t sn)
Get the base address of socket sn RX buffer. More...
uint32_t | getSn_TxBASE (uint8_t sn)
Get the base address of socket sn TX buffer. More...

Detailed Description

These are functions to access socket registers.

Macro Definition Documentation

◆ getSn_CR

#define getSn_CR ( sn ) WIZCHIP_READ(Sn_CR(sn))

Get Sn_CR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_CR.
See also
setSn_CR()

Definition at line 1397 of file w5100.h.

◆ getSn_DHAR

#define getSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)

Get Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dhar | Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes.
See also
setSn_DHAR()

Definition at line 1468 of file w5100.h.

◆ getSn_DIPR

#define getSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)

Get Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dipr | Pointer variable to get socket n destination IP address. It should be allocated 4 bytes.
See also
SetSn_DIPR()

Definition at line 1488 of file w5100.h.

◆ getSn_DPORT

#define getSn_DPORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))

Get Sn_DPORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_DPORT.
See also
setSn_DPORT()

Definition at line 1510 of file w5100.h.

◆ getSn_FRAG

#define getSn_FRAG ( sn ) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))

Get Sn_FRAG register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_FRAG.
See also
setSn_FRAG()

Definition at line 1749 of file w5100.h.

◆ getSn_IR

#define getSn_IR ( sn ) WIZCHIP_READ(Sn_IR(sn))

Get Sn_IR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_IR.
See also
setSn_IR()

Definition at line 1417 of file w5100.h.

◆ getSn_MR

#define getSn_MR ( sn ) WIZCHIP_READ(Sn_MR(sn))

Get Sn_MR register.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.
Returns
Value of Sn_MR.
See also
setSn_MR()

Definition at line 1377 of file w5100.h.

◆ getSn_MSSR

#define getSn_MSSR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))

Get Sn_MSSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_MSSR.
See also
setSn_MSSR()

Definition at line 1532 of file w5100.h.

◆ getSn_PORT

#define getSn_PORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))

Get Sn_PORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_PORT.
See also
setSn_PORT()

Definition at line 1448 of file w5100.h.

◆ getSn_PROTO

#define getSn_PROTO ( sn ) WIZCHIP_READ(Sn_TOS(sn))

Get Sn_PROTO register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_PROTO.
See also
setSn_PROTO()

Definition at line 1552 of file w5100.h.

◆ getSn_RX_RD

#define getSn_RX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))

Get Sn_RX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_. uint16_t. Value of Sn_RX_RD.
See also
setSn_RX_RD()

Definition at line 1705 of file w5100.h.

◆ getSn_RX_WR

#define getSn_RX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))

Get Sn_RX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_WR.

Definition at line 1727 of file w5100.h.

◆ getSn_RxMASK

#define getSn_RxMASK ( sn ) (getSn_RxMAX(sn) - 1)

Get the mask of socket sn RX buffer.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Mask value

Definition at line 1777 of file w5100.h.

◆ getSn_RxMAX

#define getSn_RxMAX ( sn ) ((uint16_t)(1 << getSn_RXMEM_SIZE(sn)) << 10)

Get the max RX buffer size of socket sn.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Max buffer size

Definition at line 1758 of file w5100.h.

◆ getSn_RXMEM_SIZE

#define getSn_RXMEM_SIZE ( sn ) ((WIZCHIP_READ(RMSR) & (0x03 << (2*sn))) >> (2*sn))

Get Sn_RXMEM_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_RXMEM.
See also
setSn_RXMEM_SIZE()

Definition at line 1613 of file w5100.h.

◆ getSn_SR

#define getSn_SR ( sn ) WIZCHIP_READ(Sn_SR(sn))

Get Sn_SR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_SR.

Definition at line 1426 of file w5100.h.

◆ getSn_TOS

#define getSn_TOS ( sn ) WIZCHIP_READ(Sn_TOS(sn))

Get Sn_TOS register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
Returns
uint8_t. Value of Sn_TOS.
See also
setSn_TOS()

Definition at line 1572 of file w5100.h.

◆ getSn_TTL

#define getSn_TTL ( sn ) WIZCHIP_READ(Sn_TTL(sn))

Get Sn_TTL register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
Returns
uint8_t. Value of Sn_TTL.
See also
setSn_TTL()

Definition at line 1592 of file w5100.h.

◆ getSn_TX_RD

#define getSn_TX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))

Get Sn_TX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_RD.

Definition at line 1653 of file w5100.h.

◆ getSn_TX_WR

#define getSn_TX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))

Get Sn_TX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_WR.
See also
setSn_TX_WR()

Definition at line 1675 of file w5100.h.

◆ getSn_TxMASK

#define getSn_TxMASK ( sn ) (getSn_TxMAX(sn) - 1)

Get the mask of socket sn TX buffer.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Mask value

Definition at line 1786 of file w5100.h.

◆ getSn_TxMAX

#define getSn_TxMAX ( sn ) ((uint16_t)(1 << getSn_TXMEM_SIZE(sn)) << 10)

Get the max TX buffer size of socket sn.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Max buffer size

Definition at line 1768 of file w5100.h.

◆ getSn_TXMEM_SIZE

#define getSn_TXMEM_SIZE ( sn ) ((WIZCHIP_READ(TMSR) & (0x03 << (2*sn))) >> (2*sn))

Get Sn_TXMEM_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_TXMEM_SIZE.
See also
setSn_TXMEM_SIZE()

Definition at line 1635 of file w5100.h.

◆ setSn_CR

#define setSn_CR | ( | sn,
 |  | cr
 | ) | WIZCHIP_WRITE(Sn_CR(sn), cr)

Set Sn_CR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)cr | Value to set Sn_CR
See also
getSn_CR()

Definition at line 1387 of file w5100.h.

◆ setSn_DHAR

#define setSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)

Set Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dhar | Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes.
See also
getSn_DHAR()

Definition at line 1458 of file w5100.h.

◆ setSn_DIPR

#define setSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)

Set Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dipr | Pointer variable to set socket n destination IP address. It should be allocated 4 bytes.
See also
getSn_DIPR()

Definition at line 1478 of file w5100.h.

◆ setSn_DPORT

#define setSn_DPORT | ( | sn,
 |  | dport
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
Sn_DPORT
#define Sn_DPORT(sn)
Peer port register address(R/W)
Definition: w5100.h:460

Set Sn_DPORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)dport | Value to set Sn_DPORT
See also
getSn_DPORT()

Definition at line 1498 of file w5100.h.

◆ setSn_FRAG

#define setSn_FRAG | ( | sn,
 |  | frag
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
}
Sn_FRAG
#define Sn_FRAG(sn)
Fragment field value in IP header register(R/W)
Definition: w5200.h:684
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59

Set Sn_FRAG register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)frag | Value to set Sn_FRAG
See also
getSn_FRAG()

Definition at line 1737 of file w5100.h.

◆ setSn_IR

#define setSn_IR | ( | sn,
 |  | ir
 | ) | WIZCHIP_WRITE(Sn_IR(sn), ir)

Set Sn_IR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)ir | Value to set Sn_IR
See also
getSn_IR()

Definition at line 1407 of file w5100.h.

◆ setSn_MR

#define setSn_MR | ( | sn,
 |  | mr
 | ) | WIZCHIP_WRITE(Sn_MR(sn),mr)

Set Sn_MR register.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.
mr | Value to set Sn_MR
See also
getSn_MR()

Definition at line 1367 of file w5100.h.

◆ setSn_MSSR

#define setSn_MSSR | ( | sn,
 |  | mss
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
Sn_MSSR
#define Sn_MSSR(sn)
Maximum Segment Size(Sn_MSSR0) register address(R/W)
Definition: w5100.h:467

Set Sn_MSSR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)mss | Value to set Sn_MSSR
See also
setSn_MSSR()

Definition at line 1520 of file w5100.h.

◆ setSn_PORT

#define setSn_PORT | ( | sn,
 |  | port
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
Sn_PORT
#define Sn_PORT(sn)
source port register(R/W)
Definition: w5100.h:432

Set Sn_PORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)port | Value to set Sn_PORT.
See also
getSn_PORT()

Definition at line 1436 of file w5100.h.

◆ setSn_PROTO

#define setSn_PROTO | ( | sn,
 |  | proto
 | ) | WIZCHIP_WRITE(Sn_TOS(sn), tos)

Set Sn_PROTO register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)proto | Value to set Sn_PROTO
See also
getSn_PROTO()

Definition at line 1542 of file w5100.h.

◆ setSn_RX_RD

#define setSn_RX_RD | ( | sn,
 |  | rxrd
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
Sn_RX_RD
#define Sn_RX_RD(sn)
Read point of Receive memory(R/W)
Definition: w5100.h:558

Set Sn_RX_RD register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)rxrd | Value to set Sn_RX_RD
See also
getSn_RX_RD()

Definition at line 1693 of file w5100.h.

◆ setSn_RX_WR

#define setSn_RX_WR | ( | sn,
 |  | rxwr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
}
Sn_RX_WR
#define Sn_RX_WR(sn)
Write point of Receive memory(R)
Definition: w5100.h:567
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59

Set Sn_RX_WR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)rxwr | Value to set Sn_RX_WR
See also
getSn_RX_WR()

Definition at line 1715 of file w5100.h.

◆ setSn_RXMEM_SIZE

#define setSn_RXMEM_SIZE | ( | sn,
 |  | rxmemsize
 | ) | WIZCHIP_WRITE(RMSR, (WIZCHIP_READ(RMSR) & ~(0x03 << (2*sn))) | (rxmemsize << (2*sn)))

Set Sn_RXMEM_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
(uint8_t)rxmemsize | Value to set Sn_RXMEM_SIZE
See also
getSn_RXMEM_SIZE()

Definition at line 1602 of file w5100.h.

◆ setSn_TOS

#define setSn_TOS | ( | sn,
 |  | tos
 | ) | WIZCHIP_WRITE(Sn_TOS(sn), tos)

Set Sn_TOS register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)tos | Value to set Sn_TOS
See also
getSn_TOS()

Definition at line 1562 of file w5100.h.

◆ setSn_TTL

#define setSn_TTL | ( | sn,
 |  | ttl
 | ) | WIZCHIP_WRITE(Sn_TTL(sn), ttl)

Set Sn_TTL register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
(uint8_t)ttl | Value to set Sn_TTL
See also
getSn_TTL()

Definition at line 1582 of file w5100.h.

◆ setSn_TX_WR

#define setSn_TX_WR | ( | sn,
 |  | txwr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
Sn_TX_WR
#define Sn_TX_WR(sn)
Transmit memory write pointer register address(R/W)
Definition: w5100.h:536

Set Sn_TX_WR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)txwr | Value to set Sn_TX_WR
See also
GetSn_TX_WR()

Definition at line 1663 of file w5100.h.

◆ setSn_TXMEM_SIZE

#define setSn_TXMEM_SIZE | ( | sn,
 |  | txmemsize
 | ) | WIZCHIP_WRITE(TMSR, (WIZCHIP_READ(TMSR) & ~(0x03 << (2*sn))) | (txmemsize << (2*sn)))

Set Sn_TXMEM_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)txmemsize | Value to set Sn_TXMEM_SIZE
See also
getSn_TXMEM_SIZE()

Definition at line 1624 of file w5100.h.

Function Documentation

◆ getSn_RX_RSR()

uint16_t getSn_RX_RSR ( uint8_t sn )

Get Sn_RX_RSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_RSR.

Definition at line 254 of file w5100s.c.

◆ getSn_RxBASE()

uint32_t getSn_RxBASE ( uint8_t sn )

Get the base address of socket sn RX buffer.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n RX buffer base address.

Definition at line 273 of file w5100s.c.

◆ getSn_TX_FSR()

uint16_t getSn_TX_FSR ( uint8_t sn )

Get Sn_TX_FSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_FSR.

Definition at line 237 of file w5100s.c.

◆ getSn_TxBASE()

uint32_t getSn_TxBASE ( uint8_t sn )

Get the base address of socket sn TX buffer.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n TX buffer base address.

Definition at line 287 of file w5100s.c.


ioLibrary: W5100S

Modules
W5100S

WHIZCHIP register defines and I/O functions of W5100S. More...

Collaboration diagram for W5100S:

Modules

WIZCHIP register
WIZCHIP register defines register group of W5100S .
WIZCHIP I/O functions
This supports the basic I/O functions for WIZCHIP register.

Detailed Description

WHIZCHIP register defines and I/O functions of W5100S.

  • WIZCHIP_register_W5100S: Common register and Socket register
  • WIZCHIP_IO_Functions_W5100S: Basic I/O function, Common register access functions and Special functions


ioLibrary: WIZCHIP register

Modules
WIZCHIP register
W5100S

WIZCHIP register defines register group of W5100S . More...

Collaboration diagram for WIZCHIP register:

Modules

Common register
Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.
Socket register
Socket register group
Socket register configures and control SOCKETn which is necessary to data communication.

Detailed Description

WIZCHIP register defines register group of W5100S .

  • Common register : Common register group W5100S
  • Socket register : SOCKET n register group W5100S


ioLibrary: Common register

Macros
Common register
W5100S » WIZCHIP register

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc. More...

Collaboration diagram for Common register:

Macros

#define | MR (_WIZCHIP_IO_BASE_ + (0x0000))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5100S_IO_BASE_ + (0x0001))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5100S_IO_BASE_ + (0x0005))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5100S_IO_BASE_ + (0x0009))
Source MAC Register address(R/W) More...
#define | SIPR (_W5100S_IO_BASE_ + (0x000F))
Source IP Register address(R/W) More...
#define | IR (_W5100S_IO_BASE_ + (0x0015))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5100S_IO_BASE_ + (0x0016))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5100S_IO_BASE_ + (0x0017))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5100S_IO_BASE_ + (0x0019))
Retry count register(R/W) More...
#define | RMSR (_W5100S_IO_BASE_ + (0x001A))
Receive Memory Size Register. More...
#define | TMSR (_W5100S_IO_BASE_ + (0x001B))
Transmit Memory Size Register. More...
#define | IR2 (_W5100S_IO_BASE_ + (0x0020))
Interrupt register 2. More...
#define | IMR2 (_W5100S_IO_BASE_ + (0x0021))
Interrupt mask register 2. More...
#define | PTIMER (_W5100S_IO_BASE_ + (0x0028))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PMAGIC (_W5100S_IO_BASE_ + (0x0029))
PPP LCP Magic number register in PPPoE mode(R) More...
#define | UIPR (_W5100S_IO_BASE_ + (0x002A))
Unreachable IP address register. More...
#define | UPORTR (_W5100S_IO_BASE_ + (0x002E))
Unreachable Port register. More...
#define | MR2 (_W5100S_IO_BASE_ + (0x0030))
MR2 Mode register 2. More...
#define | PHAR (_W5100S_IO_BASE_ + (0x0032))
Destination Hardware address in PPPoE. More...
#define | PSIDR (_W5100S_IO_BASE_ + (0x0038))
Session ID in PPPoE. More...
#define | PMRUR (_W5100S_IO_BASE_ + (0x003A))
Maximum receive Unit in PPPoE. More...
#define | PHYSR (_W5100S_IO_BASE_ + (0x003C))
PHY status register. More...
#define | PHYSR1 (_W5100S_IO_BASE_ + (0x003D))
PHY status register(hidden) More...
#define | PHYAR (_W5100S_IO_BASE_ + (0x003E))
PHY Address value. More...
#define | PHYRAR (_W5100S_IO_BASE_ + (0x003F))
PHY Register address. More...
#define | PHYDIR (_W5100S_IO_BASE_ + (0x0040))
PHY Data input register. More...
#define | PHYDOR (_W5100S_IO_BASE_ + (0x0042))
PHY data output register. More...
#define | PHYACR (_W5100S_IO_BASE_ + (0x0044))
PHY Action register. More...
#define | PHYDIVR (_W5100S_IO_BASE_ + (0x0045))
PHY Division register. More...
#define | PHYCR0 (_W5100S_IO_BASE_ + (0x0046))
PHY Control register 0. More...
#define | PHYCR1 (_W5100S_IO_BASE_ + (0x0047))
PHY Control register 1. More...
#define | SLCR (_W5100S_IO_BASE_ + (0x004C))
Socket-less control register. More...
#define | SLRTR (_W5100S_IO_BASE_ + (0x004D))
Socket-less retry time register. More...
#define | SLRCR (_W5100S_IO_BASE_ + (0x004F))
Socket-less retry count register. More...
#define | SLPIPR (_W5100S_IO_BASE_ + (0x0050))
Socket-less peer IP address register. More...
#define | SLPHAR (_W5100S_IO_BASE_ + (0x0054))
Socket-less peer hardware address register. More...
#define | PINGSEQR (_W5100S_IO_BASE_ + (0x005A))
Ping sequence number register. More...
#define | PINGIDR (_W5100S_IO_BASE_ + (0x005C))
Ping ID register. More...
#define | SLIMR (_W5100S_IO_BASE_ + (0x005E))
Socket-less interrupt mask register. More...
#define | SLIR (_W5100S_IO_BASE_ + (0x005F))
Socket-less interrupt register. More...
#define | DBGOUT (_W5100S_IO_BASE_ + (0x0060))
DBGOUT(hidden) More...
#define | NICMAXCOLR (_W5100S_IO_BASE_ + (0x0063))
NICMAXCOLR(hidden) More...
#define | CHIPLCKR (_W5100S_IO_BASE_ + (0x0070))
Chip Configuration locking register. More...
#define | NETLCKR (_W5100S_IO_BASE_ + (0x0071))
Network Configuration locking register. More...
#define | PHYLCKR (_W5100S_IO_BASE_ + (0x0072))
PHY Configuration locking register. More...
#define | VERR (_W5100S_IO_BASE_ + (0x0080))
version register More...
#define | TCNTR (_W5100S_IO_BASE_ + (0x0082))
Core 100us Counter register. More...
#define | TCNTCLKR (_W5100S_IO_BASE_ + (0x0088))
Core 100us Counter clear register. More...

Detailed Description

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.

See also
MR : Mode register.
GAR, SUBR, SHAR, SIPR
IR, Sn_IR, IMR : Interrupt.
RTR, RCR : Data retransmission.
PTIMER, PMAGIC : PPPoE.

Macro Definition Documentation

◆ _IMR_

#define _IMR_ (_W5100S_IO_BASE_ + (0x0016))

Socket Interrupt Mask Register(R/W)

Each bit of IMR corresponds to each bit of IR. When a bit of IMR is and the corresponding bit of IR is set, Interrupt will be issued.

Definition at line 272 of file w5100s.h.

◆ _RCR_

#define _RCR_ (_W5100S_IO_BASE_ + (0x0019))

Retry count register(R/W)

RCR configures the number of time of retransmission. When retransmission occurs as many as ref RCR+1 Timeout interrupt is issued (Sn_IR_TIMEOUT = '1').

Definition at line 290 of file w5100s.h.

◆ _RTR_

#define _RTR_ (_W5100S_IO_BASE_ + (0x0017))

Timeout register address( 1 is 100us )(R/W)

RTR configures the retransmission timeout period. The unit of timeout period is 100us and the default of RTR is x07D0or 000 And so the default timeout period is 200ms(100us X 2000). During the time configured by RTR, W5100S waits for the peer response to the packet that is transmitted by Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). If the peer does not respond within the RTR time, W5100S retransmits the packet or issues timeout.

Definition at line 282 of file w5100s.h.

◆ CHIPLCKR

#define CHIPLCKR (_W5100S_IO_BASE_ + (0x0070))

Chip Configuration locking register.

Definition at line 571 of file w5100s.h.

◆ DBGOUT

#define DBGOUT (_W5100S_IO_BASE_ + (0x0060))

DBGOUT(hidden)

Definition at line 556 of file w5100s.h.

◆ GAR

#define GAR (_W5100S_IO_BASE_ + (0x0001))

Gateway IP Register address(R/W)

GAR configures the default gateway address.

Definition at line 220 of file w5100s.h.

◆ IMR2

#define IMR2 (_W5100S_IO_BASE_ + (0x0021))

Interrupt mask register 2.

IMR2 Each bit of IMR2 corresponds to each bit of IR2. When a bit of IMR2 is and the corresponding bit of IR2 is set, Interrupt will be issued.

Definition at line 349 of file w5100s.h.

◆ IR

#define IR (_W5100S_IO_BASE_ + (0x0015))

Interrupt Register(R/W)

IR indicates the interrupt status. Each bit of IR will be still until the bit will be written to by the host. If IR is not equal to x00 INTn PIN is asserted to low until it is x00

Each bit of IR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
CONFLICT | UNREACH | PPPoE | Reserved | S3_INT | S2_INT | S1_INT | S0_INT
  • IR_CONFLICT : IP conflict
  • IR_UNREACH : Destination unreachable
  • IR_PPPoE : PPPoE connection close
  • IR_SOCK(3) : SOCKET 3 Interrupt
  • IR_SOCK(2) : SOCKET 2 Interrupt
  • IR_SOCK(1) : SOCKET 1 Interrupt
  • IR_SOCK(0) : SOCKET 0 Interrupt

Definition at line 264 of file w5100s.h.

◆ IR2

#define IR2 (_W5100S_IO_BASE_ + (0x0020))

Interrupt register 2.

IR2 indicates the interrupt status. Each bit of IR2 will be still until the bit will be written to by the host.

7:1 | 0
Reserved | WOL
  • IR2_WOL : WOL MAGIC PACKET Interrupt Mask

Definition at line 341 of file w5100s.h.

◆ MR

#define MR (_WIZCHIP_IO_BASE_ + (0x0000))

Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc.

Each bit of MR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
RST | Reserved | WOL | PB | PPPoE | Reserved | AI | IND
  • MR_RST : Reset
  • MR_PB : Ping block
  • MR_PPPOE : PPPoE mode
  • MR_AI : Address Auto-Increment in Indirect Bus Interface
  • MR_IND : Indirect Bus Interface mode

Definition at line 210 of file w5100s.h.

◆ MR2

#define MR2 (_W5100S_IO_BASE_ + (0x0030))

MR2 Mode register 2.

Definition at line 389 of file w5100s.h.

◆ NETLCKR

#define NETLCKR (_W5100S_IO_BASE_ + (0x0071))

Network Configuration locking register.

Definition at line 578 of file w5100s.h.

◆ NICMAXCOLR

#define NICMAXCOLR (_W5100S_IO_BASE_ + (0x0063))

NICMAXCOLR(hidden)

Definition at line 563 of file w5100s.h.

◆ PHAR

#define PHAR (_W5100S_IO_BASE_ + (0x0032))

Destination Hardware address in PPPoE.

Definition at line 397 of file w5100s.h.

◆ PHYACR

#define PHYACR (_W5100S_IO_BASE_ + (0x0044))

PHY Action register.

Definition at line 463 of file w5100s.h.

◆ PHYAR

#define PHYAR (_W5100S_IO_BASE_ + (0x003E))

PHY Address value.

Definition at line 435 of file w5100s.h.

◆ PHYCR0

#define PHYCR0 (_W5100S_IO_BASE_ + (0x0046))

PHY Control register 0.

Definition at line 477 of file w5100s.h.

◆ PHYCR1

#define PHYCR1 (_W5100S_IO_BASE_ + (0x0047))

PHY Control register 1.

Definition at line 483 of file w5100s.h.

◆ PHYDIR

#define PHYDIR (_W5100S_IO_BASE_ + (0x0040))

PHY Data input register.

Definition at line 449 of file w5100s.h.

◆ PHYDIVR

#define PHYDIVR (_W5100S_IO_BASE_ + (0x0045))

PHY Division register.

Definition at line 470 of file w5100s.h.

◆ PHYDOR

#define PHYDOR (_W5100S_IO_BASE_ + (0x0042))

PHY data output register.

Definition at line 456 of file w5100s.h.

◆ PHYLCKR

#define PHYLCKR (_W5100S_IO_BASE_ + (0x0072))

PHY Configuration locking register.

Definition at line 585 of file w5100s.h.

◆ PHYRAR

#define PHYRAR (_W5100S_IO_BASE_ + (0x003F))

PHY Register address.

Definition at line 442 of file w5100s.h.

◆ PHYSR

#define PHYSR (_W5100S_IO_BASE_ + (0x003C))

PHY status register.

Definition at line 421 of file w5100s.h.

◆ PHYSR1

#define PHYSR1 (_W5100S_IO_BASE_ + (0x003D))

PHY status register(hidden)

Definition at line 428 of file w5100s.h.

◆ PINGIDR

#define PINGIDR (_W5100S_IO_BASE_ + (0x005C))

Ping ID register.

Definition at line 535 of file w5100s.h.

◆ PINGSEQR

#define PINGSEQR (_W5100S_IO_BASE_ + (0x005A))

Ping sequence number register.

Definition at line 528 of file w5100s.h.

◆ PMAGIC

#define PMAGIC (_W5100S_IO_BASE_ + (0x0029))

PPP LCP Magic number register in PPPoE mode(R)

PMAGIC configures the 4bytes magic number to be used in LCP negotiation.

Definition at line 364 of file w5100s.h.

◆ PMRUR

#define PMRUR (_W5100S_IO_BASE_ + (0x003A))

Maximum receive Unit in PPPoE.

Definition at line 411 of file w5100s.h.

◆ PSIDR

#define PSIDR (_W5100S_IO_BASE_ + (0x0038))

Session ID in PPPoE.

Definition at line 404 of file w5100s.h.

◆ PTIMER

#define PTIMER (_W5100S_IO_BASE_ + (0x0028))

PPP LCP Request Timer register in PPPoE mode(R)

PTIMER configures the time for sending LCP echo request. The unit of time is 25ms.

Definition at line 357 of file w5100s.h.

◆ RMSR

#define RMSR (_W5100S_IO_BASE_ + (0x001A))

Receive Memory Size Register.

RMSR register configures RX bufffer Size of the SOCKET The sum of the RX buffers can not exceed 8kB.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
S3-1 | S3-0 | S2-1 | S2-0 | S1-1 | S1-0 | S0-1 | S0-0
Memory Size | Sn-1 | Sn-0
1KB | 0 | 0
2KB | 0 | 1
4KB | 1 | 0
8KB | 1 | 1

Definition at line 309 of file w5100s.h.

◆ SHAR

#define SHAR (_W5100S_IO_BASE_ + (0x0009))

Source MAC Register address(R/W)

SHAR configures the source hardware address.

Definition at line 234 of file w5100s.h.

◆ SIPR

#define SIPR (_W5100S_IO_BASE_ + (0x000F))

Source IP Register address(R/W)

SIPR configures the source IP address.

Definition at line 241 of file w5100s.h.

◆ SLCR

#define SLCR (_W5100S_IO_BASE_ + (0x004C))

Socket-less control register.

Definition at line 492 of file w5100s.h.

◆ SLIMR

#define SLIMR (_W5100S_IO_BASE_ + (0x005E))

Socket-less interrupt mask register.

Definition at line 542 of file w5100s.h.

◆ SLIR

#define SLIR (_W5100S_IO_BASE_ + (0x005F))

Socket-less interrupt register.

Definition at line 549 of file w5100s.h.

◆ SLPHAR

#define SLPHAR (_W5100S_IO_BASE_ + (0x0054))

Socket-less peer hardware address register.

Definition at line 521 of file w5100s.h.

◆ SLPIPR

#define SLPIPR (_W5100S_IO_BASE_ + (0x0050))

Socket-less peer IP address register.

Definition at line 514 of file w5100s.h.

◆ SLRCR

#define SLRCR (_W5100S_IO_BASE_ + (0x004F))

Socket-less retry count register.

Definition at line 507 of file w5100s.h.

◆ SLRTR

#define SLRTR (_W5100S_IO_BASE_ + (0x004D))

Socket-less retry time register.

Definition at line 499 of file w5100s.h.

◆ SUBR

#define SUBR (_W5100S_IO_BASE_ + (0x0005))

Subnet mask Register address(R/W)

SUBR configures the subnet mask address.

Definition at line 227 of file w5100s.h.

◆ TCNTCLKR

#define TCNTCLKR (_W5100S_IO_BASE_ + (0x0088))

Core 100us Counter clear register.

Definition at line 606 of file w5100s.h.

◆ TCNTR

#define TCNTR (_W5100S_IO_BASE_ + (0x0082))

Core 100us Counter register.

Definition at line 599 of file w5100s.h.

◆ TMSR

#define TMSR (_W5100S_IO_BASE_ + (0x001B))

Transmit Memory Size Register.

TMSR register configures TX bufffer Size of the SOCKET The sum of the TX buffers can not exceed 8kB.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
S3-1 | S3-0 | S2-1 | S2-0 | S1-1 | S1-0 | S0-1 | S0-0
Memory Size | Sn-1 | Sn-0
1KB | 0 | 0
2KB | 0 | 1
4KB | 1 | 0
8KB | 1 | 1

Definition at line 328 of file w5100s.h.

◆ UIPR

#define UIPR (_W5100S_IO_BASE_ + (0x002A))

Unreachable IP address register.

Definition at line 371 of file w5100s.h.

◆ UPORTR

#define UPORTR (_W5100S_IO_BASE_ + (0x002E))

Unreachable Port register.

Definition at line 378 of file w5100s.h.

◆ VERR

#define VERR (_W5100S_IO_BASE_ + (0x0080))

version register

Definition at line 592 of file w5100s.h.


ioLibrary: Socket register

Macros
Socket register
W5100S » WIZCHIP register

Socket register group
Socket register configures and control SOCKETn which is necessary to data communication. More...

Collaboration diagram for Socket register:

Macros

#define | Sn_MR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))
socket Mode register(R/W) More...
#define | Sn_CR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))
Socket command register(R/W) More...
#define | Sn_IR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))
Socket interrupt register(R) More...
#define | Sn_SR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))
Socket status register(R) More...
#define | Sn_PORT(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))
source port register(R/W) More...
#define | Sn_DHAR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))
Peer IP register address(R/W) More...
#define | Sn_DPORT(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))
Peer port register address(R/W) More...
#define | Sn_MSSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_PROTO(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOS(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_RXBUF_SIZE(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E))
Receive memory size register(R/W) More...
#define | Sn_TXBUF_SIZE(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F))
Transmit memory size register(R/W) More...
#define | Sn_TX_FSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))
Received data size register(R) More...
#define | Sn_RX_RD(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))
Write point of Receive memory(R) More...
#define | Sn_IMR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C))
Socket interrupt mask register. More...
#define | Sn_FRAGR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D))
Socket fragment field register. More...
#define | Sn_MR2(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002F))
Socket Mode register 2. More...
#define | Sn_KPALVTR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0030))
Socket n Keep Alive Timer Register. More...
#define | Sn_RTR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0032))
Socket n Timer Status Register. More...
#define | Sn_RCR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0034))
Socket n Retry Count-value Register. More...

Detailed Description

Socket register group
Socket register configures and control SOCKETn which is necessary to data communication.

See also
Sn_MR, Sn_CR, Sn_IR : SOCKETn Control
Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information
Sn_MSSR, Sn_TOS, Sn_TTL, Sn_FRAGR : Internet protocol.
Sn_RXMEM_SIZE, Sn_TXMEM_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication

Macro Definition Documentation

◆ Sn_CR

#define Sn_CR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))

Socket command register(R/W)

This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.
After W5100S accepts the command, the Sn_CR register is automatically cleared to 0x00. Even though Sn_CR is cleared to 0x00, the command is still being processed.
To check whether the command is completed or not, please check the Sn_IR or Sn_SR.

  • Sn_CR_OPEN : Initialize or open socket.
  • Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode)
  • Sn_CR_CONNECT : Send connection request in TCP mode(Client mode)
  • Sn_CR_DISCON : Send closing request in TCP mode.
  • Sn_CR_CLOSE : Close socket.
  • Sn_CR_SEND : Update TX buffer pointer and send data.
  • Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process.
  • Sn_CR_SEND_KEEP : Send keep alive message.
  • Sn_CR_RECV : Update RX buffer pointer and receive data.
  • In case of S0_MR(P3:P0) = S0_MR_PPPoE
    Value | Symbol | Description
    0x23 | PCON | PPPoE connection begins by transmitting PPPoE discovery packet
    0x24 | PDISCON | Closes PPPoE connection
    0x25 | PCR | In each phase, it transmits REQ message.
    0x26 | PCN | In each phase, it transmits NAK message.
    0x27 | PCJ | In each phase, it transmits REJECT message.

Definition at line 673 of file w5100s.h.

◆ Sn_DHAR

#define Sn_DHAR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))

Peer MAC register address(R/W)

Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or it indicates that it is acquired in ARP-process by CONNECT/SEND command.

Definition at line 733 of file w5100s.h.

◆ Sn_DIPR

#define Sn_DIPR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))

Peer IP register address(R/W)

Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP client mode, it configures an IP address of TCP server before CONNECT command. In TCP server mode, it indicates an IP address of TCP client after successfully establishing connection. In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command.

Definition at line 743 of file w5100s.h.

◆ Sn_DPORT

#define Sn_DPORT ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))

Peer port register address(R/W)

Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP clientmode, it configures the listen port number of TCP server before CONNECT command. In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command.

Definition at line 753 of file w5100s.h.

◆ Sn_FRAGR

#define Sn_FRAGR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D))

Socket fragment field register.

Register to configure the Fragment field of IP Header

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.

Definition at line 905 of file w5100s.h.

◆ Sn_IMR

#define Sn_IMR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C))

Socket interrupt mask register.

Register address to configure the interrupt mask of the socket

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.

Definition at line 897 of file w5100s.h.

◆ Sn_IR

#define Sn_IR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))

Socket interrupt register(R)

Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).
When an interrupt occurs and the corresponding bit IR_SOCK(N) in IMR are set, IR_SOCK(N) in IR becomes '1'.
In order to clear the Sn_IR bit, the host should write the bit to

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
PRECV | PFAIL | PNEXT | SEND_OK | TIMEOUT | RECV | DISCON | CON
  • Sn_IR_PRECV : PPP Receive Interrupt
  • Sn_IR_PFAIL : PPP Fail Interrupt
  • Sn_IR_PNEXT : PPP Next Phase Interrupt
  • Sn_IR_SENDOK : SEND_OK Interrupt
  • Sn_IR_TIMEOUT : TIMEOUT Interrupt
  • Sn_IR_RECV : RECV Interrupt
  • Sn_IR_DISCON : DISCON Interrupt
  • Sn_IR_CON : CON Interrupt

Definition at line 694 of file w5100s.h.

◆ Sn_KPALVTR

#define Sn_KPALVTR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0030))

Socket n Keep Alive Timer Register.

Register to set the transmission period of keep alive packet.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.

Definition at line 921 of file w5100s.h.

◆ Sn_MR

#define Sn_MR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))

socket Mode register(R/W)

Sn_MR configures the option or protocol type of Socket n.

Each bit of Sn_MR defined as the following.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
MULTI | MF | ND/MC | Reserved | Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0]
  • Sn_MR_MULTI : Support UDP Multicasting
  • Sn_MR_MF : Support MACRAW
  • Sn_MR_ND : No Delayed Ack(TCP) flag
  • Sn_MR_MC : IGMP version used in UDP mulitcasting
  • Protocol
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 0 | 0 | 0 | Closed
    0 | 0 | 0 | 1 | TCP
    0 | 0 | 1 | 0 | UDP
    0 | 1 | 0 | 0 | MACRAW
  • In case of Socket 0
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 1 | 0 | 0 | MACRAW
    0 | 1 | 0 | 1 | PPPoE
    • Sn_MR_MACRAW : MAC LAYER RAW SOCK

Sn_MR_UDP : UDP

  • Sn_MR_TCP : TCP
  • Sn_MR_CLOSE : Unused socket
    Note
    MACRAW mode should be only used in Socket 0.

Definition at line 645 of file w5100s.h.

◆ Sn_MR2

#define Sn_MR2 ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002F))

Socket Mode register 2.

Register to set mode 2

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.

Definition at line 913 of file w5100s.h.

◆ Sn_MSSR

#define Sn_MSSR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))

Maximum Segment Size(Sn_MSSR0) register address(R/W)

Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n.

Definition at line 760 of file w5100s.h.

◆ Sn_PORT

#define Sn_PORT ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))

source port register(R/W)

Sn_PORT configures the source port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered.

Definition at line 725 of file w5100s.h.

◆ Sn_PROTO

#define Sn_PROTO ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))

IP Protocol(PROTO) Register(R/W)

Sn_PROTO that sets the protocol number field of the IP header at the IP layer. It is valid only in IPRAW mode, and ignored in other modes.

Definition at line 768 of file w5100s.h.

◆ Sn_RCR

#define Sn_RCR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0034))

Socket n Retry Count-value Register.

Register to set the retry count value

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.

Definition at line 945 of file w5100s.h.

◆ Sn_RTR

#define Sn_RTR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0032))

Socket n Timer Status Register.

todo delete

Parameters
sn Socket number. It should be 0 ~ WIZCHIP_SOCK_NUM expect bit 4.

Socket n Retry Time-value Register

Register to set the retry time value

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.

Definition at line 937 of file w5100s.h.

◆ Sn_RX_RD

#define Sn_RX_RD ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))

Read point of Receive memory(R/W)

Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.

  1. Read the starting save address of the received data.
  2. Read data from the starting address of Socket n RX Buffer.
  3. After reading the received data, Update Sn_RX_RD to the increased value as many as the reading size. If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, update with the lower 16bits value ignored the carry bit.
  4. Order RECV command is for notifying the updated Sn_RX_RD to W5100S.

Definition at line 877 of file w5100s.h.

◆ Sn_RX_RSR

#define Sn_RX_RSR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))

Received data size register(R)

Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. Sn_RX_RSR does not exceed the Sn_RXMEM_SIZE and is calculated as the difference between Socket n RX Write Pointer (Sn_RX_WR)and Socket n RX Read Pointer (Sn_RX_RD)

Definition at line 864 of file w5100s.h.

◆ Sn_RX_WR

#define Sn_RX_WR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))

Write point of Receive memory(R)

Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 886 of file w5100s.h.

◆ Sn_RXBUF_SIZE

#define Sn_RXBUF_SIZE ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E))

Receive memory size register(R/W)

Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. Socket n RX Buffer Block size can be configured with 1,2,4 and 8Kbytes. If a different size is configured, the data cannot be normally received from a peer. Although Socket n RX Buffer Block size is initially configured to 2Kbytes, user can re-configure its size using Sn_RXBUF_SIZE. The total sum of Sn_RXBUF_SIZE can not be exceed 8Kbytes. When exceeded, the data reception error is occurred.

Definition at line 806 of file w5100s.h.

◆ Sn_SR

#define Sn_SR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))

Socket status register(R)

Sn_SR indicates the status of Socket n.
The status of Socket n is changed by Sn_CR or some special control packet as SYN, FIN packet in TCP.

Normal status
  • SOCK_CLOSED : Closed
  • SOCK_INIT : Initiate state
  • SOCK_LISTEN : Listen state
  • SOCK_ESTABLISHED : Success to connect
  • SOCK_CLOSE_WAIT : Closing state
  • SOCK_UDP : UDP socket
  • SOCK_MACRAW : MAC raw mode socket
Temporary status during changing the status of Socket n.
  • SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
  • SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
  • SOCK_FIN_WAIT : Connection state
  • SOCK_CLOSING : Closing state
  • SOCK_TIME_WAIT : Closing state
  • SOCK_LAST_ACK : Closing state

Definition at line 717 of file w5100s.h.

◆ Sn_TOS

#define Sn_TOS ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015)

IP Type of Service(TOS) Register(R/W)

Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. It is set before OPEN command.

Definition at line 776 of file w5100s.h.

◆ Sn_TTL

#define Sn_TTL ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))

IP Time to live(TTL) Register(R/W)

Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. It is set before OPEN command.

Definition at line 784 of file w5100s.h.

◆ Sn_TX_FSR

#define Sn_TX_FSR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))

Transmit free memory size register(R)

Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by Sn_TXMEM_SIZE. Data bigger than Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, transmit the data after dividing into the checked size and saving in the Socket n TX buffer.

Definition at line 829 of file w5100s.h.

◆ Sn_TX_RD

#define Sn_TX_RD ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))

Transmit memory read pointer register address(R)

Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001), it is re-initialized while connecting with TCP. After its initialization, it is auto-increased by SEND command. SEND command transmits the saved data from the current Sn_TX_RD to the Sn_TX_WR in the Socket n TX Buffer. After transmitting the saved data, the SEND command increases the Sn_TX_RD as same as the Sn_TX_WR. If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 841 of file w5100s.h.

◆ Sn_TX_WR

#define Sn_TX_WR ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))

Transmit memory write pointer register address(R/W)

Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001), it is re-initialized while connecting with TCP.
It should be read or be updated like as follows.

  1. Read the starting address for saving the transmitting data.
  2. Save the transmitting data from the starting address of Socket n TX buffer.
  3. After saving the transmitting data, update Sn_TX_WR to the increased value as many as transmitting data size. If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.
  4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command

Definition at line 855 of file w5100s.h.

◆ Sn_TXBUF_SIZE

#define Sn_TXBUF_SIZE ( sn ) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F))

Transmit memory size register(R/W)

Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4 and 8Kbytes. If a different size is configured, the data cannot be normally transmitted to a peer. Although Socket n TX Buffer Block size is initially configured to 2Kbytes, user can be re-configure its size using Sn_TXBUF_SIZE. The total sum of Sn_TXBUF_SIZE can not be exceed 8Kbytes. When exceeded, the data transmission error is occurred.

Definition at line 817 of file w5100s.h.


ioLibrary: WIZCHIP I/O functions

Modules
WIZCHIP I/O functions
W5100S

This supports the basic I/O functions for WIZCHIP register. More...

Collaboration diagram for WIZCHIP I/O functions:

Modules

Basic I/O function
These are basic input/output functions to read values from register or write values to register.
Common register access functions
These are functions to access common registers.
Socket register access functions
These are functions to access socket registers.
Special functions
These are special functions to access to the PHY.

Detailed Description

This supports the basic I/O functions for WIZCHIP register.

  • Basic I/O function
    WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF(), wiz_recv_data(), wiz_recv_ignore(), wiz_send_data()

  • Common register access functions
    1. Mode
      getMR(), setMR()
    2. Interrupt
      getIR(), setIR(), getIMR(), setIMR(),
    3. Network Information
      getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR()
    4. Retransmission
      getRCR(), setRCR(), getRTR(), setRTR()
    5. PPPoE
      getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC()
  • Socket register access functions
    1. SOCKET control
      getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IR(), setSn_IR()
    2. SOCKET information
      getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() getSn_MSSR(), setSn_MSSR()
    3. SOCKET communication
      getSn_RXMEM_SIZE(), setSn_RXMEM_SIZE(), getSn_TXMEM_SIZE(), setSn_TXMEM_SIZE()
      getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR()
      getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR()
      getSn_TX_FSR(), getSn_RX_RSR()
    4. IP header field
      getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS()
      getSn_TTL(), setSn_TTL()


ioLibrary: Basic I/O function

Functions
Basic I/O function
W5100S » WIZCHIP I/O functions

These are basic input/output functions to read values from register or write values to register. More...

Collaboration diagram for Basic I/O function:

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...

Detailed Description

These are basic input/output functions to read values from register or write values to register.

Function Documentation

◆ wiz_recv_data()

void wiz_recv_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after that, it copies the received data from internal RX memory to wizdata(pointer variable) of the length of len(variable) bytes. This function is being called by recv() also.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
wizdata | Pointer buffer to read data
len | Data length
See also
wiz_send_data()

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after copy the data from receive buffer update the Rx write pointer register. User should read upper byte first and lower byte later to get proper value. It calculate the actual physical address where one has to read the data from Receive buffer. Here also take care of the condition while it exceed the Rx memory uper-bound of socket.

Definition at line 353 of file w5100s.c.

◆ wiz_recv_ignore()

void wiz_recv_ignore | ( | uint8_t | sn,
 |  | uint16_t | len
 | ) |  |

It discard the received data in RX memory.

It discards the data of the length of len(variable) bytes in internal RX memory.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
len | Data length

Definition at line 385 of file w5100s.c.

◆ wiz_send_data()

void wiz_send_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to internal TX memory.

This function reads the Tx write pointer register and after that, it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory and updates the Tx write pointer register. This function is being called by send() and sendto() function also.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
wizdata | Pointer buffer to write data
len | Data length
See also
wiz_recv_data()

It copies data to internal TX memory.

This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer register. User should read upper byte first and lower byte later to get proper value. And this function is being used for copy the data form application buffer to Transmite buffer of the chip. It calculate the actual physical address where one has to write the data in transmite buffer. Here also take care of the condition while it exceed the Tx memory uper-bound of socket.

Definition at line 311 of file w5100s.c.

◆ WIZCHIP_READ()

uint8_t WIZCHIP_READ ( uint32_t AddrSel )

It reads 1 byte value from a register.

Parameters
AddrSel Register address
Returns
The value of register

It reads 1 byte value from a register.

Definition at line 83 of file w5100s.c.

◆ WIZCHIP_READ_BUF()

void WIZCHIP_READ_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It reads sequence data from registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to read data
len | Data length

It reads sequence data from registers.

Definition at line 181 of file w5100s.c.

◆ WIZCHIP_WRITE()

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

It writes 1 byte value to a register.

Parameters
AddrSel | Register address
wb | Write data
Returns
void

It writes 1 byte value to a register.

Definition at line 47 of file w5100s.c.

◆ WIZCHIP_WRITE_BUF()

void WIZCHIP_WRITE_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It writes sequence data to registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to write data
len | Data length

It writes sequence data to registers.

Definition at line 124 of file w5100s.c.


ioLibrary: Common register access functions

Macros
Common register access functions
W5100S » WIZCHIP I/O functions

These are functions to access common registers. More...

Collaboration diagram for Common register access functions:

Macros

#define | setMR(mr) (*((uint8_t*)MR) = mr)
Set Mode Register. More...
#define | getMR() (*(uint8_t*)MR)
Get MR. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set GAR. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get GAR. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR,subr,4)
Set SUBR. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get SUBR. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set SHAR. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get SHAR. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set SIPR. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get SIPR. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xE0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xE0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr)
Set IMR register. More...
#define | getIMR() WIZCHIP_READ(_IMR_)
Get IMR register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | setRMSR(rmsr) WIZCHIP_WRITE(RMSR,rmsr)
Get RMSR register. More...
#define | getRMSR() WIZCHIP_READ(RMSR)
Get RMSR register. More...
#define | setTMSR(tmsr) WIZCHIP_WRITE(TMSR,tmsr)
Get TMSR register. More...
#define | getTMSR() WIZCHIP_READ(TMSR)
Get TMSR register. More...
#define | getPATR() (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
Get PATR register. More...
#define | getPPPALGO() WIZCHIP_READ(PPPALGO)
Get PPPALGO register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...
#define | setIR2(ir2) WIZCHIP_WRITE(IR2, ir2)
Set IR2 register. More...
#define | getIR2() WIZCHIP_READ(IR2)
Get IR2 register. More...
#define | setIMR2(imr2) WIZCHIP_WRITE(IMR2,imr2)
Set IMR2 register. More...
#define | getIMR2() WIZCHIP_READ(IMR2)
Get IMR2 register. More...
#define | setUIPR(uipr) WIZCHIP_WRITE_BUF(UIPR,uipr,4)
Set UIPR(Unreachable IP Address Register) registers. More...
#define | getUIPR(uipr) WIZCHIP_READ_BUF(UIPR,uipr,4)
Get UIPR(Unreachable IP Address Register) registers. More...
#define | setUPORTR(uportr)
Set UPORTR(Unreachable Port Address Register) register. More...
#define | getUPORTR() (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(UPORTR+1))
Get UPORTR(Unreachable Port Address Register) register. More...
#define | setMR2(mr2) WIZCHIP_WRITE(MR2,mr2)
Set MR2 register. More...
#define | getMR2() WIZCHIP_READ(MR2)
Get MR2 register. More...
#define | setPHAR(phar) WIZCHIP_WRITE_BUF(PHAR,phar,6)
Set PHAR registers. More...
#define | getPHAR(phar) WIZCHIP_READ_BUF(PHAR,phar,6)
Get PHAR registers. More...
#define | setPSIDR(psidr)
Set PSIDR register. More...
#define | getPSIDR() (((uint16_t)WIZCHIP_READ(PSIDR) << 8) + WIZCHIP_READ(PSIDR+1))
Get PSIDR register. More...
#define | setPMRUR(pmrur)
Set PMRUR register. More...
#define | getPMRUR() (((uint16_t)WIZCHIP_READ(PMRUR) << 8) + WIZCHIP_READ(PMRUR+1))
Get PMRUR register. More...
#define | getPHYSR() WIZCHIP_READ(PHYSR)
Get PHYSR register. More...
#define | getPHYSR1() WIZCHIP_READ(PHYSR1)
Get PHYSR1 register. More...
#define | getPHYRAR() WIZCHIP_READ(PHYRAR)
Get PHYRAR register. More...
#define | setPHYRR(phyrar) WIZCHIP_WRITE(PHYRAR, phyrar)
Set PHYRR register. More...
#define | getPHYDIR() (((uint16_t)WIZCHIP_READ(PHYDIR+1) << 8) + WIZCHIP_READ(PHYDIR))
Get PHYDIR register. More...
#define | setPHYDIR(phydir)
Set PHYDIR register. More...
#define | getPHYDOR() (((uint16_t)WIZCHIP_READ(PHYDOR+1) << 8) + WIZCHIP_READ(PHYDOR))
Get PHYDOR register. More...
#define | setPHYDOR(phydor)
Set PHYDOR register. More...
#define | getPHYACR() WIZCHIP_READ(PHYACR)
Get PHYACR register. More...
#define | setPHYACR(phyacr) WIZCHIP_WRITE(PHYACR,phyacr)
Set PHYACR register. More...
#define | setPHYDIVR(phydivr) WIZCHIP_WRITE(PHYDIVR, phydivr)
Set PHYDIVR register. More...
#define | getPHYDIVR() WIZCHIP_READ(PHYDIVR)
Get PHYDIVR register. More...
#define | setPHYCR0(phych0) WIZCHIP_WRITE(PHYCR0,phych0)
Set PHYCR0 register. More...
#define | getPHYCR0() WIZCHIP_READ(PHYCR0)
Get PHYCR0 register. More...
#define | setPHYCR1(phycr1) WIZCHIP_WRITE(PHYCR1,phycr1)
Set PHYCR1 register. More...
#define | getPHYCR1() WIZCHIP_READ(PHYCR1)
Get PHYCR1 register. More...
#define | setSLCR(rqcr) WIZCHIP_WRITE(SLCR, rqcr)
Set SLCR register. More...
#define | getSLCR() WIZCHIP_READ(RQCR)
Get RQCR register. More...
#define | setSLRTR(slrtr)
Set SLRTR register. More...
#define | getSLRTR() (((uint16_t)WIZCHIP_READ(SLRTR) << 8) + WIZCHIP_READ(SLRTR+1))
Get SLRTR register. More...
#define | setSLRCR(slrcr) WIZCHIP_WRITE(SLRCR,slrcr)
Set SLRCR register. More...
#define | getSLRCR() WIZCHIP_READ(SLRCR)
Get SLRCR register. More...
#define | setSLPIPR(slpipr) WIZCHIP_WRITE_BUF(SLPIPR,slpipr,4)
Set SLPIPR registers. More...
#define | getSLPIPR(slpipr) WIZCHIP_READ_BUF(SLPIPR,slpipr,4)
Get SLPIPR registers. More...
#define | setSLPHAR(slphar) WIZCHIP_WRITE_BUF(SLPHAR,slphar,6)
Get SLPHAR registers. More...
#define | getSLPHAR(slphar) WIZCHIP_READ_BUF(SLPHAR,slphar,6)
Get SLPHAR registers. More...
#define | setPINGSEQR(pingseqr)
Set PINGSEQR register. More...
#define | getPINGSEQR() (((uint16_t)WIZCHIP_READ(PINGSEQR) << 8) + WIZCHIP_READ(PINGSEQR+1))
Get PINGSEQR register. More...
#define | setPINGIDR(pingidr)
Set PINGIDR register. More...
#define | getPINGIDR() (((uint16_t)WIZCHIP_READ(PINGIDR) << 8) + WIZCHIP_READ(PINGIDR+1))
Get PINGIDR register. More...
#define | setSLIMR(slimr) WIZCHIP_WRITE(SLIMR, slimr)
Set SLIMR register. More...
#define | getSLIMR() WIZCHIP_READ(SLIMR)
Get SLIMR register. More...
#define | setSLIR(slir) WIZCHIP_WRITE(SLIR, slir)
Set SLIR register. More...
#define | getSLIR() WIZCHIP_READ(SLIR)
Get SLIMR register. More...
#define | setNICMAXCOLR(nicmaxcolr) WIZCHIP_WRITE(NICMAXCOLR,nicmaxcolr)
Set NICMAXCOLR register. More...
#define | getNICMAXCOLR() WIZCHIP_READ(NICMAXCOLR)
Get NICMAXCOLR register. More...
#define | CHIPLOCK() WIZCHIP_WRITE(CHIPLCKR,0xff)
LOCK Chip Information. More...
#define | CHIPUNLOCK() WIZCHIP_WRITE(CHIPLCKR,0xCE)
Unlock Chip Information. More...
#define | NETLOCK() WIZCHIP_WRITE(NETLCKR,0x3A)
LOCK Chip Information. More...
#define | NETUNLOCK() WIZCHIP_WRITE(NETLCKR,0xC5)
Unlock Chip Information. More...
#define | PHYLOCK() WIZCHIP_WRITE(PHYLCKR,0xff)
Lock PHYCR0,CR1 Information. More...
#define | PHYUNLOCK() WIZCHIP_WRITE(PHYLCKR,0x53)
Lock PHYCR0,CR1 Information. More...
#define | getTCNTR() (((uint16_t)WIZCHIP_READ(TCNTR) << 8) + WIZCHIP_READ(TCNTR+1))
Get TCNTR register. More...
#define | setTCNTCLKR(var) WIZCHIP_WRITE(TCNTCLKR, var)
Set TCNTR register. More...

Detailed Description

These are functions to access common registers.

Macro Definition Documentation

◆ CHIPLOCK

#define CHIPLOCK ( ) WIZCHIP_WRITE(CHIPLCKR,0xff)

LOCK Chip Information.

See also
CHIPULLOCK()

Definition at line 2604 of file w5100s.h.

◆ CHIPUNLOCK

#define CHIPUNLOCK ( ) WIZCHIP_WRITE(CHIPLCKR,0xCE)

Unlock Chip Information.

See also
CHIPLOCK()

Definition at line 2612 of file w5100s.h.

◆ getGAR

#define getGAR ( gar ) WIZCHIP_READ_BUF(GAR,gar,4)

Get GAR.

Parameters
(uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes.
See also
setGAR()

Definition at line 1864 of file w5100s.h.

◆ getIMR

#define getIMR ( ) WIZCHIP_READ(_IMR_)

Get IMR register.

Returns
uint8_t. Value of IMR register.
See also
setIMR()

Definition at line 1958 of file w5100s.h.

◆ getIMR2

#define getIMR2 ( ) WIZCHIP_READ(IMR2)

Get IMR2 register.

Returns
uint8_t. Value of IMR2 register.
See also
getIMR2()

Definition at line 2127 of file w5100s.h.

◆ getIR

#define getIR ( ) (WIZCHIP_READ(IR) & 0xE0)

Get IR register.

Returns
uint8_t. Value of IR register.
See also
setIR()

Definition at line 1939 of file w5100s.h.

◆ getIR2

#define getIR2 ( ) WIZCHIP_READ(IR2)

Get IR2 register.

Returns
uint8_t. Value of IR2 register.
See also
setIR2()

Definition at line 2109 of file w5100s.h.

◆ getMR

#define getMR ( ) (*(uint8_t*)MR)

Get MR.

Returns
uint8_t. The value of Mode register.
See also
setMR()

Definition at line 1846 of file w5100s.h.

◆ getMR2

#define getMR2 ( ) WIZCHIP_READ(MR2)

Get MR2 register.

Returns
uint8_t. Value of MR2 register.
See also
setMR2()

Definition at line 2183 of file w5100s.h.

◆ getNICMAXCOLR

#define getNICMAXCOLR ( ) WIZCHIP_READ(NICMAXCOLR)

Get NICMAXCOLR register.

Returns
uint8_t. Value of NICMAXCOLR register.
See also
setNICMAXCOLR()

Definition at line 2594 of file w5100s.h.

◆ getPATR

#define getPATR ( ) (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))

Get PATR register.

Returns
uint16_t. Value to set PATR register

Definition at line 2039 of file w5100s.h.

◆ getPHAR

#define getPHAR ( phar ) WIZCHIP_READ_BUF(PHAR,phar,6)

Get PHAR registers.

Parameters
(uint8_t*)phar Pointer variable to get PHAR registers.
See also
setPHAR()

Definition at line 2201 of file w5100s.h.

◆ getPHYACR

#define getPHYACR ( ) WIZCHIP_READ(PHYACR)

Get PHYACR register.

Returns
uint8_t. Value of PHYACR register.
See also
setPHYACR()

Definition at line 2338 of file w5100s.h.

◆ getPHYCR0

#define getPHYCR0 ( ) WIZCHIP_READ(PHYCR0)

Get PHYCR0 register.

Returns
uint8_t. Value of PHYCR0 register.
See also
setPHYCR0()

Definition at line 2384 of file w5100s.h.

◆ getPHYCR1

#define getPHYCR1 ( ) WIZCHIP_READ(PHYCR1)

Get PHYCR1 register.

Returns
uint8_t. Value of PHYCR1 register.
See also
setPHYCR1()

Definition at line 2402 of file w5100s.h.

◆ getPHYDIR

#define getPHYDIR ( ) (((uint16_t)WIZCHIP_READ(PHYDIR+1) << 8) + WIZCHIP_READ(PHYDIR))

Get PHYDIR register.

Returns
uint16_t. Value of PHYDIR register.
See also
setPHYRAR()

Definition at line 2294 of file w5100s.h.

◆ getPHYDIVR

#define getPHYDIVR ( ) WIZCHIP_READ(PHYDIVR)

Get PHYDIVR register.

Returns
uint8_t. Value of PHYDIVR register.
See also
setPHYDIVR()

Definition at line 2366 of file w5100s.h.

◆ getPHYDOR

#define getPHYDOR ( ) (((uint16_t)WIZCHIP_READ(PHYDOR+1) << 8) + WIZCHIP_READ(PHYDOR))

Get PHYDOR register.

Returns
uint16_t. Value of PHYDOR register.
See also
setPHYDOR()

Definition at line 2316 of file w5100s.h.

◆ getPHYRAR

#define getPHYRAR ( ) WIZCHIP_READ(PHYRAR)

Get PHYRAR register.

Returns
uint8_t. Value of PHYRAR register.
See also
setPHYRAR()

Definition at line 2275 of file w5100s.h.

◆ getPHYSR

#define getPHYSR ( ) WIZCHIP_READ(PHYSR)

Get PHYSR register.

Returns
uint8_t. Value of PHYSR register.
See also
setPHYSR()

Definition at line 2250 of file w5100s.h.

◆ getPHYSR1

#define getPHYSR1 ( ) WIZCHIP_READ(PHYSR1)

Get PHYSR1 register.

Returns
uint8_t. Value of PHYSR1 register.
See also
setPHYSR1()

Definition at line 2259 of file w5100s.h.

◆ getPINGIDR

#define getPINGIDR ( ) (((uint16_t)WIZCHIP_READ(PINGIDR) << 8) + WIZCHIP_READ(PINGIDR+1))

Get PINGIDR register.

Returns
uint16_t. Value of PINGIDR register.
See also
setPINGIDR()

Definition at line 2533 of file w5100s.h.

◆ getPINGSEQR

#define getPINGSEQR ( ) (((uint16_t)WIZCHIP_READ(PINGSEQR) << 8) + WIZCHIP_READ(PINGSEQR+1))

Get PINGSEQR register.

Returns
uint16_t. Value of PINGSEQR register.
See also
setPINGSEQR()

Definition at line 2513 of file w5100s.h.

◆ getPMAGIC

#define getPMAGIC ( ) WIZCHIP_READ(PMAGIC)

Get PMAGIC register.

Returns
uint8_t. Value of PMAGIC register.
See also
setPMAGIC()

Definition at line 2084 of file w5100s.h.

◆ getPMRUR

#define getPMRUR ( ) (((uint16_t)WIZCHIP_READ(PMRUR) << 8) + WIZCHIP_READ(PMRUR+1))

Get PMRUR register.

Returns
uint16_t. Value of PMRUR register.
See also
setPMRUR()

Definition at line 2241 of file w5100s.h.

◆ getPPPALGO

#define getPPPALGO ( ) WIZCHIP_READ(PPPALGO)

Get PPPALGO register.

Returns
uint8_t. Value to set PPPALGO register

Definition at line 2047 of file w5100s.h.

◆ getPSIDR

#define getPSIDR ( ) (((uint16_t)WIZCHIP_READ(PSIDR) << 8) + WIZCHIP_READ(PSIDR+1))

Get PSIDR register.

Returns
uint16_t. Value of PSIDR register.
See also
setPSIDR()

Definition at line 2221 of file w5100s.h.

◆ getPTIMER

#define getPTIMER ( ) WIZCHIP_READ(PTIMER)

Get PTIMER register.

Returns
uint8_t. Value of PTIMER register.
See also
setPTIMER()

Definition at line 2066 of file w5100s.h.

◆ getRCR

#define getRCR ( ) WIZCHIP_READ(_RCR_)

Get RCR register.

Returns
uint8_t. Value of RCR register.
See also
setRCR()

Definition at line 1996 of file w5100s.h.

◆ getRMSR

#define getRMSR ( ) WIZCHIP_READ(RMSR)

Get RMSR register.

Returns
uint8_t. Value of RMSR register.
See also
setRMSR()

Definition at line 2013 of file w5100s.h.

◆ getRTR

#define getRTR ( ) (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))

Get RTR register.

Returns
uint16_t. Value of RTR register.
See also
setRTR()

Definition at line 1978 of file w5100s.h.

◆ getSHAR

#define getSHAR ( shar ) WIZCHIP_READ_BUF(SHAR, shar, 6)

Get SHAR.

Parameters
(uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes.
See also
setSHAR()

Definition at line 1903 of file w5100s.h.

◆ getSIPR

#define getSIPR ( sipr ) WIZCHIP_READ_BUF(SIPR, sipr, 4)

Get SIPR.

Parameters
(uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes.
See also
setSIPR()

Definition at line 1921 of file w5100s.h.

◆ getSLCR

#define getSLCR ( ) WIZCHIP_READ(RQCR)

Get RQCR register.

Returns
uint8_t. Value of RQCR register.
See also
setRQCR()

Definition at line 2420 of file w5100s.h.

◆ getSLIMR

#define getSLIMR ( ) WIZCHIP_READ(SLIMR)

Get SLIMR register.

Returns
uint8_t. Value of SLIMR register.
See also
setSLIMR()

Definition at line 2551 of file w5100s.h.

◆ getSLIR

#define getSLIR ( ) WIZCHIP_READ(SLIR)

Get SLIMR register.

Returns
uint8_t. Value of SLIMR register.
See also
setSLIMR()

Definition at line 2569 of file w5100s.h.

◆ getSLPHAR

#define getSLPHAR ( slphar ) WIZCHIP_READ_BUF(SLPHAR,slphar,6)

Get SLPHAR registers.

Parameters
(uint8_t*)slphar Values to get SLPHAR registers.
See also
getSLPHAR()

Definition at line 2493 of file w5100s.h.

◆ getSLPIPR

#define getSLPIPR ( slpipr ) WIZCHIP_READ_BUF(SLPIPR,slpipr,4)

Get SLPIPR registers.

Parameters
(uint8_t*)slpipr Values to get SLPIPR registers.
See also
getSLPIPR()

Definition at line 2475 of file w5100s.h.

◆ getSLRCR

#define getSLRCR ( ) WIZCHIP_READ(SLRCR)

Get SLRCR register.

Returns
uint8_t. Value of SLRCR register.
See also
setSLRCR()

Definition at line 2457 of file w5100s.h.

◆ getSLRTR

#define getSLRTR ( ) (((uint16_t)WIZCHIP_READ(SLRTR) << 8) + WIZCHIP_READ(SLRTR+1))

Get SLRTR register.

Returns
uint16_t. Value of SLRTR register.
See also
setSLRTR()

Definition at line 2439 of file w5100s.h.

◆ getSUBR

#define getSUBR ( subr ) WIZCHIP_READ_BUF(SUBR, subr, 4)

Get SUBR.

Parameters
(uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes.
See also
setSUBR()

Definition at line 1885 of file w5100s.h.

◆ getTCNTR

#define getTCNTR ( ) (((uint16_t)WIZCHIP_READ(TCNTR) << 8) + WIZCHIP_READ(TCNTR+1))

Get TCNTR register.

Returns
uint16_t. Value of TCNTR register.
See also
setNTCNTR()

Definition at line 2665 of file w5100s.h.

◆ getTMSR

#define getTMSR ( ) WIZCHIP_READ(TMSR)

Get TMSR register.

Returns
uint8_t. Value of TMSR register.
See also
setTMSR()

Definition at line 2030 of file w5100s.h.

◆ getUIPR

#define getUIPR ( uipr ) WIZCHIP_READ_BUF(UIPR,uipr,4)

Get UIPR(Unreachable IP Address Register) registers.

Parameters
(uint8_t*)uipr Value to get UIPR registers
See also
setUIPR()

Definition at line 2145 of file w5100s.h.

◆ getUPORTR

#define getUPORTR ( ) (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(UPORTR+1))

Get UPORTR(Unreachable Port Address Register) register.

Returns
uint16_t. Value of UPORTR register.
See also
setUPORTR()

Definition at line 2165 of file w5100s.h.

◆ NETLOCK

#define NETLOCK ( ) WIZCHIP_WRITE(NETLCKR,0x3A)

LOCK Chip Information.

See also
CHIPULLOCK()

Definition at line 2622 of file w5100s.h.

◆ NETUNLOCK

#define NETUNLOCK ( ) WIZCHIP_WRITE(NETLCKR,0xC5)

Unlock Chip Information.

See also
CHIPLOCK()

Definition at line 2630 of file w5100s.h.

◆ PHYLOCK

#define PHYLOCK ( ) WIZCHIP_WRITE(PHYLCKR,0xff)

Lock PHYCR0,CR1 Information.

See also
CHIPULLOCK()

Definition at line 2639 of file w5100s.h.

◆ PHYUNLOCK

#define PHYUNLOCK ( ) WIZCHIP_WRITE(PHYLCKR,0x53)

Lock PHYCR0,CR1 Information.

See also
CHIPULLOCK()

Definition at line 2647 of file w5100s.h.

◆ setGAR

#define setGAR ( gar ) WIZCHIP_WRITE_BUF(GAR,gar,4)

Set GAR.

Parameters
(uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes.
See also
getGAR()

Definition at line 1855 of file w5100s.h.

◆ setIMR

#define setIMR ( imr ) WIZCHIP_WRITE(_IMR_, imr)

Set IMR register.

Parameters
(uint8_t)imr Value to set IMR register.
See also
getIMR()

Definition at line 1949 of file w5100s.h.

◆ setIMR2

#define setIMR2 ( imr2 ) WIZCHIP_WRITE(IMR2,imr2)

Set IMR2 register.

Parameters
(uint8_t)imr2 Value to set IMR2 register.
See also
setIMR2()

Definition at line 2118 of file w5100s.h.

◆ setIR

#define setIR ( ir ) WIZCHIP_WRITE(IR, (ir & 0xE0))

Set IR register.

Parameters
(uint8_t)ir Value to set IR register.
See also
getIR()

Definition at line 1930 of file w5100s.h.

◆ setIR2

#define setIR2 ( ir2 ) WIZCHIP_WRITE(IR2, ir2)

Set IR2 register.

Parameters
(uint8_t)ir2 Value to set IR2 register.
See also
getIR2()

Definition at line 2100 of file w5100s.h.

◆ setMR

#define setMR ( mr ) (*((uint8_t*)MR) = mr)

Set Mode Register.

Parameters
(uint8_t)mr The value to be set.
See also
getMR()

Definition at line 1834 of file w5100s.h.

◆ setMR2

#define setMR2 ( mr2 ) WIZCHIP_WRITE(MR2,mr2)

Set MR2 register.

Parameters
(uint8_t)mr2 Value to set MR2 registers.
See also
getMR2()

Definition at line 2174 of file w5100s.h.

◆ setNICMAXCOLR

#define setNICMAXCOLR ( nicmaxcolr ) WIZCHIP_WRITE(NICMAXCOLR,nicmaxcolr)

Set NICMAXCOLR register.

Parameters
(uint8_t)nicmaxcolr Value to set NICMAXCOLR register.
See also
getNICMAXCOLR()

Definition at line 2585 of file w5100s.h.

◆ setPHAR

#define setPHAR ( phar ) WIZCHIP_WRITE_BUF(PHAR,phar,6)

Set PHAR registers.

Parameters
(uint8_t*)phar Value to set PHAR registers.
See also
getPHAR()

Definition at line 2192 of file w5100s.h.

◆ setPHYACR

#define setPHYACR ( phyacr ) WIZCHIP_WRITE(PHYACR,phyacr)

Set PHYACR register.

Parameters
(uint8_t)phyacr Value to set PHYACR register.
See also
getPHYACR()

Definition at line 2348 of file w5100s.h.

◆ setPHYCR0

#define setPHYCR0 ( phych0 ) WIZCHIP_WRITE(PHYCR0,phych0)

Set PHYCR0 register.

Parameters
(uint8_t)phych0 Value to set PHYCR0 register.
See also
getPHYCR0()

Definition at line 2375 of file w5100s.h.

◆ setPHYCR1

#define setPHYCR1 ( phycr1 ) WIZCHIP_WRITE(PHYCR1,phycr1)

Set PHYCR1 register.

Parameters
(uint8_t)phycr1 Value to set PHYCR1 register.
See also
getPHYCR1()

Definition at line 2393 of file w5100s.h.

◆ setPHYDIR

#define setPHYDIR ( phydir )
Value:
{\
WIZCHIP_WRITE(PHYDIR+1, (uint8_t)(phydir >> 8)); \
WIZCHIP_WRITE(PHYDIR, (uint8_t) phydir); \
}
PHYDIR
#define PHYDIR
PHY Data input register.
Definition: w5100s.h:449

Set PHYDIR register.

Parameters
(uint16_t)phydir Value to set PHYDIR register.
See also
getPHYDIR()

Definition at line 2304 of file w5100s.h.

◆ setPHYDIVR

#define setPHYDIVR ( phydivr ) WIZCHIP_WRITE(PHYDIVR, phydivr)

Set PHYDIVR register.

Parameters
(uint8_t)phydivr Value to set PHYDIVR register.
See also
getPHYDIVR()

Definition at line 2357 of file w5100s.h.

◆ setPHYDOR

#define setPHYDOR ( phydor )
Value:
{\
WIZCHIP_WRITE(PHYDOR, (uint8_t)(phydor >> 8)); \
WIZCHIP_WRITE(PHYDOR+1, (uint8_t) phydor); \
}
PHYDOR
#define PHYDOR
PHY data output register.
Definition: w5100s.h:456

Set PHYDOR register.

Parameters
(uint16_t)phydor Value to set PHYDOR register.
See also
getPHYDOR()

Definition at line 2326 of file w5100s.h.

◆ setPHYRR

#define setPHYRR ( phyrar ) WIZCHIP_WRITE(PHYRAR, phyrar)

Set PHYRR register.

Parameters
(uint8_t)phyrar Value to set PHYRR register.
See also
getPHYRR()

Definition at line 2284 of file w5100s.h.

◆ setPINGIDR

#define setPINGIDR ( pingidr )
Value:
{\
WIZCHIP_WRITE(PINGIDR, (uint8_t)(pingidr >> 8)); \
WIZCHIP_WRITE(PINGIDR+1, (uint8_t) pingidr); \
}
PINGIDR
#define PINGIDR
Ping ID register.
Definition: w5100s.h:535

Set PINGIDR register.

Parameters
(uint16_t)pingidr Value to set PINGIDR register.
See also
getPINGIDR()

Definition at line 2522 of file w5100s.h.

◆ setPINGSEQR

#define setPINGSEQR ( pingseqr )
Value:
{\
WIZCHIP_WRITE(PINGSEQR, (uint8_t)(pingseqr >> 8)); \
WIZCHIP_WRITE(PINGSEQR+1, (uint8_t) pingseqr); \
}
PINGSEQR
#define PINGSEQR
Ping sequence number register.
Definition: w5100s.h:528

Set PINGSEQR register.

Parameters
(uint16_t)pingseqr Value to set PINGSEQR register.
See also
getPINGSEQR()

Definition at line 2502 of file w5100s.h.

◆ setPMAGIC

#define setPMAGIC ( pmagic ) WIZCHIP_WRITE(PMAGIC, pmagic)

Set PMAGIC register.

Parameters
(uint8_t)pmagic Value to set PMAGIC register.
See also
getPMAGIC()

Definition at line 2075 of file w5100s.h.

◆ setPMRUR

#define setPMRUR ( pmrur )
Value:
{\
WIZCHIP_WRITE(PMRUR, (uint8_t)(pmrur >> 8)); \
WIZCHIP_WRITE(PMRUR+1, (uint8_t) pmrur); \
}
PMRUR
#define PMRUR
Maximum receive Unit in PPPoE.
Definition: w5100s.h:411

Set PMRUR register.

Parameters
(uint16_t)pmrur Value to set PMRUR register.
See also
getPMRUR()

Definition at line 2230 of file w5100s.h.

◆ setPSIDR

#define setPSIDR ( psidr )
Value:
{\
WIZCHIP_WRITE(PSIDR, (uint8_t)(psidr >> 8)); \
WIZCHIP_WRITE(PSIDR+1, (uint8_t) psidr); \
}
PSIDR
#define PSIDR
Session ID in PPPoE.
Definition: w5100s.h:404

Set PSIDR register.

Parameters
(uint16_t)psidr Value to set PSIDR register.
See also
getPSIDR()

Definition at line 2210 of file w5100s.h.

◆ setPTIMER

#define setPTIMER ( ptimer ) WIZCHIP_WRITE(PTIMER, ptimer)

Set PTIMER register.

Parameters
(uint8_t)ptimer Value to set PTIMER register.
See also
getPTIMER()

Definition at line 2057 of file w5100s.h.

◆ setRCR

#define setRCR ( rcr ) WIZCHIP_WRITE(_RCR_, rcr)

Set RCR register.

Parameters
(uint8_t)rcr Value to set RCR register.
See also
getRCR()

Definition at line 1987 of file w5100s.h.

◆ setRMSR

#define setRMSR ( rmsr ) WIZCHIP_WRITE(RMSR,rmsr)

Get RMSR register.

See also
getRMSR()

Definition at line 2004 of file w5100s.h.

◆ setRTR

#define setRTR ( rtr )
Value:
{\
WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
}
_RTR_
#define _RTR_
Timeout register address( 1 is 100us )(R/W)
Definition: w5100s.h:282
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set RTR register.

Parameters
(uint16_t)rtr Value to set RTR register.
See also
getRTR()

Definition at line 1967 of file w5100s.h.

◆ setSHAR

#define setSHAR ( shar ) WIZCHIP_WRITE_BUF(SHAR, shar, 6)

Set SHAR.

Parameters
(uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes.
See also
getSHAR()

Definition at line 1894 of file w5100s.h.

◆ setSIPR

#define setSIPR ( sipr ) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)

Set SIPR.

Parameters
(uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes.
See also
getSIPR()

Definition at line 1912 of file w5100s.h.

◆ setSLCR

#define setSLCR ( rqcr ) WIZCHIP_WRITE(SLCR, rqcr)

Set SLCR register.

Parameters
(uint8_t)rqcr Value to set SLCR register.
See also
getSLCR()

Definition at line 2411 of file w5100s.h.

◆ setSLIMR

#define setSLIMR ( slimr ) WIZCHIP_WRITE(SLIMR, slimr)

Set SLIMR register.

Parameters
(uint8_t)slimr Value to set SLIMR register.
See also
getSLIMR()

Definition at line 2542 of file w5100s.h.

◆ setSLIR

#define setSLIR ( slir ) WIZCHIP_WRITE(SLIR, slir)

Set SLIR register.

Parameters
(uint8_t)slir Value to set SLIR register.
See also
getSLIMR()

Definition at line 2560 of file w5100s.h.

◆ setSLPHAR

#define setSLPHAR ( slphar ) WIZCHIP_WRITE_BUF(SLPHAR,slphar,6)

Get SLPHAR registers.

Parameters
(uint8_t*)slphar Values to set SLPHAR registers.
See also
getSLPHAR()

Definition at line 2484 of file w5100s.h.

◆ setSLPIPR

#define setSLPIPR ( slpipr ) WIZCHIP_WRITE_BUF(SLPIPR,slpipr,4)

Set SLPIPR registers.

Parameters
(uint8_t*)slpipr Values to set SLPIPR registers.
See also
getSLPIPR()

Definition at line 2466 of file w5100s.h.

◆ setSLRCR

#define setSLRCR ( slrcr ) WIZCHIP_WRITE(SLRCR,slrcr)

Set SLRCR register.

Parameters
(uint8_t)slrcr Value to set SLRCR register.
See also
getSLRCR()

Definition at line 2448 of file w5100s.h.

◆ setSLRTR

#define setSLRTR ( slrtr )
Value:
WIZCHIP_WRITE(SLRTR, (uint8_t)(slrtr >> 8)); \
WIZCHIP_WRITE(SLRTR+1, (uint8_t) slrtr); \
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
SLRTR
#define SLRTR
Socket-less retry time register.
Definition: w5100s.h:499

Set SLRTR register.

Parameters
(uint16_t)slrtr Value to set SLRTR register.
See also
getSLRTR()

Definition at line 2429 of file w5100s.h.

◆ setSUBR

#define setSUBR ( subr ) WIZCHIP_WRITE_BUF(SUBR,subr,4)

Set SUBR.

Parameters
(uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes.
Note
If subr is null pointer, set the backup subnet to SUBR.
If subr is 0.0.0.0, back up SUBR and clear it.
Otherwize, set subr to SUBR
See also
getSUBR()

Definition at line 1876 of file w5100s.h.

◆ setTCNTCLKR

#define setTCNTCLKR ( var ) WIZCHIP_WRITE(TCNTCLKR, var)

Set TCNTR register.

Parameters
(uint8_t) Value to set TCNTR register.
See also
getTCNTCLKR()

Definition at line 2676 of file w5100s.h.

◆ setTMSR

#define setTMSR ( tmsr ) WIZCHIP_WRITE(TMSR,tmsr)

Get TMSR register.

See also
getTMSR()

Definition at line 2021 of file w5100s.h.

◆ setUIPR

#define setUIPR ( uipr ) WIZCHIP_WRITE_BUF(UIPR,uipr,4)

Set UIPR(Unreachable IP Address Register) registers.

Parameters
(uint8_t*)uipr Value to set UIPR registers.
See also
setUIPR()

Definition at line 2136 of file w5100s.h.

◆ setUPORTR

#define setUPORTR ( uportr )
Value:
{\
WIZCHIP_WRITE(UPORTR, (uint8_t)(uportr >> 8)); \
WIZCHIP_WRITE(UPORTR+1, (uint8_t) uportr); \
}
UPORTR
#define UPORTR
Unreachable Port register.
Definition: w5100s.h:378

Set UPORTR(Unreachable Port Address Register) register.

Parameters
(uint16_t)uportr Value to set UPORTR register.
See also
getUPORTR()

Definition at line 2154 of file w5100s.h.


ioLibrary: Socket register access functions

Macros | Functions
Socket register access functions
W5100S » WIZCHIP I/O functions

These are functions to access socket registers. More...

Collaboration diagram for Socket register access functions:

Macros

#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ir)
Set Sn_IR register. More...
#define | getSn_IR(sn) WIZCHIP_READ(Sn_IR(sn))
Get Sn_IR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_DHAR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_PROTO(sn, proto) WIZCHIP_WRITE(Sn_PROTO(sn), proto)
Set Sn_PROTO register. More...
#define | getSn_PROTO(sn) WIZCHIP_READ(Sn_PROTO(sn))
Get Sn_PROTO register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXMEM_SIZE(sn, rxmemsize) WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxmemsize)
Set Sn_RXMEM_SIZE register. More...
#define | getSn_RXMEM_SIZE(sn) WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
Get Sn_RXMEM_SIZE register. More...
#define | setSn_TXMEM_SIZE(sn, txmemsize) WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn),txmemsize)
Set Sn_TXMEM_SIZE register. More...
#define | getSn_TXMEM_SIZE(sn) WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
Get Sn_TXMEM_SIZE register. More...
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | setSn_RX_WR(sn, rxwr)
Set Sn_RX_WR register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_FRAGR(sn, fragr)
Set Sn_FRAGR register. More...
#define | getSn_FRAGR(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAGR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAGR(sn),1)))
Get Sn_FRAGR register. More...
#define | getSn_RxMAX(sn) ((uint16_t)(getSn_RXMEM_SIZE(sn)) << 10)
Get the max RX buffer size of socket sn. More...
#define | getSn_TxMAX(sn) ((uint16_t)(getSn_TXMEM_SIZE(sn)) << 10)
Get the max TX buffer size of socket sn. More...
#define | getSn_RxMASK(sn) (getSn_RxMAX(sn) - 1)
Get the mask of socket sn RX buffer. More...
#define | getSn_TxMASK(sn) (getSn_TxMAX(sn) - 1)
Get the mask of socket sn TX buffer. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn),imr)
Set the interrupt mask register of socket sn. More...
#define | getSn_IMR(sn) WIZCHIP_READ(Sn_IMR(sn))
Get the interrupt mask register of socket sn. More...
#define | setSn_MR2(sn, mr2) WIZCHIP_WRITE(Sn_MR2(sn), mr2)
Set the Sn_MR2 value of socket sn. More...
#define | getSn_MR2(sn) WIZCHIP_READ(Sn_MR2(sn))
Get the Sn_MR2 value of socket sn. More...
#define | setSn_KPALVTR(sn, kpalvtr) WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvtr)
Set the Sn_KPALVTR value of socket sn. More...
#define | getSn_KPALVTR(sn) WIZCHIP_READ(Sn_KPALVTR(sn))
Get the Sn_KPALVTR value of socket sn. More...
#define | getSn_TSR(sn) WIZCHIP_READ(Sn_TSR(sn))
Get the Sn_TSR register of socket sn. More...
#define | setSn_RTR(sn, rtr)
Set the Sn_RTR register of socket sn. More...
#define | getSn_RTR(sn) (((uint16_t)WIZCHIP_READ(Sn_RTR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RTR(sn),1)))
Get the Sn_RTR register of socket sn. More...
#define | setSn_RCR(sn, rcr) WIZCHIP_WRITE(Sn_RCR(sn),rcr)
Set the Sn_RCR register of socket sn. More...
#define | getSn_RCR(sn) WIZCHIP_READ(Sn_RCR(sn))
Get the Sn_RCR of socket sn. More...

Functions

uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
uint32_t | getSn_RxBASE (uint8_t sn)
Get the base address of socket sn RX buffer. More...
uint32_t | getSn_TxBASE (uint8_t sn)
Get the base address of socket sn TX buffer. More...

Detailed Description

These are functions to access socket registers.

Macro Definition Documentation

◆ getSn_CR

#define getSn_CR ( sn ) WIZCHIP_READ(Sn_CR(sn))

Get Sn_CR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_CR.
See also
setSn_CR()

Definition at line 2725 of file w5100s.h.

◆ getSn_DHAR

#define getSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)

Get Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dhar | Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes.
See also
setSn_DHAR()

Definition at line 2796 of file w5100s.h.

◆ getSn_DIPR

#define getSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)

Get Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dipr | Pointer variable to get socket n destination IP address. It should be allocated 4 bytes.
See also
SetSn_DIPR()

Definition at line 2816 of file w5100s.h.

◆ getSn_DPORT

#define getSn_DPORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))

Get Sn_DPORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_DPORT.
See also
setSn_DPORT()

Definition at line 2838 of file w5100s.h.

◆ getSn_FRAGR

#define getSn_FRAGR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_FRAGR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAGR(sn),1)))

Get Sn_FRAGR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_FRAGR.
See also
setSn_FRAG()

Definition at line 3077 of file w5100s.h.

◆ getSn_IMR

#define getSn_IMR ( sn ) WIZCHIP_READ(Sn_IMR(sn))

Get the interrupt mask register of socket sn.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n interrupt mask register.

Definition at line 3153 of file w5100s.h.

◆ getSn_IR

#define getSn_IR ( sn ) WIZCHIP_READ(Sn_IR(sn))

Get Sn_IR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_IR.
See also
setSn_IR()

Definition at line 2745 of file w5100s.h.

◆ getSn_KPALVTR

#define getSn_KPALVTR ( sn ) WIZCHIP_READ(Sn_KPALVTR(sn))

Get the Sn_KPALVTR value of socket sn.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of the Sn_KPALVTR register.

Definition at line 3189 of file w5100s.h.

◆ getSn_MR

#define getSn_MR ( sn ) WIZCHIP_READ(Sn_MR(sn))

Get Sn_MR register.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.
Returns
Value of Sn_MR.
See also
setSn_MR()

Definition at line 2705 of file w5100s.h.

◆ getSn_MR2

#define getSn_MR2 ( sn ) WIZCHIP_READ(Sn_MR2(sn))

Get the Sn_MR2 value of socket sn.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n Sn_MR2 register.

Definition at line 3171 of file w5100s.h.

◆ getSn_MSSR

#define getSn_MSSR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))

Get Sn_MSSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_MSSR.
See also
setSn_MSSR()

Definition at line 2860 of file w5100s.h.

◆ getSn_PORT

#define getSn_PORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))

Get Sn_PORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_PORT.
See also
setSn_PORT()

Definition at line 2776 of file w5100s.h.

◆ getSn_PROTO

#define getSn_PROTO ( sn ) WIZCHIP_READ(Sn_PROTO(sn))

Get Sn_PROTO register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_PROTO.
See also
setSn_PROTO()

Definition at line 2880 of file w5100s.h.

◆ getSn_RCR

#define getSn_RCR ( sn ) WIZCHIP_READ(Sn_RCR(sn))

Get the Sn_RCR of socket sn.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of the Socket n Sn_RCR.

Definition at line 3236 of file w5100s.h.

◆ getSn_RTR

#define getSn_RTR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RTR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RTR(sn),1)))

Get the Sn_RTR register of socket sn.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of the Socket n Sn_RTR register.

Definition at line 3218 of file w5100s.h.

◆ getSn_RX_RD

#define getSn_RX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))

Get Sn_RX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_. uint16_t. Value of Sn_RX_RD.
See also
setSn_RX_RD()

Definition at line 3033 of file w5100s.h.

◆ getSn_RX_WR

#define getSn_RX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))

Get Sn_RX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_WR.

Definition at line 3055 of file w5100s.h.

◆ getSn_RxMASK

#define getSn_RxMASK ( sn ) (getSn_RxMAX(sn) - 1)

Get the mask of socket sn RX buffer.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Mask value

Definition at line 3105 of file w5100s.h.

◆ getSn_RxMAX

#define getSn_RxMAX ( sn ) ((uint16_t)(getSn_RXMEM_SIZE(sn)) << 10)

Get the max RX buffer size of socket sn.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Max buffer size

Definition at line 3086 of file w5100s.h.

◆ getSn_RXMEM_SIZE

#define getSn_RXMEM_SIZE ( sn ) WIZCHIP_READ(Sn_RXBUF_SIZE(sn))

Get Sn_RXMEM_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_RXMEM.
See also
setSn_RXMEM_SIZE()

Definition at line 2941 of file w5100s.h.

◆ getSn_SR

#define getSn_SR ( sn ) WIZCHIP_READ(Sn_SR(sn))

Get Sn_SR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_SR.

Definition at line 2754 of file w5100s.h.

◆ getSn_TOS

#define getSn_TOS ( sn ) WIZCHIP_READ(Sn_TOS(sn))

Get Sn_TOS register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
Returns
uint8_t. Value of Sn_TOS.
See also
setSn_TOS()

Definition at line 2900 of file w5100s.h.

◆ getSn_TSR

#define getSn_TSR ( sn ) WIZCHIP_READ(Sn_TSR(sn))

Get the Sn_TSR register of socket sn.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of the Socket n Sn_TSR register.

Definition at line 3198 of file w5100s.h.

◆ getSn_TTL

#define getSn_TTL ( sn ) WIZCHIP_READ(Sn_TTL(sn))

Get Sn_TTL register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
Returns
uint8_t. Value of Sn_TTL.
See also
setSn_TTL()

Definition at line 2920 of file w5100s.h.

◆ getSn_TX_RD

#define getSn_TX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))

Get Sn_TX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_RD.

Definition at line 2981 of file w5100s.h.

◆ getSn_TX_WR

#define getSn_TX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))

Get Sn_TX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_WR.
See also
setSn_TX_WR()

Definition at line 3003 of file w5100s.h.

◆ getSn_TxMASK

#define getSn_TxMASK ( sn ) (getSn_TxMAX(sn) - 1)

Get the mask of socket sn TX buffer.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Mask value

Definition at line 3114 of file w5100s.h.

◆ getSn_TxMAX

#define getSn_TxMAX ( sn ) ((uint16_t)(getSn_TXMEM_SIZE(sn)) << 10)

Get the max TX buffer size of socket sn.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Max buffer size

Definition at line 3096 of file w5100s.h.

◆ getSn_TXMEM_SIZE

#define getSn_TXMEM_SIZE ( sn ) WIZCHIP_READ(Sn_TXBUF_SIZE(sn))

Get Sn_TXMEM_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_TXMEM_SIZE.
See also
setSn_TXMEM_SIZE()

Definition at line 2963 of file w5100s.h.

◆ setSn_CR

#define setSn_CR | ( | sn,
 |  | cr
 | ) | WIZCHIP_WRITE(Sn_CR(sn), cr)

Set Sn_CR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)cr | Value to set Sn_CR
See also
getSn_CR()

Definition at line 2715 of file w5100s.h.

◆ setSn_DHAR

#define setSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)

Set Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dhar | Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes.
See also
getSn_DHAR()

Definition at line 2786 of file w5100s.h.

◆ setSn_DIPR

#define setSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)

Set Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dipr | Pointer variable to set socket n destination IP address. It should be allocated 4 bytes.
See also
getSn_DIPR()

Definition at line 2806 of file w5100s.h.

◆ setSn_DPORT

#define setSn_DPORT | ( | sn,
 |  | dport
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
}
Sn_DPORT
#define Sn_DPORT(sn)
Peer port register address(R/W)
Definition: w5100s.h:753
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set Sn_DPORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)dport | Value to set Sn_DPORT
See also
getSn_DPORT()

Definition at line 2826 of file w5100s.h.

◆ setSn_FRAGR

#define setSn_FRAGR | ( | sn,
 |  | fragr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_FRAGR(sn), (uint8_t)(fragr >>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAGR(sn),1), (uint8_t) fragr); \
}
Sn_FRAGR
#define Sn_FRAGR(sn)
Socket fragment field register.
Definition: w5100s.h:905
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set Sn_FRAGR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)frag | Value to set Sn_FRAGR
See also
getSn_FRAG()

Definition at line 3065 of file w5100s.h.

◆ setSn_IMR

#define setSn_IMR | ( | sn,
 |  | imr
 | ) | WIZCHIP_WRITE(Sn_IMR(sn),imr)

Set the interrupt mask register of socket sn.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)imr | Value to set Sn_IMR
See also
getSn_IMR(sn)

Definition at line 3144 of file w5100s.h.

◆ setSn_IR

#define setSn_IR | ( | sn,
 |  | ir
 | ) | WIZCHIP_WRITE(Sn_IR(sn), ir)

Set Sn_IR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)ir | Value to set Sn_IR
See also
getSn_IR()

Definition at line 2735 of file w5100s.h.

◆ setSn_KPALVTR

#define setSn_KPALVTR | ( | sn,
 |  | kpalvtr
 | ) | WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvtr)

Set the Sn_KPALVTR value of socket sn.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
kpalvtr | Value of the Sn_KPALVTR register to set.

Definition at line 3180 of file w5100s.h.

◆ setSn_MR

#define setSn_MR | ( | sn,
 |  | mr
 | ) | WIZCHIP_WRITE(Sn_MR(sn),mr)

Set Sn_MR register.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.
mr | Value to set Sn_MR
See also
getSn_MR()

Definition at line 2695 of file w5100s.h.

◆ setSn_MR2

#define setSn_MR2 | ( | sn,
 |  | mr2
 | ) | WIZCHIP_WRITE(Sn_MR2(sn), mr2)

Set the Sn_MR2 value of socket sn.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
mr2 | Value of Sn_MR2 register to set.

Definition at line 3162 of file w5100s.h.

◆ setSn_MSSR

#define setSn_MSSR | ( | sn,
 |  | mss
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
}
Sn_MSSR
#define Sn_MSSR(sn)
Maximum Segment Size(Sn_MSSR0) register address(R/W)
Definition: w5100s.h:760
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set Sn_MSSR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)mss | Value to set Sn_MSSR
See also
setSn_MSSR()

Definition at line 2848 of file w5100s.h.

◆ setSn_PORT

#define setSn_PORT | ( | sn,
 |  | port
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
}
Sn_PORT
#define Sn_PORT(sn)
source port register(R/W)
Definition: w5100s.h:725
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set Sn_PORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)port | Value to set Sn_PORT.
See also
getSn_PORT()

Definition at line 2764 of file w5100s.h.

◆ setSn_PROTO

#define setSn_PROTO | ( | sn,
 |  | proto
 | ) | WIZCHIP_WRITE(Sn_PROTO(sn), proto)

Set Sn_PROTO register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)proto | Value to set Sn_PROTO
See also
getSn_PROTO()

Definition at line 2870 of file w5100s.h.

◆ setSn_RCR

#define setSn_RCR | ( | sn,
 |  | rcr
 | ) | WIZCHIP_WRITE(Sn_RCR(sn),rcr)

Set the Sn_RCR register of socket sn.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of the Socket n Sn_RCR register to set.

Definition at line 3227 of file w5100s.h.

◆ setSn_RTR

#define setSn_RTR | ( | sn,
 |  | rtr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RTR(sn), (uint8_t)(rtr >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RTR(sn),1), (uint8_t) rtr); \
}
Sn_RTR
#define Sn_RTR(sn)
Socket n Timer Status Register.
Definition: w5100s.h:937
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set the Sn_RTR register of socket sn.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)rtr | Value of the Socket n Sn_RTR register to set.

Definition at line 3207 of file w5100s.h.

◆ setSn_RX_RD

#define setSn_RX_RD | ( | sn,
 |  | rxrd
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
}
Sn_RX_RD
#define Sn_RX_RD(sn)
Read point of Receive memory(R/W)
Definition: w5100s.h:877
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set Sn_RX_RD register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)rxrd | Value to set Sn_RX_RD
See also
getSn_RX_RD()

Definition at line 3021 of file w5100s.h.

◆ setSn_RX_WR

#define setSn_RX_WR | ( | sn,
 |  | rxwr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
}
Sn_RX_WR
#define Sn_RX_WR(sn)
Write point of Receive memory(R)
Definition: w5100s.h:886
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set Sn_RX_WR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)rxwr | Value to set Sn_RX_WR
See also
getSn_RX_WR()

Definition at line 3043 of file w5100s.h.

◆ setSn_RXMEM_SIZE

#define setSn_RXMEM_SIZE | ( | sn,
 |  | rxmemsize
 | ) | WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxmemsize)

Set Sn_RXMEM_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
(uint8_t)rxmemsize | Value to set Sn_RXMEM_SIZE
See also
getSn_RXMEM_SIZE()

Definition at line 2930 of file w5100s.h.

◆ setSn_TOS

#define setSn_TOS | ( | sn,
 |  | tos
 | ) | WIZCHIP_WRITE(Sn_TOS(sn), tos)

Set Sn_TOS register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)tos | Value to set Sn_TOS
See also
getSn_TOS()

Definition at line 2890 of file w5100s.h.

◆ setSn_TTL

#define setSn_TTL | ( | sn,
 |  | ttl
 | ) | WIZCHIP_WRITE(Sn_TTL(sn), ttl)

Set Sn_TTL register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
(uint8_t)ttl | Value to set Sn_TTL
See also
getSn_TTL()

Definition at line 2910 of file w5100s.h.

◆ setSn_TX_WR

#define setSn_TX_WR | ( | sn,
 |  | txwr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
}
Sn_TX_WR
#define Sn_TX_WR(sn)
Transmit memory write pointer register address(R/W)
Definition: w5100s.h:855
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100s.h:61

Set Sn_TX_WR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)txwr | Value to set Sn_TX_WR
See also
GetSn_TX_WR()

Definition at line 2991 of file w5100s.h.

◆ setSn_TXMEM_SIZE

#define setSn_TXMEM_SIZE | ( | sn,
 |  | txmemsize
 | ) | WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn),txmemsize)

Set Sn_TXMEM_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)txmemsize | Value to set Sn_TXMEM_SIZE
See also
getSn_TXMEM_SIZE()

Definition at line 2952 of file w5100s.h.

Function Documentation

◆ getSn_RX_RSR()

uint16_t getSn_RX_RSR ( uint8_t sn )

Get Sn_RX_RSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_RSR.

Definition at line 254 of file w5100s.c.

◆ getSn_RxBASE()

uint32_t getSn_RxBASE ( uint8_t sn )

Get the base address of socket sn RX buffer.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n RX buffer base address.

Definition at line 273 of file w5100s.c.

◆ getSn_TX_FSR()

uint16_t getSn_TX_FSR ( uint8_t sn )

Get Sn_TX_FSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_FSR.

Definition at line 237 of file w5100s.c.

◆ getSn_TxBASE()

uint32_t getSn_TxBASE ( uint8_t sn )

Get the base address of socket sn TX buffer.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n TX buffer base address.

Definition at line 287 of file w5100s.c.


ioLibrary: Special functions

Functions
Special functions
W5100S » WIZCHIP I/O functions

These are special functions to access to the PHY. More...

Collaboration diagram for Special functions:

Functions

void | wiz_mdio_write (uint8_t PHYMDIO_regadr, uint16_t var)
Write data to the PHY via MDC/MDIO interface. More...
uint16_t | wiz_mdio_read (uint8_t PHYMDIO_regadr)
Read data from the PHY via MDC/MDIO interface. More...
void | wiz_delay_ms (uint32_t ms)
Delay function. More...

Detailed Description

These are special functions to access to the PHY.

Function Documentation

◆ wiz_delay_ms()

void wiz_delay_ms ( uint32_t ms )

Delay function.

Delay function using internal 100us timer of the W5100S

Parameters
(uint32_t)ms Time to delay in milliseconds.

Definition at line 412 of file w5100s.c.

◆ wiz_mdio_read()

uint16_t wiz_mdio_read ( uint8_t PHYMDIO_regadr )

Read data from the PHY via MDC/MDIO interface.

Read command or status data from the PHY via MDC/MDIO interface.

Parameters
(uint8_t)PHYMDIO_regadr Address of the PHY register. It should be PHYMDIO_BMCR or PHYMDIO_BMSR.
Returns
The value of the PHY register

Definition at line 404 of file w5100s.c.

◆ wiz_mdio_write()

void wiz_mdio_write | ( | uint8_t | PHYMDIO_regadr,
 |  | uint16_t | var
 | ) |  |

Write data to the PHY via MDC/MDIO interface.

Write command data to the PHY via MDC/MDIO interface.

Parameters
(uint8_t)PHYMDIO_regadr | Address of the PHY register. It should be PHYMDIO_BMCR or PHYMDIO_BMSR.
(uint16_t)var | Data to write to the PHY register. Please refer to the bit definitions of the BMCR and BMSR register.

Definition at line 395 of file w5100s.c.


ioLibrary: W5200

Modules
W5200

WHIZCHIP register defines and I/O functions of W5200. More...

Collaboration diagram for W5200:

Modules

WIZCHIP register
WIZCHIP register defines register group of W5200 .
WIZCHIP I/O functions
This supports the basic I/O functions for WIZCHIP register.

Detailed Description

WHIZCHIP register defines and I/O functions of W5200.

  • WIZCHIP register : Common register and Socket register
  • WIZCHIP I/O functions : Basic I/O function, Common register access functions and Socket register


ioLibrary: WIZCHIP register

Modules
WIZCHIP register
W5200

WIZCHIP register defines register group of W5200 . More...

Collaboration diagram for WIZCHIP register:

Modules

Common register
Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.
Socket register
Socket register group
Socket register configures and control SOCKETn which is necessary to data communication.

Detailed Description

WIZCHIP register defines register group of W5200 .

  • Common register : Common register group w5200
  • Socket register : SOCKET n register group w5200


ioLibrary: Common register

Macros
Common register
W5200 » WIZCHIP register

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc. More...

Collaboration diagram for Common register:

Macros

#define | MR (_W5200_IO_BASE_ + (0x0000))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5200_IO_BASE_ + (0x0001))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5200_IO_BASE_ + (0x0005))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5200_IO_BASE_ + (0x0009))
Source MAC Register address(R/W) More...
#define | SIPR (_W5200_IO_BASE_ + (0x000F))
Source IP Register address(R/W) More...
#define | IR (_W5200_IO_BASE_ + (0x0015))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5200_IO_BASE_ + (0x0016))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5200_IO_BASE_ + (0x0017))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5200_IO_BASE_ + (0x0019))
Retry count register(R/W) More...
#define | PATR (_W5200_IO_BASE_ + (0x001C))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PPPALGO (_W5200_IO_BASE_ + (0x001E))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | VERSIONR (_W5200_IO_BASE_ + (0x001F))
chip version register address(R) More...
#define | PTIMER (_W5200_IO_BASE_ + (0x0028))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PMAGIC (_W5200_IO_BASE_ + (0x0029))
PPP LCP Magic number register in PPPoE mode(R) More...
#define | INTLEVEL (_W5200_IO_BASE_ + (0x0030))
Set Interrupt low level timer register address(R/W) More...
#define | IR2 (_W5200_IO_BASE_ + (0x0034))
Socket Interrupt Register(R/W) More...
#define | PHYSTATUS (_W5200_IO_BASE_ + (0x0035))
PHYSTATUS(R/W) More...
#define | IMR2 (_W5200_IO_BASE_ + (0x0036))
Interrupt mask register(R/W) More...

Detailed Description

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.

See also
MR : Mode register.
GAR, SUBR, SHAR, SIPR
INTLEVEL, IR, IMR, IR2, IMR2 : Interrupt.
RTR, RCR : Data retransmission.
PTIMER, PMAGIC : PPPoE.
PHYSTATUS, VERSIONR : etc.

Macro Definition Documentation

◆ _IMR_

#define _IMR_ (_W5200_IO_BASE_ + (0x0016))

Socket Interrupt Mask Register(R/W)

Each bit of IMR corresponds to each bit of IR2. When a bit of IMR is and the corresponding bit of IR2 is Interrupt will be issued. In other words, if a bit of IMR, an interrupt will be not issued even if the corresponding bit of IR2 is set

Note
This Register is same operated as SMIR of W5100, W5300 and W5550.
So, setSIMR() set a value to IMR for integrating with ioLibrary

Definition at line 265 of file w5200.h.

◆ _RCR_

#define _RCR_ (_W5200_IO_BASE_ + (0x0019))

Retry count register(R/W)

RCR configures the number of time of retransmission. When retransmission occurs as many as ref RCR+1 Timeout interrupt is issued (Sn_IR_TIMEOUT = '1').

Definition at line 283 of file w5200.h.

◆ _RTR_

#define _RTR_ (_W5200_IO_BASE_ + (0x0017))

Timeout register address( 1 is 100us )(R/W)

RTR configures the retransmission timeout period. The unit of timeout period is 100us and the default of RTR is x07D0. And so the default timeout period is 200ms(100us X 2000). During the time configured by RTR, W5200 waits for the peer response to the packet that is transmitted by Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). If the peer does not respond within the RTR time, W5200 retransmits the packet or issues timeout.

Definition at line 275 of file w5200.h.

◆ GAR

#define GAR (_W5200_IO_BASE_ + (0x0001))

Gateway IP Register address(R/W)

GAR configures the default gateway address.

Definition at line 215 of file w5200.h.

◆ IMR2

#define IMR2 (_W5200_IO_BASE_ + (0x0036))

Interrupt mask register(R/W)

IMR2 is used to mask interrupts. Each bit of IMR corresponds to each bit of IR. When a bit of IMR2 is and the corresponding bit of IR is an interrupt will be issued. In other words, if a bit of IMR2 is an interrupt will not be issued even if the corresponding bit of IR is

Each bit of IMR2 defined as the following.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
IM_IR7 | Reserved | IM_IR5 | Reserved | Reserved | Reserved | Reserved | Reserved
  • IM_IR7 : IP Conflict Interrupt Mask
  • IM_IR5 : PPPoE Close Interrupt Mask
    Note
    This Register is same operated as _IMR_ of W5100, W5300 and W5550.
    So, setIMR() set a value to IMR2 for integrating with ioLibrary

Definition at line 389 of file w5200.h.

◆ INTLEVEL

#define INTLEVEL (_W5200_IO_BASE_ + (0x0030))

Set Interrupt low level timer register address(R/W)

INTLEVEL configures the Interrupt Assert Time.

Definition at line 346 of file w5200.h.

◆ IR

#define IR (_W5200_IO_BASE_ + (0x0015))

Interrupt Register(R/W)

IR indicates the interrupt status. Each bit of IR will be still until the bit will be written to by the host. If IR is not equal to x00 INTn PIN is asserted to low until it is x00

Each bit of IR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
CONFLICT | Reserved | PPPoE | Reserved | Reserved | Reserved | Reserved | Reserved
  • IR_CONFLICT : IP conflict
  • IR_PPPoE : PPPoE connection close

Definition at line 254 of file w5200.h.

◆ IR2

#define IR2 (_W5200_IO_BASE_ + (0x0034))

Socket Interrupt Register(R/W)

IR2 indicates the interrupt status of Socket.
Each bit of IR2 be still until Sn_IR is cleared by the host.
If Sn_IR is not equal to x00 the n-th bit of IR2 is and INTn PIN is asserted until IR2 is x00

Definition at line 357 of file w5200.h.

◆ MR

#define MR (_W5200_IO_BASE_ + (0x0000))

Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc.

Each bit of MR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
RST | Reserved | WOL | PB | PPPoE | Reserved | AI | IND
  • MR_RST : Reset
  • MR_WOL : Wake on LAN
  • MR_PB : Ping block
  • MR_PPPOE : PPPoE mode
  • MR_AI : Address Auto-Increment in Indirect Bus Interface
  • MR_IND : Indirect Bus Interface mode

Definition at line 207 of file w5200.h.

◆ PATR

#define PATR (_W5200_IO_BASE_ + (0x001C))

PPP LCP Request Timer register in PPPoE mode(R)

PATR notifies authentication method that has been agreed at the connection with PPPoE Server. W5200 supports two types of Authentication method - PAP and CHAP.

Definition at line 294 of file w5200.h.

◆ PHYSTATUS

#define PHYSTATUS (_W5200_IO_BASE_ + (0x0035))

PHYSTATUS(R/W)

PHYSTATUS is the Register to indicate W5200 status of PHY.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
Reserved | Reserved | LINK | POWERSAVE | POWERDOWN | Reserved | Reserved | Reserved
  • PHYSTATUS_LINK : Link Status Register[Read Only]
  • PHYSTATUS_POWERSAVE : Power save mode of PHY[R/W]
  • PHYSTATUS_POWERDOWN : Power down mode of PHY[R/W]

Definition at line 371 of file w5200.h.

◆ PMAGIC

#define PMAGIC (_W5200_IO_BASE_ + (0x0029))

PPP LCP Magic number register in PPPoE mode(R)

PMAGIC configures the 4bytes magic number to be used in LCP negotiation.

Definition at line 332 of file w5200.h.

◆ PPPALGO

#define PPPALGO (_W5200_IO_BASE_ + (0x001E))

PPP LCP Request Timer register in PPPoE mode(R)

PPPALGO notifies authentication algorithm in PPPoE mode. For detailed information, please refer to PPPoE application note.

Definition at line 302 of file w5200.h.

◆ PTIMER

#define PTIMER (_W5200_IO_BASE_ + (0x0028))

PPP LCP Request Timer register in PPPoE mode(R)

PTIMER configures the time for sending LCP echo request. The unit of time is 25ms.

Definition at line 325 of file w5200.h.

◆ SHAR

#define SHAR (_W5200_IO_BASE_ + (0x0009))

Source MAC Register address(R/W)

SHAR configures the source hardware address.

Definition at line 229 of file w5200.h.

◆ SIPR

#define SIPR (_W5200_IO_BASE_ + (0x000F))

Source IP Register address(R/W)

SIPR configures the source IP address.

Definition at line 236 of file w5200.h.

◆ SUBR

#define SUBR (_W5200_IO_BASE_ + (0x0005))

Subnet mask Register address(R/W)

SUBR configures the subnet mask address.

Definition at line 222 of file w5200.h.

◆ VERSIONR

#define VERSIONR (_W5200_IO_BASE_ + (0x001F))

chip version register address(R)

VERSIONR always indicates the W5200 version as 0x03.

Definition at line 309 of file w5200.h.


ioLibrary: Socket register

Macros
Socket register
W5200 » WIZCHIP register

Socket register group
Socket register configures and control SOCKETn which is necessary to data communication. More...

Collaboration diagram for Socket register:

Macros

#define | Sn_MR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))
socket Mode register(R/W) More...
#define | Sn_CR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))
Socket command register(R/W) More...
#define | Sn_IR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))
Socket interrupt register(R) More...
#define | Sn_SR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))
Socket status register(R) More...
#define | Sn_PORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))
source port register(R/W) More...
#define | Sn_DHAR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))
Peer IP register address(R/W) More...
#define | Sn_DPORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))
Peer port register address(R/W) More...
#define | Sn_MSSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_PROTO(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOS(sn) (WIZCHIP_SREG_BLOCK(sn) + 0x0015)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_RXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E))
Receive memory size register(R/W) More...
#define | Sn_TXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F))
Transmit memory size register(R/W) More...
#define | Sn_TX_FSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))
Received data size register(R) More...
#define | Sn_RX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))
Write point of Receive memory(R) More...
#define | Sn_IMR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C))
socket interrupt mask register(R) More...
#define | Sn_FRAG(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D))
Fragment field value in IP header register(R/W) More...

Detailed Description

Socket register group
Socket register configures and control SOCKETn which is necessary to data communication.

See also
Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control
Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information
Sn_MSSR, Sn_TOS, Sn_TTL, Sn_FRAG : Internet protocol.
Sn_RXMEM_SIZE, Sn_TXMEM_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication

Macro Definition Documentation

◆ Sn_CR

#define Sn_CR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))

Socket command register(R/W)

This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.
After W5200 accepts the command, the Sn_CR register is automatically cleared to 0x00. Even though Sn_CR is cleared to 0x00, the command is still being processed.
To check whether the command is completed or not, please check the Sn_IR or Sn_SR.

  • Sn_CR_OPEN : Initialize or open socket.
  • Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode)
  • Sn_CR_CONNECT : Send connection request in TCP mode(Client mode)
  • Sn_CR_DISCON : Send closing request in TCP mode.
  • Sn_CR_CLOSE : Close socket.
  • Sn_CR_SEND : Update TX buffer pointer and send data.
  • Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process.
  • Sn_CR_SEND_KEEP : Send keep alive message.
  • Sn_CR_RECV : Update RX buffer pointer and receive data.
  • In case of S0_MR(P3:P0) = S0_MR_PPPoE
    Value | Symbol | Description
    0x23 | PCON | PPPoE connection begins by transmitting PPPoE discovery packet
    0x24 | PDISCON | Closes PPPoE connection
    0x25 | PCR | In each phase, it transmits REQ message.
    0x26 | PCN | In each phase, it transmits NAK message.
    0x27 | PCJ | In each phase, it transmits REJECT message.

Definition at line 457 of file w5200.h.

◆ Sn_DHAR

#define Sn_DHAR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))

Peer MAC register address(R/W)

Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or it indicates that it is acquired in ARP-process by CONNECT/SEND command.

Definition at line 517 of file w5200.h.

◆ Sn_DIPR

#define Sn_DIPR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))

Peer IP register address(R/W)

Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP client mode, it configures an IP address of TCP server before CONNECT command. In TCP server mode, it indicates an IP address of TCP client after successfully establishing connection. In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command.

Definition at line 527 of file w5200.h.

◆ Sn_DPORT

#define Sn_DPORT ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))

Peer port register address(R/W)

Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP clientmode, it configures the listen port number of TCP server before CONNECT command. In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command.

Definition at line 537 of file w5200.h.

◆ Sn_FRAG

#define Sn_FRAG ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D))

Fragment field value in IP header register(R/W)

Sn_FRAG configures the FRAG(Fragment field in IP header).

Definition at line 684 of file w5200.h.

◆ Sn_IMR

#define Sn_IMR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C))

socket interrupt mask register(R)

Sn_IMR masks the interrupt of Socket n. Each bit corresponds to each bit of Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of Sn_IMR is the corresponding bit of Sn_IR becomes When both the corresponding bit of Sn_IMR and Sn_IR are and the n-th bit of IR is Host is interrupted by asserted INTn PIN to low.

Definition at line 677 of file w5200.h.

◆ Sn_IR

#define Sn_IR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))

Socket interrupt register(R)

Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).
When an interrupt occurs and the corresponding bit of Sn_IMR is the corresponding bit of Sn_IR becomes
In order to clear the Sn_IR bit, the host should write the bit to

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
PRECV | PFAIL | PNEXT | SEND_OK | TIMEOUT | RECV | DISCON | CON
  • Sn_IR_PRECV : PPP Receive Interrupt
  • Sn_IR_PFAIL : PPP Fail Interrupt
  • Sn_IR_PNEXT : PPP Next Phase Interrupt
  • Sn_IR_SENDOK : SEND_OK Interrupt
  • Sn_IR_TIMEOUT : TIMEOUT Interrupt
  • Sn_IR_RECV : RECV Interrupt
  • Sn_IR_DISCON : DISCON Interrupt
  • Sn_IR_CON : CON Interrupt

Definition at line 478 of file w5200.h.

◆ Sn_MR

#define Sn_MR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))

socket Mode register(R/W)

Sn_MR configures the option or protocol type of Socket n.

Each bit of Sn_MR defined as the following.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
MULTI | MF | ND/MC | Reserved | Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0]
  • Sn_MR_MULTI : Support UDP Multicasting
  • Sn_MR_MF : Support MACRAW
  • Sn_MR_ND : No Delayed Ack(TCP) flag
  • Sn_MR_MC : IGMP version used in UDP mulitcasting
  • Protocol
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 0 | 0 | 0 | Closed
    0 | 0 | 0 | 1 | TCP
    0 | 0 | 1 | 0 | UDP
    0 | 1 | 0 | 0 | MACRAW
  • In case of Socket 0
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 1 | 0 | 0 | MACRAW
    0 | 1 | 0 | 1 | PPPoE
    • Sn_MR_MACRAW : MAC LAYER RAW SOCK
    • Sn_MR_UDP : UDP
    • Sn_MR_TCP : TCP
    • Sn_MR_CLOSE : Unused socket
      Note
      MACRAW mode should be only used in Socket 0.

Definition at line 429 of file w5200.h.

◆ Sn_MSSR

#define Sn_MSSR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))

Maximum Segment Size(Sn_MSSR0) register address(R/W)

Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n.

Definition at line 544 of file w5200.h.

◆ Sn_PORT

#define Sn_PORT ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))

source port register(R/W)

Sn_PORT configures the source port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered.

Definition at line 509 of file w5200.h.

◆ Sn_PROTO

#define Sn_PROTO ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))

IP Protocol(PROTO) Register(R/W)

Sn_PROTO that sets the protocol number field of the IP header at the IP layer. It is valid only in IPRAW mode, and ignored in other modes.

Definition at line 552 of file w5200.h.

◆ Sn_RX_RD

#define Sn_RX_RD ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))

Read point of Receive memory(R/W)

Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.

  1. Read the starting save address of the received data.
  2. Read data from the starting address of Socket n RX Buffer.
  3. After reading the received data, Update Sn_RX_RD to the increased value as many as the reading size. If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, update with the lower 16bits value ignored the carry bit.
  4. Order RECV command is for notifying the updated Sn_RX_RD to W5200.

Definition at line 658 of file w5200.h.

◆ Sn_RX_RSR

#define Sn_RX_RSR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))

Received data size register(R)

Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. Sn_RX_RSR does not exceed the Sn_RXMEM_SIZE and is calculated as the difference between Socket n RX Write Pointer (Sn_RX_WR)and Socket n RX Read Pointer (Sn_RX_RD)

Definition at line 645 of file w5200.h.

◆ Sn_RX_WR

#define Sn_RX_WR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))

Write point of Receive memory(R)

Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 667 of file w5200.h.

◆ Sn_RXMEM_SIZE

#define Sn_RXMEM_SIZE ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E))

Receive memory size register(R/W)

Sn_RXMEM_SIZE configures the RX buffer block size of Socket n. Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. If a different size is configured, the data cannot be normally received from a peer. Although Socket n RX Buffer Block size is initially configured to 2Kbytes, user can re-configure its size using Sn_RXMEM_SIZE. The total sum of Sn_RXMEM_SIZE can not be exceed 16Kbytes. When exceeded, the data reception error is occurred.

Definition at line 588 of file w5200.h.

◆ Sn_SR

#define Sn_SR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))

Socket status register(R)

Sn_SR indicates the status of Socket n.
The status of Socket n is changed by Sn_CR or some special control packet as SYN, FIN packet in TCP.

Normal status
  • SOCK_CLOSED : Closed
  • SOCK_INIT : Initiate state
  • SOCK_LISTEN : Listen state
  • SOCK_ESTABLISHED : Success to connect
  • SOCK_CLOSE_WAIT : Closing state
  • SOCK_UDP : UDP socket
  • SOCK_MACRAW : MAC raw mode socket
Temporary status during changing the status of Socket n.
  • SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
  • SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
  • SOCK_FIN_WAIT : Connection state
  • SOCK_CLOSING : Closing state
  • SOCK_TIME_WAIT : Closing state
  • SOCK_LAST_ACK : Closing state

Definition at line 501 of file w5200.h.

◆ Sn_TOS

#define Sn_TOS ( sn ) (WIZCHIP_SREG_BLOCK(sn) + 0x0015)

IP Type of Service(TOS) Register(R/W)

Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. It is set before OPEN command.

Definition at line 560 of file w5200.h.

◆ Sn_TTL

#define Sn_TTL ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))

IP Time to live(TTL) Register(R/W)

Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. It is set before OPEN command.

Definition at line 568 of file w5200.h.

◆ Sn_TX_FSR

#define Sn_TX_FSR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))

Transmit free memory size register(R)

Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by Sn_TXMEM_SIZE. Data bigger than Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, transmit the data after dividing into the checked size and saving in the Socket n TX buffer.

Definition at line 610 of file w5200.h.

◆ Sn_TX_RD

#define Sn_TX_RD ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))

Transmit memory read pointer register address(R)

Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001), it is re-initialized while connecting with TCP. After its initialization, it is auto-increased by SEND command. SEND command transmits the saved data from the current Sn_TX_RD to the Sn_TX_WR in the Socket n TX Buffer. After transmitting the saved data, the SEND command increases the Sn_TX_RD as same as the Sn_TX_WR. If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 622 of file w5200.h.

◆ Sn_TX_WR

#define Sn_TX_WR ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))

Transmit memory write pointer register address(R/W)

Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001), it is re-initialized while connecting with TCP.
It should be read or be updated like as follows.

  1. Read the starting address for saving the transmitting data.
  2. Save the transmitting data from the starting address of Socket n TX buffer.
  3. After saving the transmitting data, update Sn_TX_WR to the increased value as many as transmitting data size. If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.
  4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command

Definition at line 636 of file w5200.h.

◆ Sn_TXMEM_SIZE

#define Sn_TXMEM_SIZE ( sn ) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F))

Transmit memory size register(R/W)

Sn_TXMEM_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. If a different size is configured, the data can't be normally transmitted to a peer. Although Socket n TX Buffer Block size is initially configured to 2Kbytes, user can be re-configure its size using Sn_TXMEM_SIZE. The total sum of Sn_TXMEM_SIZE can not be exceed 16Kbytes. When exceeded, the data transmission error is occurred.

Definition at line 599 of file w5200.h.


ioLibrary: WIZCHIP I/O functions

Modules
WIZCHIP I/O functions
W5200

This supports the basic I/O functions for WIZCHIP register. More...

Collaboration diagram for WIZCHIP I/O functions:

Modules

Basic I/O function
These are basic input/output functions to read values from register or write values to register.
Common register access functions
These are functions to access common registers.
Socket register access functions
These are functions to access socket registers.

Detailed Description

This supports the basic I/O functions for WIZCHIP register.

  • Basic I/O function
    WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()

  • Common register access functions
    1. Mode
      getMR(), setMR()
    2. Interrupt
      getIR(), setIR(), getIMR(), setIMR(), getIR2(), setIR2(), getIMR2(), setIMR2(), getINTLEVEL(), setINTLEVEL()
    3. Network Information
      getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR()
    4. Retransmission
      getRCR(), setRCR(), getRTR(), setRTR()
    5. PPPoE
      getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC()
    6. etc.
      getPHYSTATUS(), getVERSIONR()

  • Socket register access functions
    1. SOCKET control
      getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR()
    2. SOCKET information
      getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() getSn_MSSR(), setSn_MSSR()
    3. SOCKET communication
      getSn_RXMEM_SIZE(), setSn_RXMEM_SIZE(), getSn_TXMEM_SIZE(), setSn_TXMEM_SIZE()
      getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR()
      getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR()
      getSn_TX_FSR(), getSn_RX_RSR()
    4. IP header field
      getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS()
      getSn_TTL(), setSn_TTL()


ioLibrary: Basic I/O function

Functions
Basic I/O function
W5200 » WIZCHIP I/O functions

These are basic input/output functions to read values from register or write values to register. More...

Collaboration diagram for Basic I/O function:

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...

Detailed Description

These are basic input/output functions to read values from register or write values to register.

Function Documentation

◆ wiz_recv_data()

void wiz_recv_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after that, it copies the received data from internal RX memory to wizdata(pointer variable) of the length of len(variable) bytes. This function is being called by recv() also.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
wizdata | Pointer buffer to read data
len | Data length
See also
wiz_send_data()

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after copy the data from receive buffer update the Rx write pointer register. User should read upper byte first and lower byte later to get proper value. It calculate the actual physical address where one has to read the data from Receive buffer. Here also take care of the condition while it exceed the Rx memory uper-bound of socket.

Definition at line 353 of file w5100s.c.

◆ wiz_recv_ignore()

void wiz_recv_ignore | ( | uint8_t | sn,
 |  | uint16_t | len
 | ) |  |

It discard the received data in RX memory.

It discards the data of the length of len(variable) bytes in internal RX memory.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
len | Data length

Definition at line 385 of file w5100s.c.

◆ wiz_send_data()

void wiz_send_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to internal TX memory.

This function reads the Tx write pointer register and after that, it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory and updates the Tx write pointer register. This function is being called by send() and sendto() function also.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
wizdata | Pointer buffer to write data
len | Data length
See also
wiz_recv_data()

It copies data to internal TX memory.

This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer register. User should read upper byte first and lower byte later to get proper value. And this function is being used for copy the data form application buffer to Transmite buffer of the chip. It calculate the actual physical address where one has to write the data in transmite buffer. Here also take care of the condition while it exceed the Tx memory uper-bound of socket.

Definition at line 311 of file w5100s.c.

◆ WIZCHIP_READ()

uint8_t WIZCHIP_READ ( uint32_t AddrSel )

It reads 1 byte value from a register.

Parameters
AddrSel Register address
Returns
The value of register

It reads 1 byte value from a register.

Definition at line 83 of file w5100s.c.

◆ WIZCHIP_READ_BUF()

void WIZCHIP_READ_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It reads sequence data from registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to read data
len | Data length

It reads sequence data from registers.

Definition at line 181 of file w5100s.c.

◆ WIZCHIP_WRITE()

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

It writes 1 byte value to a register.

Parameters
AddrSel | Register address
wb | Write data
Returns
void

It writes 1 byte value to a register.

Definition at line 47 of file w5100s.c.

◆ WIZCHIP_WRITE_BUF()

void WIZCHIP_WRITE_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It writes sequence data to registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to write data
len | Data length

It writes sequence data to registers.

Definition at line 124 of file w5100s.c.


ioLibrary: Common register access functions

Macros
Common register access functions
W5200 » WIZCHIP I/O functions

These are functions to access common registers. More...

Collaboration diagram for Common register access functions:

Macros

#define | setMR(mr) (*((uint8_t*)MR) = mr)
Set Mode Register. More...
#define | getMR() (*(uint8_t*)MR)
Get MR. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set GAR. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get GAR. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR, subr,4)
Set SUBR. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get SUBR. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set SHAR. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get SHAR. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set SIPR. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get SIPR. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xA0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xA0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(IMR2, imr & 0xA0)
Set IMR2 register. More...
#define | getIMR() (WIZCHIP_READ(IMR2) & 0xA0)
Get IMR2 register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | getPATR() (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
Get PATR register. More...
#define | getPPPALGO() WIZCHIP_READ(PPPALGO)
Get PPPALGO register. More...
#define | getVERSIONR() WIZCHIP_READ(VERSIONR)
Get VERSIONR register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...
#define | setINTLEVEL(intlevel)
Set INTLEVEL register. More...
#define | getINTLEVEL() (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
Get INTLEVEL register. More...
#define | setIR2(ir2) WIZCHIP_WRITE(IR2, ir2)
Set IR2 register. More...
#define | getIR2() WIZCHIP_READ(IR2)
Get IR2 register. More...
#define | getPHYSTATUS() WIZCHIP_READ(PHYSTATUS)
Get PHYSTATUS register. More...
#define | setIMR2(imr2) WIZCHIP_WRITE(_IMR_, imr2)
Set IMR register. More...
#define | getIMR2() WIZCHIP_READ(_IMR_)
Get IMR register. More...

Detailed Description

These are functions to access common registers.

Macro Definition Documentation

◆ getGAR

#define getGAR ( gar ) WIZCHIP_READ_BUF(GAR,gar,4)

Get GAR.

Parameters
(uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes.
See also
setGAR()

Definition at line 1268 of file w5200.h.

◆ getIMR

#define getIMR ( ) (WIZCHIP_READ(IMR2) & 0xA0)

Get IMR2 register.

Returns
uint8_t. Value of IMR2 register.
See also
setIMR()

Definition at line 1370 of file w5200.h.

◆ getIMR2

#define getIMR2 ( ) WIZCHIP_READ(_IMR_)

Get IMR register.

Returns
uint8_t. Value of IMR2 register.
See also
setIMR2()

Definition at line 1546 of file w5200.h.

◆ getINTLEVEL

#define getINTLEVEL ( ) (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))

Get INTLEVEL register.

Returns
uint16_t. Value of INTLEVEL register.
See also
setINTLEVEL()

Definition at line 1488 of file w5200.h.

◆ getIR

#define getIR ( ) (WIZCHIP_READ(IR) & 0xA0)

Get IR register.

Returns
uint8_t. Value of IR register.
See also
setIR()

Definition at line 1342 of file w5200.h.

◆ getIR2

#define getIR2 ( ) WIZCHIP_READ(IR2)

Get IR2 register.

Returns
uint8_t. Value of IR2 register.
See also
setIR2()

Definition at line 1507 of file w5200.h.

◆ getMR

#define getMR ( ) (*(uint8_t*)MR)

Get MR.

Returns
uint8_t. The value of Mode register.
See also
setMR()

Definition at line 1250 of file w5200.h.

◆ getPATR

#define getPATR ( ) (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))

Get PATR register.

Returns
uint16_t. Value to set PATR register

Definition at line 1416 of file w5200.h.

◆ getPHYSTATUS

#define getPHYSTATUS ( ) WIZCHIP_READ(PHYSTATUS)

Get PHYSTATUS register.

Returns
uint8_t. Value to set PHYSTATUS register.

Definition at line 1516 of file w5200.h.

◆ getPMAGIC

#define getPMAGIC ( ) WIZCHIP_READ(PMAGIC)

Get PMAGIC register.

Returns
uint8_t. Value of PMAGIC register.
See also
setPMAGIC()

Definition at line 1469 of file w5200.h.

◆ getPPPALGO

#define getPPPALGO ( ) WIZCHIP_READ(PPPALGO)

Get PPPALGO register.

Returns
uint8_t. Value to set PPPALGO register

Definition at line 1424 of file w5200.h.

◆ getPTIMER

#define getPTIMER ( ) WIZCHIP_READ(PTIMER)

Get PTIMER register.

Returns
uint8_t. Value of PTIMER register.
See also
setPTIMER()

Definition at line 1451 of file w5200.h.

◆ getRCR

#define getRCR ( ) WIZCHIP_READ(_RCR_)

Get RCR register.

Returns
uint8_t. Value of RCR register.
See also
setRCR()

Definition at line 1408 of file w5200.h.

◆ getRTR

#define getRTR ( ) (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))

Get RTR register.

Returns
uint16_t. Value of RTR register.
See also
setRTR()

Definition at line 1390 of file w5200.h.

◆ getSHAR

#define getSHAR ( shar ) WIZCHIP_READ_BUF(SHAR, shar, 6)

Get SHAR.

Parameters
(uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes.
See also
setSHAR()

Definition at line 1307 of file w5200.h.

◆ getSIPR

#define getSIPR ( sipr ) WIZCHIP_READ_BUF(SIPR, sipr, 4)

Get SIPR.

Parameters
(uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes.
See also
setSIPR()

Definition at line 1325 of file w5200.h.

◆ getSUBR

#define getSUBR ( subr ) WIZCHIP_READ_BUF(SUBR, subr, 4)

Get SUBR.

Parameters
(uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes.
See also
setSUBR()

Definition at line 1289 of file w5200.h.

◆ getVERSIONR

#define getVERSIONR ( ) WIZCHIP_READ(VERSIONR)

Get VERSIONR register.

Returns
uint8_t. Value to set VERSIONR register

Definition at line 1433 of file w5200.h.

◆ setGAR

#define setGAR ( gar ) WIZCHIP_WRITE_BUF(GAR,gar,4)

Set GAR.

Parameters
(uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes.
See also
getGAR()

Definition at line 1259 of file w5200.h.

◆ setIMR

#define setIMR ( imr ) WIZCHIP_WRITE(IMR2, imr & 0xA0)

Set IMR2 register.

Parameters
(uint8_t)imr Value to set IMR2 register.
See also
getIMR()

Definition at line 1356 of file w5200.h.

◆ setIMR2

#define setIMR2 ( imr2 ) WIZCHIP_WRITE(_IMR_, imr2)

Set IMR register.

Parameters
(uint8_t)imr2 Value to set IMR2 register.
See also
getIMR2()
Note
If possible, Don't use this function. Instead, Use setSIMR() for compatible with ioLibrary.

Definition at line 1531 of file w5200.h.

◆ setINTLEVEL

#define setINTLEVEL ( intlevel )
Value:
{\
WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61
INTLEVEL
#define INTLEVEL
Set Interrupt low level timer register address(R/W)
Definition: w5200.h:346

Set INTLEVEL register.

Parameters
(uint16_t)intlevel Value to set INTLEVEL register.
See also
getINTLEVEL()

Definition at line 1478 of file w5200.h.

◆ setIR

#define setIR ( ir ) WIZCHIP_WRITE(IR, (ir & 0xA0))

Set IR register.

Parameters
(uint8_t)ir Value to set IR register.
See also
getIR()

Definition at line 1334 of file w5200.h.

◆ setIR2

#define setIR2 ( ir2 ) WIZCHIP_WRITE(IR2, ir2)

Set IR2 register.

Parameters
(uint8_t)ir2 Value to set IR2 register.
See also
getIR2()

Definition at line 1497 of file w5200.h.

◆ setMR

#define setMR ( mr ) (*((uint8_t*)MR) = mr)

Set Mode Register.

Parameters
(uint8_t)mr The value to be set.
See also
getMR()

Definition at line 1238 of file w5200.h.

◆ setPMAGIC

#define setPMAGIC ( pmagic ) WIZCHIP_WRITE(PMAGIC, pmagic)

Set PMAGIC register.

Parameters
(uint8_t)pmagic Value to set PMAGIC register.
See also
getPMAGIC()

Definition at line 1460 of file w5200.h.

◆ setPTIMER

#define setPTIMER ( ptimer ) WIZCHIP_WRITE(PTIMER, ptimer)

Set PTIMER register.

Parameters
(uint8_t)ptimer Value to set PTIMER register.
See also
getPTIMER()

Definition at line 1442 of file w5200.h.

◆ setRCR

#define setRCR ( rcr ) WIZCHIP_WRITE(_RCR_, rcr)

Set RCR register.

Parameters
(uint8_t)rcr Value to set RCR register.
See also
getRCR()

Definition at line 1399 of file w5200.h.

◆ setRTR

#define setRTR ( rtr )
Value:
{\
WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
}
_RTR_
#define _RTR_
Timeout register address( 1 is 100us )(R/W)
Definition: w5200.h:275
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61

Set RTR register.

Parameters
(uint16_t)rtr Value to set RTR register.
See also
getRTR()

Definition at line 1379 of file w5200.h.

◆ setSHAR

#define setSHAR ( shar ) WIZCHIP_WRITE_BUF(SHAR, shar, 6)

Set SHAR.

Parameters
(uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes.
See also
getSHAR()

Definition at line 1298 of file w5200.h.

◆ setSIPR

#define setSIPR ( sipr ) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)

Set SIPR.

Parameters
(uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes.
See also
getSIPR()

Definition at line 1316 of file w5200.h.

◆ setSUBR

#define setSUBR ( subr ) WIZCHIP_WRITE_BUF(SUBR, subr,4)

Set SUBR.

Parameters
(uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes.
Note
If subr is null pointer, set the backup subnet to SUBR.
If subr is 0.0.0.0, back up SUBR and clear it.
Otherwize, set subr to SUBR
See also
getSUBR()

Definition at line 1280 of file w5200.h.


ioLibrary: Socket register access functions

Macros | Functions
Socket register access functions
W5200 » WIZCHIP I/O functions

These are functions to access socket registers. More...

Collaboration diagram for Socket register access functions:

Macros

#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ir)
Set Sn_IR register. More...
#define | getSn_IR(sn) WIZCHIP_READ(Sn_IR(sn))
Get Sn_IR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), imr)
Set Sn_IMR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), imr)
Set Sn_IMR register. More...
#define | getSn_IMR(sn) WIZCHIP_READ(Sn_IMR(sn))
Get Sn_IMR register. More...
#define | getSn_IMR(sn) WIZCHIP_READ(Sn_IMR(sn))
Get Sn_IMR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_DHAR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_PROTO(sn, proto) WIZCHIP_WRITE(Sn_PROTO(sn), proto)
Set Sn_PROTO register. More...
#define | getSn_PROTO(sn) WIZCHIP_READ(Sn_PROTO(sn))
Get Sn_PROTO register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXMEM_SIZE(sn, rxmemsize) WIZCHIP_WRITE(Sn_RXMEM_SIZE(sn),rxmemsize)
Set Sn_RXMEM_SIZE register. More...
#define | getSn_RXMEM_SIZE(sn) WIZCHIP_READ(Sn_RXMEM_SIZE(sn))
Get Sn_RXMEM_SIZE register. More...
#define | setSn_TXMEM_SIZE(sn, txmemsize) WIZCHIP_WRITE(Sn_TXMEM_SIZE(sn), txmemsize)
Set Sn_TXMEM_SIZE register. More...
#define | getSn_TXMEM_SIZE(sn) WIZCHIP_READ(Sn_TXMEM_SIZE(sn))
Get Sn_TXMEM_SIZE register. More...
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | setSn_RX_WR(sn, rxwr)
Set Sn_RX_WR register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_FRAG(sn, frag)
Set Sn_FRAG register. More...
#define | getSn_FRAG(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
Get Sn_FRAG register. More...
#define | getSn_RxMAX(sn) ((uint16_t)getSn_RXMEM_SIZE(sn) << 10)
Get the max RX buffer size of socket sn. More...
#define | getSn_TxMAX(sn) ((uint16_t)getSn_TXMEM_SIZE(sn) << 10)
Get the max TX buffer size of socket sn. More...
#define | getSn_RxMASK(sn) ((uint16_t)getSn_RxMAX(sn) - 1)
Get the mask of socket sn RX buffer. More...
#define | getSn_TxMASK(sn) ((uint16_t)getSn_TxMAX(sn) - 1)
Get the mask of socket sn TX buffer. More...

Functions

uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
uint16_t | getSn_RxBASE (uint8_t sn)
Get the base address of socket sn RX buffer. More...
uint16_t | getSn_TxBASE (uint8_t sn)
Get the base address of socket sn TX buffer. More...

Detailed Description

These are functions to access socket registers.

Macro Definition Documentation

◆ getSn_CR

#define getSn_CR ( sn ) WIZCHIP_READ(Sn_CR(sn))

Get Sn_CR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_CR.
See also
setSn_CR()

Definition at line 1589 of file w5200.h.

◆ getSn_DHAR

#define getSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)

Get Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dhar | Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes.
See also
setSn_DHAR()

Definition at line 1680 of file w5200.h.

◆ getSn_DIPR

#define getSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)

Get Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dipr | Pointer variable to get socket n destination IP address. It should be allocated 4 bytes.
See also
SetSn_DIPR()

Definition at line 1700 of file w5200.h.

◆ getSn_DPORT

#define getSn_DPORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))

Get Sn_DPORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_DPORT.
See also
setSn_DPORT()

Definition at line 1722 of file w5200.h.

◆ getSn_FRAG

#define getSn_FRAG ( sn ) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))

Get Sn_FRAG register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_FRAG.
See also
setSn_FRAG()

Definition at line 1995 of file w5200.h.

◆ getSn_IMR [1/2]

#define getSn_IMR ( sn ) WIZCHIP_READ(Sn_IMR(sn))

Get Sn_IMR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_IMR.
See also
setSn_IMR()

Definition at line 1973 of file w5200.h.

◆ getSn_IMR [2/2]

#define getSn_IMR ( sn ) WIZCHIP_READ(Sn_IMR(sn))

Get Sn_IMR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_IMR.
See also
setSn_IMR()

Definition at line 1973 of file w5200.h.

◆ getSn_IR

#define getSn_IR ( sn ) WIZCHIP_READ(Sn_IR(sn))

Get Sn_IR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_IR.
See also
setSn_IR()

Definition at line 1609 of file w5200.h.

◆ getSn_MR

#define getSn_MR ( sn ) WIZCHIP_READ(Sn_MR(sn))

Get Sn_MR register.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.
Returns
Value of Sn_MR.
See also
setSn_MR()

Definition at line 1569 of file w5200.h.

◆ getSn_MSSR

#define getSn_MSSR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))

Get Sn_MSSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_MSSR.
See also
setSn_MSSR()

Definition at line 1744 of file w5200.h.

◆ getSn_PORT

#define getSn_PORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))

Get Sn_PORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_PORT.
See also
setSn_PORT()

Definition at line 1660 of file w5200.h.

◆ getSn_PROTO

#define getSn_PROTO ( sn ) WIZCHIP_READ(Sn_PROTO(sn))

Get Sn_PROTO register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_PROTO.
See also
setSn_PROTO()

Definition at line 1774 of file w5200.h.

◆ getSn_RX_RD

#define getSn_RX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))

Get Sn_RX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_RD.
See also
setSn_RX_RD()

Definition at line 1931 of file w5200.h.

◆ getSn_RX_WR

#define getSn_RX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))

Get Sn_RX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_WR.

Definition at line 1953 of file w5200.h.

◆ getSn_RxMASK

#define getSn_RxMASK ( sn ) ((uint16_t)getSn_RxMAX(sn) - 1)

Get the mask of socket sn RX buffer.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Mask value

Definition at line 2022 of file w5200.h.

◆ getSn_RxMAX

#define getSn_RxMAX ( sn ) ((uint16_t)getSn_RXMEM_SIZE(sn) << 10)

Get the max RX buffer size of socket sn.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Max buffer size

Definition at line 2004 of file w5200.h.

◆ getSn_RXMEM_SIZE

#define getSn_RXMEM_SIZE ( sn ) WIZCHIP_READ(Sn_RXMEM_SIZE(sn))

Get Sn_RXMEM_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_RXMEM.
See also
setSn_RXMEM_SIZE()

Definition at line 1836 of file w5200.h.

◆ getSn_SR

#define getSn_SR ( sn ) WIZCHIP_READ(Sn_SR(sn))

Get Sn_SR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_SR.

Definition at line 1638 of file w5200.h.

◆ getSn_TOS

#define getSn_TOS ( sn ) WIZCHIP_READ(Sn_TOS(sn))

Get Sn_TOS register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
Returns
uint8_t. Value of Sn_TOS.
See also
setSn_TOS()

Definition at line 1794 of file w5200.h.

◆ getSn_TTL

#define getSn_TTL ( sn ) WIZCHIP_READ(Sn_TTL(sn))

Get Sn_TTL register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
Returns
uint8_t. Value of Sn_TTL.
See also
setSn_TTL()

Definition at line 1814 of file w5200.h.

◆ getSn_TX_RD

#define getSn_TX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))

Get Sn_TX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_RD.

Definition at line 1879 of file w5200.h.

◆ getSn_TX_WR

#define getSn_TX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))

Get Sn_TX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_WR.
See also
setSn_TX_WR()

Definition at line 1901 of file w5200.h.

◆ getSn_TxMASK

#define getSn_TxMASK ( sn ) ((uint16_t)getSn_TxMAX(sn) - 1)

Get the mask of socket sn TX buffer.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Mask value

Definition at line 2031 of file w5200.h.

◆ getSn_TxMAX

#define getSn_TxMAX ( sn ) ((uint16_t)getSn_TXMEM_SIZE(sn) << 10)

Get the max TX buffer size of socket sn.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Max buffer size

Definition at line 2013 of file w5200.h.

◆ getSn_TXMEM_SIZE

#define getSn_TXMEM_SIZE ( sn ) WIZCHIP_READ(Sn_TXMEM_SIZE(sn))

Get Sn_TXMEM_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_TXMEM_SIZE.
See also
setSn_TXMEM_SIZE()

Definition at line 1860 of file w5200.h.

◆ setSn_CR

#define setSn_CR | ( | sn,
 |  | cr
 | ) | WIZCHIP_WRITE(Sn_CR(sn), cr)

Set Sn_CR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)cr | Value to set Sn_CR
See also
getSn_CR()

Definition at line 1579 of file w5200.h.

◆ setSn_DHAR

#define setSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)

Set Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dhar | Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes.
See also
getSn_DHAR()

Definition at line 1670 of file w5200.h.

◆ setSn_DIPR

#define setSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)

Set Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t*)dipr | Pointer variable to set socket n destination IP address. It should be allocated 4 bytes.
See also
getSn_DIPR()

Definition at line 1690 of file w5200.h.

◆ setSn_DPORT

#define setSn_DPORT | ( | sn,
 |  | dport
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
}
Sn_DPORT
#define Sn_DPORT(sn)
Peer port register address(R/W)
Definition: w5200.h:537
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61

Set Sn_DPORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)dport | Value to set Sn_DPORT
See also
getSn_DPORT()

Definition at line 1710 of file w5200.h.

◆ setSn_FRAG

#define setSn_FRAG | ( | sn,
 |  | frag
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
}
Sn_FRAG
#define Sn_FRAG(sn)
Fragment field value in IP header register(R/W)
Definition: w5200.h:684
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61

Set Sn_FRAG register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)frag | Value to set Sn_FRAG
See also
getSn_FRAG()

Definition at line 1983 of file w5200.h.

◆ setSn_IMR [1/2]

#define setSn_IMR | ( | sn,
 |  | imr
 | ) | WIZCHIP_WRITE(Sn_IMR(sn), imr)

Set Sn_IMR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)imr | Value to set Sn_IMR
See also
getSn_IMR()
Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)imr | Value to set Sn_IMR
See also
getSn_IMR()

Definition at line 1963 of file w5200.h.

◆ setSn_IMR [2/2]

#define setSn_IMR | ( | sn,
 |  | imr
 | ) | WIZCHIP_WRITE(Sn_IMR(sn), imr)

Set Sn_IMR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)imr | Value to set Sn_IMR
See also
getSn_IMR()
Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)imr | Value to set Sn_IMR
See also
getSn_IMR()

Definition at line 1963 of file w5200.h.

◆ setSn_IR

#define setSn_IR | ( | sn,
 |  | ir
 | ) | WIZCHIP_WRITE(Sn_IR(sn), ir)

Set Sn_IR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)ir | Value to set Sn_IR
See also
getSn_IR()

Definition at line 1599 of file w5200.h.

◆ setSn_MR

#define setSn_MR | ( | sn,
 |  | mr
 | ) | WIZCHIP_WRITE(Sn_MR(sn),mr)

Set Sn_MR register.

Parameters
sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ expect bit 4.
mr | Value to set Sn_MR
See also
getSn_MR()

Definition at line 1559 of file w5200.h.

◆ setSn_MSSR

#define setSn_MSSR | ( | sn,
 |  | mss
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61
Sn_MSSR
#define Sn_MSSR(sn)
Maximum Segment Size(Sn_MSSR0) register address(R/W)
Definition: w5200.h:544

Set Sn_MSSR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)mss | Value to set Sn_MSSR
See also
setSn_MSSR()

Definition at line 1732 of file w5200.h.

◆ setSn_PORT

#define setSn_PORT | ( | sn,
 |  | port
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
}
Sn_PORT
#define Sn_PORT(sn)
source port register(R/W)
Definition: w5200.h:509
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61

Set Sn_PORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)port | Value to set Sn_PORT.
See also
getSn_PORT()

Definition at line 1648 of file w5200.h.

◆ setSn_PROTO

#define setSn_PROTO | ( | sn,
 |  | proto
 | ) | WIZCHIP_WRITE(Sn_PROTO(sn), proto)

Set Sn_PROTO register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)proto | Value to set Sn_PROTO
See also
getSn_PROTO()

Definition at line 1759 of file w5200.h.

◆ setSn_RX_RD

#define setSn_RX_RD | ( | sn,
 |  | rxrd
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
}
Sn_RX_RD
#define Sn_RX_RD(sn)
Read point of Receive memory(R/W)
Definition: w5200.h:658
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61

Set Sn_RX_RD register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)rxrd | Value to set Sn_RX_RD
See also
getSn_RX_RD()

Definition at line 1919 of file w5200.h.

◆ setSn_RX_WR

#define setSn_RX_WR | ( | sn,
 |  | rxwr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61
Sn_RX_WR
#define Sn_RX_WR(sn)
Write point of Receive memory(R)
Definition: w5200.h:667

Set Sn_RX_WR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)rxwr | Value to set Sn_RX_WR
See also
getSn_RX_WR()

Definition at line 1941 of file w5200.h.

◆ setSn_RXMEM_SIZE

#define setSn_RXMEM_SIZE | ( | sn,
 |  | rxmemsize
 | ) | WIZCHIP_WRITE(Sn_RXMEM_SIZE(sn),rxmemsize)

Set Sn_RXMEM_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
(uint8_t)rxmemsize | Value to set Sn_RXMEM_SIZE
See also
getSn_RXMEM_SIZE()

Definition at line 1824 of file w5200.h.

◆ setSn_TOS

#define setSn_TOS | ( | sn,
 |  | tos
 | ) | WIZCHIP_WRITE(Sn_TOS(sn), tos)

Set Sn_TOS register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)tos | Value to set Sn_TOS
See also
getSn_TOS()

Definition at line 1784 of file w5200.h.

◆ setSn_TTL

#define setSn_TTL | ( | sn,
 |  | ttl
 | ) | WIZCHIP_WRITE(Sn_TTL(sn), ttl)

Set Sn_TTL register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
(uint8_t)ttl | Value to set Sn_TTL
See also
getSn_TTL()

Definition at line 1804 of file w5200.h.

◆ setSn_TX_WR

#define setSn_TX_WR | ( | sn,
 |  | txwr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5200.h:61
Sn_TX_WR
#define Sn_TX_WR(sn)
Transmit memory write pointer register address(R/W)
Definition: w5200.h:636

Set Sn_TX_WR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint16_t)txwr | Value to set Sn_TX_WR
See also
GetSn_TX_WR()

Definition at line 1889 of file w5200.h.

◆ setSn_TXMEM_SIZE

#define setSn_TXMEM_SIZE | ( | sn,
 |  | txmemsize
 | ) | WIZCHIP_WRITE(Sn_TXMEM_SIZE(sn), txmemsize)

Set Sn_TXMEM_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)txmemsize | Value to set Sn_TXMEM_SIZE
See also
getSn_TXMEM_SIZE()

Definition at line 1848 of file w5200.h.

Function Documentation

◆ getSn_RX_RSR()

uint16_t getSn_RX_RSR ( uint8_t sn )

Get Sn_RX_RSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_RSR.

Definition at line 254 of file w5100s.c.

◆ getSn_RxBASE()

uint16_t getSn_RxBASE ( uint8_t sn )

Get the base address of socket sn RX buffer.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n RX buffer base address.

Definition at line 273 of file w5100s.c.

◆ getSn_TX_FSR()

uint16_t getSn_TX_FSR ( uint8_t sn )

Get Sn_TX_FSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_FSR.

Definition at line 237 of file w5100s.c.

◆ getSn_TxBASE()

uint16_t getSn_TxBASE ( uint8_t sn )

Get the base address of socket sn TX buffer.

Parameters
sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Socket n TX buffer base address.

Definition at line 287 of file w5100s.c.


ioLibrary: W5300

Modules
W5300

WHIZCHIP register defines and I/O functions of W5300. More...

Collaboration diagram for W5300:

Modules

WIZCHIP register
WHIZCHIP register defines register group of W5300.
WIZCHIP I/O functions
This supports the basic I/O functions for WIZCHIP register.

Detailed Description

WHIZCHIP register defines and I/O functions of W5300.

  • WIZCHIP register : Common register and Socket register
  • WIZCHIP I/O functions : Basic I/O function, Common register access functions and Socket register access functions


ioLibrary: WIZCHIP register

Modules
WIZCHIP register
W5300

WHIZCHIP register defines register group of W5300. More...

Collaboration diagram for WIZCHIP register:

Modules

Common register
Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.
Socket register
Socket register group.
Socket register configures and control SOCKETn which is necessary to data communication.

Detailed Description

WHIZCHIP register defines register group of W5300.

  • Common register : Common register group
  • Socket register : SOCKET n register group


ioLibrary: Common register

Macros
Common register
W5300 » WIZCHIP register

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc. More...

Collaboration diagram for Common register:

Macros

#define | MR (_WIZCHIP_IO_BASE_)
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | IR (_W5300_IO_BASE_ + 0x02)
Interrupt Register(R/W) More...
#define | _IMR_ (_W5300_IO_BASE_ + 0x04)
Socket Interrupt Mask Register(R/W) More...
#define | SHAR (_W5300_IO_BASE_ + 0x08)
Source MAC Register address(R/W) More...
#define | GAR (_W5300_IO_BASE_ + 0x10)
Gateway IP Register address(R/W) More...
#define | SUBR (_W5300_IO_BASE_ + 0x14)
Subnet mask Register address(R/W) More...
#define | SIPR (_W5300_IO_BASE_ + 0x18)
Source IP Register address(R/W) More...
#define | _RTR_ (_W5300_IO_BASE_ + 0x1C)
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5300_IO_BASE_ + 0x1E)
Retry count register(R/W) More...
#define | TMS01R (_W5300_IO_BASE_ + 0x20)
TX memory size of SOCKET 0 & 1. More...
#define | TMS23R (TMS01R + 2)
TX memory size of SOCKET 2 & 3. More...
#define | TMS45R (TMS01R + 4)
TX memory size of SOCKET 4 & 5. More...
#define | TMS67R (TMS01R + 6)
TX memory size of SOCKET 6 & 7. More...
#define | TMSR0 TMS01R
TX memory size of SOCKET 0. More...
#define | TMSR1 (TMSR0 + 1)
TX memory size of SOCKET 1. More...
#define | TMSR2 (TMSR0 + 2)
TX memory size of SOCKET 2. More...
#define | TMSR3 (TMSR0 + 3)
TX memory size of SOCKET 3. More...
#define | TMSR4 (TMSR0 + 4)
TX memory size of SOCKET 4. More...
#define | TMSR5 (TMSR0 + 5)
TX memory size of SOCKET 5. More...
#define | TMSR6 (TMSR0 + 6)
TX memory size of SOCKET 6. More...
#define | TMSR7 (TMSR0 + 7)
TX memory size of SOCKET 7. More...
#define | RMS01R (_W5300_IO_BASE_ + 0x28)
RX memory size of SOCKET 0 & 1. More...
#define | RMS23R (RMS01R + 2)
RX memory size of SOCKET 2 & 3. More...
#define | RMS45R (RMS01R + 4)
RX memory size of SOCKET 4 & 5. More...
#define | RMS67R (RMS01R + 6)
RX memory size of SOCKET 6 & 7. More...
#define | RMSR0 RMS01R
RX memory size of SOCKET 0. More...
#define | RMSR1 (RMSR0 + 1)
RX memory size of SOCKET 1. More...
#define | RMSR3 (RMSR0 + 3)
RX memory size of SOCKET 3. More...
#define | RMSR4 (RMSR0 + 4)
RX memory size of SOCKET 4. More...
#define | RMSR5 (RMSR0 + 5)
RX memory size of SOCKET 5. More...
#define | RMSR6 (RMSR0 + 6)
RX memory size of SOCKET 6. More...
#define | RMSR7 (RMSR0 + 7)
RX memory size of SOCKET 7. More...
#define | MTYPER (_W5300_IO_BASE_ + 0x30)
Memory Type Register. More...
#define | PATR (_W5300_IO_BASE_ + 0x32)
PPPoE Authentication Type register. More...
#define | PTIMER (_W5300_IO_BASE_ + 0x36)
PPP Link Control Protocol Request Timer Register. More...
#define | PMAGICR (_W5300_IO_BASE_ + 0x38)
PPP LCP magic number register. More...
#define | PSIDR (_W5300_IO_BASE_ + 0x3C)
PPPoE session ID register. More...
#define | PDHAR (_W5300_IO_BASE_ + 0x40)
PPPoE destination hardware address register. More...
#define | UIPR (_W5300_IO_BASE_ + 0x48)
Unreachable IP address register. More...
#define | UPORTR (_W5300_IO_BASE_ + 0x4C)
Unreachable port number register. More...
#define | FMTUR (_W5300_IO_BASE_ + 0x4E)
Fragment MTU register. More...
#define | Pn_BRDYR(n) (_W5300_IO_BASE_ + 0x60 + n*4)
PIN 'BRDYn' configure register. More...
#define | Pn_BDPTHR(n) (_W5300_IO_BASE_ + 0x60 + n*4 + 2)
PIN 'BRDYn' buffer depth Register. More...
#define | IDR (_W5300_IO_BASE_ + 0xFE)
W5300 identification register. More...

Detailed Description

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.

See also
MR : Mode register.
GAR, SUBR, SHAR, SIPR : Network Configuration
IR, IMR : Interrupt.
MTYPER, TMS01R,TMS23R, TMS45R, TMS67R,RMS01R,RMS23R, RMS45R, RMS67R : Socket TX/RX memory
RTR, RCR : Data retransmission.
PTIMER, PMAGIC, PSID, PDHAR : PPPoE.
UIPR, UPORTR, FMTUR : ICMP message.
Pn_BRDYR, Pn_BDPTHR, IDR : etc.

Macro Definition Documentation

◆ _IMR_

#define _IMR_ (_W5300_IO_BASE_ + 0x04)

Socket Interrupt Mask Register(R/W)

Each bit of IMR corresponds to each bit of IR. When a bit of IMR is and the corresponding bit of IR is Interrupt will be issued. In other words, if a bit of IMR, an interrupt will be not issued even if the corresponding bit of IR is set

Note
: In W5300, IMR is operated same as IMR and SIMR in other WIZCHIP(5100,5200,W5500)

Definition at line 256 of file w5300.h.

◆ _RCR_

#define _RCR_ (_W5300_IO_BASE_ + 0x1E)

Retry count register(R/W)

RCR configures the number of time of retransmission. When retransmission occurs as many as ref RCR+1 Timeout interrupt is issued (Sn_IR_TIMEOUT = '1').

Definition at line 307 of file w5300.h.

◆ _RTR_

#define _RTR_ (_W5300_IO_BASE_ + 0x1C)

Timeout register address( 1 is 100us )(R/W)

RTR configures the retransmission timeout period. The unit of timeout period is 100us and the default of RTR is x07D0. And so the default timeout period is 200ms(100us X 2000). During the time configured by RTR, W5300 waits for the peer response to the packet that is transmitted by Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). If the peer does not respond within the RTR time, W5300 retransmits the packet or issues timeout.

Definition at line 299 of file w5300.h.

◆ FMTUR

#define FMTUR (_W5300_IO_BASE_ + 0x4E)

Fragment MTU register.

When communicating with the peer having a different MTU, W5300 can receive an ICMP(Fragment MTU) packet. At this case, IR(FMTU) becomes ‘1’ and destination IP address and fragment MTU value of ICMP packet can be acquired through UIPR and FMTUR. In order to keep communicating with the peer having Fragment MTU, set the FMTUR first in Sn_MSSR of the SOCKETn, and try the next communication.

Definition at line 561 of file w5300.h.

◆ GAR

#define GAR (_W5300_IO_BASE_ + 0x10)

Gateway IP Register address(R/W)

GAR configures the default gateway address.

Definition at line 275 of file w5300.h.

◆ IDR

#define IDR (_W5300_IO_BASE_ + 0xFE)

W5300 identification register.

Read Only. 0x5300.

Definition at line 601 of file w5300.h.

◆ IR

#define IR (_W5300_IO_BASE_ + 0x02)

Interrupt Register(R/W)

IR indicates the interrupt status. Each bit of IR will be still until the bit will be written to by the host. If IR is not equal to 0x0000 INTn PIN is asserted to low until it is 0x0000

Each bit of IR defined as follows.

15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
IPCF | DPUR | PPPT | FMTU | Reserved | Reserved | Reserved | Reserved
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
S7_INT | S6_INT | S5_INT | S4_INT | S3_INT | S2_INT | S1_INT | S0_INT
  • IR_IPCF : IP conflict
  • IR_DPUR : Destination Port Unreachable
  • IR_PPPT : PPPoE Termination
  • IR_FMTU : Fragmented MTU
  • IR_SnINT(n) : Interrupted from SOCKETn
Note
: In W5300, IR is operated same as IR and SIR in other WIZCHIP(5100,5200,W5500)

Definition at line 246 of file w5300.h.

◆ MR

#define MR (_WIZCHIP_IO_BASE_)

Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc.

Each bit of MR defined as follows.

15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
DBW | MPF | WDF |  |  | RDF | Reserved | FS
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
RST | Reserved | WOL | PB | PPPoE | Reserved | FARP | Reserved
  • MR_DBW : Data bus width (0 : 8 Bit, 1 : 16 Bit), Read Only
  • MR_MPF : Received a Pause Frame from MAC layer (0 : Normal Frame, 1 : Pause Frame), Read Only
  • MR_WDF : Write Data Fetch time (When CS signal is low, W5300 Fetch a written data by Host after PLL_CLK * MR_WDF)
  • MR_RDH : Read Data Hold time (0 : No use data hold time, 1 : Use data hold time, 2 PLL_CLK)
  • MR_FS : FIFO Swap (0 : Disable Swap, 1 : Enable Swap)
  • MR_RST : Reset
  • MR_WOL : Wake on LAN
  • MR_PB : Ping block
  • MR_PPPOE : PPPoE mode
  • MR_FARP : Force ARP mode

Definition at line 224 of file w5300.h.

◆ MTYPER

#define MTYPER (_W5300_IO_BASE_ + 0x30)

Memory Type Register.

W5300’s 128Kbytes data memory (Internal TX/RX memory) is composed of 16 memory blocks of 8Kbytes. MTYPER configures type of each 8KB memory block in order to select RX or TX memory. The type of 8KB memory block corresponds to each bit of MTYPER. When the bit is ‘1’, it is used as TX memory, and the bit is ‘0’, it is used as RX memory. MTYPER is configured as TX memory type from the lower bit. The rest of the bits not configured as TX memory, should be set as ‘0’.

Definition at line 493 of file w5300.h.

◆ PATR

#define PATR (_W5300_IO_BASE_ + 0x32)

PPPoE Authentication Type register.

It notifies authentication method negotiated with PPPoE server. W5300 supports 2 types of authentication methods.

  • PAP : 0xC023
  • CHAP : 0xC223

Definition at line 503 of file w5300.h.

◆ PDHAR

#define PDHAR (_W5300_IO_BASE_ + 0x40)

PPPoE destination hardware address register.

It notifies hardware address of PPPoE server (acquired by PPPoE-process of W5300).

Definition at line 535 of file w5300.h.

◆ PMAGICR

#define PMAGICR (_W5300_IO_BASE_ + 0x38)

PPP LCP magic number register.

It configures byte value to be used for 4bytes “Magic Number” during LCP negotiation with PPPoE server.

Definition at line 519 of file w5300.h.

◆ Pn_BDPTHR

#define Pn_BDPTHR ( n ) (_W5300_IO_BASE_ + 0x60 + n*4 + 2)

PIN 'BRDYn' buffer depth Register.

It configures buffer depth of PIN "BRDYn". When monitoring TX memory and Sn_TX_FSR is same or bigger than Pn_BDPTHR, the PIN "BRDYn" is signaled. When monitoring RX memory and if Sn_RX_RSR is same or bigger than Pn_BDPTHR, PIN "BRDYn" is signaled. The value for Pn_BDPTHR can't exceed TX/RX memory size allocated by TMSR or RMSR such like as TMS01R or RMS01R.

Definition at line 594 of file w5300.h.

◆ Pn_BRDYR

#define Pn_BRDYR ( n ) (_W5300_IO_BASE_ + 0x60 + n*4)

PIN 'BRDYn' configure register.

It configures the PIN "BRDYn" which is monitoring TX/RX memory status of the specified SOCKET. If the free buffer size of TX memory is same or bigger than the buffer depth of Pn_BDPTHR, or received buffer size of RX memory is same or bigger than the Pn_BDPTHR, PIN "BRDYn" is signaled.

15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
Reserved, Read as 0
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
PEN | MT | PPL | Reserved |  | SN
  • Pn_PEN Enable PIN 'BRDYn' (0 : Disable, 1 : Enable)
  • Pn_MT Monitoring Memory type (0 : RX memory, 1 : TX Memory)
  • Pn_PPL PIN Polarity bit of Pn_BRDYR. (0 : Low sensitive, 1 : High sensitive)
  • Pn_SN(n) Monitoring SOCKET number of Pn_BRDYR

Definition at line 584 of file w5300.h.

◆ PSIDR

#define PSIDR (_W5300_IO_BASE_ + 0x3C)

PPPoE session ID register.

It notifies PPP session ID to be used for communication with PPPoE server (acquired by PPPoE-process of W5300).

Definition at line 528 of file w5300.h.

◆ PTIMER

#define PTIMER (_W5300_IO_BASE_ + 0x36)

PPP Link Control Protocol Request Timer Register.

It configures transmitting timer of link control protocol (LCP) echo request. Value 1 is about 25ms.

Definition at line 512 of file w5300.h.

◆ RMS01R

#define RMS01R (_W5300_IO_BASE_ + 0x28)

RX memory size of SOCKET 0 & 1.

RMS01R configures the RX buffer block size of SOCKET 0 & 1. The default value is configured with 8KB and can be configure from 0 to 64KB with unit 1KB. But the sum of all SOCKET RX buffer size should be multiple of 8 and the sum of all SOCKET RX and TX memory size can't exceed 128KB. When exceeded nor multiple of 8, the data reception is invalid.

Definition at line 403 of file w5300.h.

◆ RMS23R

#define RMS23R (RMS01R + 2)

RX memory size of SOCKET 2 & 3.

Refer to RMS01R

Definition at line 410 of file w5300.h.

◆ RMS45R

#define RMS45R (RMS01R + 4)

RX memory size of SOCKET 4 & 5.

Refer to RMS01R

Definition at line 417 of file w5300.h.

◆ RMS67R

#define RMS67R (RMS01R + 6)

RX memory size of SOCKET 6 & 7.

Refer to RMS01R

Definition at line 424 of file w5300.h.

◆ RMSR0

#define RMSR0 RMS01R

RX memory size of SOCKET 0.

refer to RMS01R

Definition at line 431 of file w5300.h.

◆ RMSR1

#define RMSR1 (RMSR0 + 1)

RX memory size of SOCKET 1.

refer to RMS01R

Definition at line 438 of file w5300.h.

◆ RMSR3

#define RMSR3 (RMSR0 + 3)

RX memory size of SOCKET 3.

refer to RMS01R

Definition at line 452 of file w5300.h.

◆ RMSR4

#define RMSR4 (RMSR0 + 4)

RX memory size of SOCKET 4.

refer to RMS01R

Definition at line 459 of file w5300.h.

◆ RMSR5

#define RMSR5 (RMSR0 + 5)

RX memory size of SOCKET 5.

refer to RMS01R

Definition at line 466 of file w5300.h.

◆ RMSR6

#define RMSR6 (RMSR0 + 6)

RX memory size of SOCKET 6.

refer to RMS01R

Definition at line 473 of file w5300.h.

◆ RMSR7

#define RMSR7 (RMSR0 + 7)

RX memory size of SOCKET 7.

refer to RMS01R

Definition at line 480 of file w5300.h.

◆ SHAR

#define SHAR (_W5300_IO_BASE_ + 0x08)

Source MAC Register address(R/W)

SHAR configures the source hardware address.

Definition at line 267 of file w5300.h.

◆ SIPR

#define SIPR (_W5300_IO_BASE_ + 0x18)

Source IP Register address(R/W)

SIPR configures the source IP address.

Definition at line 289 of file w5300.h.

◆ SUBR

#define SUBR (_W5300_IO_BASE_ + 0x14)

Subnet mask Register address(R/W)

SUBR configures the subnet mask address.

Definition at line 282 of file w5300.h.

◆ TMS01R

#define TMS01R (_W5300_IO_BASE_ + 0x20)

TX memory size of SOCKET 0 & 1.

TMS01R configures the TX buffer block size of SOCKET 0 & 1. The default value is configured with 8KB and can be configure from 0 to 64KB with unit 1KB. But the sum of all SOCKET TX buffer size should be multiple of 8 and the sum of all SOCKET TX and RX memory size can't exceed 128KB. When exceeded nor multiple of 8, the data transmittion is invalid.

Definition at line 316 of file w5300.h.

◆ TMS23R

#define TMS23R (TMS01R + 2)

TX memory size of SOCKET 2 & 3.

refer to TMS01R

Definition at line 323 of file w5300.h.

◆ TMS45R

#define TMS45R (TMS01R + 4)

TX memory size of SOCKET 4 & 5.

refer to TMS01R

Definition at line 330 of file w5300.h.

◆ TMS67R

#define TMS67R (TMS01R + 6)

TX memory size of SOCKET 6 & 7.

refer to TMS01R

Definition at line 337 of file w5300.h.

◆ TMSR0

#define TMSR0 TMS01R

TX memory size of SOCKET 0.

refer to TMS01R

Definition at line 344 of file w5300.h.

◆ TMSR1

#define TMSR1 (TMSR0 + 1)

TX memory size of SOCKET 1.

refer to TMS01R

Definition at line 351 of file w5300.h.

◆ TMSR2

#define TMSR2 (TMSR0 + 2)

TX memory size of SOCKET 2.

refer to TMS01R

Definition at line 358 of file w5300.h.

◆ TMSR3

#define TMSR3 (TMSR0 + 3)

TX memory size of SOCKET 3.

refer to TMS01R

Definition at line 365 of file w5300.h.

◆ TMSR4

#define TMSR4 (TMSR0 + 4)

TX memory size of SOCKET 4.

refer to TMS01R

Definition at line 372 of file w5300.h.

◆ TMSR5

#define TMSR5 (TMSR0 + 5)

TX memory size of SOCKET 5.

refer to TMS01R

Definition at line 379 of file w5300.h.

◆ TMSR6

#define TMSR6 (TMSR0 + 6)

TX memory size of SOCKET 6.

refer to TMS01R

Definition at line 386 of file w5300.h.

◆ TMSR7

#define TMSR7 (TMSR0 + 7)

TX memory size of SOCKET 7.

refer to TMS01R

Definition at line 393 of file w5300.h.

◆ UIPR

#define UIPR (_W5300_IO_BASE_ + 0x48)

Unreachable IP address register.

When trying to transmit UDP data to destination port number which is not open, W5300 can receive ICMP (Destination port unreachable) packet.
In this case, IR_DPUR bit of IR becomes '1'. And destination IP address and unreachable port number of ICMP packet can be acquired through UIPR and UPORTR.

Definition at line 545 of file w5300.h.

◆ UPORTR

#define UPORTR (_W5300_IO_BASE_ + 0x4C)

Unreachable port number register.

Refer to UIPR.

Definition at line 552 of file w5300.h.


ioLibrary: Socket register

Macros
Socket register
W5300 » WIZCHIP register

Socket register group.
Socket register configures and control SOCKETn which is necessary to data communication. More...

Collaboration diagram for Socket register:

Macros

#define | Sn_MR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x00)
Socket Mode register(R/W) More...
#define | Sn_CR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x02)
Socket command register(R/W) More...
#define | Sn_IMR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x04)
socket interrupt mask register(R) More...
#define | Sn_IR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x06)
Socket interrupt register(R) More...
#define | Sn_SSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x08)
Socket status register(R) More...
#define | Sn_PORTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0A)
source port register(R/W) More...
#define | Sn_DHAR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0C)
Peer MAC register address(R/W) More...
#define | Sn_DPORTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x12)
Peer port register address(R/W) More...
#define | Sn_DIPR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x14)
Peer IP register address(R/W) More...
#define | Sn_MSSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x18)
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_KPALVTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1A)
Keep Alive Timer register(R/W) More...
#define | Sn_PROTOR(n) Sn_KPALVTR(n)
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1C)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTLR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1E)
IP Time to live(TTL) Register(R/W) More...
#define | Sn_TX_WRSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x20)
SOCKETn TX write size register(R/W) More...
#define | Sn_TX_FSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0024)
Transmit free memory size register(R) More...
#define | Sn_FRAGR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x002C)
Fragment field value in IP header register(R/W) More...
#define | Sn_TX_FIFOR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x2E)
SOCKET n TX FIFO regsiter. More...
#define | Sn_RX_FIFOR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x30)
SOCKET n RX FIFO register. More...

Detailed Description

Socket register group.
Socket register configures and control SOCKETn which is necessary to data communication.

See also
Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control
Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information
Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol.
Sn_TX_WRSR, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR, Sn_TX_FIFOR, Sn_RX_FIFOR : Data communication

Macro Definition Documentation

◆ Sn_CR

#define Sn_CR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x02)

Socket command register(R/W)

This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.
After W5500 accepts the command, the Sn_CR register is automatically cleared to 0x00. Even though Sn_CR is cleared to 0x00, the command is still being processed.
To check whether the command is completed or not, please check the Sn_IR or Sn_SR.

  • Sn_CR_OPEN : Initialize or open socket.
  • Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode)
  • Sn_CR_CONNECT : Send connection request in TCP mode(Client mode)
  • Sn_CR_DISCON : Send closing request in TCP mode.
  • Sn_CR_CLOSE : Close socket.
  • Sn_CR_SEND : Update TX buffer pointer and send data.
  • Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process.
  • Sn_CR_SEND_KEEP : Send keep alive message.
  • Sn_CR_RECV : Update RX buffer pointer and receive data.
  • Sn_CR_PCON : PPPoE connection begins by transmitting PPPoE discovery packet.
  • Sn_CR_PDISCON : Closes PPPoE connection.
  • Sn_CR_PCR : In each phase, it transmits REQ message.
  • Sn_CR_PCN : In each phase, it transmits NAK message.
  • Sn_CR_PCJ : In each phase, it transmits REJECT message.

Definition at line 666 of file w5300.h.

◆ Sn_DHAR

#define Sn_DHAR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0C)

Peer MAC register address(R/W)

Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or it indicates that it is acquired in ARP-process by CONNECT/SEND command.

Definition at line 743 of file w5300.h.

◆ Sn_DIPR

#define Sn_DIPR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x14)

Peer IP register address(R/W)

Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command.

Definition at line 765 of file w5300.h.

◆ Sn_DPORTR

#define Sn_DPORTR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x12)

Peer port register address(R/W)

Sn_DPORTR configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command.

Definition at line 753 of file w5300.h.

◆ Sn_FRAGR

#define Sn_FRAGR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x002C)

Fragment field value in IP header register(R/W)

Sn_FRAGR configures the FRAG(Fragment field in IP header).

Definition at line 848 of file w5300.h.

◆ Sn_IMR

#define Sn_IMR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x04)

socket interrupt mask register(R)

Sn_IMR masks the interrupt of Socket n. Each bit corresponds to each bit of Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of Sn_IMR is the corresponding bit of Sn_IR becomes When both the corresponding bit of Sn_IMR and Sn_IR are and the n-th bit of IR is Host is interrupted by asserted INTn PIN to low.

Definition at line 676 of file w5300.h.

◆ Sn_IR

#define Sn_IR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x06)

Socket interrupt register(R)

Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).
When an interrupt occurs and the corresponding bit of Sn_IMR is the corresponding bit of Sn_IR becomes
In order to clear the Sn_IR bit, the host should write the bit to

15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
Reserved. Read as 0
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
PRECV | PFAIL | PNEXT | SENDOK | TIMEOUT | RECV | DISCON | CON
  • Sn_IR_PRECV : PPP receive
  • Sn_IR_PFAIL : PPP fail
  • Sn_IR_PNEXT : PPP next phase
  • Sn_IR_SENDOK : SENDOK
  • Sn_IR_TIMEOUT : TIMEOUT
  • Sn_IR_RECV : RECV
  • Sn_IR_DISCON : DISCON
  • Sn_IR_CON : CON

Definition at line 699 of file w5300.h.

◆ Sn_KPALVTR

#define Sn_KPALVTR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1A)

Keep Alive Timer register(R/W)

Sn_KPALVTR configures the transmitting timer of KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, and ignored in other modes. The time unit is 5s. KA packet is transmittable after Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. In case of 'Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). In case of 'Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). Manual-keep-alive-process is ignored in case of 'Sn_KPALVTR > 0'.

Definition at line 785 of file w5300.h.

◆ Sn_MR

#define Sn_MR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x00)

Socket Mode register(R/W)

Sn_MR configures the option or protocol type of Socket n.

Each bit of Sn_MR defined as the following.

15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
Reserved. Read as 0 |  |  |  |  |  |  | ALIGN
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
MULTI | MF | ND/IGMPv | Reserved | PROTOCOL[3:0]
  • Sn_MR_ALIGN : Alignment bit of Sn_MR, Only valid in Sn_MR_TCP. (C0 : Include TCP PACK_INFO, 1 : Not include TCP PACK_INFO)
  • Sn_MR_MULTI : Support UDP Multicasting
  • Sn_MR_MF : Enable MAC Filter (0 : Disable, 1 - Enable), When enabled, W5300 can receive only both own and broadcast packet.
  • Sn_MR_ND : No Delayed Ack(TCP) flag
  • Sn_MR_IGMPv : IGMP version used in UDP mulitcasting. (0 : Version 2, 1 : Version 2)
  • PROTOCOL[3:0]
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 0 | 0 | 0 | Closed
    0 | 0 | 0 | 1 | TCP
    0 | 0 | 1 | 0 | UDP
    0 | 0 | 1 | 1 | IPCRAW
    0 | 1 | 0 | 0 | MACRAW
    0 | 1 | 0 | 1 | PPPoE
    • Sn_MR_PPPoE : PPPoE
      • Sn_MR_MACRAW : MAC LAYER RAW SOCK
    • Sn_MR_IPRAW : IP LAYER RAW SOCK
    • Sn_MR_UDP : UDP
    • Sn_MR_TCP : TCP
    • Sn_MR_CLOSE : Unused socket
      Note
      MACRAW mode should be only used in Socket 0.

Definition at line 642 of file w5300.h.

◆ Sn_MSSR

#define Sn_MSSR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x18)

Maximum Segment Size(Sn_MSSR0) register address(R/W)

Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n.

Definition at line 772 of file w5300.h.

◆ Sn_PORTR

#define Sn_PORTR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0A)

source port register(R/W)

Sn_PORTR configures the source port number of Socket n. It is valid when Socket n is used in TCP/UPD mode. It should be set before OPEN command is ordered.

Definition at line 734 of file w5300.h.

◆ Sn_PROTOR

#define Sn_PROTOR ( n ) Sn_KPALVTR(n)

IP Protocol(PROTO) Register(R/W)

Sn_PROTO that sets the protocol number field of the IP header at the IP layer. It is valid only in IPRAW mode, and ignored in other modes.

Definition at line 793 of file w5300.h.

◆ Sn_RX_FIFOR

#define Sn_RX_FIFOR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x30)

SOCKET n RX FIFO register.

It indirectly accesses to internal RX memory of SOCKETn. The internal RX memory can't be directly accessed by the host, but can be accessed through Sn_RX_FIFOR. If MR(MT) = '0', only the Host-Read of internal RX memory is allowed through Sn_RX_FIFOR. But if MR(MT) is '1', both of Host-Read and Host-Write are allowed.

Definition at line 869 of file w5300.h.

◆ Sn_SSR

#define Sn_SSR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x08)

Socket status register(R)

Sn_SSR indicates the status of Socket n.
The status of Socket n is changed by Sn_CR or some special control packet as SYN, FIN packet in TCP.

Normal status
  • SOCK_CLOSED : Closed
  • SOCK_INIT : Initiate state
  • SOCK_LISTEN : Listen state
  • SOCK_ESTABLISHED : Success to connect
  • SOCK_CLOSE_WAIT : Closing state
  • SOCK_UDP : UDP socket
  • SOCK_IPRAW : IPRAW socket
  • SOCK_MACRAW : MAC raw mode socket
  • SOCK_PPPoE : PPPoE mode Socket
Temporary status during changing the status of Socket n.
  • SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
  • SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
  • SOCK_FIN_WAIT : Connection state
  • SOCK_CLOSING : Closing state
  • SOCK_TIME_WAIT : Closing state
  • SOCK_LAST_ACK : Closing state
  • SOCK_ARP : ARP request state

Definition at line 725 of file w5300.h.

◆ Sn_TOSR

#define Sn_TOSR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1C)

IP Type of Service(TOS) Register(R/W)

Sn_TOSR configures the TOS(Type Of Service field in IP Header) of Socket n. It is set before OPEN command.

Definition at line 802 of file w5300.h.

◆ Sn_TTLR

#define Sn_TTLR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1E)

IP Time to live(TTL) Register(R/W)

Sn_TTLR configures the TTL(Time To Live field in IP header) of Socket n. It is set before OPEN command.

Definition at line 811 of file w5300.h.

◆ Sn_TX_FIFOR

#define Sn_TX_FIFOR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x2E)

SOCKET n TX FIFO regsiter.

It indirectly accesses internal TX memory of SOCKETn. The internal TX memory can't be accessed directly by the host, but can be accessed through Sn_TX_FIFOR. If MR(MT) = '0', only the Host-Write of internal TX memory is allowed through Sn_TX_FIFOR. But if MR(MT) is '1', both of Host-Read and Host-Write are allowed.

Definition at line 859 of file w5300.h.

◆ Sn_TX_FSR

#define Sn_TX_FSR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0024)

Transmit free memory size register(R)

Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by TMSR such as TMS01SR. Data bigger than Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, transmit the data after dividing into the checked size and saving in the Socket n TX buffer.

Definition at line 832 of file w5300.h.

◆ Sn_TX_WRSR

#define Sn_TX_WRSR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x20)

SOCKETn TX write size register(R/W)

It sets the byte size of the data written in internal TX memory through Sn_TX_FIFOR. It is set before SEND or SEND_MAC command, and can't be bigger than internal TX memory size set by TMSR such as TMS01R, TMS23R and etc.

Definition at line 821 of file w5300.h.


ioLibrary: WIZCHIP I/O functions

Modules
WIZCHIP I/O functions
W5300

This supports the basic I/O functions for WIZCHIP register. More...

Collaboration diagram for WIZCHIP I/O functions:

Modules

Basic I/O function
These are basic input/output functions to read values from register or write values to register.
Common register access functions
These are functions to access common registers.
Socket register access functions
These are functions to access socket registers.

Detailed Description

This supports the basic I/O functions for WIZCHIP register.

  • Basic I/O function
    WIZCHIP_READ(), WIZCHIP_WRITE()

  • Common register access functions
    1. Mode
      getMR(), setMR()
    2. Interrupt
      getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR()
    3. Network Information
      getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR()
    4. Retransmission
      getRCR(), setRCR(), getRTR(), setRTR()
    5. PPPoE
      getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU()
    6. ICMP packet
      getUIPR(), getUPORTR()

Socket Memory
getMTYPER(), setMTYPER()
getTMS01R(), getTMS23R(), getTMS45R(), getTMS67R(), setTMS01R(), setTMS23R(), setTMS45R(), setTMS67R()
getRMS01R(), getRMS23R(), getRMS45R(), getRMS67R(), setRMS01R(), setRMS23R(), setRMS45R(), setRMS67R()

  1. etc.
    getPn_BRDYR(), setPn_BRDYR(), getPn_BDPTHR(), setPn_BDPTHR(), getIDR()

Socket register access functions

  1. SOCKET control
    getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR()
  2. SOCKET information
    getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() getSn_MSSR(), setSn_MSSR()
  3. SOCKET communication
    getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE()
    getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR()
    getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR()
    getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR()
  4. IP header field
    getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS()
    getSn_TTL(), setSn_TTL()


ioLibrary: Basic I/O function

Functions
Basic I/O function
W5300 » WIZCHIP I/O functions

These are basic input/output functions to read values from register or write values to register. More...

Collaboration diagram for Basic I/O function:

Functions

uint16_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint16_t wb)
It writes 1 byte value to a register. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint32_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint32_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint32_t len)
It discard the received data in RX memory. More...

Detailed Description

These are basic input/output functions to read values from register or write values to register.

Function Documentation

◆ wiz_recv_data()

void wiz_recv_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint32_t | len
 | ) |  |

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after that, it copies the received data from internal RX memory to wizdata(pointer variable) of the length of len(variable) bytes. This function is being called by recv() also.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
wizdata | Pointer buffer to read data
len | Data length
See also
wiz_send_data()

◆ wiz_recv_ignore()

void wiz_recv_ignore | ( | uint8_t | sn,
 |  | uint32_t | len
 | ) |  |

It discard the received data in RX memory.

It discards the data of the length of len(variable) bytes in internal RX memory.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
len | Data length

◆ wiz_send_data()

void wiz_send_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint32_t | len
 | ) |  |

It copies data to internal TX memory.

This function reads the Tx write pointer register and after that, it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory and updates the Tx write pointer register. This function is being called by send() and sendto() function also.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
wizdata | Pointer buffer to write data
len | Data length
See also
wiz_recv_data()

◆ WIZCHIP_READ()

uint16_t WIZCHIP_READ ( uint32_t AddrSel )

It reads 1 byte value from a register.

Parameters
AddrSel Register address
Returns
The value of register

It reads 1 byte value from a register.

Definition at line 83 of file w5100s.c.

◆ WIZCHIP_WRITE()

void WIZCHIP_WRITE | ( | uint32_t | AddrSel,
 |  | uint16_t | wb
 | ) |  |

It writes 1 byte value to a register.

Parameters
AddrSel | Register address
wb | Write data
Returns
void


ioLibrary: Common register access functions

Macros | Functions
Common register access functions
W5300 » WIZCHIP I/O functions

These are functions to access common registers. More...

Collaboration diagram for Common register access functions:

Macros

#define | setIR(ir) WIZCHIP_WRITE(IR, ir & 0xF0FF)
Set Mode Register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xF0FF)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr & 0xF0FF)
Set IMR register. More...
#define | getIMR() (WIZCHIP_READ(_IMR_) & 0xF0FF)
Get IMR register. More...
#define | setSHAR(shar)
Set local MAC address. More...
#define | setGAR(gar)
Set gateway IP address. More...
#define | getGAR(gar)
Get gateway IP address. More...
#define | setSUBR(subr)
Set subnet mask address. More...
#define | getSUBR(subr)
Get subnet mask address. More...
#define | setSIPR(sipr)
Set local IP address. More...
#define | getSIPR(sipr)
Get local IP address. More...
#define | setRTR(rtr) WIZCHIP_WRITE(_RTR_, rtr)
Set RTR register. More...
#define | getRTR() WIZCHIP_READ(_RTR_)
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, ((uint16_t)rcr)&0x00FF)
Set RCR register. More...
#define | getRCR() ((uint8_t)(WIZCHIP_READ(_RCR_) & 0x00FF))
Get RCR register. More...
#define | setTMS01R(tms01r) WIZCHIP_WRITE(TMS01R,tms01r)
Set TMS01R register. More...
#define | getTMS01R() WIZCHIP_READ(TMS01R)
Get TMS01R register. More...
#define | setTMS23R(tms23r) WIZCHIP_WRITE(TMS23R,tms23r)
Set TMS23R register. More...
#define | getTMS23R() WIZCHIP_READ(TMS23R)
Get TMS23R register. More...
#define | setTMS45R(tms45r) WIZCHIP_WRITE(TMS45R,tms45r)
Set TMS45R register. More...
#define | getTMS45R() WIZCHIP_READ(TMS45R)
Get TMS45R register. More...
#define | setTMS67R(tms67r) WIZCHIP_WRITE(TMS67R,tms67r)
Set TMS67R register. More...
#define | getTMS67R() WIZCHIP_READ(TMS67R)
Get TMS67R register. More...
#define | setRMS01R(rms01r) WIZCHIP_WRITE(RMS01R,rms01r)
Set RMS01R register. More...
#define | getRMS01R() WIZCHIP_READ(RMS01R)
Get RMS01R register. More...
#define | setRMS23R(rms23r) WIZCHIP_WRITE(RMS23R,rms23r)
Set RMS23R register. More...
#define | getRMS23R() WIZCHIP_READ(RMS23R)
Get RMS23R register. More...
#define | setRMS45R(rms45r) WIZCHIP_WRITE(RMS45R,rms45r)
Set RMS45R register. More...
#define | getRMS45R() WIZCHIP_READ(RMS45R)
Get RMS45R register. More...
#define | setRMS67R(rms67r) WIZCHIP_WRITE(RMS67R,rms67r)
Set RMS67R register. More...
#define | getRMS67R() WIZCHIP_READ(RMS67R)
Get RMS67R register. More...
#define | setMTYPER(mtype) WIZCHIP_WRITE(MTYPER, mtype)
Set MTYPER register. More...
#define | getMTYPER() WIZCHIP_READ(MTYPER)
Get MTYPER register. More...
#define | getPATR() WIZCHIP_READ(PATR)
Get RATR register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ((uint16_t)ptimer) & 0x00FF)
Set PTIMER register. More...
#define | getPTIMER() ((uint8_t)(WIZCHIP_READ(PTIMER) & 0x00FF))
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, ((uint16_t)pmagic) & 0x00FF)
Set PMAGIC register. More...
#define | getPMAGIC() ((uint8_t)(WIZCHIP_READ(PMAGIC) & 0x00FF))
Get PMAGIC register. More...
#define | getPSIDR() WIZCHIP_READ(PSIDR)
Get PSID register. More...
#define | getPDHAR(pdhar)
Get PDHAR register. More...
#define | getUIPR(uipr)
Get unreachable IP address. UIPR. More...
#define | getUPORTR() WIZCHIP_READ(UPORTR)
Get UPORTR register. More...
#define | getFMTUR() WIZCHIP_READ(FMTUR)
Get FMTUR register. More...
#define | getPn_BRDYR(p) ((uint8_t)(WIZCHIP_READ(Pn_BRDYR(p)) & 0x00FF))
Get Pn_BRDYR register. More...
#define | setPn_BRDYR(p, brdyr) WIZCHIP_WRITE(Pn_BRDYR(p), brdyr & 0x00E7)
Set Pn_BRDYR register. More...
#define | getPn_BDPTHR(p) WIZCHIP_READ(Pn_BDPTHR(p))
Get Pn_BDPTHR register. More...
#define | setPn_BDPTHR(p, bdpthr) WIZCHIP_WRITE(Pn_BDPTHR(p),bdpthr)
Set Pn_BDPTHR register. More...
#define | getIDR() WIZCHIP_READ(IDR)
Get IDR register. More...

Functions

void | setTMSR (uint8_t sn, uint8_t tmsr)
Set TMSR0 ~ TMSR7 register. More...
uint8_t | getTMSR (uint8_t sn)
Get TMSR0 ~ TMSR7 register. More...
void | setRMSR (uint8_t sn, uint8_t rmsr)
Set RMS01R ~ RMS67R register. More...
uint8_t | getRMSR (uint8_t sn)
Get RMS01R ~ RMS67R register. More...

Detailed Description

These are functions to access common registers.

Macro Definition Documentation

◆ getFMTUR

#define getFMTUR ( ) WIZCHIP_READ(FMTUR)

Get FMTUR register.

Returns
uint16_t. Value of FMTUR register.

Definition at line 1830 of file w5300.h.

◆ getGAR

#define getGAR ( gar )
Value:
{ \
(gar)[0] = (uint8_t)(WIZCHIP_READ(GAR) >> 8); \
(gar)[1] = (uint8_t)(WIZCHIP_READ(GAR)); \
(gar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(GAR,2)) >> 8); \
(gar)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(GAR,2))); \
}
GAR
#define GAR
Gateway IP Register address(R/W)
Definition: w5300.h:275
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Get gateway IP address.

Parameters
(uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes.
See also
setGAR()

Definition at line 1445 of file w5300.h.

◆ getIDR

#define getIDR ( ) WIZCHIP_READ(IDR)

Get IDR register.

Returns
uint16_t. Always 0x5300.

Definition at line 1875 of file w5300.h.

◆ getIMR

#define getIMR ( ) (WIZCHIP_READ(_IMR_) & 0xF0FF)

Get IMR register.

Returns
uint16_t. Value of IR register.
See also
setIMR()

Definition at line 1398 of file w5300.h.

◆ getIR

#define getIR ( ) (WIZCHIP_READ(IR) & 0xF0FF)

Get IR register.

Returns
uint8_t. Value of IR register.
See also
setIR()

Definition at line 1379 of file w5300.h.

◆ getMTYPER

#define getMTYPER ( ) WIZCHIP_READ(MTYPER)

Get MTYPER register.

Returns
uint16_t. Value of MTYPER register.
See also
setMTYPER()

Definition at line 1736 of file w5300.h.

◆ getPATR

#define getPATR ( ) WIZCHIP_READ(PATR)

Get RATR register.

Returns
uint16_t. Value of PATR register.

Definition at line 1744 of file w5300.h.

◆ getPDHAR

#define getPDHAR ( pdhar )
Value:
{ \
(pdhar)[0] = (uint8_t)(WIZCHIP_READ(PDHAR) >> 8); \
(pdhar)[1] = (uint8_t)(WIZCHIP_READ(PDHAR)); \
(pdhar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,2)) >> 8); \
(pdhar)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,2))); \
(pdhar)[4] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,4)) >> 8); \
(pdhar)[5] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,4))); \
}
PDHAR
#define PDHAR
PPPoE destination hardware address register.
Definition: w5300.h:535
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Get PDHAR register.

Parameters
(uint8_t*)pdhar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes.

Definition at line 1796 of file w5300.h.

◆ getPMAGIC

#define getPMAGIC ( ) ((uint8_t)(WIZCHIP_READ(PMAGIC) & 0x00FF))

Get PMAGIC register.

Returns
uint8_t. Value of PMAGIC register.
See also
setPMAGIC()

Definition at line 1780 of file w5300.h.

◆ getPn_BDPTHR

#define getPn_BDPTHR ( p ) WIZCHIP_READ(Pn_BDPTHR(p))

Get Pn_BDPTHR register.

Parameters
p Pin number (p = 0,1,2,3)
Returns
uint16_t. Value of Pn_BDPTHR register.

Definition at line 1857 of file w5300.h.

◆ getPn_BRDYR

#define getPn_BRDYR ( p ) ((uint8_t)(WIZCHIP_READ(Pn_BRDYR(p)) & 0x00FF))

Get Pn_BRDYR register.

Returns
uint8_t. Value of Pn_BRDYR register.

Definition at line 1839 of file w5300.h.

◆ getPSIDR

#define getPSIDR ( ) WIZCHIP_READ(PSIDR)

Get PSID register.

Returns
uint16_t. Value of PSID register.

Definition at line 1788 of file w5300.h.

◆ getPTIMER

#define getPTIMER ( ) ((uint8_t)(WIZCHIP_READ(PTIMER) & 0x00FF))

Get PTIMER register.

Returns
uint8_t. Value of PTIMER register.
See also
setPTIMER()

Definition at line 1762 of file w5300.h.

◆ getRCR

#define getRCR ( ) ((uint8_t)(WIZCHIP_READ(_RCR_) & 0x00FF))

Get RCR register.

Returns
uint8_t. Value of RCR register.
See also
setRCR()

Definition at line 1534 of file w5300.h.

◆ getRMS01R

#define getRMS01R ( ) WIZCHIP_READ(RMS01R)

Get RMS01R register.

Returns
uint16_t. Value of RMS01R register.
See also
setRMS01R()

Definition at line 1644 of file w5300.h.

◆ getRMS23R

#define getRMS23R ( ) WIZCHIP_READ(RMS23R)

Get RMS23R register.

Returns
uint16_t. Value of RMS23R register.
See also
setRMS23R()

Definition at line 1662 of file w5300.h.

◆ getRMS45R

#define getRMS45R ( ) WIZCHIP_READ(RMS45R)

Get RMS45R register.

Returns
uint16_t. Value of RMS45R register.
See also
setRMS45R()

Definition at line 1680 of file w5300.h.

◆ getRMS67R

#define getRMS67R ( ) WIZCHIP_READ(RMS67R)

Get RMS67R register.

Returns
uint16_t. Value of RMS67R register.
See also
setRMS67R()

Definition at line 1698 of file w5300.h.

◆ getRTR

#define getRTR ( ) WIZCHIP_READ(_RTR_)

Get RTR register.

Returns
uint16_t. Value of RTR register.
See also
setRTR()

Definition at line 1516 of file w5300.h.

◆ getSIPR

#define getSIPR ( sipr )
Value:
{ \
(sipr)[0] = (uint8_t)(WIZCHIP_READ(SIPR) >> 8); \
(sipr)[1] = (uint8_t)(WIZCHIP_READ(SIPR)); \
(sipr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SIPR,2)) >> 8); \
(sipr)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SIPR,2))); \
}
SIPR
#define SIPR
Source IP Register address(R/W)
Definition: w5300.h:289
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Get local IP address.

Parameters
(uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes.
See also
setSIPR()

Definition at line 1493 of file w5300.h.

◆ getSUBR

#define getSUBR ( subr )
Value:
{ \
(subr)[0] = (uint8_t)(WIZCHIP_READ(SUBR) >> 8); \
(subr)[1] = (uint8_t)(WIZCHIP_READ(SUBR)); \
(subr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SUBR,2)) >> 8); \
(subr)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SUBR,2))); \
}
SUBR
#define SUBR
Subnet mask Register address(R/W)
Definition: w5300.h:282
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Get subnet mask address.

Parameters
(uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes.
See also
setSUBR()

Definition at line 1469 of file w5300.h.

◆ getTMS01R

#define getTMS01R ( ) WIZCHIP_READ(TMS01R)

Get TMS01R register.

Returns
uint16_t. Value of TMS01R register.
See also
setTMS01R()

Definition at line 1552 of file w5300.h.

◆ getTMS23R

#define getTMS23R ( ) WIZCHIP_READ(TMS23R)

Get TMS23R register.

Returns
uint16_t. Value of TMS23R register.
See also
setTMS23R()

Definition at line 1570 of file w5300.h.

◆ getTMS45R

#define getTMS45R ( ) WIZCHIP_READ(TMS45R)

Get TMS45R register.

Returns
uint16_t. Value of TMS45R register.
See also
setTMS45R()

Definition at line 1588 of file w5300.h.

◆ getTMS67R

#define getTMS67R ( ) WIZCHIP_READ(TMS67R)

Get TMS67R register.

Returns
uint16_t. Value of TMS67R register.
See also
setTMS67R()

Definition at line 1606 of file w5300.h.

◆ getUIPR

#define getUIPR ( uipr )
Value:
{ \
(uipr)[0] = (uint8_t)(WIZCHIP_READ(UIPR) >> 8); \
(uipr)[1] = (uint8_t)(WIZCHIP_READ(UIPR)); \
(uipr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(UIPR,2)) >> 8); \
(uipr)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(UIPR,2))); \
}
UIPR
#define UIPR
Unreachable IP address register.
Definition: w5300.h:545
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Get unreachable IP address. UIPR.

Parameters
(uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes.

Definition at line 1810 of file w5300.h.

◆ getUPORTR

#define getUPORTR ( ) WIZCHIP_READ(UPORTR)

Get UPORTR register.

Returns
uint16_t. Value of UPORTR register.

Definition at line 1822 of file w5300.h.

◆ setGAR

#define setGAR ( gar )
Value:
{ \
WIZCHIP_WRITE(GAR, (((uint16_t)((gar)[0])) << 8) + (((uint16_t)((gar)[1])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(GAR,2), (((uint16_t)((gar)[2])) << 8) + (((uint16_t)((gar)[3])) & 0x00FF)); \
}
GAR
#define GAR
Gateway IP Register address(R/W)
Definition: w5300.h:275
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Set gateway IP address.

Parameters
(uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes.
See also
getGAR()

Definition at line 1434 of file w5300.h.

◆ setIMR

#define setIMR ( imr ) WIZCHIP_WRITE(_IMR_, imr & 0xF0FF)

Set IMR register.

Parameters
(uint16_t)imr Value to set IMR register.
See also
getIMR()

Definition at line 1389 of file w5300.h.

◆ setIR

#define setIR ( ir ) WIZCHIP_WRITE(IR, ir & 0xF0FF)

Set Mode Register.

Parameters
(

Definition at line 1370 of file w5300.h.

◆ setMTYPER

#define setMTYPER ( mtype ) WIZCHIP_WRITE(MTYPER, mtype)

Set MTYPER register.

Parameters
(uint16_t)mtyper Value to set MTYPER register.
See also
getMTYPER()

Definition at line 1727 of file w5300.h.

◆ setPMAGIC

#define setPMAGIC ( pmagic ) WIZCHIP_WRITE(PMAGIC, ((uint16_t)pmagic) & 0x00FF)

Set PMAGIC register.

Parameters
(uint8_t)pmagic Value to set PMAGIC register.
See also
getPMAGIC()

Definition at line 1771 of file w5300.h.

◆ setPn_BDPTHR

#define setPn_BDPTHR | ( | p,
 |  | bdpthr
 | ) | WIZCHIP_WRITE(Pn_BDPTHR(p),bdpthr)

Set Pn_BDPTHR register.

Parameters
p | Pin number (p = 0,1,2,3)
bdpthr | Value of Pn_BDPTHR

Definition at line 1866 of file w5300.h.

◆ setPn_BRDYR

#define setPn_BRDYR | ( | p,
 |  | brdyr
 | ) | WIZCHIP_WRITE(Pn_BRDYR(p), brdyr & 0x00E7)

Set Pn_BRDYR register.

Parameters
p | Pin number (p = 0,1,2,3)
brdyr | Set a value Pn_BRDYR(p).

Definition at line 1848 of file w5300.h.

◆ setPTIMER

#define setPTIMER ( ptimer ) WIZCHIP_WRITE(PTIMER, ((uint16_t)ptimer) & 0x00FF)

Set PTIMER register.

Parameters
(uint8_t)ptimer Value to set PTIMER register.
See also
getPTIMER()

Definition at line 1753 of file w5300.h.

◆ setRCR

#define setRCR ( rcr ) WIZCHIP_WRITE(_RCR_, ((uint16_t)rcr)&0x00FF)

Set RCR register.

Parameters
(uint8_t)rcr Value to set RCR register.
See also
getRCR()

Definition at line 1525 of file w5300.h.

◆ setRMS01R

#define setRMS01R ( rms01r ) WIZCHIP_WRITE(RMS01R,rms01r)

Set RMS01R register.

Parameters
(uint16_t)rms01r Value to set RMS01R register. The lower socket memory size is located at MSB of rms01r.
See also
getRMS01R()

Definition at line 1635 of file w5300.h.

◆ setRMS23R

#define setRMS23R ( rms23r ) WIZCHIP_WRITE(RMS23R,rms23r)

Set RMS23R register.

Parameters
(uint16_t)rms23r Value to set RMS23R register. The lower socket memory size is located at MSB of rms01r.
See also
getRMS23R()

Definition at line 1653 of file w5300.h.

◆ setRMS45R

#define setRMS45R ( rms45r ) WIZCHIP_WRITE(RMS45R,rms45r)

Set RMS45R register.

Parameters
(uint16_t)rms45r Value to set RMS45R register. The lower socket memory size is located at MSB of rms45r.
See also
getRMS45R()

Definition at line 1671 of file w5300.h.

◆ setRMS67R

#define setRMS67R ( rms67r ) WIZCHIP_WRITE(RMS67R,rms67r)

Set RMS67R register.

Parameters
(uint16_t)rms67r Value to set RMS67R register. The lower socket memory size is located at MSB of rms67r.
See also
getRMS67R()

Definition at line 1689 of file w5300.h.

◆ setRTR

#define setRTR ( rtr ) WIZCHIP_WRITE(_RTR_, rtr)

Set RTR register.

Parameters
(uint16_t)rtr Value to set RTR register.
See also
getRTR()

Definition at line 1507 of file w5300.h.

◆ setSHAR

#define setSHAR ( shar )
Value:
{ \
WIZCHIP_WRITE(SHAR, (((uint16_t)((shar)[0])) << 8) + (((uint16_t)((shar)[1])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SHAR,2), (((uint16_t)((shar)[2])) << 8) + (((uint16_t)((shar)[3])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SHAR,4), (((uint16_t)((shar)[4])) << 8) + (((uint16_t)((shar)[5])) & 0x00FF)); \
}
SHAR
#define SHAR
Source MAC Register address(R/W)
Definition: w5300.h:267
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Set local MAC address.

Parameters
(uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes.
See also
getSHAR()

Definition at line 1407 of file w5300.h.

◆ setSIPR

#define setSIPR ( sipr )
Value:
{ \
WIZCHIP_WRITE(SIPR, (((uint16_t)((sipr)[0])) << 8) + (((uint16_t)((sipr)[1])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SIPR,2), (((uint16_t)((sipr)[2])) << 8) + (((uint16_t)((sipr)[3])) & 0x00FF)); \
}
SIPR
#define SIPR
Source IP Register address(R/W)
Definition: w5300.h:289
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Set local IP address.

Parameters
(uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes.
See also
getSIPR()

Definition at line 1482 of file w5300.h.

◆ setSUBR

#define setSUBR ( subr )
Value:
{ \
WIZCHIP_WRITE(SUBR, (((uint16_t)((subr)[0])) << 8) + (((uint16_t)((subr)[1])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SUBR,2), (((uint16_t)((subr)[2])) << 8) + (((uint16_t)((subr)[3])) & 0x00FF)); \
}
SUBR
#define SUBR
Subnet mask Register address(R/W)
Definition: w5300.h:282
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Set subnet mask address.

Parameters
(uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes.
See also
getSUBR()

Definition at line 1458 of file w5300.h.

◆ setTMS01R

#define setTMS01R ( tms01r ) WIZCHIP_WRITE(TMS01R,tms01r)

Set TMS01R register.

Parameters
(uint16_t)tms01r Value to set TMS01R register. The lower socket memory size is located at MSB of tms01r.
See also
getTMS01R()

Definition at line 1543 of file w5300.h.

◆ setTMS23R

#define setTMS23R ( tms23r ) WIZCHIP_WRITE(TMS23R,tms23r)

Set TMS23R register.

Parameters
(uint16_t)tms23r Value to set TMS23R register. The lower socket memory size is located at MSB of tms01r.
See also
getTMS23R()

Definition at line 1561 of file w5300.h.

◆ setTMS45R

#define setTMS45R ( tms45r ) WIZCHIP_WRITE(TMS45R,tms45r)

Set TMS45R register.

Parameters
(uint16_t)tms45r Value to set TMS45R register. The lower socket memory size is located at MSB of tms45r.
See also
getTMS45R()

Definition at line 1579 of file w5300.h.

◆ setTMS67R

#define setTMS67R ( tms67r ) WIZCHIP_WRITE(TMS67R,tms67r)

Set TMS67R register.

Parameters
(uint16_t)tms67r Value to set TMS67R register. The lower socket memory size is located at MSB of tms67r.
See also
getTMS67R()

Definition at line 1597 of file w5300.h.

Function Documentation

◆ getRMSR()

uint8_t getRMSR ( uint8_t sn )

Get RMS01R ~ RMS67R register.

Parameters
(uint8_t)sn Socket number. It shoudl be 0 ~ 7.
Returns
uint8_t. Value of RMSR0 ~ RMSR7 register.
See also
setRMSR()

◆ getTMSR()

uint8_t getTMSR ( uint8_t sn )

Get TMSR0 ~ TMSR7 register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of TMSR0 ~ TMSR7
See also
getTMSR()

◆ setRMSR()

void setRMSR | ( | uint8_t | sn,
 |  | uint8_t | rmsr
 | ) |  |

Set RMS01R ~ RMS67R register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)rmsr | Value to set RMSR0 ~RMSR7 register.
See also
getTMSR()

◆ setTMSR()

void setTMSR | ( | uint8_t | sn,
 |  | uint8_t | tmsr
 | ) |  |

Set TMSR0 ~ TMSR7 register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)tmsr | Value to set TMSR0 ~TMSR7 register.
See also
getTMSR()


ioLibrary: Socket register access functions

Macros | Functions
Socket register access functions
W5300 » WIZCHIP I/O functions

These are functions to access socket registers. More...

Collaboration diagram for Socket register access functions:

Macros

#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), ((uint16_t)cr) & 0x00FF)
Set Sn_CR register. More...
#define | getSn_CR(sn) ((uint8_t)WIZCHIP_READ(Sn_CR(sn)))
Get Sn_CR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), ((uint16_t)imr) & 0x00FF)
Set Sn_IMR register. More...
#define | getSn_IMR(sn) ((uint8_t)WIZCHIP_READ(Sn_IMR(sn)))
Get Sn_IMR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ((uint16_t)ir) & 0x00FF)
Set Sn_IR register. More...
#define | getSn_IR(sn) ((uint8_t)WIZCHIP_READ(Sn_IR(sn)))
Get Sn_IR register. More...
#define | getSn_SSR(sn) ((uint8_t)WIZCHIP_READ(Sn_SR(sn)))
Get Sn_SR register. More...
#define | setSn_PORTR(sn, port) WIZCHIP_WRITE(Sn_PORTR(sn), port)
Set Sn_PORTR register. More...
#define | getSn_PORTR(sn, port) WIZCHIP_READ(Sn_PORTR(sn))
Get Sn_PORTR register. More...
#define | setSn_DHAR(sn, dhar)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar)
Get Sn_MR register. More...
#define | setSn_DPORTR(sn, dport) WIZCHIP_WRITE(Sn_DPORTR(sn),dport)
Set Sn_DPORT register. More...
#define | getSn_DPORTR(sn) WIZCHIP_READ(Sn_DPORTR(sn))
Get Sn_DPORT register. More...
#define | setSn_DIPR(sn, dipr)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr)
Get Sn_DIPR register. More...
#define | setSn_MSSR(sn, mss) WIZCHIP_WRITE(Sn_MSSR(sn), mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) WIZCHIP_READ(Sn_MSSR(sn))
Get Sn_MSSR register. More...
#define | setSn_KPALVTR(sn, kpalvt) WIZCHIP_WRITE(Sn_KPALVTR(sn), (WIZCHIP_READ(Sn_KPALVTR(sn)) & 0x00FF) | (((uint16_t)kpalvt)<<8))
Set Sn_KPALVTR register. More...
#define | getSn_KPALVTR(sn) ((uint8_t)(WIZCHIP_READ(Sn_KPALVTR(sn)) >> 8))
Get Sn_KPALVTR register. More...
#define | setSn_PROTOR(sn, proto) WIZCHIP_WRITE(Sn_PROTOR(sn),(WIZCHIP_READ(Sn_PROTOR(sn) & 0xFF00) | (((uint16_t)proto) & 0x00FF))
Set Sn_PROTOR register. More...
#define | getSn_PROTOR(sn) ((uint8_t)WIZCHIP_READ(Sn_PROTOR(sn)))
Get Sn_PROTOR register. More...
#define | setSn_TX_WRSR(sn, txwrs)
Set Sn_TX_WRSR register. More...
#define | getSn_TX_WRSR(sn) ( (((uint32_t)WIZCHIP_READ(Sn_TX_WRSR(sn))) << 16) + (((uint32_t)WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WRSR(sn),1))) & 0x0000FFFF) )
Get Sn_TX_WRSR register. More...
#define | setSn_TX_FIFOR(sn, txfifo) WIZCHIP_WRITE(Sn_TX_FIFOR(sn), txfifo);
Set Sn_TX_FIFOR register. More...
#define | getSn_RX_FIFOR(sn) WIZCHIP_READ(Sn_RX_FIFOR(sn));
Get Sn_RX_FIFOR register. More...
#define | setSn_TOSR(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), ((uint16_t)tos) & 0x00FF)
Set Sn_TOSR register. More...
#define | getSn_TOSR(sn) ((uint8_t)WIZCHIP_READ(Sn_TOSR(sn)))
Get Sn_TOSR register. More...
#define | setSn_TTLR(sn, ttl) WIZCHIP_WRITE(Sn_TTLR(sn), ((uint16_t)ttl) & 0x00FF)
Set Sn_TTLR register. More...
#define | getSn_TTLR(sn) ((uint8_t)WIZCHIP_READ(Sn_TTL(sn)))
Get Sn_TTLR register. More...
#define | setSn_FRAGR(sn, frag) WIZCHIP_WRITE(Sn_FRAGR(sn), (uint16_t)(frag >>8))
Set Sn_FRAGR register. More...
#define | getSn_FRAGR(sn) (WIZCHIP_READ(Sn_FRAG(sn)) << 8)
Get Sn_FRAGR register. More...

Functions

uint32_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint32_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...

Detailed Description

These are functions to access socket registers.

Macro Definition Documentation

◆ getSn_CR

#define getSn_CR ( sn ) ((uint8_t)WIZCHIP_READ(Sn_CR(sn)))

Get Sn_CR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_CR.
See also
setSn_CR()

Definition at line 1920 of file w5300.h.

◆ getSn_DHAR

#define getSn_DHAR | ( | sn,
 |  | dhar
 | ) |
Value:
{ \
(dhar)[0] = (uint8_t)(WIZCHIP_READ(Sn_DHAR(sn)) >> 8); \
(dhar)[1] = (uint8_t) WIZCHIP_READ(Sn_DHAR(sn)); \
(dhar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),2)) >> 8); \
(dhar)[3] = (uint8_t) WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),2)); \
(dhar)[4] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),4)) >> 8); \
(dhar)[5] = (uint8_t) WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),4)); \
}
Sn_DHAR
#define Sn_DHAR(n)
Peer MAC register address(R/W)
Definition: w5300.h:743
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Get Sn_MR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dhar | Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes.
See also
setSn_DHAR()

Definition at line 2015 of file w5300.h.

◆ getSn_DIPR

#define getSn_DIPR | ( | sn,
 |  | dipr
 | ) |
Value:
{ \
(dipr)[0] = (uint8_t)(WIZCHIP_READ(Sn_DIPR(sn)) >> 8); \
(dipr)[1] = (uint8_t) WIZCHIP_READ(Sn_DIPR(sn)); \
(dipr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DIPR(sn),2)) >> 8); \
(dipr)[3] = (uint8_t) WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DIPR(sn),2)); \
}
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60
Sn_DIPR
#define Sn_DIPR(n)
Peer IP register address(R/W)
Definition: w5300.h:765

Get Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dipr | Pointer variable to get socket n destination IP address. It should be allocated 4 bytes.
See also
setSn_DIPR()

Definition at line 2068 of file w5300.h.

◆ getSn_DPORTR

#define getSn_DPORTR ( sn ) WIZCHIP_READ(Sn_DPORTR(sn))

Get Sn_DPORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_DPORT.
See also
setSn_DPORT()
Note
This function is not available because W5300 have a bug to read Sn_DPORTR.
Don't use this function.

Definition at line 2045 of file w5300.h.

◆ getSn_FRAGR

#define getSn_FRAGR ( sn ) (WIZCHIP_READ(Sn_FRAG(sn)) << 8)

Get Sn_FRAGR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_FRAGR.
See also
setSn_FRAGR()

Definition at line 2255 of file w5300.h.

◆ getSn_IMR

#define getSn_IMR ( sn ) ((uint8_t)WIZCHIP_READ(Sn_IMR(sn)))

Get Sn_IMR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_IMR.
See also
setSn_IMR()

Definition at line 1940 of file w5300.h.

◆ getSn_IR

#define getSn_IR ( sn ) ((uint8_t)WIZCHIP_READ(Sn_IR(sn)))

Get Sn_IR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_IR.
See also
setSn_IR()

Definition at line 1960 of file w5300.h.

◆ getSn_KPALVTR

#define getSn_KPALVTR ( sn ) ((uint8_t)(WIZCHIP_READ(Sn_KPALVTR(sn)) >> 8))

Get Sn_KPALVTR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_KPALVTR.
See also
setSn_KPALVTR()

Definition at line 2112 of file w5300.h.

◆ getSn_MR

#define getSn_MR ( sn ) WIZCHIP_READ(Sn_MR(sn))

Get Sn_MR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_MR.
See also
setSn_MR()

Definition at line 1900 of file w5300.h.

◆ getSn_MSSR

#define getSn_MSSR ( sn ) WIZCHIP_READ(Sn_MSSR(sn))

Get Sn_MSSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_MSSR.
See also
setSn_MSSR()

Definition at line 2092 of file w5300.h.

◆ getSn_PORTR

#define getSn_PORTR | ( | sn,
 |  | port
 | ) | WIZCHIP_READ(Sn_PORTR(sn))

Get Sn_PORTR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Variable of Sn_PORTR.
See also
setSn_PORTR()

Definition at line 1991 of file w5300.h.

◆ getSn_PROTOR

#define getSn_PROTOR ( sn ) ((uint8_t)WIZCHIP_READ(Sn_PROTOR(sn)))

Get Sn_PROTOR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint8_t. Value of Sn_PROTOR.
See also
setSn_PROTOR()

Definition at line 2133 of file w5300.h.

◆ getSn_RX_FIFOR

#define getSn_RX_FIFOR ( sn ) WIZCHIP_READ(Sn_RX_FIFOR(sn));

Get Sn_RX_FIFOR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_RX_FIFOR.

Definition at line 2190 of file w5300.h.

◆ getSn_SSR

#define getSn_SSR ( sn ) ((uint8_t)WIZCHIP_READ(Sn_SR(sn)))

Get Sn_SR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_SR.

Definition at line 1969 of file w5300.h.

◆ getSn_TOSR

#define getSn_TOSR ( sn ) ((uint8_t)WIZCHIP_READ(Sn_TOSR(sn)))

Get Sn_TOSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_ .
Returns
uint8_t. Value of Sn_TOSR.
See also
setSn_TOSR()

Definition at line 2211 of file w5300.h.

◆ getSn_TTLR

#define getSn_TTLR ( sn ) ((uint8_t)WIZCHIP_READ(Sn_TTL(sn)))

Get Sn_TTLR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_TTLR.
See also
setSn_TTLR()

Definition at line 2233 of file w5300.h.

◆ getSn_TX_WRSR

#define getSn_TX_WRSR ( sn ) ( (((uint32_t)WIZCHIP_READ(Sn_TX_WRSR(sn))) << 16) + (((uint32_t)WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WRSR(sn),1))) & 0x0000FFFF) )

Get Sn_TX_WRSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint32_t. Value of Sn_TX_WRSR.
See also
setSn_TX_WRSR()

Definition at line 2156 of file w5300.h.

◆ setSn_CR

#define setSn_CR | ( | sn,
 |  | cr
 | ) | WIZCHIP_WRITE(Sn_CR(sn), ((uint16_t)cr) & 0x00FF)

Set Sn_CR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)cr | Value to set Sn_CR
See also
getSn_CR()

Definition at line 1910 of file w5300.h.

◆ setSn_DHAR

#define setSn_DHAR | ( | sn,
 |  | dhar
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_DHAR(sn), (((uint16_t)((dhar)[0])) << 8) + (((uint16_t)((dhar)[1])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),2), (((uint16_t)((dhar)[0])) << 8) + (((uint16_t)((dhar)[1])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),4), (((uint16_t)((dhar)[0])) << 8) + (((uint16_t)((dhar)[1])) & 0x00FF)); \
}
Sn_DHAR
#define Sn_DHAR(n)
Peer MAC register address(R/W)
Definition: w5300.h:743
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Set Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dhar | Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes.
See also
getSn_DHAR()

Definition at line 2002 of file w5300.h.

◆ setSn_DIPR

#define setSn_DIPR | ( | sn,
 |  | dipr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_DIPR(sn), (((uint16_t)((dipr)[0])) << 8) + (((uint16_t)((dipr)[1])) & 0x00FF)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DIPR(sn),2), (((uint16_t)((dipr)[2])) << 8) + (((uint16_t)((dipr)[3])) & 0x00FF)); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60
Sn_DIPR
#define Sn_DIPR(n)
Peer IP register address(R/W)
Definition: w5300.h:765

Set Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dipr | Pointer variable to set socket n destination IP address. It should be allocated 4 bytes.
See also
getSn_DIPR()

Definition at line 2056 of file w5300.h.

◆ setSn_DPORTR

#define setSn_DPORTR | ( | sn,
 |  | dport
 | ) | WIZCHIP_WRITE(Sn_DPORTR(sn),dport)

Set Sn_DPORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)dport | Value to set Sn_DPORT
See also
getSn_DPORT()

Definition at line 2031 of file w5300.h.

◆ setSn_FRAGR

#define setSn_FRAGR | ( | sn,
 |  | frag
 | ) | WIZCHIP_WRITE(Sn_FRAGR(sn), (uint16_t)(frag >>8))

Set Sn_FRAGR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)frag | Value to set Sn_FRAGR
See also
getSn_FRAGR()

Definition at line 2244 of file w5300.h.

◆ setSn_IMR

#define setSn_IMR | ( | sn,
 |  | imr
 | ) | WIZCHIP_WRITE(Sn_IMR(sn), ((uint16_t)imr) & 0x00FF)

Set Sn_IMR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)imr | Value to set Sn_IMR
See also
getSn_IMR()

Definition at line 1930 of file w5300.h.

◆ setSn_IR

#define setSn_IR | ( | sn,
 |  | ir
 | ) | WIZCHIP_WRITE(Sn_IR(sn), ((uint16_t)ir) & 0x00FF)

Set Sn_IR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)ir | Value to set Sn_IR
See also
getSn_IR()

Definition at line 1950 of file w5300.h.

◆ setSn_KPALVTR

#define setSn_KPALVTR | ( | sn,
 |  | kpalvt
 | ) | WIZCHIP_WRITE(Sn_KPALVTR(sn), (WIZCHIP_READ(Sn_KPALVTR(sn)) & 0x00FF) | (((uint16_t)kpalvt)<<8))

Set Sn_KPALVTR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)kpalvt | Value to set Sn_KPALVTR
See also
getSn_KPALVTR()

Definition at line 2102 of file w5300.h.

◆ setSn_MR

#define setSn_MR | ( | sn,
 |  | mr
 | ) | WIZCHIP_WRITE(Sn_MR(sn),mr)

Set Sn_MR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)mr | Value to set Sn_MR
See also
getSn_MR()

Definition at line 1890 of file w5300.h.

◆ setSn_MSSR

#define setSn_MSSR | ( | sn,
 |  | mss
 | ) | WIZCHIP_WRITE(Sn_MSSR(sn), mss)

Set Sn_MSSR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)mss | Value to set Sn_MSSR
See also
setSn_MSSR()

Definition at line 2082 of file w5300.h.

◆ setSn_PORTR

#define setSn_PORTR | ( | sn,
 |  | port
 | ) | WIZCHIP_WRITE(Sn_PORTR(sn), port)

Set Sn_PORTR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)port | Variable to set Sn_PORTR.
See also
getSn_PORTR()

Definition at line 1980 of file w5300.h.

◆ setSn_PROTOR

#define setSn_PROTOR | ( | sn,
 |  | proto
 | ) | WIZCHIP_WRITE(Sn_PROTOR(sn),(WIZCHIP_READ(Sn_PROTOR(sn) & 0xFF00) | (((uint16_t)proto) & 0x00FF))

Set Sn_PROTOR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)proto | Value to set Sn_PROTOR
See also
getSn_PROTOR()

Definition at line 2122 of file w5300.h.

◆ setSn_TOSR

#define setSn_TOSR | ( | sn,
 |  | tos
 | ) | WIZCHIP_WRITE(Sn_TOS(sn), ((uint16_t)tos) & 0x00FF)

Set Sn_TOSR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
(uint8_t)tos | Value to set Sn_TOSR
See also
getSn_TOSR()

Definition at line 2200 of file w5300.h.

◆ setSn_TTLR

#define setSn_TTLR | ( | sn,
 |  | ttl
 | ) | WIZCHIP_WRITE(Sn_TTLR(sn), ((uint16_t)ttl) & 0x00FF)

Set Sn_TTLR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)ttl | Value to set Sn_TTLR
See also
getSn_TTLR()

Definition at line 2222 of file w5300.h.

◆ setSn_TX_FIFOR

#define setSn_TX_FIFOR | ( | sn,
 |  | txfifo
 | ) | WIZCHIP_WRITE(Sn_TX_FIFOR(sn), txfifo);

Set Sn_TX_FIFOR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)txfifo. | Value to set Sn_TX_FIFOR.

Definition at line 2181 of file w5300.h.

◆ setSn_TX_WRSR

#define setSn_TX_WRSR | ( | sn,
 |  | txwrs
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_TX_WRSR(sn), (uint16_t)(((uint32_t)txwrs) >> 16)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WRSR(sn),2), (uint16_t)txwrs); \
}
Sn_TX_WRSR
#define Sn_TX_WRSR(n)
SOCKETn TX write size register(R/W)
Definition: w5300.h:821
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Set Sn_TX_WRSR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint32_t)txwrs | Value to set Sn_KPALVTR (It should be <= 0x00010000)
See also
getSn_TX_WRSR()

Definition at line 2144 of file w5300.h.

Function Documentation

◆ getSn_RX_RSR()

uint32_t getSn_RX_RSR ( uint8_t sn )

Get Sn_RX_RSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint32_t. Value of Sn_RX_RSR.
Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_RSR.

Definition at line 254 of file w5100s.c.

◆ getSn_TX_FSR()

uint32_t getSn_TX_FSR ( uint8_t sn )

Get Sn_TX_FSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint32_t. Value of Sn_TX_FSR.
Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_FSR.

Definition at line 237 of file w5100s.c.


ioLibrary: W5500

Modules
W5500

WHIZCHIP register defines and I/O functions of W5500. More...

Collaboration diagram for W5500:

Modules

WIZCHIP register
WHIZCHIP register defines register group of W5500.
WIZCHIP I/O functions
This supports the basic I/O functions for WIZCHIP register.

Detailed Description

WHIZCHIP register defines and I/O functions of W5500.

  • WIZCHIP register : Common register and Socket register
  • WIZCHIP I/O functions : Basic I/O function, Common register access functions and Socket register access functions


ioLibrary: WIZCHIP register

Modules
WIZCHIP register
W5500

WHIZCHIP register defines register group of W5500. More...

Collaboration diagram for WIZCHIP register:

Modules

Common register
Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.
Socket register
Socket register group.
Socket register configures and control SOCKETn which is necessary to data communication.

Detailed Description

WHIZCHIP register defines register group of W5500.

  • Common register : Common register group
  • Socket register : SOCKET n register group


ioLibrary: Common register

Macros
Common register
W5500 » WIZCHIP register

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc. More...

Collaboration diagram for Common register:

Macros

#define | MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Source MAC Register address(R/W) More...
#define | SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3))
Source IP Register address(R/W) More...
#define | INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Set Interrupt low level timer register address(R/W) More...
#define | IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Interrupt mask register(R/W) More...
#define | SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Socket Interrupt Register(R/W) More...
#define | SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))
Retry count register(R/W) More...
#define | PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP LCP Request Timer register in PPPoE mode(R/W) More...
#define | PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP LCP Magic number register in PPPoE mode(R/W) More...
#define | PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP Destination MAC Register address(R/W) More...
#define | PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP Session Identification Register(R/W) More...
#define | PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP Maximum Segment Size(MSS) register(R/W) More...
#define | UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Unreachable IP register address in UDP mode(R) More...
#define | UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3))
Unreachable Port register address in UDP mode(R) More...
#define | PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3))
PHY Status Register(R/W) More...
#define | VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3))
chip version register address(R) More...

Detailed Description

Common register group
It set the basic for the networking
It set the configuration such as interrupt, network information, ICMP, etc.

See also
MR : Mode register.
GAR, SUBR, SHAR, SIPR
INTLEVEL, IR, IMR, SIR, SIMR : Interrupt.
RTR, RCR : Data retransmission.
PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE.
UIPR, UPORTR : ICMP message.
PHYCFGR, VERSIONR : etc.

Macro Definition Documentation

◆ _IMR_

#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Interrupt mask register(R/W)

IMR is used to mask interrupts. Each bit of IMR corresponds to each bit of IR. When a bit of IMR is and the corresponding bit of IR is an interrupt will be issued. In other words, if a bit of IMR is an interrupt will not be issued even if the corresponding bit of IR is

Each bit of IMR defined as the following.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
IM_IR7 | IM_IR6 | IM_IR5 | IM_IR4 | Reserved | Reserved | Reserved | Reserved
  • IM_IR7 : IP Conflict Interrupt Mask
  • IM_IR6 : Destination unreachable Interrupt Mask
  • IM_IR5 : PPPoE Close Interrupt Mask
  • IM_IR4 : Magic Packet Interrupt Mask

Definition at line 286 of file w5500.h.

◆ _RCR_

#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))

Retry count register(R/W)

RCR configures the number of time of retransmission. When retransmission occurs as many as ref RCR+1 Timeout interrupt is issued (Sn_IR_TIMEOUT = '1').

Definition at line 325 of file w5500.h.

◆ _RTR_

#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Timeout register address( 1 is 100us )(R/W)

RTR configures the retransmission timeout period. The unit of timeout period is 100us and the default of RTR is x07D0. And so the default timeout period is 200ms(100us X 2000). During the time configured by RTR, W5500 waits for the peer response to the packet that is transmitted by Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). If the peer does not respond within the RTR time, W5500 retransmits the packet or issues timeout.

Definition at line 315 of file w5500.h.

◆ GAR

#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Gateway IP Register address(R/W)

GAR configures the default gateway address.

Definition at line 221 of file w5500.h.

◆ INTLEVEL

#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Set Interrupt low level timer register address(R/W)

INTLEVEL configures the Interrupt Assert Time.

Definition at line 249 of file w5500.h.

◆ IR

#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Interrupt Register(R/W)

IR indicates the interrupt status. Each bit of IR will be still until the bit will be written to by the host. If IR is not equal to x00 INTn PIN is asserted to low until it is x00

Each bit of IR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
CONFLICT | UNREACH | PPPoE | MP | Reserved | Reserved | Reserved | Reserved
  • IR_CONFLICT : IP conflict
  • IR_UNREACH : Destination unreachable
  • IR_PPPoE : PPPoE connection close
  • IR_MP : Magic packet

Definition at line 266 of file w5500.h.

◆ MR

#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc.

Each bit of MR defined as follows.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
RST | Reserved | WOL | PB | PPPoE | Reserved | FARP | Reserved
  • MR_RST : Reset
  • MR_WOL : Wake on LAN
  • MR_PB : Ping block
  • MR_PPPOE : PPPoE mode
  • MR_FARP : Force ARP mode

Definition at line 214 of file w5500.h.

◆ PHAR

#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3))

PPP Destination MAC Register address(R/W)

PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process.

Definition at line 346 of file w5500.h.

◆ PHYCFGR

#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3))

PHY Status Register(R/W)

PHYCFGR configures PHY operation mode and resets PHY. In addition, PHYCFGR indicates the status of PHY such as duplex, Speed, Link.

Definition at line 385 of file w5500.h.

◆ PMAGIC

#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3))

PPP LCP Magic number register in PPPoE mode(R/W)

PMAGIC configures the 4bytes magic number to be used in LCP negotiation.

Definition at line 339 of file w5500.h.

◆ PMRU

#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3))

PPP Maximum Segment Size(MSS) register(R/W)

PMRU configures the maximum receive unit of PPPoE.

Definition at line 360 of file w5500.h.

◆ PSID

#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3))

PPP Session Identification Register(R/W)

PSID configures the PPPoE sever session ID acquired during PPPoE connection process.

Definition at line 353 of file w5500.h.

◆ PTIMER

#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3))

PPP LCP Request Timer register in PPPoE mode(R/W)

PTIMER configures the time for sending LCP echo request. The unit of time is 25ms.

Definition at line 332 of file w5500.h.

◆ SHAR

#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Source MAC Register address(R/W)

SHAR configures the source hardware address.

Definition at line 235 of file w5500.h.

◆ SIMR

#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Socket Interrupt Mask Register(R/W)

Each bit of SIMR corresponds to each bit of SIR. When a bit of SIMR is and the corresponding bit of SIR is Interrupt will be issued. In other words, if a bit of SIMR is an interrupt will be not issued even if the corresponding bit of SIR is

Definition at line 303 of file w5500.h.

◆ SIPR

#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3))

Source IP Register address(R/W)

SIPR configures the source IP address.

Definition at line 242 of file w5500.h.

◆ SIR

#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Socket Interrupt Register(R/W)

SIR indicates the interrupt status of Socket.
Each bit of SIR be still until Sn_IR is cleared by the host.
If Sn_IR is not equal to x00 the n-th bit of SIR is and INTn PIN is asserted until SIR is x00

Definition at line 294 of file w5500.h.

◆ SUBR

#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Subnet mask Register address(R/W)

SUBR configures the subnet mask address.

Definition at line 228 of file w5500.h.

◆ UIPR

#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3))

Unreachable IP register address in UDP mode(R)

W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number which socket is not open and IR_UNREACH bit of IR becomes and UIPR & UPORTR indicates the destination IP address & port number respectively.

Definition at line 369 of file w5500.h.

◆ UPORTR

#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3))

Unreachable Port register address in UDP mode(R)

W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number which socket is not open and IR_UNREACH bit of IR becomes and UIPR & UPORTR indicates the destination IP address & port number respectively.

Definition at line 378 of file w5500.h.

◆ VERSIONR

#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3))

chip version register address(R)

VERSIONR always indicates the W5500 version as 0x04.

Definition at line 403 of file w5500.h.


ioLibrary: Socket register

Macros
Socket register
W5500 » WIZCHIP register

Socket register group.
Socket register configures and control SOCKETn which is necessary to data communication. More...

Collaboration diagram for Socket register:

Macros

#define | Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
socket Mode register(R/W) More...
#define | Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Socket command register(R/W) More...
#define | Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Socket interrupt register(R) More...
#define | Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Socket status register(R) More...
#define | Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
source port register(R/W) More...
#define | Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Peer IP register address(R/W) More...
#define | Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Peer port register address(R/W) More...
#define | Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Receive memory size register(R/W) More...
#define | Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit memory size register(R/W) More...
#define | Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Received data size register(R) More...
#define | Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Write point of Receive memory(R) More...
#define | Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
socket interrupt mask register(R) More...
#define | Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Fragment field value in IP header register(R/W) More...
#define | Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Keep Alive Timer register(R/W) More...

Detailed Description

Socket register group.
Socket register configures and control SOCKETn which is necessary to data communication.

See also
Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control
Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information
Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol.
Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication

Macro Definition Documentation

◆ Sn_CR

#define Sn_CR ( N ) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Socket command register(R/W)

This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.
After W5500 accepts the command, the Sn_CR register is automatically cleared to 0x00. Even though Sn_CR is cleared to 0x00, the command is still being processed.
To check whether the command is completed or not, please check the Sn_IR or Sn_SR.

  • Sn_CR_OPEN : Initialize or open socket.
  • Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode)
  • Sn_CR_CONNECT : Send connection request in TCP mode(Client mode)
  • Sn_CR_DISCON : Send closing request in TCP mode.
  • Sn_CR_CLOSE : Close socket.
  • Sn_CR_SEND : Update TX buffer pointer and send data.
  • Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process.
  • Sn_CR_SEND_KEEP : Send keep alive message.
  • Sn_CR_RECV : Update RX buffer pointer and receive data.

Definition at line 456 of file w5500.h.

◆ Sn_DHAR

#define Sn_DHAR ( N ) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Peer MAC register address(R/W)

Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or it indicates that it is acquired in ARP-process by CONNECT/SEND command.

Definition at line 513 of file w5500.h.

◆ Sn_DIPR

#define Sn_DIPR ( N ) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Peer IP register address(R/W)

Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command.

Definition at line 523 of file w5500.h.

◆ Sn_DPORT

#define Sn_DPORT ( N ) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Peer port register address(R/W)

Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command.

Definition at line 533 of file w5500.h.

◆ Sn_FRAG

#define Sn_FRAG ( N ) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Fragment field value in IP header register(R/W)

Sn_FRAG configures the FRAG(Fragment field in IP header).

Definition at line 672 of file w5500.h.

◆ Sn_IMR

#define Sn_IMR ( N ) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

socket interrupt mask register(R)

Sn_IMR masks the interrupt of Socket n. Each bit corresponds to each bit of Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of Sn_IMR is the corresponding bit of Sn_IR becomes When both the corresponding bit of Sn_IMR and Sn_IR are and the n-th bit of IR is Host is interrupted by asserted INTn PIN to low.

Definition at line 665 of file w5500.h.

◆ Sn_IR

#define Sn_IR ( N ) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Socket interrupt register(R)

Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).
When an interrupt occurs and the corresponding bit of Sn_IMR is the corresponding bit of Sn_IR becomes
In order to clear the Sn_IR bit, the host should write the bit to

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
Reserved | Reserved | Reserved | SEND_OK | TIMEOUT | RECV | DISCON | CON
  • Sn_IR_SENDOK : SEND_OK Interrupt
  • Sn_IR_TIMEOUT : TIMEOUT Interrupt
  • Sn_IR_RECV : RECV Interrupt
  • Sn_IR_DISCON : DISCON Interrupt
  • Sn_IR_CON : CON Interrupt

Definition at line 474 of file w5500.h.

◆ Sn_KPALVTR

#define Sn_KPALVTR ( N ) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Keep Alive Timer register(R/W)

Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, and ignored in other modes. The time unit is 5s. KA packet is transmittable after Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. In case of 'Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). In case of 'Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). Manual-keep-alive-process is ignored in case of 'Sn_KPALVTR > 0'.

Definition at line 685 of file w5500.h.

◆ Sn_MR

#define Sn_MR ( N ) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

socket Mode register(R/W)

Sn_MR configures the option or protocol type of Socket n.

Each bit of Sn_MR defined as the following.

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
MULTI/MFEN | BCASTB | ND/MC/MMB | UCASTB/MIP6B | Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0]
  • Sn_MR_MULTI : Support UDP Multicasting
  • Sn_MR_BCASTB : Broadcast block in UDP Multicasting
  • Sn_MR_ND : No Delayed Ack(TCP) flag
  • Sn_MR_MC : IGMP version used in UDP mulitcasting
  • Sn_MR_MMB : Multicast Blocking in Sn_MR_MACRAW mode
  • Sn_MR_UCASTB : Unicast Block in UDP Multicating
  • Sn_MR_MIP6B : IPv6 packet Blocking in Sn_MR_MACRAW mode
  • Protocol
    Protocol[3] | Protocol[2] | Protocol[1] | Protocol[0] | Meaning
    0 | 0 | 0 | 0 | Closed
    0 | 0 | 0 | 1 | TCP
    0 | 0 | 1 | 0 | UDP
    0 | 1 | 0 | 0 | MACRAW
    • Sn_MR_MACRAW : MAC LAYER RAW SOCK
    • Sn_MR_UDP : UDP
    • Sn_MR_TCP : TCP
    • Sn_MR_CLOSE : Unused socket
      Note
      MACRAW mode should be only used in Socket 0.

Definition at line 437 of file w5500.h.

◆ Sn_MSSR

#define Sn_MSSR ( N ) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Maximum Segment Size(Sn_MSSR0) register address(R/W)

Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n.

Definition at line 540 of file w5500.h.

◆ Sn_PORT

#define Sn_PORT ( N ) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

source port register(R/W)

Sn_PORT configures the source port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered.

Definition at line 505 of file w5500.h.

◆ Sn_RX_RD

#define Sn_RX_RD ( N ) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Read point of Receive memory(R/W)

Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.

  1. Read the starting save address of the received data.
  2. Read data from the starting address of Socket n RX Buffer.
  3. After reading the received data, Update Sn_RX_RD to the increased value as many as the reading size. If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, update with the lower 16bits value ignored the carry bit.
  4. Order RECV command is for notifying the updated Sn_RX_RD to W5500.

Definition at line 646 of file w5500.h.

◆ Sn_RX_RSR

#define Sn_RX_RSR ( N ) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Received data size register(R)

Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. Sn_RX_RSR does not exceed the Sn_RXBUF_SIZE and is calculated as the difference between �Socket n RX Write Pointer (Sn_RX_WR)and �Socket n RX Read Pointer (Sn_RX_RD)

Definition at line 633 of file w5500.h.

◆ Sn_RX_WR

#define Sn_RX_WR ( N ) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Write point of Receive memory(R)

Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 655 of file w5500.h.

◆ Sn_RXBUF_SIZE

#define Sn_RXBUF_SIZE ( N ) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Receive memory size register(R/W)

Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. If a different size is configured, the data cannot be normally received from a peer. Although Socket n RX Buffer Block size is initially configured to 2Kbytes, user can re-configure its size using Sn_RXBUF_SIZE. The total sum of Sn_RXBUF_SIZE can not be exceed 16Kbytes. When exceeded, the data reception error is occurred.

Definition at line 576 of file w5500.h.

◆ Sn_SR

#define Sn_SR ( N ) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Socket status register(R)

Sn_SR indicates the status of Socket n.
The status of Socket n is changed by Sn_CR or some special control packet as SYN, FIN packet in TCP.

Normal status
  • SOCK_CLOSED : Closed
  • SOCK_INIT : Initiate state
  • SOCK_LISTEN : Listen state
  • SOCK_ESTABLISHED : Success to connect
  • SOCK_CLOSE_WAIT : Closing state
  • SOCK_UDP : UDP socket
  • SOCK_MACRAW : MAC raw mode socket
Temporary status during changing the status of Socket n.
  • SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
  • SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
  • SOCK_FIN_WAIT : Connection state
  • SOCK_CLOSING : Closing state
  • SOCK_TIME_WAIT : Closing state
  • SOCK_LAST_ACK : Closing state

Definition at line 497 of file w5500.h.

◆ Sn_TOS

#define Sn_TOS ( N ) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

IP Type of Service(TOS) Register(R/W)

Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. It is set before OPEN command.

Definition at line 550 of file w5500.h.

◆ Sn_TTL

#define Sn_TTL ( N ) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

IP Time to live(TTL) Register(R/W)

Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. It is set before OPEN command.

Definition at line 557 of file w5500.h.

◆ Sn_TX_FSR

#define Sn_TX_FSR ( N ) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Transmit free memory size register(R)

Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by Sn_TXBUF_SIZE. Data bigger than Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, transmit the data after dividing into the checked size and saving in the Socket n TX buffer.

Definition at line 598 of file w5500.h.

◆ Sn_TX_RD

#define Sn_TX_RD ( N ) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Transmit memory read pointer register address(R)

Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. After its initialization, it is auto-increased by SEND command. SEND command transmits the saved data from the current Sn_TX_RD to the Sn_TX_WR in the Socket n TX Buffer. After transmitting the saved data, the SEND command increases the Sn_TX_RD as same as the Sn_TX_WR. If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.

Definition at line 610 of file w5500.h.

◆ Sn_TX_WR

#define Sn_TX_WR ( N ) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Transmit memory write pointer register address(R/W)

Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.
It should be read or be updated like as follows.

  1. Read the starting address for saving the transmitting data.
  2. Save the transmitting data from the starting address of Socket n TX buffer.
  3. After saving the transmitting data, update Sn_TX_WR to the increased value as many as transmitting data size. If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.
  4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command

Definition at line 624 of file w5500.h.

◆ Sn_TXBUF_SIZE

#define Sn_TXBUF_SIZE ( N ) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))

Transmit memory size register(R/W)

Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. If a different size is configured, the data can�t be normally transmitted to a peer. Although Socket n TX Buffer Block size is initially configured to 2Kbytes, user can be re-configure its size using Sn_TXBUF_SIZE. The total sum of Sn_TXBUF_SIZE can not be exceed 16Kbytes. When exceeded, the data transmission error is occurred.

Definition at line 587 of file w5500.h.


ioLibrary: WIZCHIP I/O functions

Modules
WIZCHIP I/O functions
W5500

This supports the basic I/O functions for WIZCHIP register. More...

Collaboration diagram for WIZCHIP I/O functions:

Modules

Basic I/O function
These are basic input/output functions to read values from register or write values to register.
Common register access functions
These are functions to access common registers.
Socket register access functions
These are functions to access socket registers.

Detailed Description

This supports the basic I/O functions for WIZCHIP register.

  • Basic I/O function
    WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()

  • Common register access functions
    1. Mode
      getMR(), setMR()
    2. Interrupt
      getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL()
    3. Network Information
      getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR()
    4. Retransmission
      getRCR(), setRCR(), getRTR(), setRTR()
    5. PPPoE
      getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU()
    6. ICMP packet
      getUIPR(), getUPORTR()
    7. etc.
      getPHYCFGR(), setPHYCFGR(), getVERSIONR()

  • Socket register access functions
    1. SOCKET control
      getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR()
    2. SOCKET information
      getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() getSn_MSSR(), setSn_MSSR()
    3. SOCKET communication
      getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE()
      getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR()
      getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR()
      getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR()
    4. IP header field
      getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS()
      getSn_TTL(), setSn_TTL()


ioLibrary: Basic I/O function

Functions
Basic I/O function
W5500 » WIZCHIP I/O functions

These are basic input/output functions to read values from register or write values to register. More...

Collaboration diagram for Basic I/O function:

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...

Detailed Description

These are basic input/output functions to read values from register or write values to register.

Function Documentation

◆ wiz_recv_data()

void wiz_recv_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after that, it copies the received data from internal RX memory to wizdata(pointer variable) of the length of len(variable) bytes. This function is being called by recv() also.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
wizdata | Pointer buffer to read data
len | Data length
See also
wiz_send_data()

It copies data to your buffer from internal RX memory.

This function read the Rx read pointer register and after copy the data from receive buffer update the Rx write pointer register. User should read upper byte first and lower byte later to get proper value. It calculate the actual physical address where one has to read the data from Receive buffer. Here also take care of the condition while it exceed the Rx memory uper-bound of socket.

Definition at line 353 of file w5100s.c.

◆ wiz_recv_ignore()

void wiz_recv_ignore | ( | uint8_t | sn,
 |  | uint16_t | len
 | ) |  |

It discard the received data in RX memory.

It discards the data of the length of len(variable) bytes in internal RX memory.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
len | Data length

It discards the data of the length of len(variable) bytes in internal RX memory.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
len | Data length

Definition at line 385 of file w5100s.c.

◆ wiz_send_data()

void wiz_send_data | ( | uint8_t | sn,
 |  | uint8_t * | wizdata,
 |  | uint16_t | len
 | ) |  |

It copies data to internal TX memory.

This function reads the Tx write pointer register and after that, it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory and updates the Tx write pointer register. This function is being called by send() and sendto() function also.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
wizdata | Pointer buffer to write data
len | Data length
See also
wiz_recv_data()

It copies data to internal TX memory.

This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer register. User should read upper byte first and lower byte later to get proper value. And this function is being used for copy the data form application buffer to Transmite buffer of the chip. It calculate the actual physical address where one has to write the data in transmite buffer. Here also take care of the condition while it exceed the Tx memory uper-bound of socket.

Definition at line 311 of file w5100s.c.

◆ WIZCHIP_READ()

uint8_t WIZCHIP_READ ( uint32_t AddrSel )

It reads 1 byte value from a register.

Parameters
AddrSel Register address
Returns
The value of register

It reads 1 byte value from a register.

Definition at line 83 of file w5100s.c.

◆ WIZCHIP_READ_BUF()

void WIZCHIP_READ_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It reads sequence data from registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to read data
len | Data length

It reads sequence data from registers.

Definition at line 181 of file w5100s.c.

◆ WIZCHIP_WRITE()

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

It writes 1 byte value to a register.

Parameters
AddrSel | Register address
wb | Write data
Returns
void

It writes 1 byte value to a register.

Definition at line 47 of file w5100s.c.

◆ WIZCHIP_WRITE_BUF()

void WIZCHIP_WRITE_BUF | ( | uint32_t | AddrSel,
 |  | uint8_t * | pBuf,
 |  | uint16_t | len
 | ) |  |

It writes sequence data to registers.

Parameters
AddrSel | Register address
pBuf | Pointer buffer to write data
len | Data length

It writes sequence data to registers.

Definition at line 124 of file w5100s.c.


ioLibrary: Common register access functions

Macros
Common register access functions
W5500 » WIZCHIP I/O functions

These are functions to access common registers. More...

Collaboration diagram for Common register access functions:

Macros

#define | getSHAR(shar)
Get local MAC address. More...
#define | setMR(mr) WIZCHIP_WRITE(MR,mr)
Set Mode Register. More...
#define | getMR() WIZCHIP_READ(MR)
Get Mode Register. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set gateway IP address. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get gateway IP address. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR, subr,4)
Set subnet mask address. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get subnet mask address. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set local MAC address. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get local MAC address. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set local IP address. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get local IP address. More...
#define | setINTLEVEL(intlevel)
Set INTLEVEL register. More...
#define | getINTLEVEL() (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
Get INTLEVEL register. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xF0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xF0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr)
Set IMR register. More...
#define | getIMR() WIZCHIP_READ(_IMR_)
Get IMR register. More...
#define | setSIR(sir) WIZCHIP_WRITE(SIR, sir)
Set SIR register. More...
#define | getSIR() WIZCHIP_READ(SIR)
Get SIR register. More...
#define | setSIMR(simr) WIZCHIP_WRITE(SIMR, simr)
Set SIMR register. More...
#define | getSIMR() WIZCHIP_READ(SIMR)
Get SIMR register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...
#define | setPHAR(phar) WIZCHIP_WRITE_BUF(PHAR, phar, 6)
Set PHAR address. More...
#define | getPHAR(phar) WIZCHIP_READ_BUF(PHAR, phar, 6)
Get PHAR address. More...
#define | setPSID(psid)
Set PSID register. More...
#define | getPSID() (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))
Get PSID register. More...
#define | setPMRU(pmru)
Set PMRU register. More...
#define | getPMRU() (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))
Get PMRU register. More...
#define | getUIPR(uipr) WIZCHIP_READ_BUF(UIPR,uipr,4)
Get unreachable IP address. More...
#define | getUPORTR() (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))
Get UPORTR register. More...
#define | setPHYCFGR(phycfgr) WIZCHIP_WRITE(PHYCFGR, phycfgr)
Set PHYCFGR register. More...
#define | getPHYCFGR() WIZCHIP_READ(PHYCFGR)
Get PHYCFGR register. More...
#define | getVERSIONR() WIZCHIP_READ(VERSIONR)
Get VERSIONR register. More...

Detailed Description

These are functions to access common registers.

Macro Definition Documentation

◆ getGAR

#define getGAR ( gar ) WIZCHIP_READ_BUF(GAR,gar,4)

Get gateway IP address.

Parameters
(uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes.
See also
setGAR()

Definition at line 1275 of file w5500.h.

◆ getIMR

#define getIMR ( ) WIZCHIP_READ(_IMR_)

Get IMR register.

Returns
uint8_t. Value of IMR register.
See also
setIMR()

Definition at line 1391 of file w5500.h.

◆ getINTLEVEL

#define getINTLEVEL ( ) (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))

Get INTLEVEL register.

Returns
uint16_t. Value of INTLEVEL register.
See also
setINTLEVEL()

Definition at line 1356 of file w5500.h.

◆ getIR

#define getIR ( ) (WIZCHIP_READ(IR) & 0xF0)

Get IR register.

Returns
uint8_t. Value of IR register.
See also
setIR()

Definition at line 1374 of file w5500.h.

◆ getMR

#define getMR ( ) WIZCHIP_READ(MR)

Get Mode Register.

Returns
uint8_t. The value of Mode register.
See also
setMR()

Definition at line 1257 of file w5500.h.

◆ getPHAR

#define getPHAR ( phar ) WIZCHIP_READ_BUF(PHAR, phar, 6)

Get PHAR address.

Parameters
(uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes.
See also
setPHAR()

Definition at line 1526 of file w5500.h.

◆ getPHYCFGR

#define getPHYCFGR ( ) WIZCHIP_READ(PHYCFGR)

Get PHYCFGR register.

Returns
uint8_t. Value of PHYCFGR register.
See also
setPHYCFGR()

Definition at line 1621 of file w5500.h.

◆ getPMAGIC

#define getPMAGIC ( ) WIZCHIP_READ(PMAGIC)

Get PMAGIC register.

Returns
uint8_t. Value of PMAGIC register.
See also
setPMAGIC()

Definition at line 1508 of file w5500.h.

◆ getPMRU

#define getPMRU ( ) (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))

Get PMRU register.

Returns
uint16_t. Value of PMRU register.
See also
setPMRU()

Definition at line 1577 of file w5500.h.

◆ getPSID

#define getPSID ( ) (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))

Get PSID register.

Returns
uint16_t. Value of PSID register.
See also
setPSID()

Definition at line 1552 of file w5500.h.

◆ getPTIMER

#define getPTIMER ( ) WIZCHIP_READ(PTIMER)

Get PTIMER register.

Returns
uint8_t. Value of PTIMER register.
See also
setPTIMER()

Definition at line 1490 of file w5500.h.

◆ getRCR

#define getRCR ( ) WIZCHIP_READ(_RCR_)

Get RCR register.

Returns
uint8_t. Value of RCR register.
See also
setRCR()

Definition at line 1470 of file w5500.h.

◆ getRTR

#define getRTR ( ) (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))

Get RTR register.

Returns
uint16_t. Value of RTR register.
See also
setRTR()

Definition at line 1451 of file w5500.h.

◆ getSHAR [1/2]

#define getSHAR ( shar ) WIZCHIP_READ_BUF(SHAR, shar, 6)

Get local MAC address.

Parameters
(uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes.
See also
setSHAR()

Definition at line 1312 of file w5500.h.

◆ getSHAR [2/2]

#define getSHAR ( shar )
Value:
{ \
(shar)[0] = (uint8_t)(WIZCHIP_READ(SHAR) >> 8); \
(shar)[1] = (uint8_t)(WIZCHIP_READ(SHAR)); \
(shar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,2)) >> 8); \
(shar)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,2))); \
(shar)[4] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,4)) >> 8); \
(shar)[5] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,4))); \
}
SHAR
#define SHAR
Source MAC Register address(R/W)
Definition: w5300.h:267
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5300.h:60

Get local MAC address.

Parameters
(uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes.
See also
setSHAR()

Definition at line 1419 of file w5300.h.

◆ getSIMR

#define getSIMR ( ) WIZCHIP_READ(SIMR)

Get SIMR register.

Returns
uint8_t. Value of SIMR register.
See also
setSIMR()

Definition at line 1426 of file w5500.h.

◆ getSIPR

#define getSIPR ( sipr ) WIZCHIP_READ_BUF(SIPR, sipr, 4)

Get local IP address.

Parameters
(uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes.
See also
setSIPR()

Definition at line 1330 of file w5500.h.

◆ getSIR

#define getSIR ( ) WIZCHIP_READ(SIR)

Get SIR register.

Returns
uint8_t. Value of SIR register.
See also
setSIR()

Definition at line 1409 of file w5500.h.

◆ getSUBR

#define getSUBR ( subr ) WIZCHIP_READ_BUF(SUBR, subr, 4)

Get subnet mask address.

Parameters
(uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes.
See also
setSUBR()

Definition at line 1294 of file w5500.h.

◆ getUIPR

#define getUIPR ( uipr ) WIZCHIP_READ_BUF(UIPR,uipr,4)

Get unreachable IP address.

Parameters
(uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes.

Definition at line 1590 of file w5500.h.

◆ getUPORTR

#define getUPORTR ( ) (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))

Get UPORTR register.

Returns
uint16_t. Value of UPORTR register.

Definition at line 1603 of file w5500.h.

◆ getVERSIONR

#define getVERSIONR ( ) WIZCHIP_READ(VERSIONR)

Get VERSIONR register.

Returns
uint8_t. Value of VERSIONR register.

Definition at line 1629 of file w5500.h.

◆ setGAR

#define setGAR ( gar ) WIZCHIP_WRITE_BUF(GAR,gar,4)

Set gateway IP address.

Parameters
(uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes.
See also
getGAR()

Definition at line 1266 of file w5500.h.

◆ setIMR

#define setIMR ( imr ) WIZCHIP_WRITE(_IMR_, imr)

Set IMR register.

Parameters
(uint8_t)imr Value to set IMR register.
See also
getIMR()

Definition at line 1382 of file w5500.h.

◆ setINTLEVEL

#define setINTLEVEL ( intlevel )
Value:
{\
WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
INTLEVEL
#define INTLEVEL
Set Interrupt low level timer register address(R/W)
Definition: w5500.h:249

Set INTLEVEL register.

Parameters
(uint16_t)intlevel Value to set INTLEVEL register.
See also
getINTLEVEL()

Definition at line 1339 of file w5500.h.

◆ setIR

#define setIR ( ir ) WIZCHIP_WRITE(IR, (ir & 0xF0))

Set IR register.

Parameters
(uint8_t)ir Value to set IR register.
See also
getIR()

Definition at line 1365 of file w5500.h.

◆ setMR

#define setMR ( mr ) WIZCHIP_WRITE(MR,mr)

Set Mode Register.

Parameters
(uint8_t)mr The value to be set.
See also
getMR()

Definition at line 1247 of file w5500.h.

◆ setPHAR

#define setPHAR ( phar ) WIZCHIP_WRITE_BUF(PHAR, phar, 6)

Set PHAR address.

Parameters
(uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes.
See also
getPHAR()

Definition at line 1517 of file w5500.h.

◆ setPHYCFGR

#define setPHYCFGR ( phycfgr ) WIZCHIP_WRITE(PHYCFGR, phycfgr)

Set PHYCFGR register.

Parameters
(uint8_t)phycfgr Value to set PHYCFGR register.
See also
getPHYCFGR()

Definition at line 1612 of file w5500.h.

◆ setPMAGIC

#define setPMAGIC ( pmagic ) WIZCHIP_WRITE(PMAGIC, pmagic)

Set PMAGIC register.

Parameters
(uint8_t)pmagic Value to set PMAGIC register.
See also
getPMAGIC()

Definition at line 1499 of file w5500.h.

◆ setPMRU

#define setPMRU ( pmru )
Value:
{ \
WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
PMRU
#define PMRU
PPP Maximum Segment Size(MSS) register(R/W)
Definition: w5500.h:360

Set PMRU register.

Parameters
(uint16_t)pmru Value to set PMRU register.
See also
getPMRU()

Definition at line 1561 of file w5500.h.

◆ setPSID

#define setPSID ( psid )
Value:
{\
WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
PSID
#define PSID
PPP Session Identification Register(R/W)
Definition: w5500.h:353

Set PSID register.

Parameters
(uint16_t)psid Value to set PSID register.
See also
getPSID()

Definition at line 1535 of file w5500.h.

◆ setPTIMER

#define setPTIMER ( ptimer ) WIZCHIP_WRITE(PTIMER, ptimer)

Set PTIMER register.

Parameters
(uint8_t)ptimer Value to set PTIMER register.
See also
getPTIMER()

Definition at line 1481 of file w5500.h.

◆ setRCR

#define setRCR ( rcr ) WIZCHIP_WRITE(_RCR_, rcr)

Set RCR register.

Parameters
(uint8_t)rcr Value to set RCR register.
See also
getRCR()

Definition at line 1461 of file w5500.h.

◆ setRTR

#define setRTR ( rtr )
Value:
{\
WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
_RTR_
#define _RTR_
Timeout register address( 1 is 100us )(R/W)
Definition: w5500.h:315

Set RTR register.

Parameters
(uint16_t)rtr Value to set RTR register.
See also
getRTR()

Definition at line 1435 of file w5500.h.

◆ setSHAR

#define setSHAR ( shar ) WIZCHIP_WRITE_BUF(SHAR, shar, 6)

Set local MAC address.

Parameters
(uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes.
See also
getSHAR()

Definition at line 1303 of file w5500.h.

◆ setSIMR

#define setSIMR ( simr ) WIZCHIP_WRITE(SIMR, simr)

Set SIMR register.

Parameters
(uint8_t)simr Value to set SIMR register.
See also
getSIMR()

Definition at line 1417 of file w5500.h.

◆ setSIPR

#define setSIPR ( sipr ) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)

Set local IP address.

Parameters
(uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes.
See also
getSIPR()

Definition at line 1321 of file w5500.h.

◆ setSIR

#define setSIR ( sir ) WIZCHIP_WRITE(SIR, sir)

Set SIR register.

Parameters
(uint8_t)sir Value to set SIR register.
See also
getSIR()

Definition at line 1400 of file w5500.h.

◆ setSUBR

#define setSUBR ( subr ) WIZCHIP_WRITE_BUF(SUBR, subr,4)

Set subnet mask address.

Parameters
(uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes.
See also
getSUBR()

Definition at line 1284 of file w5500.h.


ioLibrary: Socket register access functions

Macros | Functions
Socket register access functions
W5500 » WIZCHIP I/O functions

These are functions to access socket registers. More...

Collaboration diagram for Socket register access functions:

Macros

#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F))
Set Sn_IR register. More...
#define | getSn_IR(sn) (WIZCHIP_READ(Sn_IR(sn)) & 0x1F)
Get Sn_IR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F))
Set Sn_IMR register. More...
#define | getSn_IMR(sn) (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F)
Get Sn_IMR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_MR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXBUF_SIZE(sn, rxbufsize) WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize)
Set Sn_RXBUF_SIZE register. More...
#define | getSn_RXBUF_SIZE(sn) WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
Get Sn_RXBUF_SIZE register. More...
#define | setSn_TXBUF_SIZE(sn, txbufsize) WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize)
Set Sn_TXBUF_SIZE register. More...
#define | getSn_TXBUF_SIZE(sn) WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
Get Sn_TXBUF_SIZE register. More...
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_FRAG(sn, frag)
Set Sn_FRAG register. More...
#define | getSn_FRAG(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
Get Sn_FRAG register. More...
#define | setSn_KPALVTR(sn, kpalvt) WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt)
Set Sn_KPALVTR register. More...
#define | getSn_KPALVTR(sn) WIZCHIP_READ(Sn_KPALVTR(sn))
Get Sn_KPALVTR register. More...

Functions

uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...

Detailed Description

These are functions to access socket registers.

Macro Definition Documentation

◆ getSn_CR

#define getSn_CR ( sn ) WIZCHIP_READ(Sn_CR(sn))

Get Sn_CR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_CR.
See also
setSn_CR()

Definition at line 1674 of file w5500.h.

◆ getSn_DHAR

#define getSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)

Get Sn_MR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dhar | Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes.
See also
setSn_DHAR()

Definition at line 1770 of file w5500.h.

◆ getSn_DIPR

#define getSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)

Get Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dipr | Pointer variable to get socket n destination IP address. It should be allocated 4 bytes.
See also
setSn_DIPR()

Definition at line 1790 of file w5500.h.

◆ getSn_DPORT

#define getSn_DPORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))

Get Sn_DPORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_DPORT.
See also
setSn_DPORT()

Definition at line 1817 of file w5500.h.

◆ getSn_FRAG

#define getSn_FRAG ( sn ) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))

Get Sn_FRAG register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_FRAG.
See also
setSn_FRAG()

Definition at line 2054 of file w5500.h.

◆ getSn_IMR

#define getSn_IMR ( sn ) (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F)

Get Sn_IMR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_IMR.
See also
setSn_IMR()

Definition at line 1714 of file w5500.h.

◆ getSn_IR

#define getSn_IR ( sn ) (WIZCHIP_READ(Sn_IR(sn)) & 0x1F)

Get Sn_IR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_IR.
See also
setSn_IR()

Definition at line 1694 of file w5500.h.

◆ getSn_KPALVTR

#define getSn_KPALVTR ( sn ) WIZCHIP_READ(Sn_KPALVTR(sn))

Get Sn_KPALVTR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_KPALVTR.
See also
setSn_KPALVTR()

Definition at line 2074 of file w5500.h.

◆ getSn_MR

#define getSn_MR ( sn ) WIZCHIP_READ(Sn_MR(sn))

Get Sn_MR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_MR.
See also
setSn_MR()

Definition at line 1654 of file w5500.h.

◆ getSn_MSSR

#define getSn_MSSR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))

Get Sn_MSSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_MSSR.
See also
setSn_MSSR()

Definition at line 1844 of file w5500.h.

◆ getSn_PORT

#define getSn_PORT ( sn ) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))

Get Sn_PORT register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_PORT.
See also
setSn_PORT()

Definition at line 1750 of file w5500.h.

◆ getSn_RX_RD

#define getSn_RX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))

Get Sn_RX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_RX_RD.
See also
setSn_RX_RD()

Definition at line 2013 of file w5500.h.

◆ getSn_RX_WR

#define getSn_RX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))

Get Sn_RX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_RX_WR.

Definition at line 2027 of file w5500.h.

◆ getSn_RXBUF_SIZE

#define getSn_RXBUF_SIZE ( sn ) WIZCHIP_READ(Sn_RXBUF_SIZE(sn))

Get Sn_RXBUF_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_RXBUF_SIZE.
See also
setSn_RXBUF_SIZE()

Definition at line 1907 of file w5500.h.

◆ getSn_SR

#define getSn_SR ( sn ) WIZCHIP_READ(Sn_SR(sn))

Get Sn_SR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_SR.

Definition at line 1723 of file w5500.h.

◆ getSn_TOS

#define getSn_TOS ( sn ) WIZCHIP_READ(Sn_TOS(sn))

Get Sn_TOS register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_TOS.
See also
setSn_TOS()

Definition at line 1864 of file w5500.h.

◆ getSn_TTL

#define getSn_TTL ( sn ) WIZCHIP_READ(Sn_TTL(sn))

Get Sn_TTL register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_TTL.
See also
setSn_TTL()

Definition at line 1885 of file w5500.h.

◆ getSn_TX_RD

#define getSn_TX_RD ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))

Get Sn_TX_RD register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_TX_RD.

Definition at line 1949 of file w5500.h.

◆ getSn_TX_WR

#define getSn_TX_WR ( sn ) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))

Get Sn_TX_WR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_TX_WR.
See also
setSn_TX_WR()

Definition at line 1976 of file w5500.h.

◆ getSn_TXBUF_SIZE

#define getSn_TXBUF_SIZE ( sn ) WIZCHIP_READ(Sn_TXBUF_SIZE(sn))

Get Sn_TXBUF_SIZE register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint8_t. Value of Sn_TXBUF_SIZE.
See also
setSn_TXBUF_SIZE()

Definition at line 1927 of file w5500.h.

◆ setSn_CR

#define setSn_CR | ( | sn,
 |  | cr
 | ) | WIZCHIP_WRITE(Sn_CR(sn), cr)

Set Sn_CR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)cr | Value to set Sn_CR
See also
getSn_CR()

Definition at line 1664 of file w5500.h.

◆ setSn_DHAR

#define setSn_DHAR | ( | sn,
 |  | dhar
 | ) | WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)

Set Sn_DHAR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dhar | Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes.
See also
getSn_DHAR()

Definition at line 1760 of file w5500.h.

◆ setSn_DIPR

#define setSn_DIPR | ( | sn,
 |  | dipr
 | ) | WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)

Set Sn_DIPR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t*)dipr | Pointer variable to set socket n destination IP address. It should be allocated 4 bytes.
See also
getSn_DIPR()

Definition at line 1780 of file w5500.h.

◆ setSn_DPORT

#define setSn_DPORT | ( | sn,
 |  | dport
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
Sn_DPORT
#define Sn_DPORT(N)
Peer port register address(R/W)
Definition: w5500.h:533

Set Sn_DPORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)dport | Value to set Sn_DPORT
See also
getSn_DPORT()

Definition at line 1800 of file w5500.h.

◆ setSn_FRAG

#define setSn_FRAG | ( | sn,
 |  | frag
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
Sn_FRAG
#define Sn_FRAG(N)
Fragment field value in IP header register(R/W)
Definition: w5500.h:672

Set Sn_FRAG register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)frag | Value to set Sn_FRAG
See also
getSn_FRAD()

Definition at line 2037 of file w5500.h.

◆ setSn_IMR

#define setSn_IMR | ( | sn,
 |  | imr
 | ) | WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F))

Set Sn_IMR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)imr | Value to set Sn_IMR
See also
getSn_IMR()

Definition at line 1704 of file w5500.h.

◆ setSn_IR

#define setSn_IR | ( | sn,
 |  | ir
 | ) | WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F))

Set Sn_IR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)ir | Value to set Sn_IR
See also
getSn_IR()

Definition at line 1684 of file w5500.h.

◆ setSn_KPALVTR

#define setSn_KPALVTR | ( | sn,
 |  | kpalvt
 | ) | WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt)

Set Sn_KPALVTR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)kpalvt | Value to set Sn_KPALVTR
See also
getSn_KPALVTR()

Definition at line 2064 of file w5500.h.

◆ setSn_MR

#define setSn_MR | ( | sn,
 |  | mr
 | ) | WIZCHIP_WRITE(Sn_MR(sn),mr)

Set Sn_MR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)mr | Value to set Sn_MR
See also
getSn_MR()

Definition at line 1644 of file w5500.h.

◆ setSn_MSSR

#define setSn_MSSR | ( | sn,
 |  | mss
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
Sn_MSSR
#define Sn_MSSR(N)
Maximum Segment Size(Sn_MSSR0) register address(R/W)
Definition: w5500.h:540

Set Sn_MSSR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)mss | Value to set Sn_MSSR
See also
setSn_MSSR()

Definition at line 1827 of file w5500.h.

◆ setSn_PORT

#define setSn_PORT | ( | sn,
 |  | port
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
Sn_PORT
#define Sn_PORT(N)
source port register(R/W)
Definition: w5500.h:505

Set Sn_PORT register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)port | Value to set Sn_PORT.
See also
getSn_PORT()

Definition at line 1733 of file w5500.h.

◆ setSn_RX_RD

#define setSn_RX_RD | ( | sn,
 |  | rxrd
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
Sn_RX_RD
#define Sn_RX_RD(N)
Read point of Receive memory(R/W)
Definition: w5500.h:646

Set Sn_RX_RD register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)rxrd | Value to set Sn_RX_RD
See also
getSn_RX_RD()

Definition at line 1996 of file w5500.h.

◆ setSn_RXBUF_SIZE

#define setSn_RXBUF_SIZE | ( | sn,
 |  | rxbufsize
 | ) | WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize)

Set Sn_RXBUF_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)rxbufsize | Value to set Sn_RXBUF_SIZE
See also
getSn_RXBUF_SIZE()

Definition at line 1896 of file w5500.h.

◆ setSn_TOS

#define setSn_TOS | ( | sn,
 |  | tos
 | ) | WIZCHIP_WRITE(Sn_TOS(sn), tos)

Set Sn_TOS register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)tos | Value to set Sn_TOS
See also
getSn_TOS()

Definition at line 1854 of file w5500.h.

◆ setSn_TTL

#define setSn_TTL | ( | sn,
 |  | ttl
 | ) | WIZCHIP_WRITE(Sn_TTL(sn), ttl)

Set Sn_TTL register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)ttl | Value to set Sn_TTL
See also
getSn_TTL()

Definition at line 1874 of file w5500.h.

◆ setSn_TX_WR

#define setSn_TX_WR | ( | sn,
 |  | txwr
 | ) |
Value:
{ \
WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
}
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Definition: w5500.h:68
Sn_TX_WR
#define Sn_TX_WR(N)
Transmit memory write pointer register address(R/W)
Definition: w5500.h:624

Set Sn_TX_WR register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint16_t)txwr | Value to set Sn_TX_WR
See also
GetSn_TX_WR()

Definition at line 1959 of file w5500.h.

◆ setSn_TXBUF_SIZE

#define setSn_TXBUF_SIZE | ( | sn,
 |  | txbufsize
 | ) | WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize)

Set Sn_TXBUF_SIZE register.

Parameters
(uint8_t)sn | Socket number. It should be 0 ~ 7.
(uint8_t)txbufsize | Value to set Sn_TXBUF_SIZE
See also
getSn_TXBUF_SIZE()

Definition at line 1917 of file w5500.h.

Function Documentation

◆ getSn_RX_RSR()

uint16_t getSn_RX_RSR ( uint8_t sn )

Get Sn_RX_RSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_RX_RSR.
Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_RX_RSR.

Definition at line 254 of file w5100s.c.

◆ getSn_TX_FSR()

uint16_t getSn_TX_FSR ( uint8_t sn )

Get Sn_TX_FSR register.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Sn_TX_FSR.
Parameters
(uint8_t)sn Socket number. It should be 0 ~ _WIZCHIP_SOCK_NUM_.
Returns
uint16_t. Value of Sn_TX_FSR.

Definition at line 237 of file w5100s.c.


ioLibrary: 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

◆ ctlnetwork()

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 359 of file wizchip_conf.c.

◆ ctlwizchip()

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 277 of file wizchip_conf.c.

◆ wizchip_clrinterrupt()

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 489 of file wizchip_conf.c.

◆ wizchip_getinterrupt()

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 516 of file wizchip_conf.c.

◆ wizchip_getinterruptmask()

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 571 of file wizchip_conf.c.

◆ wizchip_getnetinfo()

void wizchip_getnetinfo ( wiz_NetInfo * pnetinfo )

Get the network information for WIZCHIP.

Parameters
pnetinfo : wizNetInfo

Definition at line 854 of file wizchip_conf.c.

◆ wizchip_getnetmode()

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 881 of file wizchip_conf.c.

◆ wizchip_gettimeout()

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 892 of file wizchip_conf.c.

◆ 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 412 of file wizchip_conf.c.

◆ wizchip_setinterruptmask()

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 547 of file wizchip_conf.c.

◆ wizchip_setnetinfo()

void wizchip_setnetinfo ( wiz_NetInfo * pnetinfo )

Set the network information for WIZCHIP.

Parameters
pnetinfo : wizNetInfo

Definition at line 840 of file wizchip_conf.c.

◆ wizchip_setnetmode()

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 867 of file wizchip_conf.c.

◆ wizchip_settimeout()

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 886 of file wizchip_conf.c.

◆ wizchip_sw_reset()

void wizchip_sw_reset ( void )

Reset WIZCHIP by softly.

Definition at line 387 of file wizchip_conf.c.

◆ wizphy_getphyconf()

void wizphy_getphyconf ( wiz_PhyConf * phyconf )

Get phy configuration information.

Parameters
phyconf : wiz_PhyConf

Definition at line 768 of file wizchip_conf.c.

◆ wizphy_getphystat()

void wizphy_getphystat ( wiz_PhyConf * phyconf )

Get phy status.

Parameters
phyconf : wiz_PhyConf

Definition at line 807 of file wizchip_conf.c.

◆ wizphy_setphyconf()

void wizphy_setphyconf ( wiz_PhyConf * phyconf )

Set the phy information for WIZCHIP without power mode.

Parameters
phyconf : wiz_PhyConf

Definition at line 738 of file wizchip_conf.c.

◆ wizphy_setphypmode()

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 814 of file wizchip_conf.c.


ioLibrary: Snmp_module

Functions
Snmp_module

Functions

void | snmpd_init (uint8_t *managerIP, uint8_t *agentIP, uint8_t sn_agent, uint8_t sn_trap)
int32_t | snmpd_run (void)
int32_t | findEntry (uint8_t *oid, int32_t len)
int32_t | getOID (int32_t id, uint8_t *oid, uint8_t *len)
int32_t | getValue (uint8_t *vptr, int32_t vlen)
int32_t | getEntry (int32_t id, uint8_t *dataType, void *ptr, int32_t *len)
int32_t | setEntry (int32_t id, void *val, int32_t vlen, uint8_t dataType, int32_t index)
int32_t | parseLength (const uint8_t *msg, int32_t *len)
int32_t | parseTLV (const uint8_t *msg, int32_t index, tlvStructType *tlv)
void | insertRespLen (int32_t reqStart, int32_t respStart, int32_t size)
int32_t | parseVarBind (int32_t reqType, int32_t index)
int32_t | parseSequence (int32_t reqType, int32_t index)
int32_t | parseSequenceOf (int32_t reqType)
int32_t | parseRequest ()
int32_t | parseCommunity ()
int32_t | parseVersion ()
int32_t | parseSNMPMessage ()
void | ipToByteArray (int8_t *ip, uint8_t *pDes)
int32_t | makeTrapVariableBindings (dataEntryType *oid_data, void *ptr, uint32_t *len)
int32_t | snmp_sendTrap (uint8_t *managerIP, uint8_t *agentIP, int8_t *community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count,...)
void | dumpCode (uint8_t *header, uint8_t *tail, uint8_t *buff, int32_t len)

Detailed Description

Function Documentation

◆ dumpCode()

void dumpCode | ( | uint8_t * | header,
 |  | uint8_t * | tail,
 |  | uint8_t * | buff,
 |  | int32_t | len
 | ) |  |

Definition at line 889 of file snmp.c.

◆ findEntry()

int32_t findEntry | ( | uint8_t * | oid,
 |  | int32_t | len
 | ) |  |

Definition at line 207 of file snmp.c.

◆ getEntry()

int32_t getEntry | ( | int32_t | id,
 |  | uint8_t * | dataType,
 |  | void * | ptr,
 |  | int32_t * | len
 | ) |  |

Definition at line 255 of file snmp.c.

◆ getOID()

int32_t getOID | ( | int32_t | id,
 |  | uint8_t * | oid,
 |  | uint8_t * | len
 | ) |  |

Definition at line 223 of file snmp.c.

◆ getValue()

int32_t getValue | ( | uint8_t * | vptr,
 |  | int32_t | vlen
 | ) |  |

Definition at line 240 of file snmp.c.

◆ insertRespLen()

void insertRespLen | ( | int32_t | reqStart,
 |  | int32_t | respStart,
 |  | int32_t | size
 | ) |  |

Definition at line 437 of file snmp.c.

◆ ipToByteArray()

void ipToByteArray | ( | int8_t * | ip,
 |  | uint8_t * | pDes
 | ) |  |

Definition at line 717 of file snmp.c.

◆ makeTrapVariableBindings()

int32_t makeTrapVariableBindings | ( | dataEntryType * | oid_data,
 |  | void * | ptr,
 |  | uint32_t * | len
 | ) |  |

Definition at line 734 of file snmp.c.

◆ parseCommunity()

int32_t parseCommunity ( )

Definition at line 644 of file snmp.c.

◆ parseLength()

int32_t parseLength | ( | const uint8_t * | msg,
 |  | int32_t * | len
 | ) |  |

Definition at line 386 of file snmp.c.

◆ parseRequest()

int32_t parseRequest ( )

Definition at line 594 of file snmp.c.

◆ parseSequence()

int32_t parseSequence | ( | int32_t | reqType,
 |  | int32_t | index
 | ) |  |

Definition at line 546 of file snmp.c.

◆ parseSequenceOf()

int32_t parseSequenceOf ( int32_t reqType )

Definition at line 568 of file snmp.c.

◆ parseSNMPMessage()

int32_t parseSNMPMessage ( )

Definition at line 694 of file snmp.c.

◆ parseTLV()

int32_t parseTLV | ( | const uint8_t * | msg,
 |  | int32_t | index,
 |  | tlvStructType * | tlv
 | ) |  |

Definition at line 410 of file snmp.c.

◆ parseVarBind()

int32_t parseVarBind | ( | int32_t | reqType,
 |  | int32_t | index
 | ) |  |

Definition at line 462 of file snmp.c.

◆ parseVersion()

int32_t parseVersion ( )

Definition at line 674 of file snmp.c.

◆ setEntry()

int32_t setEntry | ( | int32_t | id,
 |  | void * | val,
 |  | int32_t | vlen,
 |  | uint8_t | dataType,
 |  | int32_t | index
 | ) |  |

Definition at line 331 of file snmp.c.

◆ snmp_sendTrap()

int32_t snmp_sendTrap | ( | uint8_t * | managerIP,
 |  | uint8_t * | agentIP,
 |  | int8_t * | community,
 |  | dataEntryType | enterprise_oid,
 |  | uint32_t | genericTrap,
 |  | uint32_t | specificTrap,
 |  | uint32_t | va_count,
 |  |  | ...
 | ) |  |

Definition at line 795 of file snmp.c.

◆ snmpd_init()

void snmpd_init | ( | uint8_t * | managerIP,
 |  | uint8_t * | agentIP,
 |  | uint8_t | sn_agent,
 |  | uint8_t | sn_trap
 | ) |  |

Initialize SNMP Daemon. This should be called just one time at first time

Parameters
none
Returns
none

Definition at line 100 of file snmp.c.

◆ snmpd_run()

int32_t snmpd_run ( void )

SNMP Process Handler. UDP Socket and SNMP Agent transaction handling.

Parameters
none
Returns
none

Definition at line 145 of file snmp.c.


ioLibrary: Data Structures

Data Structures
Here are the data structures with brief descriptions:
[detail level 12]
C __file |
▼C __WIZCHIP | The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions
C _CRIS |
C _CS |
C _IF |
C _datetime |
C _httpServer_webContent |
C _ntpformat |
C _st_http_request |
C _st_http_socket |
C _un_l2cval |
C Command |
C dataEntryType |
C dhdr |
C ftpc |
C ftpd |
C MessageData |
C messageStruct |
▼C MQTTClient |
C MessageHandlers |
C MQTTConnackFlags |
C MQTTConnectFlags |
C MQTTHeader |
C MQTTLenString |
C MQTTMessage |
C MQTTPacket_connectData |
C MQTTPacket_willOptions |
C MQTTString |
C MQTTTransport |
C Network |
C RIP_MSG |
C tftp_data |
C tftp_error |
C tftp_option |
C Timer |
C tlvStructType |
C wiz_NetInfo_t |
C wiz_NetTimeout_t |
C wiz_PhyConf_t |


ioLibrary: __file Struct Reference

Data Fields
__file Struct Reference

#include <stdio_private.h>

Data Fields

char * | buf
unsigned char | unget
uint8_t | flags
int | size
int | len
int(* | put )(char)
int(* | get )(void)

Detailed Description

Definition at line 35 of file stdio_private.h.

Field Documentation

◆ buf

char * buf

Definition at line 36 of file stdio_private.h.

◆ flags

uint8_t flags

Definition at line 38 of file stdio_private.h.

◆ get

int(* get)(void)

Definition at line 56 of file stdio_private.h.

◆ len

int len

Definition at line 54 of file stdio_private.h.

◆ put

int(* put)(char)

Definition at line 55 of file stdio_private.h.

◆ size

int size

Definition at line 53 of file stdio_private.h.

◆ unget

unsigned char unget

Definition at line 37 of file stdio_private.h.

The documentation for this struct was generated from the following file:
  • Internet/FTPClient/stdio_private.h


ioLibrary: _datetime Struct Reference

Data Fields
_datetime Struct Reference

#include <sntp.h>

Data Fields

uint16_t | yy
uint8_t | mo
uint8_t | dd
uint8_t | hh
uint8_t | mm
uint8_t | ss

Detailed Description

Definition at line 47 of file sntp.h.

Field Documentation

◆ dd

uint8_t dd

Definition at line 51 of file sntp.h.

◆ hh

uint8_t hh

Definition at line 52 of file sntp.h.

◆ mm

uint8_t mm

Definition at line 53 of file sntp.h.

◆ mo

uint8_t mo

Definition at line 50 of file sntp.h.

◆ ss

uint8_t ss

Definition at line 54 of file sntp.h.

◆ yy

uint16_t yy

Definition at line 49 of file sntp.h.

The documentation for this struct was generated from the following file:
  • Internet/SNTP/sntp.h


ioLibrary: _httpServer_webContent Struct Reference

Data Fields
_httpServer_webContent Struct Reference

#include <httpServer.h>

Data Fields

uint8_t * | content_name
uint32_t | content_len
uint8_t * | content

Detailed Description

Definition at line 79 of file httpServer.h.

Field Documentation

◆ content

uint8_t* content

Definition at line 83 of file httpServer.h.

◆ content_len

uint32_t content_len

Definition at line 82 of file httpServer.h.

◆ content_name

uint8_t* content_name

Definition at line 81 of file httpServer.h.

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


ioLibrary: _ntpformat Struct Reference

Data Fields
_ntpformat Struct Reference

#include <sntp.h>

Data Fields

uint8_t | dstaddr [4]
char | version
char | leap
char | mode
char | stratum
char | poll
s_char precision
tdist rootdelay
tdist rootdisp
char | refid
tstamp reftime
tstamp org
tstamp rec
tstamp xmt

Detailed Description

Definition at line 26 of file sntp.h.

Field Documentation

◆ dstaddr

uint8_t dstaddr[4]

Definition at line 29 of file sntp.h.

◆ leap

char leap

Definition at line 31 of file sntp.h.

◆ mode

char mode

Definition at line 32 of file sntp.h.

◆ org

tstamp org

Definition at line 40 of file sntp.h.

◆ poll

char poll

Definition at line 34 of file sntp.h.

◆ precision

s_char precision

Definition at line 35 of file sntp.h.

◆ rec

tstamp rec

Definition at line 41 of file sntp.h.

◆ refid

char refid

Definition at line 38 of file sntp.h.

◆ reftime

tstamp reftime

Definition at line 39 of file sntp.h.

◆ rootdelay

tdist rootdelay

Definition at line 36 of file sntp.h.

◆ rootdisp

tdist rootdisp

Definition at line 37 of file sntp.h.

◆ stratum

char stratum

Definition at line 33 of file sntp.h.

◆ version

char version

Definition at line 30 of file sntp.h.

◆ xmt

tstamp xmt

Definition at line 42 of file sntp.h.

The documentation for this struct was generated from the following file:
  • Internet/SNTP/sntp.h


ioLibrary: _st_http_request Struct Reference

Data Fields
_st_http_request Struct Reference

#include <httpParser.h>

Data Fields

uint8_t | METHOD
uint8_t | TYPE
uint8_t | URI [MAX_URI_SIZE]

Detailed Description

Definition at line 127 of file httpParser.h.

Field Documentation

◆ METHOD

uint8_t METHOD

request method(METHOD_GET...).

Definition at line 129 of file httpParser.h.

◆ TYPE

uint8_t TYPE

request type(PTYPE_HTML...).

Definition at line 130 of file httpParser.h.

◆ URI

uint8_t URI[MAX_URI_SIZE]

request file name.

Definition at line 131 of file httpParser.h.

The documentation for this struct was generated from the following file:
  • Internet/httpServer/httpParser.h


ioLibrary: _st_http_socket Struct Reference

Data Fields
_st_http_socket Struct Reference

#include <httpServer.h>

Data Fields

uint8_t | sock_status
uint8_t | file_name [MAX_CONTENT_NAME_LEN]
uint32_t | file_start
uint32_t | file_len
uint32_t | file_offset
uint8_t | storage_type

Detailed Description

Definition at line 66 of file httpServer.h.

Field Documentation

◆ file_len

uint32_t file_len

Definition at line 71 of file httpServer.h.

◆ file_name

uint8_t file_name[MAX_CONTENT_NAME_LEN]

Definition at line 69 of file httpServer.h.

◆ file_offset

uint32_t file_offset

Definition at line 72 of file httpServer.h.

◆ file_start

uint32_t file_start

Definition at line 70 of file httpServer.h.

◆ sock_status

uint8_t sock_status

Definition at line 68 of file httpServer.h.

◆ storage_type

uint8_t storage_type

Definition at line 73 of file httpServer.h.

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


ioLibrary: _un_l2cval Union Reference

Data Fields
_un_l2cval Union Reference

#include <ftpc.h>

Data Fields

uint32_t | lVal
uint8_t | cVal [4]

Detailed Description

Definition at line 107 of file ftpc.h.

Field Documentation

◆ cVal

uint8_t cVal

Definition at line 109 of file ftpc.h.

◆ lVal

uint32_t lVal

Definition at line 108 of file ftpc.h.

The documentation for this union was generated from the following files:
  • Internet/FTPClient/ftpc.h
  • Internet/FTPServer/ftpd.h


ioLibrary: Command Struct Reference

Data Fields
Command Struct Reference

#include <ftpc.h>

Data Fields

enum CommandFirst | First
enum CommandSecond | Second

Detailed Description

Definition at line 84 of file ftpc.h.

Field Documentation

◆ First

enum CommandFirst First

Definition at line 85 of file ftpc.h.

◆ Second

enum CommandSecond Second

Definition at line 86 of file ftpc.h.

The documentation for this struct was generated from the following file:
  • Internet/FTPClient/ftpc.h


ioLibrary: dataEntryType Struct Reference

Data Fields
dataEntryType Struct Reference

#include <snmp.h>

Data Fields

uint8_t | oidlen
uint8_t | oid [MAX_OID]
uint8_t | dataType
uint8_t | dataLen
union {
uint8_t octetstring [MAX_STRING]
uint32_t intval
} u
void(* | getfunction )(void *, uint8_t *)
void(* | setfunction )(int32_t)

Detailed Description

Definition at line 74 of file snmp.h.

Field Documentation

◆ dataLen

uint8_t dataLen

Definition at line 78 of file snmp.h.

◆ dataType

uint8_t dataType

Definition at line 77 of file snmp.h.

◆ getfunction

void(* getfunction) (void *, uint8_t *)

Definition at line 83 of file snmp.h.

◆ intval

uint32_t intval

Definition at line 81 of file snmp.h.

◆ octetstring

uint8_t octetstring[MAX_STRING]

Definition at line 80 of file snmp.h.

◆ oid

uint8_t oid[MAX_OID]

Definition at line 76 of file snmp.h.

◆ oidlen

uint8_t oidlen

Definition at line 75 of file snmp.h.

◆ setfunction

void(* setfunction) (int32_t)

Definition at line 84 of file snmp.h.

◆ u

union { ... } u
The documentation for this struct was generated from the following file:
  • Internet/SNMP/snmp.h


ioLibrary: dhdr Struct Reference

Data Fields
dhdr Struct Reference

Data Fields

uint16_t | id
uint8_t | qr
uint8_t | opcode
uint8_t | aa
uint8_t | tc
uint8_t | rd
uint8_t | ra
uint8_t | rcode
uint16_t | qdcount
uint16_t | ancount
uint16_t | nscount
uint16_t | arcount

Detailed Description

Definition at line 92 of file dns.c.

Field Documentation

◆ aa

uint8_t aa

Definition at line 100 of file dns.c.

◆ ancount

uint16_t ancount

Definition at line 112 of file dns.c.

◆ arcount

uint16_t arcount

Definition at line 114 of file dns.c.

◆ id

uint16_t id

Definition at line 94 of file dns.c.

◆ nscount

uint16_t nscount

Definition at line 113 of file dns.c.

◆ opcode

uint8_t opcode

Definition at line 98 of file dns.c.

◆ qdcount

uint16_t qdcount

Definition at line 111 of file dns.c.

◆ qr

uint8_t qr

Definition at line 95 of file dns.c.

◆ ra

uint8_t ra

Definition at line 103 of file dns.c.

◆ rcode

uint8_t rcode

Definition at line 104 of file dns.c.

◆ rd

uint8_t rd

Definition at line 102 of file dns.c.

◆ tc

uint8_t tc

Definition at line 101 of file dns.c.

The documentation for this struct was generated from the following file:
  • Internet/DNS/dns.c


ioLibrary: ftpc Struct Reference

Data Fields
ftpc Struct Reference

#include <ftpc.h>

Data Fields

uint8_t | control
uint8_t | data
enum ftpc_type | type
enum ftpc_datasock_state | dsock_state
enum ftpc_datasock_mode | dsock_mode
char | workingdir [LINELEN]
char | filename [LINELEN]

Detailed Description

Definition at line 88 of file ftpc.h.

Field Documentation

◆ control

uint8_t control

Definition at line 89 of file ftpc.h.

◆ data

uint8_t data

Definition at line 90 of file ftpc.h.

◆ dsock_mode

enum ftpc_datasock_mode dsock_mode

Definition at line 95 of file ftpc.h.

◆ dsock_state

enum ftpc_datasock_state dsock_state

Definition at line 94 of file ftpc.h.

◆ filename

char filename[LINELEN]

Definition at line 98 of file ftpc.h.

◆ type

enum ftpc_type type

Definition at line 92 of file ftpc.h.

◆ workingdir

char workingdir[LINELEN]

Definition at line 97 of file ftpc.h.

The documentation for this struct was generated from the following file:
  • Internet/FTPClient/ftpc.h


ioLibrary: ftpd Struct Reference

Data Fields
ftpd Struct Reference

#include <ftpd.h>

Data Fields

uint8_t | control
uint8_t | data
enum ftp_type | type
enum ftp_state | state
enum ftp_cmd | current_cmd
enum datasock_state | dsock_state
enum datasock_mode | dsock_mode
char | username [LINELEN]
char | workingdir [LINELEN]
char | filename [LINELEN]

Detailed Description

Definition at line 100 of file ftpd.h.

Field Documentation

◆ control

uint8_t control

Definition at line 101 of file ftpd.h.

◆ current_cmd

enum ftp_cmd current_cmd

Definition at line 107 of file ftpd.h.

◆ data

uint8_t data

Definition at line 102 of file ftpd.h.

◆ dsock_mode

enum datasock_mode dsock_mode

Definition at line 110 of file ftpd.h.

◆ dsock_state

enum datasock_state dsock_state

Definition at line 109 of file ftpd.h.

◆ filename

char filename[LINELEN]

Definition at line 114 of file ftpd.h.

◆ state

enum ftp_state state

Definition at line 105 of file ftpd.h.

◆ type

enum ftp_type type

Definition at line 104 of file ftpd.h.

◆ username

char username[LINELEN]

Definition at line 112 of file ftpd.h.

◆ workingdir

char workingdir[LINELEN]

Definition at line 113 of file ftpd.h.

The documentation for this struct was generated from the following file:
  • Internet/FTPServer/ftpd.h


ioLibrary: MessageData Struct Reference

Data Fields
MessageData Struct Reference

#include <MQTTClient.h>

Collaboration diagram for MessageData:
[legend]

Data Fields

MQTTMessage * message
MQTTString * topicName

Detailed Description

Definition at line 78 of file MQTTClient.h.

Field Documentation

◆ message

MQTTMessage* message

Definition at line 80 of file MQTTClient.h.

◆ topicName

MQTTString* topicName

Definition at line 81 of file MQTTClient.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTClient.h


ioLibrary: messageStruct Struct Reference

Data Fields
messageStruct Struct Reference

#include <snmp.h>

Data Fields

uint8_t | buffer [MAX_SNMPMSG_LEN]
int32_t | len
int32_t | index

Detailed Description

Definition at line 87 of file snmp.h.

Field Documentation

◆ buffer

uint8_t buffer[MAX_SNMPMSG_LEN]

Definition at line 88 of file snmp.h.

◆ index

int32_t index

Definition at line 90 of file snmp.h.

◆ len

int32_t len

Definition at line 89 of file snmp.h.

The documentation for this struct was generated from the following file:
  • Internet/SNMP/snmp.h


ioLibrary: MQTTClient Struct Reference

Data Structures | Data Fields
MQTTClient Struct Reference

#include <MQTTClient.h>

Collaboration diagram for MQTTClient:
[legend]

Data Structures

struct MessageHandlers

Data Fields

unsigned int | next_packetid
unsigned int | command_timeout_ms
size_t | buf_size
size_t | readbuf_size
unsigned char * | buf
unsigned char * | readbuf
unsigned int | keepAliveInterval
char | ping_outstanding
int | isconnected
struct MQTTClient::MessageHandlers | messageHandlers [MAX_MESSAGE_HANDLERS]
void(* | defaultMessageHandler )(MessageData *)
Network * ipstack
Timer ping_timer

Detailed Description

Definition at line 86 of file MQTTClient.h.

Field Documentation

◆ buf

unsigned char* buf

Definition at line 92 of file MQTTClient.h.

◆ buf_size

size_t buf_size

Definition at line 90 of file MQTTClient.h.

◆ command_timeout_ms

unsigned int command_timeout_ms

Definition at line 88 of file MQTTClient.h.

◆ defaultMessageHandler

void(* defaultMessageHandler) (MessageData *)

Definition at line 104 of file MQTTClient.h.

◆ ipstack

Network* ipstack

Definition at line 106 of file MQTTClient.h.

◆ isconnected

int isconnected

Definition at line 96 of file MQTTClient.h.

◆ keepAliveInterval

unsigned int keepAliveInterval

Definition at line 94 of file MQTTClient.h.

◆ messageHandlers

struct MQTTClient::MessageHandlers messageHandlers[MAX_MESSAGE_HANDLERS]

◆ next_packetid

unsigned int next_packetid

Definition at line 88 of file MQTTClient.h.

◆ ping_outstanding

char ping_outstanding

Definition at line 95 of file MQTTClient.h.

◆ ping_timer

Timer ping_timer

Definition at line 107 of file MQTTClient.h.

◆ readbuf

unsigned char * readbuf

Definition at line 92 of file MQTTClient.h.

◆ readbuf_size

size_t readbuf_size

Definition at line 90 of file MQTTClient.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTClient.h


ioLibrary: MQTTClient::MessageHandlers Struct Reference

  • MQTTClient
  • MessageHandlers
Data Fields
MQTTClient::MessageHandlers Struct Reference

#include <MQTTClient.h>

Data Fields

const char * | topicFilter
void(* | fp )(MessageData *)

Detailed Description

Definition at line 98 of file MQTTClient.h.

Field Documentation

◆ fp

void(* fp) (MessageData *)

Definition at line 101 of file MQTTClient.h.

◆ topicFilter

const char* topicFilter

Definition at line 100 of file MQTTClient.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTClient.h


ioLibrary: MQTTConnackFlags Union Reference

Data Fields
MQTTConnackFlags Union Reference

#include <MQTTConnect.h>

Data Fields

unsigned char all
struct {
unsigned int: 7
unsigned int sessionpresent: 1
} bits

Detailed Description

Definition at line 106 of file MQTTConnect.h.

Field Documentation

◆ all

unsigned char all

all connack flags

Definition at line 108 of file MQTTConnect.h.

◆ bits

struct { ... } bits

◆ int

unsigned int

unused

Definition at line 118 of file MQTTConnect.h.

◆ sessionpresent

unsigned int sessionpresent

session present flag

Definition at line 119 of file MQTTConnect.h.

The documentation for this union was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTConnect.h


ioLibrary: MQTTConnectFlags Union Reference

Data Fields
MQTTConnectFlags Union Reference

#include <MQTTConnect.h>

Data Fields

unsigned char all
struct {
unsigned int: 1
unsigned int cleansession: 1
unsigned int will: 1
unsigned int willQoS: 2
unsigned int willRetain: 1
unsigned int password: 1
unsigned int username: 1
} bits

Detailed Description

Definition at line 29 of file MQTTConnect.h.

Field Documentation

◆ all

unsigned char all

all connect flags

Definition at line 31 of file MQTTConnect.h.

◆ bits

struct { ... } bits

◆ cleansession

unsigned int cleansession

cleansession flag

Definition at line 47 of file MQTTConnect.h.

◆ int

unsigned int

unused

Definition at line 46 of file MQTTConnect.h.

◆ password

unsigned int password

3.1 password

Definition at line 51 of file MQTTConnect.h.

◆ username

unsigned int username

3.1 user name

Definition at line 52 of file MQTTConnect.h.

◆ will

unsigned int will

will flag

Definition at line 48 of file MQTTConnect.h.

◆ willQoS

unsigned int willQoS

will QoS value

Definition at line 49 of file MQTTConnect.h.

◆ willRetain

unsigned int willRetain

will retain setting

Definition at line 50 of file MQTTConnect.h.

The documentation for this union was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTConnect.h


ioLibrary: MQTTHeader Union Reference

Data Fields
MQTTHeader Union Reference

#include <MQTTPacket.h>

Data Fields

unsigned char byte
struct {
unsigned int retain: 1
unsigned int qos: 2
unsigned int dup: 1
unsigned int type: 4
} bits

Detailed Description

Bitfields for the MQTT header byte.

Definition at line 53 of file MQTTPacket.h.

Field Documentation

◆ bits

struct { ... } bits

◆ byte

unsigned char byte

the whole byte

Definition at line 55 of file MQTTPacket.h.

◆ dup

unsigned int dup

DUP flag bit

Definition at line 69 of file MQTTPacket.h.

◆ qos

unsigned int qos

QoS value, 0, 1 or 2

Definition at line 68 of file MQTTPacket.h.

◆ retain

unsigned int retain

retained flag bit

Definition at line 67 of file MQTTPacket.h.

◆ type

unsigned int type

message type nibble

Definition at line 70 of file MQTTPacket.h.

The documentation for this union was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTPacket.h


ioLibrary: MQTTLenString Struct Reference

Data Fields
MQTTLenString Struct Reference

#include <MQTTPacket.h>

Data Fields

int | len
char * | data

Detailed Description

Definition at line 75 of file MQTTPacket.h.

Field Documentation

◆ data

char* data

Definition at line 78 of file MQTTPacket.h.

◆ len

int len

Definition at line 77 of file MQTTPacket.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTPacket.h


ioLibrary: MQTTMessage Struct Reference

Data Fields
MQTTMessage Struct Reference

#include <MQTTClient.h>

Data Fields

enum QoS | qos
unsigned char | retained
unsigned char | dup
unsigned short | id
void * | payload
size_t | payloadlen

Detailed Description

Definition at line 68 of file MQTTClient.h.

Field Documentation

◆ dup

unsigned char dup

Definition at line 72 of file MQTTClient.h.

◆ id

unsigned short id

Definition at line 73 of file MQTTClient.h.

◆ payload

void* payload

Definition at line 74 of file MQTTClient.h.

◆ payloadlen

size_t payloadlen

Definition at line 75 of file MQTTClient.h.

◆ qos

enum QoS qos

Definition at line 70 of file MQTTClient.h.

◆ retained

unsigned char retained

Definition at line 71 of file MQTTClient.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTClient.h


ioLibrary: MQTTPacket_connectData Struct Reference

Data Fields
MQTTPacket_connectData Struct Reference

#include <MQTTConnect.h>

Collaboration diagram for MQTTPacket_connectData:
[legend]

Data Fields

char | struct_id [4]
int | struct_version
unsigned char | MQTTVersion
MQTTString clientID
unsigned short | keepAliveInterval
unsigned char | cleansession
unsigned char | willFlag
MQTTPacket_willOptions will
MQTTString username
MQTTString password

Detailed Description

Definition at line 88 of file MQTTConnect.h.

Field Documentation

◆ cleansession

unsigned char cleansession

Definition at line 99 of file MQTTConnect.h.

◆ clientID

MQTTString clientID

Definition at line 97 of file MQTTConnect.h.

◆ keepAliveInterval

unsigned short keepAliveInterval

Definition at line 98 of file MQTTConnect.h.

◆ MQTTVersion

unsigned char MQTTVersion

Version of MQTT to be used. 3 = 3.1 4 = 3.1.1

Definition at line 96 of file MQTTConnect.h.

◆ password

MQTTString password

Definition at line 103 of file MQTTConnect.h.

◆ struct_id

char struct_id[4]

The eyecatcher for this structure. must be MQTC.

Definition at line 91 of file MQTTConnect.h.

◆ struct_version

int struct_version

The version number of this structure. Must be 0

Definition at line 93 of file MQTTConnect.h.

◆ username

MQTTString username

Definition at line 102 of file MQTTConnect.h.

◆ will

MQTTPacket_willOptions will

Definition at line 101 of file MQTTConnect.h.

◆ willFlag

unsigned char willFlag

Definition at line 100 of file MQTTConnect.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTConnect.h


ioLibrary: MQTTPacket_willOptions Struct Reference

Data Fields
MQTTPacket_willOptions Struct Reference

#include <MQTTConnect.h>

Collaboration diagram for MQTTPacket_willOptions:
[legend]

Data Fields

char | struct_id [4]
int | struct_version
MQTTString topicName
MQTTString message
unsigned char | retained
char | qos

Detailed Description

Defines the MQTT "Last Will and Testament" (LWT) settings for the connect packet.

Definition at line 63 of file MQTTConnect.h.

Field Documentation

◆ message

MQTTString message

The LWT payload.

Definition at line 72 of file MQTTConnect.h.

◆ qos

char qos

The quality of service setting for the LWT message (see MQTTAsync_message.qos and qos).

Definition at line 81 of file MQTTConnect.h.

◆ retained

unsigned char retained

The retained flag for the LWT message (see MQTTAsync_message.retained).

Definition at line 76 of file MQTTConnect.h.

◆ struct_id

char struct_id[4]

The eyecatcher for this structure. must be MQTW.

Definition at line 66 of file MQTTConnect.h.

◆ struct_version

int struct_version

The version number of this structure. Must be 0

Definition at line 68 of file MQTTConnect.h.

◆ topicName

MQTTString topicName

The LWT topic to which the LWT message will be published.

Definition at line 70 of file MQTTConnect.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTConnect.h


ioLibrary: MQTTString Struct Reference

Data Fields
MQTTString Struct Reference

#include <MQTTPacket.h>

Collaboration diagram for MQTTString:
[legend]

Data Fields

char * cstring
MQTTLenString lenstring

Detailed Description

Definition at line 81 of file MQTTPacket.h.

Field Documentation

◆ cstring

char* cstring

Definition at line 83 of file MQTTPacket.h.

◆ lenstring

MQTTLenString lenstring

Definition at line 84 of file MQTTPacket.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTPacket.h


ioLibrary: MQTTTransport Struct Reference

Data Fields
MQTTTransport Struct Reference

#include <MQTTPacket.h>

Data Fields

int(* | getfn )(void *, unsigned char *, int)
void * | sck
int | multiplier
int | rem_len
int | len
char | state

Detailed Description

Definition at line 117 of file MQTTPacket.h.

Field Documentation

◆ getfn

int(* getfn) (void *, unsigned char *, int)

Definition at line 118 of file MQTTPacket.h.

◆ len

int len

Definition at line 122 of file MQTTPacket.h.

◆ multiplier

int multiplier

Definition at line 120 of file MQTTPacket.h.

◆ rem_len

int rem_len

Definition at line 121 of file MQTTPacket.h.

◆ sck

void* sck

Definition at line 119 of file MQTTPacket.h.

◆ state

char state

Definition at line 123 of file MQTTPacket.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/MQTTPacket/src/MQTTPacket.h


ioLibrary: Network Struct Reference

Data Fields
Network Struct Reference

#include <mqtt_interface.h>

Data Fields

int | my_socket
int(* | mqttread )(Network *, unsigned char *, int, int)
int(* | mqttwrite )(Network *, unsigned char *, int, int)
void(* | disconnect )(Network *)

Detailed Description

Definition at line 234 of file mqtt_interface.h.

Field Documentation

◆ disconnect

void(* disconnect) (Network *)

Definition at line 239 of file mqtt_interface.h.

◆ mqttread

int(* mqttread) (Network *, unsigned char *, int, int)

Definition at line 237 of file mqtt_interface.h.

◆ mqttwrite

int(* mqttwrite) (Network *, unsigned char *, int, int)

Definition at line 238 of file mqtt_interface.h.

◆ my_socket

int my_socket

Definition at line 236 of file mqtt_interface.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/mqtt_interface.h


ioLibrary: RIP_MSG Struct Reference

Data Fields
RIP_MSG Struct Reference

Data Fields

uint8_t | op
DHCP_BOOTREQUEST or DHCP_BOOTREPLY More...
uint8_t | htype
DHCP_HTYPE10MB or DHCP_HTYPE100MB More...
uint8_t | hlen
DHCP_HLENETHERNET More...
uint8_t | hops
DHCP_HOPS More...
uint32_t | xid
DHCP_XID This increase one every DHCP transaction. More...
uint16_t | secs
DHCP_SECS More...
uint16_t | flags
DHCP_FLAGSBROADCAST or DHCP_FLAGSUNICAST More...
uint8_t | ciaddr [4]
Request IP to DHCP sever More...
uint8_t | yiaddr [4]
Offered IP from DHCP server More...
uint8_t | siaddr [4]
No use. More...
uint8_t | giaddr [4]
No use. More...
uint8_t | chaddr [16]
DHCP client 6bytes MAC address. Others is filled to zero. More...
uint8_t | sname [64]
No use. More...
uint8_t | file [128]
No use. More...
uint8_t | OPT [OPT_SIZE]
Option. More...

Detailed Description

Definition at line 172 of file dhcp.c.

Field Documentation

◆ chaddr

uint8_t chaddr[16]

DHCP client 6bytes MAC address. Others is filled to zero.

Definition at line 184 of file dhcp.c.

◆ ciaddr

uint8_t ciaddr[4]

Request IP to DHCP sever

Definition at line 180 of file dhcp.c.

◆ file

uint8_t file[128]

No use.

Definition at line 186 of file dhcp.c.

◆ flags

uint16_t flags

DHCP_FLAGSBROADCAST or DHCP_FLAGSUNICAST

Definition at line 179 of file dhcp.c.

◆ giaddr

uint8_t giaddr[4]

No use.

Definition at line 183 of file dhcp.c.

◆ hlen

uint8_t hlen

DHCP_HLENETHERNET

Definition at line 175 of file dhcp.c.

◆ hops

uint8_t hops

DHCP_HOPS

Definition at line 176 of file dhcp.c.

◆ htype

uint8_t htype

DHCP_HTYPE10MB or DHCP_HTYPE100MB

Definition at line 174 of file dhcp.c.

◆ op

uint8_t op

DHCP_BOOTREQUEST or DHCP_BOOTREPLY

Definition at line 173 of file dhcp.c.

◆ OPT

uint8_t OPT[OPT_SIZE]

Option.

Definition at line 187 of file dhcp.c.

◆ secs

uint16_t secs

DHCP_SECS

Definition at line 178 of file dhcp.c.

◆ siaddr

uint8_t siaddr[4]

No use.

Definition at line 182 of file dhcp.c.

◆ sname

uint8_t sname[64]

No use.

Definition at line 185 of file dhcp.c.

◆ xid

uint32_t xid

DHCP_XID This increase one every DHCP transaction.

Definition at line 177 of file dhcp.c.

◆ yiaddr

uint8_t yiaddr[4]

Offered IP from DHCP server

Definition at line 181 of file dhcp.c.

The documentation for this struct was generated from the following file:
  • Internet/DHCP/dhcp.c


ioLibrary: tftp_data Struct Reference

Data Fields
tftp_data Struct Reference

#include <tftp.h>

Data Fields

uint16_t | opcode
uint16_t | block_num
uint8_t | data [0]

Detailed Description

Definition at line 69 of file tftp.h.

Field Documentation

◆ block_num

uint16_t block_num

Definition at line 71 of file tftp.h.

◆ data

uint8_t data[0]

Definition at line 72 of file tftp.h.

◆ opcode

uint16_t opcode

Definition at line 70 of file tftp.h.

The documentation for this struct was generated from the following file:
  • Internet/TFTP/tftp.h


ioLibrary: tftp_error Struct Reference

Data Fields
tftp_error Struct Reference

#include <tftp.h>

Data Fields

uint16_t | opcode
uint16_t | error_code
uint8_t | error_msg [0]

Detailed Description

Definition at line 75 of file tftp.h.

Field Documentation

◆ error_code

uint16_t error_code

Definition at line 77 of file tftp.h.

◆ error_msg

uint8_t error_msg[0]

Definition at line 78 of file tftp.h.

◆ opcode

uint16_t opcode

Definition at line 76 of file tftp.h.

The documentation for this struct was generated from the following file:
  • Internet/TFTP/tftp.h


ioLibrary: tftp_option Struct Reference

Data Fields
tftp_option Struct Reference

#include <tftp.h>

Data Fields

uint8_t * | code
uint8_t * | value

Detailed Description

Definition at line 81 of file tftp.h.

Field Documentation

◆ code

uint8_t* code

Definition at line 82 of file tftp.h.

◆ value

uint8_t* value

Definition at line 83 of file tftp.h.

The documentation for this struct was generated from the following file:
  • Internet/TFTP/tftp.h


ioLibrary: Timer Struct Reference

Data Fields
Timer Struct Reference

#include <mqtt_interface.h>

Data Fields

unsigned long | systick_period
unsigned long | end_time

Detailed Description

Definition at line 225 of file mqtt_interface.h.

Field Documentation

◆ end_time

unsigned long end_time

Definition at line 227 of file mqtt_interface.h.

◆ systick_period

unsigned long systick_period

Definition at line 226 of file mqtt_interface.h.

The documentation for this struct was generated from the following file:
  • Internet/MQTT/mqtt_interface.h


ioLibrary: tlvStructType Struct Reference

Data Fields
tlvStructType Struct Reference

#include <snmp.h>

Data Fields

int32_t | start
int32_t | len
int32_t | vstart
int32_t | nstart

Detailed Description

Definition at line 93 of file snmp.h.

Field Documentation

◆ len

int32_t len

Definition at line 95 of file snmp.h.

◆ nstart

int32_t nstart

Definition at line 97 of file snmp.h.

◆ start

int32_t start

Definition at line 94 of file snmp.h.

◆ vstart

int32_t vstart

Definition at line 96 of file snmp.h.

The documentation for this struct was generated from the following file:
  • Internet/SNMP/snmp.h


ioLibrary: Data Structure Index

Data Structure Index
_ | c | d | f | m | n | r | t | w
_
_un_l2cval
m
MQTTPacket_willOptions tftp_error
c
MQTTString tftp_option
__file MessageData MQTTTransport Timer
__WIZCHIP Command MQTTClient::MessageHandlers
n
tlvStructType
__WIZCHIP::_CRIS
d
messageStruct
w
__WIZCHIP::_CS MQTTClient Network
_datetime dataEntryType MQTTConnackFlags
r
wiz_NetInfo_t
_httpServer_webContent dhdr MQTTConnectFlags wiz_NetTimeout_t
__WIZCHIP::_IF
f
MQTTHeader RIP_MSG wiz_PhyConf_t
_ntpformat MQTTLenString
t
_st_http_request ftpc MQTTMessage
_st_http_socket ftpd MQTTPacket_connectData tftp_data
_ | c | d | f | m | n | r | t | w


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- _ -

  • _deselect : __WIZCHIP::_CS
  • _enter : __WIZCHIP::_CRIS
  • _exit : __WIZCHIP::_CRIS
  • _read_burst : __WIZCHIP::_IF
  • _read_byte : __WIZCHIP::_IF
  • _read_data : __WIZCHIP::_IF
  • _select : __WIZCHIP::_CS
  • _write_burst : __WIZCHIP::_IF
  • _write_byte : __WIZCHIP::_IF
  • _write_data : __WIZCHIP::_IF


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- a -

  • aa : dhdr
  • all : MQTTConnackFlags , MQTTConnectFlags
  • ancount : dhdr
  • arcount : dhdr


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- b -

  • bits : MQTTConnackFlags , MQTTConnectFlags , MQTTHeader
  • block_num : tftp_data
  • buf : __file , MQTTClient
  • buf_size : MQTTClient
  • buffer : messageStruct
  • BUS : __WIZCHIP::_IF
  • by : wiz_PhyConf_t
  • byte : MQTTHeader


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- c -

  • chaddr : RIP_MSG
  • ciaddr : RIP_MSG
  • cleansession : MQTTConnectFlags , MQTTPacket_connectData
  • clientID : MQTTPacket_connectData
  • code : tftp_option
  • command_timeout_ms : MQTTClient
  • content : _httpServer_webContent
  • content_len : _httpServer_webContent
  • content_name : _httpServer_webContent
  • control : ftpc , ftpd
  • CRIS : __WIZCHIP
  • CS : __WIZCHIP
  • cstring : MQTTString
  • current_cmd : ftpd
  • cVal : _un_l2cval


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- d -

  • data : ftpc , ftpd , MQTTLenString , tftp_data
  • dataLen : dataEntryType
  • dataType : dataEntryType
  • dd : _datetime
  • defaultMessageHandler : MQTTClient
  • dhcp : wiz_NetInfo_t
  • disconnect : Network
  • dns : wiz_NetInfo_t
  • dsock_mode : ftpc , ftpd
  • dsock_state : ftpc , ftpd
  • dstaddr : _ntpformat
  • dup : MQTTHeader , MQTTMessage
  • duplex : wiz_PhyConf_t


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- e -

  • end_time : Timer
  • error_code : tftp_error
  • error_msg : tftp_error


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- f -

  • file : RIP_MSG
  • file_len : _st_http_socket
  • file_name : _st_http_socket
  • file_offset : _st_http_socket
  • file_start : _st_http_socket
  • filename : ftpc , ftpd
  • First : Command
  • flags : __file , RIP_MSG
  • fp : MQTTClient::MessageHandlers


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- g -

  • get : __file
  • getfn : MQTTTransport
  • getfunction : dataEntryType
  • giaddr : RIP_MSG
  • gw : wiz_NetInfo_t


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- h -

  • hh : _datetime
  • hlen : RIP_MSG
  • hops : RIP_MSG
  • htype : RIP_MSG


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- i -

  • id : __WIZCHIP , dhdr , MQTTMessage
  • IF : __WIZCHIP
  • if_mode : __WIZCHIP
  • index : messageStruct
  • int : MQTTConnackFlags , MQTTConnectFlags
  • intval : dataEntryType
  • ip : wiz_NetInfo_t
  • ipstack : MQTTClient
  • isconnected : MQTTClient


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- k -

  • keepAliveInterval : MQTTClient , MQTTPacket_connectData


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- l -

  • leap : _ntpformat
  • len : __file , messageStruct , MQTTLenString , MQTTTransport , tlvStructType
  • lenstring : MQTTString
  • lVal : _un_l2cval


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- m -

  • mac : wiz_NetInfo_t
  • message : MessageData , MQTTPacket_willOptions
  • messageHandlers : MQTTClient
  • METHOD : _st_http_request
  • mm : _datetime
  • mo : _datetime
  • mode : _ntpformat , wiz_PhyConf_t
  • mqttread : Network
  • MQTTVersion : MQTTPacket_connectData
  • mqttwrite : Network
  • multiplier : MQTTTransport
  • my_socket : Network


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- n -

  • next_packetid : MQTTClient
  • nscount : dhdr
  • nstart : tlvStructType


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- o -

  • octetstring : dataEntryType
  • oid : dataEntryType
  • oidlen : dataEntryType
  • op : RIP_MSG
  • opcode : dhdr , tftp_data , tftp_error
  • OPT : RIP_MSG
  • org : _ntpformat


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- p -

  • password : MQTTConnectFlags , MQTTPacket_connectData
  • payload : MQTTMessage
  • payloadlen : MQTTMessage
  • ping_outstanding : MQTTClient
  • ping_timer : MQTTClient
  • poll : _ntpformat
  • precision : _ntpformat
  • put : __file


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- q -

  • qdcount : dhdr
  • qos : MQTTHeader , MQTTMessage , MQTTPacket_willOptions
  • qr : dhdr


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- r -

  • ra : dhdr
  • rcode : dhdr
  • rd : dhdr
  • readbuf : MQTTClient
  • readbuf_size : MQTTClient
  • rec : _ntpformat
  • refid : _ntpformat
  • reftime : _ntpformat
  • rem_len : MQTTTransport
  • retain : MQTTHeader
  • retained : MQTTMessage , MQTTPacket_willOptions
  • retry_cnt : wiz_NetTimeout_t
  • rootdelay : _ntpformat
  • rootdisp : _ntpformat


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- s -

  • sck : MQTTTransport
  • Second : Command
  • secs : RIP_MSG
  • sessionpresent : MQTTConnackFlags
  • setfunction : dataEntryType
  • siaddr : RIP_MSG
  • size : __file
  • sn : wiz_NetInfo_t
  • sname : RIP_MSG
  • sock_status : _st_http_socket
  • speed : wiz_PhyConf_t
  • SPI : __WIZCHIP::_IF
  • ss : _datetime
  • start : tlvStructType
  • state : ftpd , MQTTTransport
  • storage_type : _st_http_socket
  • stratum : _ntpformat
  • struct_id : MQTTPacket_connectData , MQTTPacket_willOptions
  • struct_version : MQTTPacket_connectData , MQTTPacket_willOptions
  • systick_period : Timer


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- t -

  • tc : dhdr
  • time_100us : wiz_NetTimeout_t
  • topicFilter : MQTTClient::MessageHandlers
  • topicName : MessageData , MQTTPacket_willOptions
  • TYPE : _st_http_request
  • type : ftpc , ftpd , MQTTHeader


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- u -

  • u : dataEntryType
  • unget : __file
  • URI : _st_http_request
  • username : ftpd , MQTTConnectFlags , MQTTPacket_connectData


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- v -

  • value : tftp_option
  • version : _ntpformat
  • vstart : tlvStructType


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- w -

  • will : MQTTConnectFlags , MQTTPacket_connectData
  • willFlag : MQTTPacket_connectData
  • willQoS : MQTTConnectFlags
  • willRetain : MQTTConnectFlags
  • workingdir : ftpc , ftpd


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- x -

  • xid : RIP_MSG
  • xmt : _ntpformat


ioLibrary: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- y -

  • yiaddr : RIP_MSG
  • yy : _datetime


ioLibrary: Data Fields - Variables

- _ -

  • _deselect : __WIZCHIP::_CS
  • _enter : __WIZCHIP::_CRIS
  • _exit : __WIZCHIP::_CRIS
  • _read_burst : __WIZCHIP::_IF
  • _read_byte : __WIZCHIP::_IF
  • _read_data : __WIZCHIP::_IF
  • _select : __WIZCHIP::_CS
  • _write_burst : __WIZCHIP::_IF
  • _write_byte : __WIZCHIP::_IF
  • _write_data : __WIZCHIP::_IF


ioLibrary: Data Fields - Variables

- a -

  • aa : dhdr
  • all : MQTTConnackFlags , MQTTConnectFlags
  • ancount : dhdr
  • arcount : dhdr


ioLibrary: Data Fields - Variables

- b -

  • bits : MQTTConnackFlags , MQTTConnectFlags , MQTTHeader
  • block_num : tftp_data
  • buf : __file , MQTTClient
  • buf_size : MQTTClient
  • buffer : messageStruct
  • BUS : __WIZCHIP::_IF
  • by : wiz_PhyConf_t
  • byte : MQTTHeader


ioLibrary: Data Fields - Variables

- c -

  • chaddr : RIP_MSG
  • ciaddr : RIP_MSG
  • cleansession : MQTTConnectFlags , MQTTPacket_connectData
  • clientID : MQTTPacket_connectData
  • code : tftp_option
  • command_timeout_ms : MQTTClient
  • content : _httpServer_webContent
  • content_len : _httpServer_webContent
  • content_name : _httpServer_webContent
  • control : ftpc , ftpd
  • CRIS : __WIZCHIP
  • CS : __WIZCHIP
  • cstring : MQTTString
  • current_cmd : ftpd
  • cVal : _un_l2cval


ioLibrary: Data Fields - Variables

- d -

  • data : ftpc , ftpd , MQTTLenString , tftp_data
  • dataLen : dataEntryType
  • dataType : dataEntryType
  • dd : _datetime
  • defaultMessageHandler : MQTTClient
  • dhcp : wiz_NetInfo_t
  • disconnect : Network
  • dns : wiz_NetInfo_t
  • dsock_mode : ftpc , ftpd
  • dsock_state : ftpc , ftpd
  • dstaddr : _ntpformat
  • dup : MQTTHeader , MQTTMessage
  • duplex : wiz_PhyConf_t


ioLibrary: Data Fields - Variables

- e -

  • end_time : Timer
  • error_code : tftp_error
  • error_msg : tftp_error


ioLibrary: Data Fields - Variables

- f -

  • file : RIP_MSG
  • file_len : _st_http_socket
  • file_name : _st_http_socket
  • file_offset : _st_http_socket
  • file_start : _st_http_socket
  • filename : ftpc , ftpd
  • First : Command
  • flags : __file , RIP_MSG
  • fp : MQTTClient::MessageHandlers


ioLibrary: Data Fields - Variables

- g -

  • get : __file
  • getfn : MQTTTransport
  • getfunction : dataEntryType
  • giaddr : RIP_MSG
  • gw : wiz_NetInfo_t


ioLibrary: Data Fields - Variables

- h -

  • hh : _datetime
  • hlen : RIP_MSG
  • hops : RIP_MSG
  • htype : RIP_MSG


ioLibrary: Data Fields - Variables

- i -

  • id : __WIZCHIP , dhdr , MQTTMessage
  • IF : __WIZCHIP
  • if_mode : __WIZCHIP
  • index : messageStruct
  • int : MQTTConnackFlags , MQTTConnectFlags
  • intval : dataEntryType
  • ip : wiz_NetInfo_t
  • ipstack : MQTTClient
  • isconnected : MQTTClient


ioLibrary: Data Fields - Variables

- k -

  • keepAliveInterval : MQTTClient , MQTTPacket_connectData


ioLibrary: Data Fields - Variables

- l -

  • leap : _ntpformat
  • len : __file , messageStruct , MQTTLenString , MQTTTransport , tlvStructType
  • lenstring : MQTTString
  • lVal : _un_l2cval


ioLibrary: Data Fields - Variables

- m -

  • mac : wiz_NetInfo_t
  • message : MessageData , MQTTPacket_willOptions
  • messageHandlers : MQTTClient
  • METHOD : _st_http_request
  • mm : _datetime
  • mo : _datetime
  • mode : _ntpformat , wiz_PhyConf_t
  • mqttread : Network
  • MQTTVersion : MQTTPacket_connectData
  • mqttwrite : Network
  • multiplier : MQTTTransport
  • my_socket : Network


ioLibrary: Data Fields - Variables

- n -

  • next_packetid : MQTTClient
  • nscount : dhdr
  • nstart : tlvStructType


ioLibrary: Data Fields - Variables

- o -

  • octetstring : dataEntryType
  • oid : dataEntryType
  • oidlen : dataEntryType
  • op : RIP_MSG
  • opcode : dhdr , tftp_data , tftp_error
  • OPT : RIP_MSG
  • org : _ntpformat


ioLibrary: Data Fields - Variables

- p -

  • password : MQTTConnectFlags , MQTTPacket_connectData
  • payload : MQTTMessage
  • payloadlen : MQTTMessage
  • ping_outstanding : MQTTClient
  • ping_timer : MQTTClient
  • poll : _ntpformat
  • precision : _ntpformat
  • put : __file


ioLibrary: Data Fields - Variables

- q -

  • qdcount : dhdr
  • qos : MQTTHeader , MQTTMessage , MQTTPacket_willOptions
  • qr : dhdr


ioLibrary: Data Fields - Variables

- r -

  • ra : dhdr
  • rcode : dhdr
  • rd : dhdr
  • readbuf : MQTTClient
  • readbuf_size : MQTTClient
  • rec : _ntpformat
  • refid : _ntpformat
  • reftime : _ntpformat
  • rem_len : MQTTTransport
  • retain : MQTTHeader
  • retained : MQTTMessage , MQTTPacket_willOptions
  • retry_cnt : wiz_NetTimeout_t
  • rootdelay : _ntpformat
  • rootdisp : _ntpformat


ioLibrary: Data Fields - Variables

- s -

  • sck : MQTTTransport
  • Second : Command
  • secs : RIP_MSG
  • sessionpresent : MQTTConnackFlags
  • setfunction : dataEntryType
  • siaddr : RIP_MSG
  • size : __file
  • sn : wiz_NetInfo_t
  • sname : RIP_MSG
  • sock_status : _st_http_socket
  • speed : wiz_PhyConf_t
  • SPI : __WIZCHIP::_IF
  • ss : _datetime
  • start : tlvStructType
  • state : ftpd , MQTTTransport
  • storage_type : _st_http_socket
  • stratum : _ntpformat
  • struct_id : MQTTPacket_connectData , MQTTPacket_willOptions
  • struct_version : MQTTPacket_connectData , MQTTPacket_willOptions
  • systick_period : Timer


ioLibrary: Data Fields - Variables

- t -

  • tc : dhdr
  • time_100us : wiz_NetTimeout_t
  • topicFilter : MQTTClient::MessageHandlers
  • topicName : MessageData , MQTTPacket_willOptions
  • TYPE : _st_http_request
  • type : ftpc , ftpd , MQTTHeader


ioLibrary: Data Fields - Variables

- u -

  • u : dataEntryType
  • unget : __file
  • URI : _st_http_request
  • username : ftpd , MQTTConnectFlags , MQTTPacket_connectData


ioLibrary: Data Fields - Variables

- v -

  • value : tftp_option
  • version : _ntpformat
  • vstart : tlvStructType


ioLibrary: Data Fields - Variables

- w -

  • will : MQTTConnectFlags , MQTTPacket_connectData
  • willFlag : MQTTPacket_connectData
  • willQoS : MQTTConnectFlags
  • willRetain : MQTTConnectFlags
  • workingdir : ftpc , ftpd


ioLibrary: Data Fields - Variables

- x -

  • xid : RIP_MSG
  • xmt : _ntpformat


ioLibrary: Data Fields - Variables

- y -

  • yiaddr : RIP_MSG
  • yy : _datetime


ioLibrary: File List

File List
Here is a list of all files with brief descriptions:
[detail level 12345]
▼ Application |
▼ loopback |
loopback.c |
loopback.h |
▼ Ethernet |
▼ W5100 |
w5100.c | W5100 HAL Interface
w5100.h | W5100 HAL Header File
▼ W5100S |
w5100s.c | W5100S HAL Interface
w5100s.h | W5100S HAL Header File
▼ W5200 |
w5200.c | W5200 HAL Interface
w5200.h | W5200 HAL Header File
▼ W5300 |
w5300.c |
w5300.h | W5300 HAL implement File
▼ W5500 |
w5500.c | W5500 HAL Interface
w5500.h | W5500 HAL Header File
socket.c | SOCKET APIs Implements file
socket.h | SOCKET APIs Header file
wizchip_conf.c | WIZCHIP Config Header File
wizchip_conf.h | WIZCHIP Config Header File
▼ image |
Berkeley_SOCKET.jpg |
w5100_w5200_w5500.jpg |
w5100_w5200_w5500_w5100s.jpg |
w5200_w5500.jpg |
w5500.jpg |
WIZnet_SOCKET.jpg |
▼ Internet |
▼ DHCP |
dhcp.c | DHCP APIs implement file
dhcp.h | DHCP APIs Header file
▼ DNS |
dns.c | DNS APIs Implement file
dns.h | DNS APIs Header file
▼ FTPClient |
ftpc.c |
ftpc.h |
stdio_private.h |
▼ FTPServer |
ftpd.c |
ftpd.h |
stdio_private.h |
▼ httpServer |
httpParser.c |
httpParser.h |
httpServer.c |
httpServer.h | Define constants and functions related HTTP Web server
httpUtil.c | HTTP Server Utilities
httpUtil.h | Header File for HTTP Server Utilities
▼ MQTT |
▼ MQTTPacket |
▼ src |
MQTTConnect.h |
MQTTConnectClient.c |
MQTTConnectServer.c |
MQTTDeserializePublish.c |
MQTTFormat.c |
MQTTFormat.h |
MQTTPacket.c |
MQTTPacket.h |
MQTTPublish.h |
MQTTSerializePublish.c |
MQTTSubscribe.h |
MQTTSubscribeClient.c |
MQTTSubscribeServer.c |
MQTTUnsubscribe.h |
MQTTUnsubscribeClient.c |
MQTTUnsubscribeServer.c |
StackTrace.h |
mqtt_interface.c | Paho MQTT to WIZnet Chip interface implement file
mqtt_interface.h | Paho MQTT to WIZnet Chip interface Header file
MQTTClient.c |
MQTTClient.h |
▼ SNMP |
snmp.c |
snmp.h |
snmp_custom.c |
snmp_custom.h |
▼ SNTP |
sntp.c |
sntp.h |
▼ TFTP |
netutil.c |
netutil.h |
tftp.c | TFTP Source File
tftp.h | TFTP Header File


ioLibrary: Application Directory Reference

  • Application
Application Directory Reference
Directory dependency graph for Application:

Directories

directory loopback


ioLibrary: Application/loopback Directory Reference

  • Application
  • loopback
loopback Directory Reference
Directory dependency graph for loopback:

Files

file | loopback.c [code]
file | loopback.h [code]


ioLibrary: Application/loopback/loopback.c File Reference

  • Application
  • loopback
Functions
loopback.c File Reference
#include <stdio.h>
#include "loopback.h"
#include "socket.h"
#include "wizchip_conf.h"
Include dependency graph for loopback.c:

Go to the source code of this file.

Functions

int32_t | loopback_tcps (uint8_t sn, uint8_t *buf, uint16_t port)
int32_t | loopback_tcpc (uint8_t sn, uint8_t *buf, uint8_t *destip, uint16_t destport)
int32_t | loopback_udps (uint8_t sn, uint8_t *buf, uint16_t port)

Function Documentation

◆ loopback_tcpc()

int32_t loopback_tcpc | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint8_t * | destip,
 |  | uint16_t | destport
 | ) |  |

Definition at line 83 of file loopback.c.

◆ loopback_tcps()

int32_t loopback_tcps | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | port
 | ) |  |

Definition at line 8 of file loopback.c.

◆ loopback_udps()

int32_t loopback_udps | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | port
 | ) |  |

Definition at line 172 of file loopback.c.


ioLibrary: Application/loopback/loopback.h File Reference

  • Application
  • loopback
Macros | Functions
loopback.h File Reference
#include <stdint.h>
Include dependency graph for loopback.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | _LOOPBACK_DEBUG_
#define | DATA_BUF_SIZE 2048
#define | LOOPBACK_MAIN_NOBLOCK 0
#define | LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK

Functions

int32_t | loopback_tcps (uint8_t sn, uint8_t *buf, uint16_t port)
int32_t | loopback_tcpc (uint8_t sn, uint8_t *buf, uint8_t *destip, uint16_t destport)
int32_t | loopback_udps (uint8_t sn, uint8_t *buf, uint16_t port)

Macro Definition Documentation

◆ _LOOPBACK_DEBUG_

#define _LOOPBACK_DEBUG_

Definition at line 7 of file loopback.h.

◆ DATA_BUF_SIZE

#define DATA_BUF_SIZE 2048

Definition at line 11 of file loopback.h.

◆ LOOPBACK_MAIN_NOBLOCK

#define LOOPBACK_MAIN_NOBLOCK 0

Definition at line 17 of file loopback.h.

◆ LOOPBACK_MODE

#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK

Definition at line 18 of file loopback.h.

Function Documentation

◆ loopback_tcpc()

int32_t loopback_tcpc | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint8_t * | destip,
 |  | uint16_t | destport
 | ) |  |

Definition at line 83 of file loopback.c.

◆ loopback_tcps()

int32_t loopback_tcps | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | port
 | ) |  |

Definition at line 8 of file loopback.c.

◆ loopback_udps()

int32_t loopback_udps | ( | uint8_t | sn,
 |  | uint8_t * | buf,
 |  | uint16_t | port
 | ) |  |

Definition at line 172 of file loopback.c.


ioLibrary: Ethernet Directory Reference

  • Ethernet
Ethernet Directory Reference
Directory dependency graph for Ethernet:

Directories

directory | W5100
directory | W5100S
directory | W5200
directory | W5300
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.


ioLibrary: Ethernet/W5100 Directory Reference

  • Ethernet
  • W5100
W5100 Directory Reference
Directory dependency graph for W5100:

Files

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


ioLibrary: Ethernet/W5100/w5100.c File Reference

  • Ethernet
  • W5100
w5100.c File Reference

W5100 HAL Interface. More...

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

Go to the source code of this file.

Detailed Description

W5100 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 w5100.c.


ioLibrary: Ethernet/W5100/w5100.h File Reference

  • Ethernet
  • W5100
Macros | Functions
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.

Macros

#define | _WIZCHIP_SN_BASE_ (0x0400)
#define | _WIZCHIP_SN_SIZE_ (0x0100)
#define | _WIZCHIP_IO_TXBUF_ (0x4000) /* Internal Tx buffer address of the iinchip */
#define | _WIZCHIP_IO_RXBUF_ (0x6000) /* Internal Rx buffer address of the iinchip */
#define | WIZCHIP_CREG_BLOCK 0x00
Common register block. More...
#define | WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
Socket N register block. More...
#define | WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
Increase offset address. More...
#define | _W5100_IO_BASE_ _WIZCHIP_IO_BASE_
#define | IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE(ADDR, VAL) WIZCHIP_WRITE(ADDR,VAL)
The defined for legacy chip driver. More...
#define | IINCHIP_READ_BUF(ADDR, BUF, LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE_BUF(ADDR, BUF, LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | MR (_WIZCHIP_IO_BASE_ + (0x0000))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5100_IO_BASE_ + (0x0001))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5100_IO_BASE_ + (0x0005))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5100_IO_BASE_ + (0x0009))
Source MAC Register address(R/W) More...
#define | SIPR (_W5100_IO_BASE_ + (0x000F))
Source IP Register address(R/W) More...
#define | IR (_W5100_IO_BASE_ + (0x0015))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5100_IO_BASE_ + (0x0016))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5100_IO_BASE_ + (0x0017))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5100_IO_BASE_ + (0x0019))
Retry count register(R/W) More...
#define | RMSR (_W5100_IO_BASE_ + (0x001A))
#define | TMSR (_W5100_IO_BASE_ + (0x001B))
#define | PATR (_W5100_IO_BASE_ + (0x001C))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PTIMER (_W5100_IO_BASE_ + (0x0028))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PMAGIC (_W5100_IO_BASE_ + (0x0029))
PPP LCP Magic number register in PPPoE mode(R) More...
#define | UIPR0 (_W5100_IO_BASE_ + (0x002A))
#define | UPORT0 (_W5100_IO_BASE + (0x002E))
#define | Sn_MR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))
socket Mode register(R/W) More...
#define | Sn_CR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))
Socket command register(R/W) More...
#define | Sn_IR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))
Socket interrupt register(R) More...
#define | Sn_SR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))
Socket status register(R) More...
#define | Sn_PORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))
source port register(R/W) More...
#define | Sn_DHAR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))
Peer IP register address(R/W) More...
#define | Sn_DPORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))
Peer port register address(R/W) More...
#define | Sn_MSSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_PROTO(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOS(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_TX_FSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))
Received data size register(R) More...
#define | Sn_RX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))
Write point of Receive memory(R) More...
#define | MR_RST 0x80
Reset. More...
#define | MR_PB 0x10
Ping block. More...
#define | MR_PPPOE 0x08
Enable PPPoE. More...
#define | MR_AI 0x02
Address Auto-Increment in Indirect Bus Interface. More...
#define | MR_IND 0x01
Indirect Bus Interface mode. More...
#define | IR_CONFLICT 0x80
Check IP conflict. More...
#define | IR_UNREACH 0x40
Get the destination unreachable message in UDP sending. More...
#define | IR_PPPoE 0x20
Get the PPPoE close message. More...
#define | IR_SOCK(sn) (0x01 << sn)
check socket interrupt More...
#define | Sn_MR_CLOSE 0x00
Unused socket. More...
#define | Sn_MR_TCP 0x01
TCP. More...
#define | Sn_MR_UDP 0x02
UDP. More...
#define | Sn_MR_IPRAW 0x03
IP LAYER RAW SOCK. More...
#define | Sn_MR_MACRAW 0x04
MAC LAYER RAW SOCK. More...
#define | Sn_MR_PPPoE 0x05
PPPoE. More...
#define | Sn_MR_ND 0x20
No Delayed Ack(TCP), Multicast flag. More...
#define | Sn_MR_MC Sn_MR_ND
Support UDP Multicasting. More...
#define | Sn_MR_MF 0x40
MAC filter enable in Sn_MR_MACRAW mode. More...
#define | Sn_MR_MFEN Sn_MR_MF
#define | Sn_MR_MULTI 0x80
Support UDP Multicasting. More...
#define | Sn_CR_OPEN 0x01
Initialize or open socket. More...
#define | Sn_CR_LISTEN 0x02
Wait connection request in TCP mode(Server mode) More...
#define | Sn_CR_CONNECT 0x04
Send connection request in TCP mode(Client mode) More...
#define | Sn_CR_DISCON 0x08
Send closing request in TCP mode. More...
#define | Sn_CR_CLOSE 0x10
Close socket. More...
#define | Sn_CR_SEND 0x20
Update TX buffer pointer and send data. More...
#define | Sn_CR_SEND_MAC 0x21
Send data with MAC address, so without ARP process. More...
#define | Sn_CR_SEND_KEEP 0x22
Send keep alive message. More...
#define | Sn_CR_RECV 0x40
Update RX buffer pointer and receive data. More...
#define | Sn_CR_PCON 0x23
PPPoE connection. More...
#define | Sn_CR_PDISCON 0x24
Closes PPPoE connection. More...
#define | Sn_CR_PCR 0x25
REQ message transmission. More...
#define | Sn_CR_PCN 0x26
NAK massage transmission. More...
#define | Sn_CR_PCJ 0x27
REJECT message transmission. More...
#define | Sn_IR_PRECV 0x80
PPP Receive Interrupt. More...
#define | Sn_IR_PFAIL 0x40
PPP Fail Interrupt. More...
#define | Sn_IR_PNEXT 0x20
PPP Next Phase Interrupt. More...
#define | Sn_IR_SENDOK 0x10
SEND_OK Interrupt. More...
#define | Sn_IR_TIMEOUT 0x08
TIMEOUT Interrupt. More...
#define | Sn_IR_RECV 0x04
RECV Interrupt. More...
#define | Sn_IR_DISCON 0x02
DISCON Interrupt. More...
#define | Sn_IR_CON 0x01
CON Interrupt. More...
#define | SOCK_CLOSED 0x00
Closed. More...
#define | SOCK_INIT 0x13
Initiate state. More...
#define | SOCK_LISTEN 0x14
Listen state. More...
#define | SOCK_SYNSENT 0x15
Connection state. More...
#define | SOCK_SYNRECV 0x16
Connection state. More...
#define | SOCK_ESTABLISHED 0x17
Success to connect. More...
#define | SOCK_FIN_WAIT 0x18
Closing state. More...
#define | SOCK_CLOSING 0x1A
Closing state. More...
#define | SOCK_TIME_WAIT 0x1B
Closing state. More...
#define | SOCK_CLOSE_WAIT 0x1C
Closing state. More...
#define | SOCK_LAST_ACK 0x1D
Closing state. More...
#define | SOCK_UDP 0x22
UDP socket. More...
#define | SOCK_IPRAW 0x32
IP raw mode socket. More...
#define | SOCK_MACRAW 0x42
MAC raw mode socket. More...
#define | SOCK_PPPOE 0x5F
PPPoE mode socket. More...
#define | IPPROTO_IP 0
Dummy for IP. More...
#define | IPPROTO_ICMP 1
Control message protocol. More...
#define | IPPROTO_IGMP 2
Internet group management protocol. More...
#define | IPPROTO_GGP 3
GW^2 (deprecated) More...
#define | IPPROTO_TCP 6
TCP. More...
#define | IPPROTO_PUP 12
PUP. More...
#define | IPPROTO_UDP 17
UDP. More...
#define | IPPROTO_IDP 22
XNS idp. More...
#define | IPPROTO_ND 77
UNOFFICIAL net disk protocol. More...
#define | IPPROTO_RAW 255
Raw IP packet. More...
#define | WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
Enter a critical section. More...
#define | WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
Exit a critical section. More...
#define | setMR(mr) (*((uint8_t*)MR) = mr)
Set Mode Register. More...
#define | getMR() (*(uint8_t*)MR)
Get MR. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set GAR. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get GAR. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR,subr,4)
Set SUBR. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get SUBR. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set SHAR. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get SHAR. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set SIPR. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get SIPR. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xA0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xA0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr)
Set IMR register. More...
#define | getIMR() WIZCHIP_READ(_IMR_)
Get IMR register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | setRMSR(rmsr) WIZCHIP_WRITE(RMSR)
Get RMSR register. More...
#define | getRMSR() WIZCHIP_READ()
Get RMSR register. More...
#define | setTMSR(rmsr) WIZCHIP_WRITE(TMSR)
Get TMSR register. More...
#define | getPATR() (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
Get TMSR register. More...
#define | getPPPALGO() WIZCHIP_READ(PPPALGO)
Get PPPALGO register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...
#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ir)
Set Sn_IR register. More...
#define | getSn_IR(sn) WIZCHIP_READ(Sn_IR(sn))
Get Sn_IR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_DHAR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_PROTO(sn, proto) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_PROTO register. More...
#define | getSn_PROTO(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_PROTO register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXMEM_SIZE(sn, rxmemsize) WIZCHIP_WRITE(RMSR, (WIZCHIP_READ(RMSR) & ~(0x03 << (2*sn))) | (rxmemsize << (2*sn)))
Set Sn_RXMEM_SIZE register. More...
#define | setSn_RXBUF_SIZE(sn, rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
#define | getSn_RXMEM_SIZE(sn) ((WIZCHIP_READ(RMSR) & (0x03 << (2*sn))) >> (2*sn))
Get Sn_RXMEM_SIZE register. More...
#define | getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
#define | setSn_TXMEM_SIZE(sn, txmemsize) WIZCHIP_WRITE(TMSR, (WIZCHIP_READ(TMSR) & ~(0x03 << (2*sn))) | (txmemsize << (2*sn)))
Set Sn_TXMEM_SIZE register. More...
#define | setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
#define | getSn_TXMEM_SIZE(sn) ((WIZCHIP_READ(TMSR) & (0x03 << (2*sn))) >> (2*sn))
Get Sn_TXMEM_SIZE register. More...
#define | getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | setSn_RX_WR(sn, rxwr)
Set Sn_RX_WR register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_FRAG(sn, frag)
Set Sn_FRAG register. More...
#define | getSn_FRAG(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
Get Sn_FRAG register. More...
#define | getSn_RxMAX(sn) ((uint16_t)(1 << getSn_RXMEM_SIZE(sn)) << 10)
Get the max RX buffer size of socket sn. More...
#define | getSn_TxMAX(sn) ((uint16_t)(1 << getSn_TXMEM_SIZE(sn)) << 10)
Get the max TX buffer size of socket sn. More...
#define | getSn_RxMASK(sn) (getSn_RxMAX(sn) - 1)
Get the mask of socket sn RX buffer. More...
#define | getSn_TxMASK(sn) (getSn_TxMAX(sn) - 1)
Get the mask of socket sn TX buffer. More...

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
uint32_t | getSn_RxBASE (uint8_t sn)
Get the base address of socket sn RX buffer. More...
uint32_t | getSn_TxBASE (uint8_t sn)
Get the base address of socket sn TX buffer. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...

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.

Macro Definition Documentation

◆ _W5100_IO_BASE_

#define _W5100_IO_BASE_ _WIZCHIP_IO_BASE_

Definition at line 62 of file w5100.h.

◆ _WIZCHIP_IO_RXBUF_

#define _WIZCHIP_IO_RXBUF_ (0x6000) /* Internal Rx buffer address of the iinchip */

Definition at line 53 of file w5100.h.

◆ _WIZCHIP_IO_TXBUF_

#define _WIZCHIP_IO_TXBUF_ (0x4000) /* Internal Tx buffer address of the iinchip */

Definition at line 52 of file w5100.h.

◆ _WIZCHIP_SN_BASE_

#define _WIZCHIP_SN_BASE_ (0x0400)

Definition at line 50 of file w5100.h.

◆ _WIZCHIP_SN_SIZE_

#define _WIZCHIP_SN_SIZE_ (0x0100)

Definition at line 51 of file w5100.h.

◆ getSn_RXBUF_SIZE

#define getSn_RXBUF_SIZE ( sn ) getSn_RXMEM_SIZE(sn)

Definition at line 1615 of file w5100.h.

◆ getSn_TXBUF_SIZE

#define getSn_TXBUF_SIZE ( sn ) getSn_TXMEM_SIZE(sn)

Definition at line 1637 of file w5100.h.

◆ IINCHIP_READ

#define IINCHIP_READ ( ADDR ) WIZCHIP_READ(ADDR)

The defined for legacy chip driver.

Definition at line 76 of file w5100.h.

◆ IINCHIP_READ_BUF

#define IINCHIP_READ_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_READ_BUF(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 78 of file w5100.h.

◆ IINCHIP_WRITE

#define IINCHIP_WRITE | ( | ADDR,
 |  | VAL
 | ) | WIZCHIP_WRITE(ADDR,VAL)

The defined for legacy chip driver.

Definition at line 77 of file w5100.h.

◆ IINCHIP_WRITE_BUF

#define IINCHIP_WRITE_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_WRITE(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 79 of file w5100.h.

◆ IPPROTO_GGP

#define IPPROTO_GGP 3

GW^2 (deprecated)

Definition at line 1013 of file w5100.h.

◆ IPPROTO_ICMP

#define IPPROTO_ICMP 1

Control message protocol.

Definition at line 1011 of file w5100.h.

◆ IPPROTO_IDP

#define IPPROTO_IDP 22

XNS idp.

Definition at line 1017 of file w5100.h.

◆ IPPROTO_IGMP

#define IPPROTO_IGMP 2

Internet group management protocol.

Definition at line 1012 of file w5100.h.

◆ IPPROTO_IP

#define IPPROTO_IP 0

Dummy for IP.

Definition at line 1010 of file w5100.h.

◆ IPPROTO_ND

#define IPPROTO_ND 77

UNOFFICIAL net disk protocol.

Definition at line 1018 of file w5100.h.

◆ IPPROTO_PUP

#define IPPROTO_PUP 12

PUP.

Definition at line 1015 of file w5100.h.

◆ IPPROTO_RAW

#define IPPROTO_RAW 255

Raw IP packet.

Definition at line 1019 of file w5100.h.

◆ IPPROTO_TCP

#define IPPROTO_TCP 6

TCP.

Definition at line 1014 of file w5100.h.

◆ IPPROTO_UDP

#define IPPROTO_UDP 17

UDP.

Definition at line 1016 of file w5100.h.

◆ IR_CONFLICT

#define IR_CONFLICT 0x80

Check IP conflict.

Bit is set as when own source IP address is same with the sender IP address in the received ARP request.check ip confict

Definition at line 618 of file w5100.h.

◆ IR_PPPoE

#define IR_PPPoE 0x20

Get the PPPoE close message.

When PPPoE is disconnected during PPPoE mode, this bit is set.get the PPPoE close message

Definition at line 631 of file w5100.h.

◆ IR_SOCK

#define IR_SOCK ( sn ) (0x01 << sn)

check socket interrupt

Definition at line 633 of file w5100.h.

◆ IR_UNREACH

#define IR_UNREACH 0x40

Get the destination unreachable message in UDP sending.

When receiving the ICMP (Destination port unreachable) packet, this bit is set as When this bit is Destination Information such as IP address and Port number may be checked with the corresponding UIPR & UPORTR.check destination unreachable

Definition at line 625 of file w5100.h.

◆ MR_AI

#define MR_AI 0x02

Address Auto-Increment in Indirect Bus Interface.

0 : Disable auto-increment
1 : Enable auto-incremente
At the Indirect Bus Interface mode, if this bit is set as ��1��, the address will be automatically increased by 1 whenever read and write are performed.auto-increment in indirect mode

Definition at line 603 of file w5100.h.

◆ MR_IND

#define MR_IND 0x01

Indirect Bus Interface mode.

0 : Disable Indirect bus Interface mode
1 : Enable Indirect bus Interface mode
If this bit is set as ��1��, Indirect Bus Interface mode is set.enable indirect mode

Definition at line 611 of file w5100.h.

◆ MR_PB

#define MR_PB 0x10

Ping block.

0 : Disable Ping block
1 : Enable Ping block
If the bit is it blocks the response to a ping request.ping block

Definition at line 586 of file w5100.h.

◆ MR_PPPOE

#define MR_PPPOE 0x08

Enable PPPoE.

0 : DisablePPPoE mode
1 : EnablePPPoE mode
If you use ADSL, this bit should be '1'.enable pppoe

Definition at line 594 of file w5100.h.

◆ MR_RST

#define MR_RST 0x80

Reset.

If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset.reset

Definition at line 577 of file w5100.h.

◆ RMSR

#define RMSR (_W5100_IO_BASE_ + (0x001A))

Definition at line 283 of file w5100.h.

◆ setSn_RXBUF_SIZE

#define setSn_RXBUF_SIZE | ( | sn,
 |  | rxmemsize
 | ) | setSn_RXMEM_SIZE(sn,rxmemsize)

Definition at line 1604 of file w5100.h.

◆ setSn_TXBUF_SIZE

#define setSn_TXBUF_SIZE | ( | sn,
 |  | txmemsize
 | ) | setSn_TXMEM_SIZE(sn,txmemsize)

Definition at line 1626 of file w5100.h.

◆ Sn_CR_CLOSE

#define Sn_CR_CLOSE 0x10

Close socket.

Sn_SR is changed to SOCK_CLOSED.

Definition at line 772 of file w5100.h.

◆ Sn_CR_CONNECT

#define Sn_CR_CONNECT 0x04

Send connection request in TCP mode(Client mode)

To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by Sn_DIPR & Sn_DPORT(destination address & port). If the connect-request is successful, the Sn_SR is changed to SOCK_ESTABLISHED and the Sn_IR(0) becomes

The connect-request fails in the following three cases.

  1. When a ARPTO occurs (Sn_IR[3] = '1') because destination hardware address is not acquired through the ARP-process.
  2. When a SYN/ACK packet is not received and TCPTO (Sn_IR(3) ='1')
  3. When a RST packet is received instead of a SYN/ACK packet. In these cases, Sn_SR is changed to SOCK_CLOSED.
    Note
    This is valid only in TCP mode and operates when Socket n acts as TCP clientsend connection request in tcp mode(Client mode)

Definition at line 753 of file w5100.h.

◆ Sn_CR_DISCON

#define Sn_CR_DISCON 0x08

Send closing request in TCP mode.

Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (Active closeor Passive close.

Active close
it transmits disconnect-request(FIN packet) to the connected peer
Passive close
When FIN packet is received from peer, a FIN packet is replied back to the peer.

When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), Sn_SR is changed to SOCK_CLOSED.
Otherwise, TCPTO occurs (Sn_IR(3)='1') and then Sn_SR is changed to SOCK_CLOSED.

Note
Valid only in TCP mode.send closing reqeuset in tcp mode

Definition at line 766 of file w5100.h.

◆ Sn_CR_LISTEN

#define Sn_CR_LISTEN 0x02

Wait connection request in TCP mode(Server mode)

This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP).// In this mode, Socket n operates as a 'TCP server' and waits for connection-request (SYN packet) from any 'TCP client'.// The Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN.// When a 'TCP client' connection request is successfully established, the Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes But when a 'TCP client' connection request is failed, Sn_IR(3) becomes and the status of Sn_SR changes to SOCK_CLOSED.wait connection request in tcp mode(Server mode)

Definition at line 741 of file w5100.h.

◆ Sn_CR_OPEN

#define Sn_CR_OPEN 0x01

Initialize or open socket.

Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). The table below shows the value of Sn_SR corresponding to Sn_MR.

Sn_MR (P[3:0]) | Sn_SR
Sn_MR_CLOSE (000) | –
Sn_MR_TCP (001) | SOCK_INIT (0x13)
Sn_MR_UDP (010) | SOCK_UDP (0x22)
S0_MR_IPRAW (011) | SOCK_IPRAW (0x32)
S0_MR_MACRAW (100) | SOCK_MACRAW (0x42)
S0_MR_PPPoE (101) | SOCK_PPPoE (0x5F)

initialize or open socket

Definition at line 730 of file w5100.h.

◆ Sn_CR_PCJ

#define Sn_CR_PCJ 0x27

REJECT message transmission.

In each phase, it transmits REJECT message.

Definition at line 836 of file w5100.h.

◆ Sn_CR_PCN

#define Sn_CR_PCN 0x26

NAK massage transmission.

In each phase, it transmits NAK message.

Definition at line 830 of file w5100.h.

◆ Sn_CR_PCON

#define Sn_CR_PCON 0x23

PPPoE connection.

PPPoE connection begins by transmitting PPPoE discovery packet

Definition at line 812 of file w5100.h.

◆ Sn_CR_PCR

#define Sn_CR_PCR 0x25

REQ message transmission.

In each phase, it transmits REQ message.

Definition at line 824 of file w5100.h.

◆ Sn_CR_PDISCON

#define Sn_CR_PDISCON 0x24

Closes PPPoE connection.

Closes PPPoE connection

Definition at line 818 of file w5100.h.

◆ Sn_CR_RECV

#define Sn_CR_RECV 0x40

Update RX buffer pointer and receive data.

RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (Sn_RX_RD).
For more details, refer to Socket n RX Received Size Register (Sn_RX_RSR), Socket n RX Write Pointer Register (Sn_RX_WR), and Socket n RX Read Pointer Register (Sn_RX_RD).

Definition at line 806 of file w5100.h.

◆ Sn_CR_SEND

#define Sn_CR_SEND 0x20

Update TX buffer pointer and send data.

SEND transmits all the data in the Socket n TX buffer.
For more details, please refer to Socket n TX Free Size Register (Sn_TX_FSR), Socket n, TX Write Pointer Register(Sn_TX_WR), and Socket n TX Read Pointer Register(Sn_TX_RD).

Definition at line 780 of file w5100.h.

◆ Sn_CR_SEND_KEEP

#define Sn_CR_SEND_KEEP 0x22

Send keep alive message.

It checks the connection status by sending 1byte keep-alive packet.
If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur.

Note
Valid only in TCP mode.

Definition at line 798 of file w5100.h.

◆ Sn_CR_SEND_MAC

#define Sn_CR_SEND_MAC 0x21

Send data with MAC address, so without ARP process.

The basic operation is same as SEND.
Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).
But SEND_MAC transmits data without the automatic ARP-process.
In this case, the destination hardware address is acquired from Sn_DHAR configured by host, instead of APR-process.

Note
Valid only in UDP mode.

Definition at line 790 of file w5100.h.

◆ Sn_IR_CON

#define Sn_IR_CON 0x01

CON Interrupt.

This is issued one time when the connection with peer is successful and then Sn_SR is changed to SOCK_ESTABLISHED.

Definition at line 885 of file w5100.h.

◆ Sn_IR_DISCON

#define Sn_IR_DISCON 0x02

DISCON Interrupt.

This is issued when FIN or FIN/ACK packet is received from a peer.

Definition at line 879 of file w5100.h.

◆ Sn_IR_PFAIL

#define Sn_IR_PFAIL 0x40

PPP Fail Interrupt.

PPP Fail Interrupts when PAP Authentication is failed.

Definition at line 849 of file w5100.h.

◆ Sn_IR_PNEXT

#define Sn_IR_PNEXT 0x20

PPP Next Phase Interrupt.

PPP Next Phase Interrupts when the phase is changed during ADSL connection process.

Definition at line 855 of file w5100.h.

◆ Sn_IR_PRECV

#define Sn_IR_PRECV 0x80

PPP Receive Interrupt.

PPP Receive Interrupts when the option which is not supported is received.

Definition at line 843 of file w5100.h.

◆ Sn_IR_RECV

#define Sn_IR_RECV 0x04

RECV Interrupt.

This is issued whenever data is received from a peer.

Definition at line 873 of file w5100.h.

◆ Sn_IR_SENDOK

#define Sn_IR_SENDOK 0x10

SEND_OK Interrupt.

This is issued when SEND command is completed.complete sending

Definition at line 861 of file w5100.h.

◆ Sn_IR_TIMEOUT

#define Sn_IR_TIMEOUT 0x08

TIMEOUT Interrupt.

This is issued when ARPTO or TCPTO occurs.assert timeout

Definition at line 867 of file w5100.h.

◆ Sn_MR_CLOSE

#define Sn_MR_CLOSE 0x00

Unused socket.

This configures the protocol mode of Socket n.unused socket

Definition at line 642 of file w5100.h.

◆ Sn_MR_IPRAW

#define Sn_MR_IPRAW 0x03

IP LAYER RAW SOCK.

Definition at line 655 of file w5100.h.

◆ Sn_MR_MACRAW

#define Sn_MR_MACRAW 0x04

MAC LAYER RAW SOCK.

This configures the protocol mode of Socket n.

Note
MACRAW mode should be only used in Socket 0.MAC LAYER RAW SOCK

Definition at line 662 of file w5100.h.

◆ Sn_MR_MC

#define Sn_MR_MC Sn_MR_ND

Support UDP Multicasting.

0 : using IGMP version 2
1 : using IGMP version 1
This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = '1') It configures the version for IGMP messages (Join/Leave/Report).Select IGMP version 1(0) or 2(1)

Definition at line 688 of file w5100.h.

◆ Sn_MR_MF

#define Sn_MR_MF 0x40

MAC filter enable in Sn_MR_MACRAW mode.

0 : disable MAC Filtering
1 : enable MAC Filtering
This bit is applied only during MACRAW mode(P[3:0] = 100.
When set as W5100 can only receive broadcasting packet or packet sent to itself. When this bit is W5100 can receive all packets on Ethernet. If user wants to implement Hybrid TCP/IP stack, it is recommended that this bit is set as for reducing host overhead to process the all received packets.Use MAC filter

Definition at line 700 of file w5100.h.

◆ Sn_MR_MFEN

#define Sn_MR_MFEN Sn_MR_MF

Definition at line 701 of file w5100.h.

◆ Sn_MR_MULTI

#define Sn_MR_MULTI 0x80

Support UDP Multicasting.

0 : disable Multicasting
1 : enable Multicasting
This bit is applied only during UDP mode(P[3:0] = 010).
To use multicasting, Sn_DIPR & Sn_DPORT should be respectively configured with the multicast group IP address & port number before Socket n is opened by OPEN command of Sn_CR.support multicating

Definition at line 713 of file w5100.h.

◆ Sn_MR_ND

#define Sn_MR_ND 0x20

No Delayed Ack(TCP), Multicast flag.

0 : Disable No Delayed ACK option
1 : Enable No Delayed ACK option
This bit is applied only during TCP mode (P[3:0] = 001).
When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.
When this bit is It sends the ACK packet after waiting for the timeout time configured by RTR.No Delayed Ack(TCP) flag

Definition at line 679 of file w5100.h.

◆ Sn_MR_PPPoE

#define Sn_MR_PPPoE 0x05

PPPoE.

This configures the protocol mode of Socket n.

Note
PPPoE mode should be only used in Socket 0.PPPoE

Definition at line 669 of file w5100.h.

◆ Sn_MR_TCP

#define Sn_MR_TCP 0x01

TCP.

This configures the protocol mode of Socket n.TCP

Definition at line 648 of file w5100.h.

◆ Sn_MR_UDP

#define Sn_MR_UDP 0x02

UDP.

This configures the protocol mode of Socket n.UDP

Definition at line 654 of file w5100.h.

◆ SOCK_CLOSE_WAIT

#define SOCK_CLOSE_WAIT 0x1C

Closing state.

This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.
This is half-closing status, and data can be transferred.
For full-closing, DISCON command is used. But For just-closing, Sn_CR_CLOSE command is used.

Definition at line 967 of file w5100.h.

◆ SOCK_CLOSED

#define SOCK_CLOSED 0x00

Closed.

This indicates that Socket n is released.
When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to SOCK_CLOSED regardless of previous status.closed

Definition at line 893 of file w5100.h.

◆ SOCK_CLOSING

#define SOCK_CLOSING 0x1A

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 951 of file w5100.h.

◆ SOCK_ESTABLISHED

#define SOCK_ESTABLISHED 0x17

Success to connect.

This indicates the status of the connection of Socket n.
It changes to SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring SOCK_LISTEN, or when the CONNECT command is successful.
During SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command.

Definition at line 935 of file w5100.h.

◆ SOCK_FIN_WAIT

#define SOCK_FIN_WAIT 0x18

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 943 of file w5100.h.

◆ SOCK_INIT

#define SOCK_INIT 0x13

Initiate state.

This indicates Socket n is opened with TCP mode.
It is changed to SOCK_INIT when Sn_MR(P[3:0]) = 001)and OPEN command is ordered.
After SOCK_INIT, user can use LISTEN /CONNECT command.init state

Definition at line 901 of file w5100.h.

◆ SOCK_IPRAW

#define SOCK_IPRAW 0x32

IP raw mode socket.

TThe socket is opened in IPRAW mode. The SOCKET status is change to SOCK_IPRAW when Sn_MR (P3:P0) is Sn_MR_IPRAW and Sn_CR_OPEN command is used.
IP Packet can be transferred without a connection similar to the UDP mode.ip raw mode socket

Definition at line 990 of file w5100.h.

◆ SOCK_LAST_ACK

#define SOCK_LAST_ACK 0x1D

Closing state.

This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.
It changes to SOCK_CLOSED when Socket n received the response successfully, or when timeout occurs (Sn_IR[TIMEOUT] = '1').

Definition at line 974 of file w5100.h.

◆ SOCK_LISTEN

#define SOCK_LISTEN 0x14

Listen state.

This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer (TCP client).
It will change to SOCK_ESTABLISHED when the connection-request is successfully accepted.
Otherwise it will change to SOCK_CLOSED after TCPTO occurred (Sn_IR(TIMEOUT) = '1').

Definition at line 909 of file w5100.h.

◆ SOCK_MACRAW

#define SOCK_MACRAW 0x42

MAC raw mode socket.

This indicates Socket 0 is opened in MACRAW mode (Sn_MR(P[3:0]) = '100' and n=0) and is valid only in Socket 0.
It changes to SOCK_MACRAW when Sn_MR(P[3:0]) = '100' and Sn_CR_OPEN command is ordered.
Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process.mac raw mode socket

Definition at line 998 of file w5100.h.

◆ SOCK_PPPOE

#define SOCK_PPPOE 0x5F

PPPoE mode socket.

It is the status that SOCKET0 is open as PPPoE mode. It is changed to SOCK_PPPoE in case of S0_CR=OPEN and S0_MR (P3:P0)=S0_MR_PPPoE.
It is temporarily used at the PPPoE connection.pppoe socket

Definition at line 1007 of file w5100.h.

◆ SOCK_SYNRECV

#define SOCK_SYNRECV 0x16

Connection state.

It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to SOCK_ESTABLISHED.
If not, it changes to SOCK_CLOSED after timeout occurs (Sn_IR[TIMEOUT] = '1').

Definition at line 926 of file w5100.h.

◆ SOCK_SYNSENT

#define SOCK_SYNSENT 0x15

Connection state.

This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
It is temporarily shown when Sn_SR is changed from SOCK_INIT to SOCK_ESTABLISHED by CONNECT command.
If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to SOCK_ESTABLISHED.
Otherwise, it changes to SOCK_CLOSED after TCPTO (Sn_IR[TIMEOUT] = '1') is occurred.

Definition at line 918 of file w5100.h.

◆ SOCK_TIME_WAIT

#define SOCK_TIME_WAIT 0x1B

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 959 of file w5100.h.

◆ SOCK_UDP

#define SOCK_UDP 0x22

UDP socket.

This indicates Socket n is opened in UDP mode(Sn_MR(P[3:0]) = 010).
It changes to SOCK_UDP when Sn_MR(P[3:0]) = 010 and Sn_CR_OPEN command is ordered.
Unlike TCP mode, data can be transfered without the connection-process.udp socket

Definition at line 982 of file w5100.h.

◆ TMSR

#define TMSR (_W5100_IO_BASE_ + (0x001B))

Definition at line 284 of file w5100.h.

◆ UIPR0

#define UIPR0 (_W5100_IO_BASE_ + (0x002A))

Definition at line 310 of file w5100.h.

◆ UPORT0

#define UPORT0 (_W5100_IO_BASE + (0x002E))

Definition at line 311 of file w5100.h.

◆ WIZCHIP_CREG_BLOCK

#define WIZCHIP_CREG_BLOCK 0x00

Common register block.

Definition at line 56 of file w5100.h.

◆ WIZCHIP_CRITICAL_ENTER

#define WIZCHIP_CRITICAL_ENTER ( ) WIZCHIP.CRIS._enter()

Enter a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_EXIT()

Definition at line 1032 of file w5100.h.

◆ WIZCHIP_CRITICAL_EXIT

#define WIZCHIP_CRITICAL_EXIT ( ) WIZCHIP.CRIS._exit()

Exit a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_ENTER()

Definition at line 1049 of file w5100.h.

◆ WIZCHIP_OFFSET_INC

#define WIZCHIP_OFFSET_INC | ( | ADDR,
 |  | N
 | ) | (ADDR + N)

Increase offset address.

Definition at line 59 of file w5100.h.

◆ WIZCHIP_SREG_BLOCK

#define WIZCHIP_SREG_BLOCK ( N ) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)

Socket N register block.

Definition at line 57 of file w5100.h.


ioLibrary: Ethernet/W5100S Directory Reference

  • Ethernet
  • W5100S
W5100S Directory Reference
Directory dependency graph for W5100S:

Files

file | w5100s.c [code]
W5100S HAL Interface.
file | w5100s.h [code]
W5100S HAL Header File.


ioLibrary: Ethernet/W5100S/w5100s.c File Reference

  • Ethernet
  • W5100S
Functions
w5100s.c File Reference

W5100S HAL Interface. More...

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

Go to the source code of this file.

Functions

void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
This function writes the data into W5100S registers. More...
uint8_t | WIZCHIP_READ (uint32_t AddrSel)
This function reads the value from W5100S registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
This function writes into W5100S memory(Buffer) More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
This function reads into W5100S memory(Buffer) More...
uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
uint32_t | getSn_RxBASE (uint8_t sn)
Get the base address of socket sn RX buffer. More...
uint32_t | getSn_TxBASE (uint8_t sn)
Get the base address of socket sn TX buffer. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
This function is being called by send() and sendto() function also. for copy the data form application buffer to Transmite buffer of the chip. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
This function is being called by recv() also. This function is being used for copy the data form Receive buffer of the chip to application buffer. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...
void | wiz_mdio_write (uint8_t PHYMDIO_regadr, uint16_t var)
Write data to the PHY via MDC/MDIO interface. More...
uint16_t | wiz_mdio_read (uint8_t PHYMDIO_regadr)
Read data from the PHY via MDC/MDIO interface. More...
void | wiz_delay_ms (uint32_t milliseconds)
Delay function. More...

Detailed Description

W5100S HAL Interface.

Version
1.0.0
Date
2018/03/29
Revision history
<2018/03/29> 1st Release
Author
Peter

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 w5100s.c.


ioLibrary: Ethernet/W5100S/w5100s.h File Reference

  • Ethernet
  • W5100S
Macros | Functions
w5100s.h File Reference

W5100S HAL Header File. More...

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

Go to the source code of this file.

Macros

#define | _WIZCHIP_SN_BASE_ (0x0400)
#define | _WIZCHIP_SN_SIZE_ (0x0100)
#define | _WIZCHIP_IO_TXBUF_ (0x4000) /* Internal Tx buffer address of the iinchip */
#define | _WIZCHIP_IO_RXBUF_ (0x6000) /* Internal Rx buffer address of the iinchip */
#define | WIZCHIP_CREG_BLOCK 0x00
Common register block. More...
#define | WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
Socket N register block. More...
#define | WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
Increase offset address. More...
#define | _W5100S_IO_BASE_ _WIZCHIP_IO_BASE_
#define | IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE(ADDR, VAL) WIZCHIP_WRITE(ADDR,VAL)
The defined for legacy chip driver. More...
#define | IINCHIP_READ_BUF(ADDR, BUF, LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE_BUF(ADDR, BUF, LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | MR (_WIZCHIP_IO_BASE_ + (0x0000))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5100S_IO_BASE_ + (0x0001))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5100S_IO_BASE_ + (0x0005))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5100S_IO_BASE_ + (0x0009))
Source MAC Register address(R/W) More...
#define | SIPR (_W5100S_IO_BASE_ + (0x000F))
Source IP Register address(R/W) More...
#define | IR (_W5100S_IO_BASE_ + (0x0015))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5100S_IO_BASE_ + (0x0016))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5100S_IO_BASE_ + (0x0017))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5100S_IO_BASE_ + (0x0019))
Retry count register(R/W) More...
#define | RMSR (_W5100S_IO_BASE_ + (0x001A))
Receive Memory Size Register. More...
#define | TMSR (_W5100S_IO_BASE_ + (0x001B))
Transmit Memory Size Register. More...
#define | IR2 (_W5100S_IO_BASE_ + (0x0020))
Interrupt register 2. More...
#define | IMR2 (_W5100S_IO_BASE_ + (0x0021))
Interrupt mask register 2. More...
#define | PTIMER (_W5100S_IO_BASE_ + (0x0028))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PMAGIC (_W5100S_IO_BASE_ + (0x0029))
PPP LCP Magic number register in PPPoE mode(R) More...
#define | UIPR (_W5100S_IO_BASE_ + (0x002A))
Unreachable IP address register. More...
#define | UPORTR (_W5100S_IO_BASE_ + (0x002E))
Unreachable Port register. More...
#define | MR2 (_W5100S_IO_BASE_ + (0x0030))
MR2 Mode register 2. More...
#define | PHAR (_W5100S_IO_BASE_ + (0x0032))
Destination Hardware address in PPPoE. More...
#define | PSIDR (_W5100S_IO_BASE_ + (0x0038))
Session ID in PPPoE. More...
#define | PMRUR (_W5100S_IO_BASE_ + (0x003A))
Maximum receive Unit in PPPoE. More...
#define | PHYSR (_W5100S_IO_BASE_ + (0x003C))
PHY status register. More...
#define | PHYSR1 (_W5100S_IO_BASE_ + (0x003D))
PHY status register(hidden) More...
#define | PHYAR (_W5100S_IO_BASE_ + (0x003E))
PHY Address value. More...
#define | PHYRAR (_W5100S_IO_BASE_ + (0x003F))
PHY Register address. More...
#define | PHYDIR (_W5100S_IO_BASE_ + (0x0040))
PHY Data input register. More...
#define | PHYDOR (_W5100S_IO_BASE_ + (0x0042))
PHY data output register. More...
#define | PHYACR (_W5100S_IO_BASE_ + (0x0044))
PHY Action register. More...
#define | PHYDIVR (_W5100S_IO_BASE_ + (0x0045))
PHY Division register. More...
#define | PHYCR0 (_W5100S_IO_BASE_ + (0x0046))
PHY Control register 0. More...
#define | PHYCR1 (_W5100S_IO_BASE_ + (0x0047))
PHY Control register 1. More...
#define | SLCR (_W5100S_IO_BASE_ + (0x004C))
Socket-less control register. More...
#define | SLRTR (_W5100S_IO_BASE_ + (0x004D))
Socket-less retry time register. More...
#define | SLRCR (_W5100S_IO_BASE_ + (0x004F))
Socket-less retry count register. More...
#define | SLPIPR (_W5100S_IO_BASE_ + (0x0050))
Socket-less peer IP address register. More...
#define | SLPHAR (_W5100S_IO_BASE_ + (0x0054))
Socket-less peer hardware address register. More...
#define | PINGSEQR (_W5100S_IO_BASE_ + (0x005A))
Ping sequence number register. More...
#define | PINGIDR (_W5100S_IO_BASE_ + (0x005C))
Ping ID register. More...
#define | SLIMR (_W5100S_IO_BASE_ + (0x005E))
Socket-less interrupt mask register. More...
#define | SLIR (_W5100S_IO_BASE_ + (0x005F))
Socket-less interrupt register. More...
#define | DBGOUT (_W5100S_IO_BASE_ + (0x0060))
DBGOUT(hidden) More...
#define | NICMAXCOLR (_W5100S_IO_BASE_ + (0x0063))
NICMAXCOLR(hidden) More...
#define | CHIPLCKR (_W5100S_IO_BASE_ + (0x0070))
Chip Configuration locking register. More...
#define | NETLCKR (_W5100S_IO_BASE_ + (0x0071))
Network Configuration locking register. More...
#define | PHYLCKR (_W5100S_IO_BASE_ + (0x0072))
PHY Configuration locking register. More...
#define | VERR (_W5100S_IO_BASE_ + (0x0080))
version register More...
#define | TCNTR (_W5100S_IO_BASE_ + (0x0082))
Core 100us Counter register. More...
#define | TCNTCLKR (_W5100S_IO_BASE_ + (0x0088))
Core 100us Counter clear register. More...
#define | Sn_MR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))
socket Mode register(R/W) More...
#define | Sn_CR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))
Socket command register(R/W) More...
#define | Sn_IR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))
Socket interrupt register(R) More...
#define | Sn_SR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))
Socket status register(R) More...
#define | Sn_PORT(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))
source port register(R/W) More...
#define | Sn_DHAR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))
Peer IP register address(R/W) More...
#define | Sn_DPORT(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))
Peer port register address(R/W) More...
#define | Sn_MSSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_PROTO(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOS(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_RXBUF_SIZE(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E))
Receive memory size register(R/W) More...
#define | Sn_TXBUF_SIZE(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F))
Transmit memory size register(R/W) More...
#define | Sn_TX_FSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))
Received data size register(R) More...
#define | Sn_RX_RD(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))
Write point of Receive memory(R) More...
#define | Sn_IMR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C))
Socket interrupt mask register. More...
#define | Sn_FRAGR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D))
Socket fragment field register. More...
#define | Sn_MR2(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002F))
Socket Mode register 2. More...
#define | Sn_KPALVTR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0030))
Socket n Keep Alive Timer Register. More...
#define | Sn_RTR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0032))
Socket n Timer Status Register. More...
#define | Sn_RCR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0034))
Socket n Retry Count-value Register. More...
#define | MR_RST 0x80
Reset. More...
#define | MR_PB 0x10
Ping block. More...
#define | MR_PPPOE 0x08
Enable PPPoE. More...
#define | MR_AI 0x02
Address Auto-Increment in Indirect Bus Interface. More...
#define | MR_IND 0x01
Indirect Bus Interface mode. More...
#define | IR_CONFLICT 0x80
Check IP conflict. More...
#define | IR_UNREACH 0x40
Get the destination unreachable message in UDP sending. More...
#define | IR_PPPoE 0x20
Get the PPPoE close message. More...
#define | IR_SOCK(sn) (0x01 << sn)
Socket interrupt bit. More...
#define | IMR_CONFLICT 0x80
IP conflict interrupt mask bit. More...
#define | IMR_UNREACH 0x40
Destination port unreachable interrupt mask bit. More...
#define | IMR_PPPoE 0x20
PADT/LCPT interrupt mask bit(PPPoE) More...
#define | IMR_SOCK(sn) (0x01 << sn)
Socket interrupt mask bit. More...
#define | SLCMD_ARP (1<<1)
Socket-less command register bit. More...
#define | SLCMD_PING (1<<0)
Socket-less command register bit. More...
#define | SLIR_TIMEOUT (1<<2)
Socket-less command interrupt and interrupt mask register bit. More...
#define | SLIR_ARP (1<<1)
Socket less command interrupt and interrupt mask register bit. More...
#define | SLIR_PING (1<<0)
Socket less command interrupt and interrupt mask register bit. More...
#define | Sn_MR_CLOSE 0x00
Unused socket. More...
#define | Sn_MR_TCP 0x01
TCP. More...
#define | Sn_MR_UDP 0x02
UDP. More...
#define | Sn_MR_IPRAW 0x03
IP LAYER RAW SOCK. More...
#define | Sn_MR_MACRAW 0x04
MAC LAYER RAW SOCK. More...
#define | Sn_MR_PPPoE 0x05
PPPoE. More...
#define | Sn_MR_ND 0x20
No Delayed Ack(TCP), Multicast flag. More...
#define | Sn_MR_MC Sn_MR_ND
Support UDP Multicasting. More...
#define | Sn_MR_MF 0x40
MAC filter enable in Sn_MR_MACRAW mode. More...
#define | Sn_MR_MFEN Sn_MR_MF
#define | Sn_MR_MULTI 0x80
Support UDP Multicasting. More...
#define | Sn_CR_OPEN 0x01
Initialize or open socket. More...
#define | Sn_CR_LISTEN 0x02
Wait connection request in TCP mode(Server mode) More...
#define | Sn_CR_CONNECT 0x04
Send connection request in TCP mode(Client mode) More...
#define | Sn_CR_DISCON 0x08
Send closing request in TCP mode. More...
#define | Sn_CR_CLOSE 0x10
Close socket. More...
#define | Sn_CR_SEND 0x20
Update TX buffer pointer and send data. More...
#define | Sn_CR_SEND_MAC 0x21
Send data with MAC address, so without ARP process. More...
#define | Sn_CR_SEND_KEEP 0x22
Send keep alive message. More...
#define | Sn_CR_RECV 0x40
Update RX buffer pointer and receive data. More...
#define | Sn_CR_IGMP_JOIN 0x23
#define | Sn_CR_IGMP_LEAVE 0x24
#define | Sn_IR_SENDOK 0x10
SEND_OK Interrupt. More...
#define | Sn_IR_TIMEOUT 0x08
TIMEOUT Interrupt. More...
#define | Sn_IR_RECV 0x04
RECV Interrupt. More...
#define | Sn_IR_DISCON 0x02
DISCON Interrupt. More...
#define | Sn_IR_CON 0x01
CON Interrupt. More...
#define | SOCK_CLOSED 0x00
Closed. More...
#define | SOCK_INIT 0x13
Initiate state. More...
#define | SOCK_LISTEN 0x14
Listen state. More...
#define | SOCK_SYNSENT 0x15
Connection state. More...
#define | SOCK_SYNRECV 0x16
Connection state. More...
#define | SOCK_ESTABLISHED 0x17
Success to connect. More...
#define | SOCK_FIN_WAIT 0x18
Closing state. More...
#define | SOCK_CLOSING 0x1A
Closing state. More...
#define | SOCK_TIME_WAIT 0x1B
Closing state. More...
#define | SOCK_CLOSE_WAIT 0x1C
Closing state. More...
#define | SOCK_LAST_ACK 0x1D
Closing state. More...
#define | SOCK_UDP 0x22
UDP socket. More...
#define | SOCK_IPRAW 0x32
IP raw mode socket. More...
#define | SOCK_MACRAW 0x42
MAC raw mode socket. More...
#define | SOCK_PPPOE 0x5F
PPPoE mode socket. More...
#define | IPPROTO_IP 0
Dummy for IP. More...
#define | IPPROTO_ICMP 1
Control message protocol. More...
#define | IPPROTO_IGMP 2
Internet group management protocol. More...
#define | IPPROTO_GGP 3
GW^2 (deprecated) More...
#define | IPPROTO_TCP 6
TCP. More...
#define | IPPROTO_PUP 12
PUP. More...
#define | IPPROTO_UDP 17
UDP. More...
#define | IPPROTO_IDP 22
XNS idp. More...
#define | IPPROTO_ND 77
UNOFFICIAL net disk protocol. More...
#define | IPPROTO_RAW 255
Raw IP packet. More...
#define | MR2_CLKSEL (1<<7)
Clock select bit. More...
#define | MR2_G_IEN (1<<6)
Interrupt pin enable bit. More...
#define | MR2_NOTCPRST (1<<5)
No TCP Reset Packet send. More...
#define | MR2_UDPURB (1<<4)
Unreachable Packet Send Block bit. More...
#define | MR2_WOL (1<<3)
Wake On LAN. More...
#define | MR2_MNOSCHK (1<<2)
MACRAW No Size Check. More...
#define | MR2_UDPFARP (1<<1)
UDP force ARP. More...
#define | MR2_SSRCHA (1<<0)
Skip SRC Hardware Address. More...
#define | IR2_MGC (1<<1)
magic packet More...
#define | IMR2_MGC (1<<1)
Magic packet interrupt mask bit. More...
#define | PHYSR_CABOFF (1<<7)
Ethernet CABLE OFF Signal. More...
#define | PHYSR_MD2 (1<<5)
#define | PHYSR_MD1 (1<<4)
#define | PHYSR_MD0 (1<<3)
#define | PHYSR_DUP (1<<2)
#define | PHYSR_SPD (1<<1)
#define | PHYSR_LNK (1<<0)
LINKDONE register. More...
#define | PHYSR1_RXPG (1<<2)
#define | PHYSR1_LPI (1<<1)
#define | PHYSR1_CLDN (1<<0)
#define | PHYCR_AUTONEGO_ENABLE (0<<2)
#define | PHYCR_AUTONEGO_DISABLE (1<<2)
#define | PHYCR_SPD_10 (1<<1)
#define | PHYCR_SPD_100 (0<<1)
#define | PHYCR_HALF_DUP (1<<0)
#define | PHYCR_FULL_DUP (0<<0)
#define | PHYCR1_RST (0<<0)
#define | PHYCR1_PWDN_ENABLE (1<<5)
#define | PHYCR1_PWDN_DISABLE (0<<5)
#define | Sn_MR2_MBBLK (1<<6)
Broadcast Blocking bit in MACRAW mode. More...
#define | Sn_MR2_MMBLK (1<<5)
Multicast Blocking bit in MACRAW mode. More...
#define | Sn_MR2_IPV6BLK (1<<4)
IPv6 packet Blocking bit in MACRAW mode. More...
#define | Sn_MR2_UBBLK (1<<1)
Broadcast Blocking bit in UDP mode. More...
#define | Sn_MR2_FPSH Sn_MR2_UBBLK
TCP Force PSH bit. More...
#define | Sn_MR2_UUBLK (1<<0)
Unicast Blocking bit in UDP mode. More...
#define | PHYMDIO_BMCR 0x00
#define | PHYMDIO_BMSR 0x01
#define | BMCR_RESET (1<<15)
#define | BMCR_MLOOPBACK (1<<14)
#define | BMCR_SPEED (1<<13)
#define | BMCR_AUTONEGO (1<<12)
#define | BMCR_PWDN (1<<11)
#define | BMCR_ISOLATE (1<<10)
#define | BMCR_RSTNEGO (1<<9)
#define | BMCR_DUP (1<<8)
#define | BMCR_COLTEST (1<<7)
#define | BMSR_AUTONEGO_COMPL (1<<5)
#define | BMSR_REMOTE_FAULT (1<<4)
#define | BMSR_LINK_STATUS (1<<2)
#define | BMSR_JAB_DETECT (1<<1)
#define | EXTENDED_CAPA (1<<0)
#define | PHYACR_READ 0x02
#define | PHYACR_WRITE 0x01
#define | WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
Enter a critical section. More...
#define | WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
Exit a critical section. More...
#define | setMR(mr) (*((uint8_t*)MR) = mr)
Set Mode Register. More...
#define | getMR() (*(uint8_t*)MR)
Get MR. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set GAR. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get GAR. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR,subr,4)
Set SUBR. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get SUBR. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set SHAR. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get SHAR. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set SIPR. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get SIPR. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xE0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xE0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr)
Set IMR register. More...
#define | getIMR() WIZCHIP_READ(_IMR_)
Get IMR register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | setRMSR(rmsr) WIZCHIP_WRITE(RMSR,rmsr)
Get RMSR register. More...
#define | getRMSR() WIZCHIP_READ(RMSR)
Get RMSR register. More...
#define | setTMSR(tmsr) WIZCHIP_WRITE(TMSR,tmsr)
Get TMSR register. More...
#define | getTMSR() WIZCHIP_READ(TMSR)
Get TMSR register. More...
#define | getPATR() (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
Get PATR register. More...
#define | getPPPALGO() WIZCHIP_READ(PPPALGO)
Get PPPALGO register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...
#define | setIR2(ir2) WIZCHIP_WRITE(IR2, ir2)
Set IR2 register. More...
#define | getIR2() WIZCHIP_READ(IR2)
Get IR2 register. More...
#define | setIMR2(imr2) WIZCHIP_WRITE(IMR2,imr2)
Set IMR2 register. More...
#define | getIMR2() WIZCHIP_READ(IMR2)
Get IMR2 register. More...
#define | setUIPR(uipr) WIZCHIP_WRITE_BUF(UIPR,uipr,4)
Set UIPR(Unreachable IP Address Register) registers. More...
#define | getUIPR(uipr) WIZCHIP_READ_BUF(UIPR,uipr,4)
Get UIPR(Unreachable IP Address Register) registers. More...
#define | setUPORTR(uportr)
Set UPORTR(Unreachable Port Address Register) register. More...
#define | getUPORTR() (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(UPORTR+1))
Get UPORTR(Unreachable Port Address Register) register. More...
#define | setMR2(mr2) WIZCHIP_WRITE(MR2,mr2)
Set MR2 register. More...
#define | getMR2() WIZCHIP_READ(MR2)
Get MR2 register. More...
#define | setPHAR(phar) WIZCHIP_WRITE_BUF(PHAR,phar,6)
Set PHAR registers. More...
#define | getPHAR(phar) WIZCHIP_READ_BUF(PHAR,phar,6)
Get PHAR registers. More...
#define | setPSIDR(psidr)
Set PSIDR register. More...
#define | getPSIDR() (((uint16_t)WIZCHIP_READ(PSIDR) << 8) + WIZCHIP_READ(PSIDR+1))
Get PSIDR register. More...
#define | setPMRUR(pmrur)
Set PMRUR register. More...
#define | getPMRUR() (((uint16_t)WIZCHIP_READ(PMRUR) << 8) + WIZCHIP_READ(PMRUR+1))
Get PMRUR register. More...
#define | getPHYSR() WIZCHIP_READ(PHYSR)
Get PHYSR register. More...
#define | getPHYSR1() WIZCHIP_READ(PHYSR1)
Get PHYSR1 register. More...
#define | getPHYAR() WIZCHIP_READ(PHYAR)
#define | getPHYRAR() WIZCHIP_READ(PHYRAR)
Get PHYRAR register. More...
#define | setPHYRR(phyrar) WIZCHIP_WRITE(PHYRAR, phyrar)
Set PHYRR register. More...
#define | getPHYDIR() (((uint16_t)WIZCHIP_READ(PHYDIR+1) << 8) + WIZCHIP_READ(PHYDIR))
Get PHYDIR register. More...
#define | setPHYDIR(phydir)
Set PHYDIR register. More...
#define | getPHYDOR() (((uint16_t)WIZCHIP_READ(PHYDOR+1) << 8) + WIZCHIP_READ(PHYDOR))
Get PHYDOR register. More...
#define | setPHYDOR(phydor)
Set PHYDOR register. More...
#define | getPHYACR() WIZCHIP_READ(PHYACR)
Get PHYACR register. More...
#define | setPHYACR(phyacr) WIZCHIP_WRITE(PHYACR,phyacr)
Set PHYACR register. More...
#define | setPHYDIVR(phydivr) WIZCHIP_WRITE(PHYDIVR, phydivr)
Set PHYDIVR register. More...
#define | getPHYDIVR() WIZCHIP_READ(PHYDIVR)
Get PHYDIVR register. More...
#define | setPHYCR0(phych0) WIZCHIP_WRITE(PHYCR0,phych0)
Set PHYCR0 register. More...
#define | getPHYCR0() WIZCHIP_READ(PHYCR0)
Get PHYCR0 register. More...
#define | setPHYCR1(phycr1) WIZCHIP_WRITE(PHYCR1,phycr1)
Set PHYCR1 register. More...
#define | getPHYCR1() WIZCHIP_READ(PHYCR1)
Get PHYCR1 register. More...
#define | setSLCR(rqcr) WIZCHIP_WRITE(SLCR, rqcr)
Set SLCR register. More...
#define | getSLCR() WIZCHIP_READ(RQCR)
Get RQCR register. More...
#define | setSLRTR(slrtr)
Set SLRTR register. More...
#define | getSLRTR() (((uint16_t)WIZCHIP_READ(SLRTR) << 8) + WIZCHIP_READ(SLRTR+1))
Get SLRTR register. More...
#define | setSLRCR(slrcr) WIZCHIP_WRITE(SLRCR,slrcr)
Set SLRCR register. More...
#define | getSLRCR() WIZCHIP_READ(SLRCR)
Get SLRCR register. More...
#define | setSLPIPR(slpipr) WIZCHIP_WRITE_BUF(SLPIPR,slpipr,4)
Set SLPIPR registers. More...
#define | getSLPIPR(slpipr) WIZCHIP_READ_BUF(SLPIPR,slpipr,4)
Get SLPIPR registers. More...
#define | setSLPHAR(slphar) WIZCHIP_WRITE_BUF(SLPHAR,slphar,6)
Get SLPHAR registers. More...
#define | getSLPHAR(slphar) WIZCHIP_READ_BUF(SLPHAR,slphar,6)
Get SLPHAR registers. More...
#define | setPINGSEQR(pingseqr)
Set PINGSEQR register. More...
#define | getPINGSEQR() (((uint16_t)WIZCHIP_READ(PINGSEQR) << 8) + WIZCHIP_READ(PINGSEQR+1))
Get PINGSEQR register. More...
#define | setPINGIDR(pingidr)
Set PINGIDR register. More...
#define | getPINGIDR() (((uint16_t)WIZCHIP_READ(PINGIDR) << 8) + WIZCHIP_READ(PINGIDR+1))
Get PINGIDR register. More...
#define | setSLIMR(slimr) WIZCHIP_WRITE(SLIMR, slimr)
Set SLIMR register. More...
#define | getSLIMR() WIZCHIP_READ(SLIMR)
Get SLIMR register. More...
#define | setSLIR(slir) WIZCHIP_WRITE(SLIR, slir)
Set SLIR register. More...
#define | getSLIR() WIZCHIP_READ(SLIR)
Get SLIMR register. More...
#define | setDBGOUT(dbgout)
#define | setNICMAXCOLR(nicmaxcolr) WIZCHIP_WRITE(NICMAXCOLR,nicmaxcolr)
Set NICMAXCOLR register. More...
#define | getNICMAXCOLR() WIZCHIP_READ(NICMAXCOLR)
Get NICMAXCOLR register. More...
#define | CHIPLOCK() WIZCHIP_WRITE(CHIPLCKR,0xff)
LOCK Chip Information. More...
#define | CHIPUNLOCK() WIZCHIP_WRITE(CHIPLCKR,0xCE)
Unlock Chip Information. More...
#define | NETLOCK() WIZCHIP_WRITE(NETLCKR,0x3A)
LOCK Chip Information. More...
#define | NETUNLOCK() WIZCHIP_WRITE(NETLCKR,0xC5)
Unlock Chip Information. More...
#define | PHYLOCK() WIZCHIP_WRITE(PHYLCKR,0xff)
Lock PHYCR0,CR1 Information. More...
#define | PHYUNLOCK() WIZCHIP_WRITE(PHYLCKR,0x53)
Lock PHYCR0,CR1 Information. More...
#define | getVER() (WIZCHIP_READ(VERR))
Get version information. More...
#define | getTCNTR() (((uint16_t)WIZCHIP_READ(TCNTR) << 8) + WIZCHIP_READ(TCNTR+1))
Get TCNTR register. More...
#define | setTCNTCLKR(var) WIZCHIP_WRITE(TCNTCLKR, var)
Set TCNTR register. More...
#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ir)
Set Sn_IR register. More...
#define | getSn_IR(sn) WIZCHIP_READ(Sn_IR(sn))
Get Sn_IR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_DHAR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_PROTO(sn, proto) WIZCHIP_WRITE(Sn_PROTO(sn), proto)
Set Sn_PROTO register. More...
#define | getSn_PROTO(sn) WIZCHIP_READ(Sn_PROTO(sn))
Get Sn_PROTO register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXMEM_SIZE(sn, rxmemsize) WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxmemsize)
Set Sn_RXMEM_SIZE register. More...
#define | setSn_RXBUF_SIZE(sn, rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
#define | getSn_RXMEM_SIZE(sn) WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
Get Sn_RXMEM_SIZE register. More...
#define | getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
#define | setSn_TXMEM_SIZE(sn, txmemsize) WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn),txmemsize)
Set Sn_TXMEM_SIZE register. More...
#define | setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
#define | getSn_TXMEM_SIZE(sn) WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
Get Sn_TXMEM_SIZE register. More...
#define | getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | setSn_RX_WR(sn, rxwr)
Set Sn_RX_WR register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_FRAGR(sn, fragr)
Set Sn_FRAGR register. More...
#define | getSn_FRAGR(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAGR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAGR(sn),1)))
Get Sn_FRAGR register. More...
#define | getSn_RxMAX(sn) ((uint16_t)(getSn_RXMEM_SIZE(sn)) << 10)
Get the max RX buffer size of socket sn. More...
#define | getSn_TxMAX(sn) ((uint16_t)(getSn_TXMEM_SIZE(sn)) << 10)
Get the max TX buffer size of socket sn. More...
#define | getSn_RxMASK(sn) (getSn_RxMAX(sn) - 1)
Get the mask of socket sn RX buffer. More...
#define | getSn_TxMASK(sn) (getSn_TxMAX(sn) - 1)
Get the mask of socket sn TX buffer. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn),imr)
Set the interrupt mask register of socket sn. More...
#define | getSn_IMR(sn) WIZCHIP_READ(Sn_IMR(sn))
Get the interrupt mask register of socket sn. More...
#define | setSn_MR2(sn, mr2) WIZCHIP_WRITE(Sn_MR2(sn), mr2)
Set the Sn_MR2 value of socket sn. More...
#define | getSn_MR2(sn) WIZCHIP_READ(Sn_MR2(sn))
Get the Sn_MR2 value of socket sn. More...
#define | setSn_KPALVTR(sn, kpalvtr) WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvtr)
Set the Sn_KPALVTR value of socket sn. More...
#define | getSn_KPALVTR(sn) WIZCHIP_READ(Sn_KPALVTR(sn))
Get the Sn_KPALVTR value of socket sn. More...
#define | getSn_TSR(sn) WIZCHIP_READ(Sn_TSR(sn))
Get the Sn_TSR register of socket sn. More...
#define | setSn_RTR(sn, rtr)
Set the Sn_RTR register of socket sn. More...
#define | getSn_RTR(sn) (((uint16_t)WIZCHIP_READ(Sn_RTR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RTR(sn),1)))
Get the Sn_RTR register of socket sn. More...
#define | setSn_RCR(sn, rcr) WIZCHIP_WRITE(Sn_RCR(sn),rcr)
Set the Sn_RCR register of socket sn. More...
#define | getSn_RCR(sn) WIZCHIP_READ(Sn_RCR(sn))
Get the Sn_RCR of socket sn. More...

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
uint32_t | getSn_RxBASE (uint8_t sn)
Get the base address of socket sn RX buffer. More...
uint32_t | getSn_TxBASE (uint8_t sn)
Get the base address of socket sn TX buffer. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...
void | wiz_mdio_write (uint8_t PHYMDIO_regadr, uint16_t var)
Write data to the PHY via MDC/MDIO interface. More...
uint16_t | wiz_mdio_read (uint8_t PHYMDIO_regadr)
Read data from the PHY via MDC/MDIO interface. More...
void | wiz_delay_ms (uint32_t ms)
Delay function. More...

Detailed Description

W5100S HAL Header File.

Version
1.0.0
Date
2018/03/29
Revision history
<2018/03/29> 1st Release
Author
Peter
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 w5100s.h.

Macro Definition Documentation

◆ _W5100S_IO_BASE_

#define _W5100S_IO_BASE_ _WIZCHIP_IO_BASE_

Definition at line 64 of file w5100s.h.

◆ _WIZCHIP_IO_RXBUF_

#define _WIZCHIP_IO_RXBUF_ (0x6000) /* Internal Rx buffer address of the iinchip */

Definition at line 55 of file w5100s.h.

◆ _WIZCHIP_IO_TXBUF_

#define _WIZCHIP_IO_TXBUF_ (0x4000) /* Internal Tx buffer address of the iinchip */

Definition at line 54 of file w5100s.h.

◆ _WIZCHIP_SN_BASE_

#define _WIZCHIP_SN_BASE_ (0x0400)

Definition at line 52 of file w5100s.h.

◆ _WIZCHIP_SN_SIZE_

#define _WIZCHIP_SN_SIZE_ (0x0100)

Definition at line 53 of file w5100s.h.

◆ BMCR_AUTONEGO

#define BMCR_AUTONEGO (1<<12)

Definition at line 1686 of file w5100s.h.

◆ BMCR_COLTEST

#define BMCR_COLTEST (1<<7)

Definition at line 1691 of file w5100s.h.

◆ BMCR_DUP

#define BMCR_DUP (1<<8)

Definition at line 1690 of file w5100s.h.

◆ BMCR_ISOLATE

#define BMCR_ISOLATE (1<<10)

Definition at line 1688 of file w5100s.h.

◆ BMCR_MLOOPBACK

#define BMCR_MLOOPBACK (1<<14)

Definition at line 1684 of file w5100s.h.

◆ BMCR_PWDN

#define BMCR_PWDN (1<<11)

Definition at line 1687 of file w5100s.h.

◆ BMCR_RESET

#define BMCR_RESET (1<<15)

Definition at line 1683 of file w5100s.h.

◆ BMCR_RSTNEGO

#define BMCR_RSTNEGO (1<<9)

Definition at line 1689 of file w5100s.h.

◆ BMCR_SPEED

#define BMCR_SPEED (1<<13)

Definition at line 1685 of file w5100s.h.

◆ BMSR_AUTONEGO_COMPL

#define BMSR_AUTONEGO_COMPL (1<<5)

Definition at line 1694 of file w5100s.h.

◆ BMSR_JAB_DETECT

#define BMSR_JAB_DETECT (1<<1)

Definition at line 1697 of file w5100s.h.

◆ BMSR_LINK_STATUS

#define BMSR_LINK_STATUS (1<<2)

Definition at line 1696 of file w5100s.h.

◆ BMSR_REMOTE_FAULT

#define BMSR_REMOTE_FAULT (1<<4)

Definition at line 1695 of file w5100s.h.

◆ EXTENDED_CAPA

#define EXTENDED_CAPA (1<<0)

Definition at line 1698 of file w5100s.h.

◆ getPHYAR

#define getPHYAR ( ) WIZCHIP_READ(PHYAR)

For internal uses The address of the PHY is fixed as "0x0A".

Definition at line 2266 of file w5100s.h.

◆ getSn_RXBUF_SIZE

#define getSn_RXBUF_SIZE ( sn ) getSn_RXMEM_SIZE(sn)

Definition at line 2943 of file w5100s.h.

◆ getSn_TXBUF_SIZE

#define getSn_TXBUF_SIZE ( sn ) getSn_TXMEM_SIZE(sn)

Definition at line 2965 of file w5100s.h.

◆ getVER

#define getVER ( ) (WIZCHIP_READ(VERR))

Get version information.

Returns
uint16_t. It must be "0x51"

Definition at line 2655 of file w5100s.h.

◆ IINCHIP_READ

#define IINCHIP_READ ( ADDR ) WIZCHIP_READ(ADDR)

The defined for legacy chip driver.

Definition at line 78 of file w5100s.h.

◆ IINCHIP_READ_BUF

#define IINCHIP_READ_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_READ_BUF(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 80 of file w5100s.h.

◆ IINCHIP_WRITE

#define IINCHIP_WRITE | ( | ADDR,
 |  | VAL
 | ) | WIZCHIP_WRITE(ADDR,VAL)

The defined for legacy chip driver.

Definition at line 79 of file w5100s.h.

◆ IINCHIP_WRITE_BUF

#define IINCHIP_WRITE_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_WRITE(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 81 of file w5100s.h.

◆ IMR2_MGC

#define IMR2_MGC (1<<1)

Magic packet interrupt mask bit.

todo

If this bit is set, each socket interrupt is enabled.

Definition at line 1508 of file w5100s.h.

◆ IMR_CONFLICT

#define IMR_CONFLICT 0x80

IP conflict interrupt mask bit.

If this bit is set, IP conflict interrupt is enabled.

Definition at line 1021 of file w5100s.h.

◆ IMR_PPPoE

#define IMR_PPPoE 0x20

PADT/LCPT interrupt mask bit(PPPoE)

If this bit is set, PADT/LCPT interrupt is enabled.

Definition at line 1033 of file w5100s.h.

◆ IMR_SOCK

#define IMR_SOCK ( sn ) (0x01 << sn)

Socket interrupt mask bit.

If this bit is set, each socket interrupt is enabled.

Definition at line 1039 of file w5100s.h.

◆ IMR_UNREACH

#define IMR_UNREACH 0x40

Destination port unreachable interrupt mask bit.

If this bit is set, destination port unreachable interrupt is enabled.

Definition at line 1027 of file w5100s.h.

◆ IPPROTO_GGP

#define IPPROTO_GGP 3

GW^2 (deprecated)

Definition at line 1416 of file w5100s.h.

◆ IPPROTO_ICMP

#define IPPROTO_ICMP 1

Control message protocol.

Definition at line 1414 of file w5100s.h.

◆ IPPROTO_IDP

#define IPPROTO_IDP 22

XNS idp.

Definition at line 1420 of file w5100s.h.

◆ IPPROTO_IGMP

#define IPPROTO_IGMP 2

Internet group management protocol.

Definition at line 1415 of file w5100s.h.

◆ IPPROTO_IP

#define IPPROTO_IP 0

Dummy for IP.

Definition at line 1413 of file w5100s.h.

◆ IPPROTO_ND

#define IPPROTO_ND 77

UNOFFICIAL net disk protocol.

Definition at line 1421 of file w5100s.h.

◆ IPPROTO_PUP

#define IPPROTO_PUP 12

PUP.

Definition at line 1418 of file w5100s.h.

◆ IPPROTO_RAW

#define IPPROTO_RAW 255

Raw IP packet.

Definition at line 1422 of file w5100s.h.

◆ IPPROTO_TCP

#define IPPROTO_TCP 6

TCP.

Definition at line 1417 of file w5100s.h.

◆ IPPROTO_UDP

#define IPPROTO_UDP 17

UDP.

Definition at line 1419 of file w5100s.h.

◆ IR2_MGC

#define IR2_MGC (1<<1)

magic packet

todo

Definition at line 1502 of file w5100s.h.

◆ IR_CONFLICT

#define IR_CONFLICT 0x80

Check IP conflict.

Bit is set as when own source IP address is same with the sender IP address in the received ARP request.check ip confict

Definition at line 996 of file w5100s.h.

◆ IR_PPPoE

#define IR_PPPoE 0x20

Get the PPPoE close message.

When PPPoE is disconnected during PPPoE mode, this bit is set.get the PPPoE close message

Definition at line 1009 of file w5100s.h.

◆ IR_SOCK

#define IR_SOCK ( sn ) (0x01 << sn)

Socket interrupt bit.

Indicates whether each socket interrupt has occured.check socket interrupt

Definition at line 1015 of file w5100s.h.

◆ IR_UNREACH

#define IR_UNREACH 0x40

Get the destination unreachable message in UDP sending.

When receiving the ICMP (Destination port unreachable) packet, this bit is set as When this bit is Destination Information such as IP address and Port number may be checked with the corresponding UIPR & UPORTR.check destination unreachable

Definition at line 1003 of file w5100s.h.

◆ MR2_CLKSEL

#define MR2_CLKSEL (1<<7)

Clock select bit.

With this bit, system clock can be selected to be 25Mhz or 100Mhz 1: 25Mhz 0: 100Mhz (default)

Definition at line 1437 of file w5100s.h.

◆ MR2_G_IEN

#define MR2_G_IEN (1<<6)

Interrupt pin enable bit.

This bit enables interrupt. 1: Enable interrupt 0: Disable interrupt

Definition at line 1445 of file w5100s.h.

◆ MR2_MNOSCHK

#define MR2_MNOSCHK (1<<2)

MACRAW No Size Check.

todo

Definition at line 1476 of file w5100s.h.

◆ MR2_NOTCPRST

#define MR2_NOTCPRST (1<<5)

No TCP Reset Packet send.

This bit prevents sending reset packet. 1: Block TCP reset packet send 0: TCP Reset packet send

Definition at line 1454 of file w5100s.h.

◆ MR2_SSRCHA

#define MR2_SSRCHA (1<<0)

Skip SRC Hardware Address.

todo

This bit can enables to receive without checking the hardware address of the peer. 1:

Definition at line 1492 of file w5100s.h.

◆ MR2_UDPFARP

#define MR2_UDPFARP (1<<1)

UDP force ARP.

This bit can enables to force ARP for each send command. 1: UDP Force ARP Enable 0: UDP Force ARP Disable.

Definition at line 1485 of file w5100s.h.

◆ MR2_UDPURB

#define MR2_UDPURB (1<<4)

Unreachable Packet Send Block bit.

This bit prevents sending Destination Port Unreachable Packet. 1: Block Destination Port Unreachable Packet Send 0: Destination Port Unreachable Packet Send

Definition at line 1462 of file w5100s.h.

◆ MR2_WOL

#define MR2_WOL (1<<3)

Wake On LAN.

This bit enables WOL packet to be received. 1: WOL packet can be received. 0: WOL packet cannot be received.

Definition at line 1470 of file w5100s.h.

◆ MR_AI

#define MR_AI 0x02

Address Auto-Increment in Indirect Bus Interface.

0 : Disable auto-increment
1 : Enable auto-incremente
At the Indirect Bus Interface mode, if this bit is set as 占쎌쥙猷욑옙占쏙옙醫롫짗占쏙옙 the address will be automatically increased by 1 whenever read and write are performed.auto-increment in indirect mode

Definition at line 981 of file w5100s.h.

◆ MR_IND

#define MR_IND 0x01

Indirect Bus Interface mode.

0 : Disable Indirect bus Interface mode
1 : Enable Indirect bus Interface mode
If this bit is set as 占쎌쥙猷욑옙占쏙옙醫롫짗占쏙옙 Indirect Bus Interface mode is set.enable indirect mode

Definition at line 989 of file w5100s.h.

◆ MR_PB

#define MR_PB 0x10

Ping block.

0 : Disable Ping block
1 : Enable Ping block
If the bit is it blocks the response to a ping request.ping block

Definition at line 964 of file w5100s.h.

◆ MR_PPPOE

#define MR_PPPOE 0x08

Enable PPPoE.

0 : DisablePPPoE mode
1 : EnablePPPoE mode
If you use ADSL, this bit should be '1'.enable pppoe

Definition at line 972 of file w5100s.h.

◆ MR_RST

#define MR_RST 0x80

Reset.

If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset.reset

Definition at line 955 of file w5100s.h.

◆ PHYACR_READ

#define PHYACR_READ 0x02

Definition at line 1741 of file w5100s.h.

◆ PHYACR_WRITE

#define PHYACR_WRITE 0x01

Definition at line 1742 of file w5100s.h.

◆ PHYCR1_PWDN_DISABLE

#define PHYCR1_PWDN_DISABLE (0<<5)

Definition at line 1594 of file w5100s.h.

◆ PHYCR1_PWDN_ENABLE

#define PHYCR1_PWDN_ENABLE (1<<5)

Definition at line 1593 of file w5100s.h.

◆ PHYCR1_RST

#define PHYCR1_RST (0<<0)

Definition at line 1591 of file w5100s.h.

◆ PHYCR_AUTONEGO_DISABLE

#define PHYCR_AUTONEGO_DISABLE (1<<2)

Definition at line 1583 of file w5100s.h.

◆ PHYCR_AUTONEGO_ENABLE

#define PHYCR_AUTONEGO_ENABLE (0<<2)

Definition at line 1582 of file w5100s.h.

◆ PHYCR_FULL_DUP

#define PHYCR_FULL_DUP (0<<0)

Definition at line 1589 of file w5100s.h.

◆ PHYCR_HALF_DUP

#define PHYCR_HALF_DUP (1<<0)

Definition at line 1588 of file w5100s.h.

◆ PHYCR_SPD_10

#define PHYCR_SPD_10 (1<<1)

Definition at line 1585 of file w5100s.h.

◆ PHYCR_SPD_100

#define PHYCR_SPD_100 (0<<1)

Definition at line 1586 of file w5100s.h.

◆ PHYMDIO_BMCR

#define PHYMDIO_BMCR 0x00

Definition at line 1644 of file w5100s.h.

◆ PHYMDIO_BMSR

#define PHYMDIO_BMSR 0x01

Definition at line 1647 of file w5100s.h.

◆ PHYSR1_CLDN

#define PHYSR1_CLDN (1<<0)

Definition at line 1580 of file w5100s.h.

◆ PHYSR1_LPI

#define PHYSR1_LPI (1<<1)

Definition at line 1574 of file w5100s.h.

◆ PHYSR1_RXPG

#define PHYSR1_RXPG (1<<2)

Definition at line 1568 of file w5100s.h.

◆ PHYSR_CABOFF

#define PHYSR_CABOFF (1<<7)

Ethernet CABLE OFF Signal.

todotodo

Definition at line 1523 of file w5100s.h.

◆ PHYSR_DUP

#define PHYSR_DUP (1<<2)

todo

Definition at line 1547 of file w5100s.h.

◆ PHYSR_LNK

#define PHYSR_LNK (1<<0)

LINKDONE register.

todo

If 1 Linked successfully, if 0 no link

Definition at line 1559 of file w5100s.h.

◆ PHYSR_MD0

#define PHYSR_MD0 (1<<3)

todo

Definition at line 1541 of file w5100s.h.

◆ PHYSR_MD1

#define PHYSR_MD1 (1<<4)

todo

Definition at line 1535 of file w5100s.h.

◆ PHYSR_MD2

#define PHYSR_MD2 (1<<5)

todo

Definition at line 1529 of file w5100s.h.

◆ PHYSR_SPD

#define PHYSR_SPD (1<<1)

todo

Definition at line 1553 of file w5100s.h.

◆ setDBGOUT

#define setDBGOUT ( dbgout )
Value:
{\
WIZCHIP_WRITE(DBGOUT,(uint8_t)(dbgout >> 16)); \
WIZCHIP_WRITE(DBGOUT,(uint8_t)(dbgout >> 8)); \
WIZCHIP_WRITE(DBGOUT,(uint8_t)(dbgout)); \
}
DBGOUT
#define DBGOUT
DBGOUT(hidden)
Definition: w5100s.h:556

Definition at line 2573 of file w5100s.h.

◆ setSn_RXBUF_SIZE

#define setSn_RXBUF_SIZE | ( | sn,
 |  | rxmemsize
 | ) | setSn_RXMEM_SIZE(sn,rxmemsize)

Definition at line 2932 of file w5100s.h.

◆ setSn_TXBUF_SIZE

#define setSn_TXBUF_SIZE | ( | sn,
 |  | txmemsize
 | ) | setSn_TXMEM_SIZE(sn,txmemsize)

Definition at line 2954 of file w5100s.h.

◆ SLCMD_ARP

#define SLCMD_ARP (1<<1)

Socket-less command register bit.

ARP command

Definition at line 1045 of file w5100s.h.

◆ SLCMD_PING

#define SLCMD_PING (1<<0)

Socket-less command register bit.

ARP command

Definition at line 1051 of file w5100s.h.

◆ SLIR_ARP

#define SLIR_ARP (1<<1)

Socket less command interrupt and interrupt mask register bit.

Socket less command ARP interrupt and interrupt mask

Definition at line 1063 of file w5100s.h.

◆ SLIR_PING

#define SLIR_PING (1<<0)

Socket less command interrupt and interrupt mask register bit.

Socket less command PING interrupt and interruptmask

Definition at line 1069 of file w5100s.h.

◆ SLIR_TIMEOUT

#define SLIR_TIMEOUT (1<<2)

Socket-less command interrupt and interrupt mask register bit.

Request command time out interrupt and interrupt mask

Definition at line 1057 of file w5100s.h.

◆ Sn_CR_CLOSE

#define Sn_CR_CLOSE 0x10

Close socket.

Sn_SR is changed to SOCK_CLOSED.

Definition at line 1209 of file w5100s.h.

◆ Sn_CR_CONNECT

#define Sn_CR_CONNECT 0x04

Send connection request in TCP mode(Client mode)

To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by Sn_DIPR & Sn_DPORT(destination address & port). If the connect-request is successful, the Sn_SR is changed to SOCK_ESTABLISHED and the Sn_IR(0) becomes

The connect-request fails in the following three cases.

  1. When a ARPTO occurs (Sn_IR[3] = '1') because destination hardware address is not acquired through the ARP-process.
  2. When a SYN/ACK packet is not received and TCPTO (Sn_IR(3) ='1')
  3. When a RST packet is received instead of a SYN/ACK packet. In these cases, Sn_SR is changed to SOCK_CLOSED.
    Note
    This is valid only in TCP mode and operates when Socket n acts as TCP clientsend connection request in tcp mode(Client mode)

Definition at line 1190 of file w5100s.h.

◆ Sn_CR_DISCON

#define Sn_CR_DISCON 0x08

Send closing request in TCP mode.

Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (Active closeor Passive close.

Active close
it transmits disconnect-request(FIN packet) to the connected peer
Passive close
When FIN packet is received from peer, a FIN packet is replied back to the peer.

When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), Sn_SR is changed to SOCK_CLOSED.
Otherwise, TCPTO occurs (Sn_IR(3)='1') and then Sn_SR is changed to SOCK_CLOSED.

Note
Valid only in TCP mode.send closing reqeuset in tcp mode

Definition at line 1203 of file w5100s.h.

◆ Sn_CR_IGMP_JOIN

#define Sn_CR_IGMP_JOIN 0x23

Definition at line 1249 of file w5100s.h.

◆ Sn_CR_IGMP_LEAVE

#define Sn_CR_IGMP_LEAVE 0x24

Definition at line 1255 of file w5100s.h.

◆ Sn_CR_LISTEN

#define Sn_CR_LISTEN 0x02

Wait connection request in TCP mode(Server mode)

This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP).// In this mode, Socket n operates as a 'TCP server' and waits for connection-request (SYN packet) from any 'TCP client'.// The Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN.// When a 'TCP client' connection request is successfully established, the Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes But when a 'TCP client' connection request is failed, Sn_IR(3) becomes and the status of Sn_SR changes to SOCK_CLOSED.wait connection request in tcp mode(Server mode)

Definition at line 1178 of file w5100s.h.

◆ Sn_CR_OPEN

#define Sn_CR_OPEN 0x01

Initialize or open socket.

Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). The table below shows the value of Sn_SR corresponding to Sn_MR.

Sn_MR (P[3:0]) | Sn_SR
Sn_MR_CLOSE (000) | –
Sn_MR_TCP (001) | SOCK_INIT (0x13)
Sn_MR_UDP (010) | SOCK_UDP (0x22)
S0_MR_IPRAW (011) | SOCK_IPRAW (0x32)
S0_MR_MACRAW (100) | SOCK_MACRAW (0x42)
S0_MR_PPPoE (101) | SOCK_PPPoE (0x5F)

initialize or open socket

Definition at line 1167 of file w5100s.h.

◆ Sn_CR_RECV

#define Sn_CR_RECV 0x40

Update RX buffer pointer and receive data.

RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (Sn_RX_RD).
For more details, refer to Socket n RX Received Size Register (Sn_RX_RSR), Socket n RX Write Pointer Register (Sn_RX_WR), and Socket n RX Read Pointer Register (Sn_RX_RD).

Definition at line 1243 of file w5100s.h.

◆ Sn_CR_SEND

#define Sn_CR_SEND 0x20

Update TX buffer pointer and send data.

SEND transmits all the data in the Socket n TX buffer.
For more details, please refer to Socket n TX Free Size Register (Sn_TX_FSR), Socket n, TX Write Pointer Register(Sn_TX_WR), and Socket n TX Read Pointer Register(Sn_TX_RD).

Definition at line 1217 of file w5100s.h.

◆ Sn_CR_SEND_KEEP

#define Sn_CR_SEND_KEEP 0x22

Send keep alive message.

It checks the connection status by sending 1byte keep-alive packet.
If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur.

Note
Valid only in TCP mode.

Definition at line 1235 of file w5100s.h.

◆ Sn_CR_SEND_MAC

#define Sn_CR_SEND_MAC 0x21

Send data with MAC address, so without ARP process.

The basic operation is same as SEND.
Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).
But SEND_MAC transmits data without the automatic ARP-process.
In this case, the destination hardware address is acquired from Sn_DHAR configured by host, instead of APR-process.

Note
Valid only in UDP mode.

Definition at line 1227 of file w5100s.h.

◆ Sn_IR_CON

#define Sn_IR_CON 0x01

CON Interrupt.

This is issued one time when the connection with peer is successful and then Sn_SR is changed to SOCK_ESTABLISHED.

Definition at line 1288 of file w5100s.h.

◆ Sn_IR_DISCON

#define Sn_IR_DISCON 0x02

DISCON Interrupt.

This is issued when FIN or FIN/ACK packet is received from a peer.

Definition at line 1282 of file w5100s.h.

◆ Sn_IR_RECV

#define Sn_IR_RECV 0x04

RECV Interrupt.

This is issued whenever data is received from a peer.

Definition at line 1276 of file w5100s.h.

◆ Sn_IR_SENDOK

#define Sn_IR_SENDOK 0x10

SEND_OK Interrupt.

This is issued when SEND command is completed.complete sending

Definition at line 1264 of file w5100s.h.

◆ Sn_IR_TIMEOUT

#define Sn_IR_TIMEOUT 0x08

TIMEOUT Interrupt.

This is issued when ARPTO or TCPTO occurs.assert timeout

Definition at line 1270 of file w5100s.h.

◆ Sn_MR2_FPSH

#define Sn_MR2_FPSH Sn_MR2_UBBLK

TCP Force PSH bit.

When the SOCKET transmits data in TCP mode, PSH Flag is set to all packets.

Definition at line 1629 of file w5100s.h.

◆ Sn_MR2_IPV6BLK

#define Sn_MR2_IPV6BLK (1<<4)

IPv6 packet Blocking bit in MACRAW mode.

In MACRAW mode, this bit is set to ????to block the IPv6 packet.

Definition at line 1615 of file w5100s.h.

◆ Sn_MR2_MBBLK

#define Sn_MR2_MBBLK (1<<6)

Broadcast Blocking bit in MACRAW mode.

In MACRAW mode, this bit is set to ????to block the broadcast packet.

Definition at line 1603 of file w5100s.h.

◆ Sn_MR2_MMBLK

#define Sn_MR2_MMBLK (1<<5)

Multicast Blocking bit in MACRAW mode.

In MACRAW mode, this bit is set to ????to block the multicast packet.

Definition at line 1609 of file w5100s.h.

◆ Sn_MR2_UBBLK

#define Sn_MR2_UBBLK (1<<1)

Broadcast Blocking bit in UDP mode.

In UDP mode, this bit is set to ????to block the broadcast packet.

Definition at line 1622 of file w5100s.h.

◆ Sn_MR2_UUBLK

#define Sn_MR2_UUBLK (1<<0)

Unicast Blocking bit in UDP mode.

In UDP mode, this bit is set to ????to block the Unicast packet.

Definition at line 1635 of file w5100s.h.

◆ Sn_MR_CLOSE

#define Sn_MR_CLOSE 0x00

Unused socket.

This configures the protocol mode of Socket n.unused socket

Definition at line 1079 of file w5100s.h.

◆ Sn_MR_IPRAW

#define Sn_MR_IPRAW 0x03

IP LAYER RAW SOCK.

Definition at line 1092 of file w5100s.h.

◆ Sn_MR_MACRAW

#define Sn_MR_MACRAW 0x04

MAC LAYER RAW SOCK.

This configures the protocol mode of Socket n.

Note
MACRAW mode should be only used in Socket 0.MAC LAYER RAW SOCK

Definition at line 1099 of file w5100s.h.

◆ Sn_MR_MC

#define Sn_MR_MC Sn_MR_ND

Support UDP Multicasting.

0 : using IGMP version 2
1 : using IGMP version 1
This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = '1') It configures the version for IGMP messages (Join/Leave/Report).Select IGMP version 1(0) or 2(1)

Definition at line 1125 of file w5100s.h.

◆ Sn_MR_MF

#define Sn_MR_MF 0x40

MAC filter enable in Sn_MR_MACRAW mode.

0 : disable MAC Filtering
1 : enable MAC Filtering
This bit is applied only during MACRAW mode(P[3:0] = 100.
When set as W5100S can only receive broadcasting packet or packet sent to itself. When this bit is W5100S can receive all packets on Ethernet. If user wants to implement Hybrid TCP/IP stack, it is recommended that this bit is set as for reducing host overhead to process the all received packets.Use MAC filter

Definition at line 1137 of file w5100s.h.

◆ Sn_MR_MFEN

#define Sn_MR_MFEN Sn_MR_MF

Definition at line 1138 of file w5100s.h.

◆ Sn_MR_MULTI

#define Sn_MR_MULTI 0x80

Support UDP Multicasting.

0 : disable Multicasting
1 : enable Multicasting
This bit is applied only during UDP mode(P[3:0] = 010).
To use multicasting, Sn_DIPR & Sn_DPORT should be respectively configured with the multicast group IP address & port number before Socket n is opened by OPEN command of Sn_CR.support multicating

Definition at line 1150 of file w5100s.h.

◆ Sn_MR_ND

#define Sn_MR_ND 0x20

No Delayed Ack(TCP), Multicast flag.

0 : Disable No Delayed ACK option
1 : Enable No Delayed ACK option
This bit is applied only during TCP mode (P[3:0] = 001).
When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.
When this bit is It sends the ACK packet after waiting for the timeout time configured by RTR.No Delayed Ack(TCP) flag

Definition at line 1116 of file w5100s.h.

◆ Sn_MR_PPPoE

#define Sn_MR_PPPoE 0x05

PPPoE.

This configures the protocol mode of Socket n.

Note
PPPoE mode should be only used in Socket 0.PPPoE

Definition at line 1106 of file w5100s.h.

◆ Sn_MR_TCP

#define Sn_MR_TCP 0x01

TCP.

This configures the protocol mode of Socket n.TCP

Definition at line 1085 of file w5100s.h.

◆ Sn_MR_UDP

#define Sn_MR_UDP 0x02

UDP.

This configures the protocol mode of Socket n.UDP

Definition at line 1091 of file w5100s.h.

◆ SOCK_CLOSE_WAIT

#define SOCK_CLOSE_WAIT 0x1C

Closing state.

This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.
This is half-closing status, and data can be transferred.
For full-closing, DISCON command is used. But For just-closing, Sn_CR_CLOSE command is used.

Definition at line 1370 of file w5100s.h.

◆ SOCK_CLOSED

#define SOCK_CLOSED 0x00

Closed.

This indicates that Socket n is released.
When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to SOCK_CLOSED regardless of previous status.closed

Definition at line 1296 of file w5100s.h.

◆ SOCK_CLOSING

#define SOCK_CLOSING 0x1A

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1354 of file w5100s.h.

◆ SOCK_ESTABLISHED

#define SOCK_ESTABLISHED 0x17

Success to connect.

This indicates the status of the connection of Socket n.
It changes to SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring SOCK_LISTEN, or when the CONNECT command is successful.
During SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command.

Definition at line 1338 of file w5100s.h.

◆ SOCK_FIN_WAIT

#define SOCK_FIN_WAIT 0x18

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1346 of file w5100s.h.

◆ SOCK_INIT

#define SOCK_INIT 0x13

Initiate state.

This indicates Socket n is opened with TCP mode.
It is changed to SOCK_INIT when Sn_MR(P[3:0]) = 001)and OPEN command is ordered.
After SOCK_INIT, user can use LISTEN /CONNECT command.init state

Definition at line 1304 of file w5100s.h.

◆ SOCK_IPRAW

#define SOCK_IPRAW 0x32

IP raw mode socket.

TThe socket is opened in IPRAW mode. The SOCKET status is change to SOCK_IPRAW when Sn_MR (P3:P0) is Sn_MR_IPRAW and Sn_CR_OPEN command is used.
IP Packet can be transferred without a connection similar to the UDP mode.ip raw mode socket

Definition at line 1393 of file w5100s.h.

◆ SOCK_LAST_ACK

#define SOCK_LAST_ACK 0x1D

Closing state.

This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.
It changes to SOCK_CLOSED when Socket n received the response successfully, or when timeout occurs (Sn_IR[TIMEOUT] = '1').

Definition at line 1377 of file w5100s.h.

◆ SOCK_LISTEN

#define SOCK_LISTEN 0x14

Listen state.

This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer (TCP client).
It will change to SOCK_ESTABLISHED when the connection-request is successfully accepted.
Otherwise it will change to SOCK_CLOSED after TCPTO occurred (Sn_IR(TIMEOUT) = '1').

Definition at line 1312 of file w5100s.h.

◆ SOCK_MACRAW

#define SOCK_MACRAW 0x42

MAC raw mode socket.

This indicates Socket 0 is opened in MACRAW mode (Sn_MR(P[3:0]) = '100' and n=0) and is valid only in Socket 0.
It changes to SOCK_MACRAW when Sn_MR(P[3:0]) = '100' and Sn_CR_OPEN command is ordered.
Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process.mac raw mode socket

Definition at line 1401 of file w5100s.h.

◆ SOCK_PPPOE

#define SOCK_PPPOE 0x5F

PPPoE mode socket.

It is the status that SOCKET0 is open as PPPoE mode. It is changed to SOCK_PPPoE in case of S0_CR=OPEN and S0_MR (P3:P0)=S0_MR_PPPoE.
It is temporarily used at the PPPoE connection.pppoe socket

Definition at line 1410 of file w5100s.h.

◆ SOCK_SYNRECV

#define SOCK_SYNRECV 0x16

Connection state.

It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to SOCK_ESTABLISHED.
If not, it changes to SOCK_CLOSED after timeout occurs (Sn_IR[TIMEOUT] = '1').

Definition at line 1329 of file w5100s.h.

◆ SOCK_SYNSENT

#define SOCK_SYNSENT 0x15

Connection state.

This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
It is temporarily shown when Sn_SR is changed from SOCK_INIT to SOCK_ESTABLISHED by CONNECT command.
If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to SOCK_ESTABLISHED.
Otherwise, it changes to SOCK_CLOSED after TCPTO (Sn_IR[TIMEOUT] = '1') is occurred.

Definition at line 1321 of file w5100s.h.

◆ SOCK_TIME_WAIT

#define SOCK_TIME_WAIT 0x1B

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1362 of file w5100s.h.

◆ SOCK_UDP

#define SOCK_UDP 0x22

UDP socket.

This indicates Socket n is opened in UDP mode(Sn_MR(P[3:0]) = 010).
It changes to SOCK_UDP when Sn_MR(P[3:0]) = 010 and Sn_CR_OPEN command is ordered.
Unlike TCP mode, data can be transfered without the connection-process.udp socket

Definition at line 1385 of file w5100s.h.

◆ WIZCHIP_CREG_BLOCK

#define WIZCHIP_CREG_BLOCK 0x00

Common register block.

Definition at line 58 of file w5100s.h.

◆ WIZCHIP_CRITICAL_ENTER

#define WIZCHIP_CRITICAL_ENTER ( ) WIZCHIP.CRIS._enter()

Enter a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_EXIT()

Definition at line 1758 of file w5100s.h.

◆ WIZCHIP_CRITICAL_EXIT

#define WIZCHIP_CRITICAL_EXIT ( ) WIZCHIP.CRIS._exit()

Exit a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_ENTER()

Definition at line 1775 of file w5100s.h.

◆ WIZCHIP_OFFSET_INC

#define WIZCHIP_OFFSET_INC | ( | ADDR,
 |  | N
 | ) | (ADDR + N)

Increase offset address.

Definition at line 61 of file w5100s.h.

◆ WIZCHIP_SREG_BLOCK

#define WIZCHIP_SREG_BLOCK ( N ) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)

Socket N register block.

Definition at line 59 of file w5100s.h.


ioLibrary: Ethernet/W5200 Directory Reference

  • Ethernet
  • W5200
W5200 Directory Reference
Directory dependency graph for W5200:

Files

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


ioLibrary: 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.


ioLibrary: Ethernet/W5200/w5200.h File Reference

  • Ethernet
  • W5200
Macros | Functions
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.

Macros

#define | _WIZCHIP_SN_BASE_ (0x4000)
#define | _WIZCHIP_SN_SIZE_ (0x0100)
#define | _WIZCHIP_IO_TXBUF_ (0x8000) /* Internal Tx buffer address of the iinchip */
#define | _WIZCHIP_IO_RXBUF_ (0xC000) /* Internal Rx buffer address of the iinchip */
#define | _W5200_SPI_READ_ (0x00 << 7)
SPI interface Read operation in Control Phase. More...
#define | _W5200_SPI_WRITE_ (0x01 << 7)
SPI interface Write operation in Control Phase. More...
#define | WIZCHIP_CREG_BLOCK 0x00
Common register block. More...
#define | WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
Socket N register block. More...
#define | WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
Increase offset address. More...
#define | IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE(ADDR, VAL) WIZCHIP_WRITE(ADDR,VAL)
The defined for legacy chip driver. More...
#define | IINCHIP_READ_BUF(ADDR, BUF, LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE_BUF(ADDR, BUF, LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | MR (_W5200_IO_BASE_ + (0x0000))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5200_IO_BASE_ + (0x0001))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5200_IO_BASE_ + (0x0005))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5200_IO_BASE_ + (0x0009))
Source MAC Register address(R/W) More...
#define | SIPR (_W5200_IO_BASE_ + (0x000F))
Source IP Register address(R/W) More...
#define | IR (_W5200_IO_BASE_ + (0x0015))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5200_IO_BASE_ + (0x0016))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5200_IO_BASE_ + (0x0017))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5200_IO_BASE_ + (0x0019))
Retry count register(R/W) More...
#define | PATR (_W5200_IO_BASE_ + (0x001C))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PPPALGO (_W5200_IO_BASE_ + (0x001E))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | VERSIONR (_W5200_IO_BASE_ + (0x001F))
chip version register address(R) More...
#define | PTIMER (_W5200_IO_BASE_ + (0x0028))
PPP LCP Request Timer register in PPPoE mode(R) More...
#define | PMAGIC (_W5200_IO_BASE_ + (0x0029))
PPP LCP Magic number register in PPPoE mode(R) More...
#define | INTLEVEL (_W5200_IO_BASE_ + (0x0030))
Set Interrupt low level timer register address(R/W) More...
#define | IR2 (_W5200_IO_BASE_ + (0x0034))
Socket Interrupt Register(R/W) More...
#define | PHYSTATUS (_W5200_IO_BASE_ + (0x0035))
PHYSTATUS(R/W) More...
#define | IMR2 (_W5200_IO_BASE_ + (0x0036))
Interrupt mask register(R/W) More...
#define | Sn_MR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000))
socket Mode register(R/W) More...
#define | Sn_CR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001))
Socket command register(R/W) More...
#define | Sn_IR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002))
Socket interrupt register(R) More...
#define | Sn_SR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003))
Socket status register(R) More...
#define | Sn_PORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004))
source port register(R/W) More...
#define | Sn_DHAR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C))
Peer IP register address(R/W) More...
#define | Sn_DPORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010))
Peer port register address(R/W) More...
#define | Sn_MSSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_PROTO(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014))
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOS(sn) (WIZCHIP_SREG_BLOCK(sn) + 0x0015)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_RXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E))
Receive memory size register(R/W) More...
#define | Sn_TXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F))
Transmit memory size register(R/W) More...
#define | Sn_TX_FSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026))
Received data size register(R) More...
#define | Sn_RX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A))
Write point of Receive memory(R) More...
#define | Sn_IMR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C))
socket interrupt mask register(R) More...
#define | Sn_FRAG(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D))
Fragment field value in IP header register(R/W) More...
#define | MR_RST 0x80
Reset. More...
#define | MR_WOL 0x20
Wake on LAN. More...
#define | MR_PB 0x10
Ping block. More...
#define | MR_PPPOE 0x08
Enable PPPoE. More...
#define | MR_AI 0x02
Address Auto-Increment in Indirect Bus Interface. More...
#define | MR_IND 0x01
Indirect Bus Interface mode. More...
#define | IR_CONFLICT 0x80
Check IP conflict. More...
#define | IR_PPPoE 0x20
Get the PPPoE close message. More...
#define | PHYSTATUS_LINK 0x20
Link Status [Read Only]. More...
#define | PHYSTATUS_POWERSAVE 0x10
Power save mode of PHY. More...
#define | PHYSTATUS_POWERDOWN 0x08
Power down mode of PHY. More...
#define | Sn_MR_CLOSE 0x00
Unused socket. More...
#define | Sn_MR_TCP 0x01
TCP. More...
#define | Sn_MR_UDP 0x02
UDP. More...
#define | Sn_MR_IPRAW 0x03
IP LAYER RAW SOCK. More...
#define | Sn_MR_MACRAW 0x04
MAC LAYER RAW SOCK. More...
#define | Sn_MR_PPPOE 0x05
PPPoE. More...
#define | Sn_MR_ND 0x20
No Delayed Ack(TCP), Multicast flag. More...
#define | Sn_MR_MC Sn_MR_ND
Support UDP Multicasting. More...
#define | Sn_MR_MF 0x40
Multicast Blocking in Sn_MR_MACRAW mode. More...
#define | Sn_MR_MFEN Sn_MR_MF
#define | Sn_MR_MULTI 0x80
Support UDP Multicasting. More...
#define | Sn_CR_OPEN 0x01
Initialize or open socket. More...
#define | Sn_CR_LISTEN 0x02
Wait connection request in TCP mode(Server mode) More...
#define | Sn_CR_CONNECT 0x04
Send connection request in TCP mode(Client mode) More...
#define | Sn_CR_DISCON 0x08
Send closing request in TCP mode. More...
#define | Sn_CR_CLOSE 0x10
Close socket. More...
#define | Sn_CR_SEND 0x20
Update TX buffer pointer and send data. More...
#define | Sn_CR_SEND_MAC 0x21
Send data with MAC address, so without ARP process. More...
#define | Sn_CR_SEND_KEEP 0x22
Send keep alive message. More...
#define | Sn_CR_RECV 0x40
Update RX buffer pointer and receive data. More...
#define | Sn_CR_PCON 0x23
PPPoE connection. More...
#define | Sn_CR_PDISCON 0x24
Closes PPPoE connection. More...
#define | Sn_CR_PCR 0x25
REQ message transmission. More...
#define | Sn_CR_PCN 0x26
NAK massage transmission. More...
#define | Sn_CR_PCJ 0x27
REJECT message transmission. More...
#define | Sn_IR_PRECV 0x80
PPP Receive Interrupt. More...
#define | Sn_IR_PFAIL 0x40
PPP Fail Interrupt. More...
#define | Sn_IR_PNEXT 0x20
PPP Next Phase Interrupt. More...
#define | Sn_IR_SENDOK 0x10
SEND_OK Interrupt. More...
#define | Sn_IR_TIMEOUT 0x08
TIMEOUT Interrupt. More...
#define | Sn_IR_RECV 0x04
RECV Interrupt. More...
#define | Sn_IR_DISCON 0x02
DISCON Interrupt. More...
#define | Sn_IR_CON 0x01
CON Interrupt. More...
#define | SOCK_CLOSED 0x00
Closed. More...
#define | SOCK_INIT 0x13
Initiate state. More...
#define | SOCK_LISTEN 0x14
Listen state. More...
#define | SOCK_SYNSENT 0x15
Connection state. More...
#define | SOCK_SYNRECV 0x16
Connection state. More...
#define | SOCK_ESTABLISHED 0x17
Success to connect. More...
#define | SOCK_FIN_WAIT 0x18
Closing state. More...
#define | SOCK_CLOSING 0x1A
Closing state. More...
#define | SOCK_TIME_WAIT 0x1B
Closing state. More...
#define | SOCK_CLOSE_WAIT 0x1C
Closing state. More...
#define | SOCK_LAST_ACK 0x1D
Closing state. More...
#define | SOCK_UDP 0x22
UDP socket. More...
#define | SOCK_IPRAW 0x32
IP raw mode socket. More...
#define | SOCK_MACRAW 0x42
MAC raw mode socket. More...
#define | SOCK_PPPOE 0x5F
PPPoE mode socket. More...
#define | IPPROTO_IP 0
Dummy for IP. More...
#define | IPPROTO_ICMP 1
Control message protocol. More...
#define | IPPROTO_IGMP 2
Internet group management protocol. More...
#define | IPPROTO_GGP 3
GW^2 (deprecated) More...
#define | IPPROTO_TCP 6
TCP. More...
#define | IPPROTO_PUP 12
PUP. More...
#define | IPPROTO_UDP 17
UDP. More...
#define | IPPROTO_IDP 22
XNS idp. More...
#define | IPPROTO_ND 77
UNOFFICIAL net disk protocol. More...
#define | IPPROTO_RAW 255
Raw IP packet. More...
#define | WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
Enter a critical section. More...
#define | WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
Exit a critical section. More...
#define | setMR(mr) (*((uint8_t*)MR) = mr)
Set Mode Register. More...
#define | getMR() (*(uint8_t*)MR)
Get MR. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set GAR. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get GAR. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR, subr,4)
Set SUBR. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get SUBR. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set SHAR. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get SHAR. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set SIPR. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get SIPR. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xA0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xA0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(IMR2, imr & 0xA0)
Set IMR2 register. More...
#define | getIMR() (WIZCHIP_READ(IMR2) & 0xA0)
Get IMR2 register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | getPATR() (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
Get PATR register. More...
#define | getPPPALGO() WIZCHIP_READ(PPPALGO)
Get PPPALGO register. More...
#define | getVERSIONR() WIZCHIP_READ(VERSIONR)
Get VERSIONR register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...
#define | setINTLEVEL(intlevel)
Set INTLEVEL register. More...
#define | getINTLEVEL() (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
Get INTLEVEL register. More...
#define | setIR2(ir2) WIZCHIP_WRITE(IR2, ir2)
Set IR2 register. More...
#define | setSIR(ir2) setIR2(ir2)
#define | getIR2() WIZCHIP_READ(IR2)
Get IR2 register. More...
#define | getSIR() getIR2()
#define | getPHYSTATUS() WIZCHIP_READ(PHYSTATUS)
Get PHYSTATUS register. More...
#define | setIMR2(imr2) WIZCHIP_WRITE(_IMR_, imr2)
Set IMR register. More...
#define | setSIMR(imr2) setIMR2(imr2)
#define | getIMR2() WIZCHIP_READ(_IMR_)
Get IMR register. More...
#define | getSIMR() getIMR2()
#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ir)
Set Sn_IR register. More...
#define | getSn_IR(sn) WIZCHIP_READ(Sn_IR(sn))
Get Sn_IR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), imr)
Set Sn_IMR register. More...
#define | getSn_IMR(sn) WIZCHIP_READ(Sn_IMR(sn))
Get Sn_IMR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_DHAR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_PROTO(sn, proto) WIZCHIP_WRITE(Sn_PROTO(sn), proto)
Set Sn_PROTO register. More...
#define | getSn_PROTO(sn) WIZCHIP_READ(Sn_PROTO(sn))
Get Sn_PROTO register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXMEM_SIZE(sn, rxmemsize) WIZCHIP_WRITE(Sn_RXMEM_SIZE(sn),rxmemsize)
Set Sn_RXMEM_SIZE register. More...
#define | setSn_RXBUF_SIZE(sn, rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
#define | getSn_RXMEM_SIZE(sn) WIZCHIP_READ(Sn_RXMEM_SIZE(sn))
Get Sn_RXMEM_SIZE register. More...
#define | getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
#define | setSn_TXMEM_SIZE(sn, txmemsize) WIZCHIP_WRITE(Sn_TXMEM_SIZE(sn), txmemsize)
Set Sn_TXMEM_SIZE register. More...
#define | setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
#define | getSn_TXMEM_SIZE(sn) WIZCHIP_READ(Sn_TXMEM_SIZE(sn))
Get Sn_TXMEM_SIZE register. More...
#define | getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | setSn_RX_WR(sn, rxwr)
Set Sn_RX_WR register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), imr)
Set Sn_IMR register. More...
#define | getSn_IMR(sn) WIZCHIP_READ(Sn_IMR(sn))
Get Sn_IMR register. More...
#define | setSn_FRAG(sn, frag)
Set Sn_FRAG register. More...
#define | getSn_FRAG(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
Get Sn_FRAG register. More...
#define | getSn_RxMAX(sn) ((uint16_t)getSn_RXMEM_SIZE(sn) << 10)
Get the max RX buffer size of socket sn. More...
#define | getSn_TxMAX(sn) ((uint16_t)getSn_TXMEM_SIZE(sn) << 10)
Get the max TX buffer size of socket sn. More...
#define | getSn_RxMASK(sn) ((uint16_t)getSn_RxMAX(sn) - 1)
Get the mask of socket sn RX buffer. More...
#define | getSn_TxMASK(sn) ((uint16_t)getSn_TxMAX(sn) - 1)
Get the mask of socket sn TX buffer. More...

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
uint16_t | getSn_RxBASE (uint8_t sn)
Get the base address of socket sn RX buffer. More...
uint16_t | getSn_TxBASE (uint8_t sn)
Get the base address of socket sn TX buffer. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...

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.

Macro Definition Documentation

◆ _W5200_SPI_READ_

#define _W5200_SPI_READ_ (0x00 << 7)

SPI interface Read operation in Control Phase.

Definition at line 55 of file w5200.h.

◆ _W5200_SPI_WRITE_

#define _W5200_SPI_WRITE_ (0x01 << 7)

SPI interface Write operation in Control Phase.

Definition at line 56 of file w5200.h.

◆ _WIZCHIP_IO_RXBUF_

#define _WIZCHIP_IO_RXBUF_ (0xC000) /* Internal Rx buffer address of the iinchip */

Definition at line 53 of file w5200.h.

◆ _WIZCHIP_IO_TXBUF_

#define _WIZCHIP_IO_TXBUF_ (0x8000) /* Internal Tx buffer address of the iinchip */

Definition at line 52 of file w5200.h.

◆ _WIZCHIP_SN_BASE_

#define _WIZCHIP_SN_BASE_ (0x4000)

Definition at line 50 of file w5200.h.

◆ _WIZCHIP_SN_SIZE_

#define _WIZCHIP_SN_SIZE_ (0x0100)

Definition at line 51 of file w5200.h.

◆ getSIMR

#define getSIMR ( ) getIMR2()

Definition at line 1548 of file w5200.h.

◆ getSIR

#define getSIR ( ) getIR2()

Definition at line 1509 of file w5200.h.

◆ getSn_RXBUF_SIZE

#define getSn_RXBUF_SIZE ( sn ) getSn_RXMEM_SIZE(sn)

Definition at line 1839 of file w5200.h.

◆ getSn_TXBUF_SIZE

#define getSn_TXBUF_SIZE ( sn ) getSn_TXMEM_SIZE(sn)

Definition at line 1863 of file w5200.h.

◆ IINCHIP_READ

#define IINCHIP_READ ( ADDR ) WIZCHIP_READ(ADDR)

The defined for legacy chip driver.

Definition at line 75 of file w5200.h.

◆ IINCHIP_READ_BUF

#define IINCHIP_READ_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_READ_BUF(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 77 of file w5200.h.

◆ IINCHIP_WRITE

#define IINCHIP_WRITE | ( | ADDR,
 |  | VAL
 | ) | WIZCHIP_WRITE(ADDR,VAL)

The defined for legacy chip driver.

Definition at line 76 of file w5200.h.

◆ IINCHIP_WRITE_BUF

#define IINCHIP_WRITE_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_WRITE(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 78 of file w5200.h.

◆ IPPROTO_GGP

#define IPPROTO_GGP 3

GW^2 (deprecated)

Definition at line 1146 of file w5200.h.

◆ IPPROTO_ICMP

#define IPPROTO_ICMP 1

Control message protocol.

Definition at line 1144 of file w5200.h.

◆ IPPROTO_IDP

#define IPPROTO_IDP 22

XNS idp.

Definition at line 1150 of file w5200.h.

◆ IPPROTO_IGMP

#define IPPROTO_IGMP 2

Internet group management protocol.

Definition at line 1145 of file w5200.h.

◆ IPPROTO_IP

#define IPPROTO_IP 0

Dummy for IP.

Definition at line 1143 of file w5200.h.

◆ IPPROTO_ND

#define IPPROTO_ND 77

UNOFFICIAL net disk protocol.

Definition at line 1151 of file w5200.h.

◆ IPPROTO_PUP

#define IPPROTO_PUP 12

PUP.

Definition at line 1148 of file w5200.h.

◆ IPPROTO_RAW

#define IPPROTO_RAW 255

Raw IP packet.

Definition at line 1152 of file w5200.h.

◆ IPPROTO_TCP

#define IPPROTO_TCP 6

TCP.

Definition at line 1147 of file w5200.h.

◆ IPPROTO_UDP

#define IPPROTO_UDP 17

UDP.

Definition at line 1149 of file w5200.h.

◆ IR_CONFLICT

#define IR_CONFLICT 0x80

Check IP conflict.

Bit is set as when own source IP address is same with the sender IP address in the received ARP request.check ip confict

Definition at line 745 of file w5200.h.

◆ IR_PPPoE

#define IR_PPPoE 0x20

Get the PPPoE close message.

When PPPoE is disconnected during PPPoE mode, this bit is set.get the PPPoE close message

Definition at line 751 of file w5200.h.

◆ MR_AI

#define MR_AI 0x02

Address Auto-Increment in Indirect Bus Interface.

0 : Disable auto-increment
1 : Enable auto-incremente
At the Indirect Bus Interface mode, if this bit is set as ��1��, the address will be automatically increased by 1 whenever read and write are performed.auto-increment in indirect mode

Definition at line 730 of file w5200.h.

◆ MR_IND

#define MR_IND 0x01

Indirect Bus Interface mode.

0 : Disable Indirect bus Interface mode
1 : Enable Indirect bus Interface mode
If this bit is set as ��1��, Indirect Bus Interface mode is set.enable indirect mode

Definition at line 738 of file w5200.h.

◆ MR_PB

#define MR_PB 0x10

Ping block.

0 : Disable Ping block
1 : Enable Ping block
If the bit is it blocks the response to a ping request.ping block

Definition at line 713 of file w5200.h.

◆ MR_PPPOE

#define MR_PPPOE 0x08

Enable PPPoE.

0 : DisablePPPoE mode
1 : EnablePPPoE mode
If you use ADSL, this bit should be '1'.enable pppoe

Definition at line 721 of file w5200.h.

◆ MR_RST

#define MR_RST 0x80

Reset.

If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset.reset

Definition at line 694 of file w5200.h.

◆ MR_WOL

#define MR_WOL 0x20

Wake on LAN.

0 : Disable WOL mode
1 : Enable WOL mode
If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (Sn_MR) for opening Socket.)

Note
The magic packet over UDP supported by W5200 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode.Wake on Lan

Definition at line 705 of file w5200.h.

◆ PHYSTATUS_LINK

#define PHYSTATUS_LINK 0x20

Link Status [Read Only].

0: Link down
1: Link up

Definition at line 757 of file w5200.h.

◆ PHYSTATUS_POWERDOWN

#define PHYSTATUS_POWERDOWN 0x08

Power down mode of PHY.

0: Disable Power down mode
1: Enable Power down mode

Definition at line 769 of file w5200.h.

◆ PHYSTATUS_POWERSAVE

#define PHYSTATUS_POWERSAVE 0x10

Power save mode of PHY.

0: Disable Power save mode
1: Enable Power save mode

Definition at line 763 of file w5200.h.

◆ setSIMR

#define setSIMR ( imr2 ) setIMR2(imr2)

Definition at line 1533 of file w5200.h.

◆ setSIR

#define setSIR ( ir2 ) setIR2(ir2)

Definition at line 1499 of file w5200.h.

◆ setSn_RXBUF_SIZE

#define setSn_RXBUF_SIZE | ( | sn,
 |  | rxmemsize
 | ) | setSn_RXMEM_SIZE(sn,rxmemsize)

Definition at line 1827 of file w5200.h.

◆ setSn_TXBUF_SIZE

#define setSn_TXBUF_SIZE | ( | sn,
 |  | txmemsize
 | ) | setSn_TXMEM_SIZE(sn,txmemsize)

Definition at line 1851 of file w5200.h.

◆ Sn_CR_CLOSE

#define Sn_CR_CLOSE 0x10

Close socket.

Sn_SR is changed to SOCK_CLOSED.

Definition at line 905 of file w5200.h.

◆ Sn_CR_CONNECT

#define Sn_CR_CONNECT 0x04

Send connection request in TCP mode(Client mode)

To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by Sn_DIPR & Sn_DPORT(destination address & port). If the connect-request is successful, the Sn_SR is changed to SOCK_ESTABLISHED and the Sn_IR(0) becomes

The connect-request fails in the following three cases.

  1. When a ARPTO occurs (Sn_IR[3] = '1') because destination hardware address is not acquired through the ARP-process.
  2. When a SYN/ACK packet is not received and TCPTO (Sn_IR(3) ='1')
  3. When a RST packet is received instead of a SYN/ACK packet. In these cases, Sn_SR is changed to SOCK_CLOSED.
    Note
    This is valid only in TCP mode and operates when Socket n acts as TCP clientsend connection request in tcp mode(Client mode)

Definition at line 886 of file w5200.h.

◆ Sn_CR_DISCON

#define Sn_CR_DISCON 0x08

Send closing request in TCP mode.

Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (Active closeor Passive close.

Active close
it transmits disconnect-request(FIN packet) to the connected peer
Passive close
When FIN packet is received from peer, a FIN packet is replied back to the peer.

When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), Sn_SR is changed to SOCK_CLOSED.
Otherwise, TCPTO occurs (Sn_IR(3)='1') and then Sn_SR is changed to SOCK_CLOSED.

Note
Valid only in TCP mode.send closing reqeuset in tcp mode

Definition at line 899 of file w5200.h.

◆ Sn_CR_LISTEN

#define Sn_CR_LISTEN 0x02

Wait connection request in TCP mode(Server mode)

This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP).// In this mode, Socket n operates as a 'TCP server' and waits for connection-request (SYN packet) from any 'TCP client'.// The Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN.// When a 'TCP client' connection request is successfully established, the Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes But when a 'TCP client' connection request is failed, Sn_IR(3) becomes and the status of Sn_SR changes to SOCK_CLOSED.wait connection request in tcp mode(Server mode)

Definition at line 874 of file w5200.h.

◆ Sn_CR_OPEN

#define Sn_CR_OPEN 0x01

Initialize or open socket.

Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). The table below shows the value of Sn_SR corresponding to Sn_MR.

Sn_MR (P[3:0]) | Sn_SR
Sn_MR_CLOSE (000) | –
Sn_MR_TCP (001) | SOCK_INIT (0x13)
Sn_MR_UDP (010) | SOCK_UDP (0x22)
S0_MR_IPRAW (011) | SOCK_IPRAW (0x32)
S0_MR_MACRAW (100) | SOCK_MACRAW (0x42)
S0_MR_PPPoE (101) | SOCK_PPPoE (0x5F)

initialize or open socket

Definition at line 863 of file w5200.h.

◆ Sn_CR_PCJ

#define Sn_CR_PCJ 0x27

REJECT message transmission.

In each phase, it transmits REJECT message.

Definition at line 969 of file w5200.h.

◆ Sn_CR_PCN

#define Sn_CR_PCN 0x26

NAK massage transmission.

In each phase, it transmits NAK message.

Definition at line 963 of file w5200.h.

◆ Sn_CR_PCON

#define Sn_CR_PCON 0x23

PPPoE connection.

PPPoE connection begins by transmitting PPPoE discovery packet

Definition at line 945 of file w5200.h.

◆ Sn_CR_PCR

#define Sn_CR_PCR 0x25

REQ message transmission.

In each phase, it transmits REQ message.

Definition at line 957 of file w5200.h.

◆ Sn_CR_PDISCON

#define Sn_CR_PDISCON 0x24

Closes PPPoE connection.

Closes PPPoE connection

Definition at line 951 of file w5200.h.

◆ Sn_CR_RECV

#define Sn_CR_RECV 0x40

Update RX buffer pointer and receive data.

RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (Sn_RX_RD).
For more details, refer to Socket n RX Received Size Register (Sn_RX_RSR), Socket n RX Write Pointer Register (Sn_RX_WR), and Socket n RX Read Pointer Register (Sn_RX_RD).

Definition at line 939 of file w5200.h.

◆ Sn_CR_SEND

#define Sn_CR_SEND 0x20

Update TX buffer pointer and send data.

SEND transmits all the data in the Socket n TX buffer.
For more details, please refer to Socket n TX Free Size Register (Sn_TX_FSR), Socket n, TX Write Pointer Register(Sn_TX_WR), and Socket n TX Read Pointer Register(Sn_TX_RD).

Definition at line 913 of file w5200.h.

◆ Sn_CR_SEND_KEEP

#define Sn_CR_SEND_KEEP 0x22

Send keep alive message.

It checks the connection status by sending 1byte keep-alive packet.
If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur.

Note
Valid only in TCP mode.

Definition at line 931 of file w5200.h.

◆ Sn_CR_SEND_MAC

#define Sn_CR_SEND_MAC 0x21

Send data with MAC address, so without ARP process.

The basic operation is same as SEND.
Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).
But SEND_MAC transmits data without the automatic ARP-process.
In this case, the destination hardware address is acquired from Sn_DHAR configured by host, instead of APR-process.

Note
Valid only in UDP mode.

Definition at line 923 of file w5200.h.

◆ Sn_IR_CON

#define Sn_IR_CON 0x01

CON Interrupt.

This is issued one time when the connection with peer is successful and then Sn_SR is changed to SOCK_ESTABLISHED.

Definition at line 1018 of file w5200.h.

◆ Sn_IR_DISCON

#define Sn_IR_DISCON 0x02

DISCON Interrupt.

This is issued when FIN or FIN/ACK packet is received from a peer.

Definition at line 1012 of file w5200.h.

◆ Sn_IR_PFAIL

#define Sn_IR_PFAIL 0x40

PPP Fail Interrupt.

PPP Fail Interrupts when PAP Authentication is failed.

Definition at line 982 of file w5200.h.

◆ Sn_IR_PNEXT

#define Sn_IR_PNEXT 0x20

PPP Next Phase Interrupt.

PPP Next Phase Interrupts when the phase is changed during ADSL connection process.

Definition at line 988 of file w5200.h.

◆ Sn_IR_PRECV

#define Sn_IR_PRECV 0x80

PPP Receive Interrupt.

PPP Receive Interrupts when the option which is not supported is received.

Definition at line 976 of file w5200.h.

◆ Sn_IR_RECV

#define Sn_IR_RECV 0x04

RECV Interrupt.

This is issued whenever data is received from a peer.

Definition at line 1006 of file w5200.h.

◆ Sn_IR_SENDOK

#define Sn_IR_SENDOK 0x10

SEND_OK Interrupt.

This is issued when SEND command is completed.complete sending

Definition at line 994 of file w5200.h.

◆ Sn_IR_TIMEOUT

#define Sn_IR_TIMEOUT 0x08

TIMEOUT Interrupt.

This is issued when ARPTO or TCPTO occurs.assert timeout

Definition at line 1000 of file w5200.h.

◆ Sn_MR_CLOSE

#define Sn_MR_CLOSE 0x00

Unused socket.

This configures the protocol mode of Socket n.unused socket

Definition at line 777 of file w5200.h.

◆ Sn_MR_IPRAW

#define Sn_MR_IPRAW 0x03

IP LAYER RAW SOCK.

Definition at line 790 of file w5200.h.

◆ Sn_MR_MACRAW

#define Sn_MR_MACRAW 0x04

MAC LAYER RAW SOCK.

This configures the protocol mode of Socket n.

Note
MACRAW mode should be only used in Socket 0.MAC LAYER RAW SOCK

Definition at line 797 of file w5200.h.

◆ Sn_MR_MC

#define Sn_MR_MC Sn_MR_ND

Support UDP Multicasting.

0 : disable Multicasting
1 : enable Multicasting
This bit is applied only during UDP mode(P[3:0] = 010).
To use multicasting, Sn_DIPR & Sn_DPORT should be respectively configured with the multicast group IP address & port number before Socket n is opened by OPEN command of Sn_CR.Select IGMP version 1(0) or 2(1)

Definition at line 825 of file w5200.h.

◆ Sn_MR_MF

#define Sn_MR_MF 0x40

Multicast Blocking in Sn_MR_MACRAW mode.

0 : using IGMP version 2
1 : using IGMP version 1
This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = '1') It configures the version for IGMP messages (Join/Leave/Report).Use MAC filter

Definition at line 834 of file w5200.h.

◆ Sn_MR_MFEN

#define Sn_MR_MFEN Sn_MR_MF

Definition at line 835 of file w5200.h.

◆ Sn_MR_MULTI

#define Sn_MR_MULTI 0x80

Support UDP Multicasting.

0 : disable Multicasting
1 : enable Multicasting
This bit is applied only during UDP mode(P[3:0] = 010).
To use multicasting, Sn_DIPR & Sn_DPORT should be respectively configured with the multicast group IP address & port number before Socket n is opened by OPEN command of Sn_CR.support multicating

Definition at line 846 of file w5200.h.

◆ Sn_MR_ND

#define Sn_MR_ND 0x20

No Delayed Ack(TCP), Multicast flag.

0 : Disable No Delayed ACK option
1 : Enable No Delayed ACK option
This bit is applied only during TCP mode (P[3:0] = 001).
When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.
When this bit is It sends the ACK packet after waiting for the timeout time configured by RTR.No Delayed Ack(TCP) flag

Definition at line 814 of file w5200.h.

◆ Sn_MR_PPPOE

#define Sn_MR_PPPOE 0x05

PPPoE.

This configures the protocol mode of Socket n.

Note
PPPoE mode should be only used in Socket 0.PPPoE

Definition at line 804 of file w5200.h.

◆ Sn_MR_TCP

#define Sn_MR_TCP 0x01

TCP.

This configures the protocol mode of Socket n.TCP

Definition at line 783 of file w5200.h.

◆ Sn_MR_UDP

#define Sn_MR_UDP 0x02

UDP.

This configures the protocol mode of Socket n.UDP

Definition at line 789 of file w5200.h.

◆ SOCK_CLOSE_WAIT

#define SOCK_CLOSE_WAIT 0x1C

Closing state.

This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.
This is half-closing status, and data can be transferred.
For full-closing, DISCON command is used. But For just-closing, CLOSE command is used.

Definition at line 1100 of file w5200.h.

◆ SOCK_CLOSED

#define SOCK_CLOSED 0x00

Closed.

This indicates that Socket n is released.
When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to SOCK_CLOSED regardless of previous status.closed

Definition at line 1026 of file w5200.h.

◆ SOCK_CLOSING

#define SOCK_CLOSING 0x1A

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1084 of file w5200.h.

◆ SOCK_ESTABLISHED

#define SOCK_ESTABLISHED 0x17

Success to connect.

This indicates the status of the connection of Socket n.
It changes to SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring SOCK_LISTEN, or when the CONNECT command is successful.
During SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command.

Definition at line 1068 of file w5200.h.

◆ SOCK_FIN_WAIT

#define SOCK_FIN_WAIT 0x18

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1076 of file w5200.h.

◆ SOCK_INIT

#define SOCK_INIT 0x13

Initiate state.

This indicates Socket n is opened with TCP mode.
It is changed to SOCK_INIT when Sn_MR(P[3:0]) = 001)and OPEN command is ordered.
After SOCK_INIT, user can use LISTEN /CONNECT command.init state

Definition at line 1034 of file w5200.h.

◆ SOCK_IPRAW

#define SOCK_IPRAW 0x32

IP raw mode socket.

TThe socket is opened in IPRAW mode. The SOCKET status is change to SOCK_IPRAW when Sn_MR (P3:P0) is Sn_MR_IPRAW and OPEN command is used.
IP Packet can be transferred without a connection similar to the UDP mode.ip raw mode socket

Definition at line 1123 of file w5200.h.

◆ SOCK_LAST_ACK

#define SOCK_LAST_ACK 0x1D

Closing state.

This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.
It changes to SOCK_CLOSED when Socket n received the response successfully, or when timeout occurs (Sn_IR[TIMEOUT] = '1').

Definition at line 1107 of file w5200.h.

◆ SOCK_LISTEN

#define SOCK_LISTEN 0x14

Listen state.

This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer (TCP client).
It will change to SOCK_ESTABLISHED when the connection-request is successfully accepted.
Otherwise it will change to SOCK_CLOSED after TCPTO occurred (Sn_IR(TIMEOUT) = '1').

Definition at line 1042 of file w5200.h.

◆ SOCK_MACRAW

#define SOCK_MACRAW 0x42

MAC raw mode socket.

This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.
It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100)and OPEN command is ordered.
Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process.mac raw mode socket

Definition at line 1131 of file w5200.h.

◆ SOCK_PPPOE

#define SOCK_PPPOE 0x5F

PPPoE mode socket.

It is the status that SOCKET0 is open as PPPoE mode. It is changed to SOCK_PPPoE in case of S0_CR=OPEN and S0_MR (P3:P0)=S0_MR_PPPoE.
It is temporarily used at the PPPoE connection.pppoe socket

Definition at line 1140 of file w5200.h.

◆ SOCK_SYNRECV

#define SOCK_SYNRECV 0x16

Connection state.

It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to SOCK_ESTABLISHED.
If not, it changes to SOCK_CLOSED after timeout occurs (Sn_IR[TIMEOUT] = '1').

Definition at line 1059 of file w5200.h.

◆ SOCK_SYNSENT

#define SOCK_SYNSENT 0x15

Connection state.

This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
It is temporarily shown when Sn_SR is changed from SOCK_INIT to SOCK_ESTABLISHED by CONNECT command.
If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to SOCK_ESTABLISHED.
Otherwise, it changes to SOCK_CLOSED after TCPTO (Sn_IR[TIMEOUT] = '1') is occurred.

Definition at line 1051 of file w5200.h.

◆ SOCK_TIME_WAIT

#define SOCK_TIME_WAIT 0x1B

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1092 of file w5200.h.

◆ SOCK_UDP

#define SOCK_UDP 0x22

UDP socket.

This indicates Socket n is opened in UDP mode(Sn_MR(P[3:0]) = 010).
It changes to SOCK_UDP when Sn_MR(P[3:0]) = 010 and OPEN command is ordered.
Unlike TCP mode, data can be transfered without the connection-process.udp socket

Definition at line 1115 of file w5200.h.

◆ WIZCHIP_CREG_BLOCK

#define WIZCHIP_CREG_BLOCK 0x00

Common register block.

Definition at line 58 of file w5200.h.

◆ WIZCHIP_CRITICAL_ENTER

#define WIZCHIP_CRITICAL_ENTER ( ) WIZCHIP.CRIS._enter()

Enter a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_EXIT()

Definition at line 1165 of file w5200.h.

◆ WIZCHIP_CRITICAL_EXIT

#define WIZCHIP_CRITICAL_EXIT ( ) WIZCHIP.CRIS._exit()

Exit a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_ENTER()

Definition at line 1182 of file w5200.h.

◆ WIZCHIP_OFFSET_INC

#define WIZCHIP_OFFSET_INC | ( | ADDR,
 |  | N
 | ) | (ADDR + N)

Increase offset address.

Definition at line 61 of file w5200.h.

◆ WIZCHIP_SREG_BLOCK

#define WIZCHIP_SREG_BLOCK ( N ) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)

Socket N register block.

Definition at line 59 of file w5200.h.


ioLibrary: Ethernet/W5300 Directory Reference

  • Ethernet
  • W5300
W5300 Directory Reference
Directory dependency graph for W5300:

Files

file | w5300.c [code]
file | w5300.h [code]
W5300 HAL implement File.


ioLibrary: Ethernet/W5300/w5300.c File Reference

  • Ethernet
  • W5300
w5300.c File Reference
#include <stdint.h>
#include "wizchip_conf.h"
Include dependency graph for w5300.c:

Go to the source code of this file.


ioLibrary: Ethernet/W5300/w5300.h File Reference

  • Ethernet
  • W5300
Macros | Functions
w5300.h File Reference

W5300 HAL implement File. More...

#include <stdint.h>
#include "wizchip_conf.h"
Include dependency graph for w5300.h:

Go to the source code of this file.

Macros

#define | _WIZCHIP_SN_BASE_ (0x0200)
#define | _WIZCHIP_SN_SIZE_ (0x0040)
#define | WIZCHIP_CREG_BLOCK 0x00
Common register block. More...
#define | WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
Socket N register block. More...
#define | WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
Increase offset address. More...
#define | _W5300_IO_BASE_ _WIZCHIP_IO_BASE_
#define | IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE(ADDR, VAL) WIZCHIP_WRITE(ADDR,VAL)
The defined for legacy chip driver. More...
#define | MR (_WIZCHIP_IO_BASE_)
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | IR (_W5300_IO_BASE_ + 0x02)
Interrupt Register(R/W) More...
#define | _IMR_ (_W5300_IO_BASE_ + 0x04)
Socket Interrupt Mask Register(R/W) More...
#define | SHAR (_W5300_IO_BASE_ + 0x08)
Source MAC Register address(R/W) More...
#define | GAR (_W5300_IO_BASE_ + 0x10)
Gateway IP Register address(R/W) More...
#define | SUBR (_W5300_IO_BASE_ + 0x14)
Subnet mask Register address(R/W) More...
#define | SIPR (_W5300_IO_BASE_ + 0x18)
Source IP Register address(R/W) More...
#define | _RTR_ (_W5300_IO_BASE_ + 0x1C)
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5300_IO_BASE_ + 0x1E)
Retry count register(R/W) More...
#define | TMS01R (_W5300_IO_BASE_ + 0x20)
TX memory size of SOCKET 0 & 1. More...
#define | TMS23R (TMS01R + 2)
TX memory size of SOCKET 2 & 3. More...
#define | TMS45R (TMS01R + 4)
TX memory size of SOCKET 4 & 5. More...
#define | TMS67R (TMS01R + 6)
TX memory size of SOCKET 6 & 7. More...
#define | TMSR0 TMS01R
TX memory size of SOCKET 0. More...
#define | TMSR1 (TMSR0 + 1)
TX memory size of SOCKET 1. More...
#define | TMSR2 (TMSR0 + 2)
TX memory size of SOCKET 2. More...
#define | TMSR3 (TMSR0 + 3)
TX memory size of SOCKET 3. More...
#define | TMSR4 (TMSR0 + 4)
TX memory size of SOCKET 4. More...
#define | TMSR5 (TMSR0 + 5)
TX memory size of SOCKET 5. More...
#define | TMSR6 (TMSR0 + 6)
TX memory size of SOCKET 6. More...
#define | TMSR7 (TMSR0 + 7)
TX memory size of SOCKET 7. More...
#define | RMS01R (_W5300_IO_BASE_ + 0x28)
RX memory size of SOCKET 0 & 1. More...
#define | RMS23R (RMS01R + 2)
RX memory size of SOCKET 2 & 3. More...
#define | RMS45R (RMS01R + 4)
RX memory size of SOCKET 4 & 5. More...
#define | RMS67R (RMS01R + 6)
RX memory size of SOCKET 6 & 7. More...
#define | RMSR0 RMS01R
RX memory size of SOCKET 0. More...
#define | RMSR1 (RMSR0 + 1)
RX memory size of SOCKET 1. More...
#define | RMSR2 (RMSR0 + 2)
RX memory size of SOCKET 2. More...
#define | RMSR3 (RMSR0 + 3)
RX memory size of SOCKET 3. More...
#define | RMSR4 (RMSR0 + 4)
RX memory size of SOCKET 4. More...
#define | RMSR5 (RMSR0 + 5)
RX memory size of SOCKET 5. More...
#define | RMSR6 (RMSR0 + 6)
RX memory size of SOCKET 6. More...
#define | RMSR7 (RMSR0 + 7)
RX memory size of SOCKET 7. More...
#define | MTYPER (_W5300_IO_BASE_ + 0x30)
Memory Type Register. More...
#define | PATR (_W5300_IO_BASE_ + 0x32)
PPPoE Authentication Type register. More...
#define | PTIMER (_W5300_IO_BASE_ + 0x36)
PPP Link Control Protocol Request Timer Register. More...
#define | PMAGICR (_W5300_IO_BASE_ + 0x38)
PPP LCP magic number register. More...
#define | PSIDR (_W5300_IO_BASE_ + 0x3C)
PPPoE session ID register. More...
#define | PDHAR (_W5300_IO_BASE_ + 0x40)
PPPoE destination hardware address register. More...
#define | UIPR (_W5300_IO_BASE_ + 0x48)
Unreachable IP address register. More...
#define | UPORTR (_W5300_IO_BASE_ + 0x4C)
Unreachable port number register. More...
#define | FMTUR (_W5300_IO_BASE_ + 0x4E)
Fragment MTU register. More...
#define | Pn_BRDYR(n) (_W5300_IO_BASE_ + 0x60 + n*4)
PIN 'BRDYn' configure register. More...
#define | Pn_BDPTHR(n) (_W5300_IO_BASE_ + 0x60 + n*4 + 2)
PIN 'BRDYn' buffer depth Register. More...
#define | IDR (_W5300_IO_BASE_ + 0xFE)
W5300 identification register. More...
#define | VERSIONR IDR
#define | Sn_MR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x00)
Socket Mode register(R/W) More...
#define | Sn_CR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x02)
Socket command register(R/W) More...
#define | Sn_IMR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x04)
socket interrupt mask register(R) More...
#define | Sn_IR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x06)
Socket interrupt register(R) More...
#define | Sn_SSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x08)
Socket status register(R) More...
#define | Sn_SR(n) Sn_SSR(n)
For Compatible ioLibrary. Refer to Sn_SSR(n) More...
#define | Sn_PORTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0A)
source port register(R/W) More...
#define | Sn_PORT(n) Sn_PORTR(n)
For compatible ioLibrary. Refer to Sn_PORTR(n). More...
#define | Sn_DHAR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0C)
Peer MAC register address(R/W) More...
#define | Sn_DPORTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x12)
Peer port register address(R/W) More...
#define | Sn_DPORT(n) Sn_DPORTR(n)
For compatible ioLibrary. Refer to Sn_DPORTR. More...
#define | Sn_DIPR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x14)
Peer IP register address(R/W) More...
#define | Sn_MSSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x18)
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_KPALVTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1A)
Keep Alive Timer register(R/W) More...
#define | Sn_PROTOR(n) Sn_KPALVTR(n)
IP Protocol(PROTO) Register(R/W) More...
#define | Sn_TOSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1C)
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TOS(n) Sn_TOSR(n)
For compatible ioLibrary. Refer to Sn_TOSR. More...
#define | Sn_TTLR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1E)
IP Time to live(TTL) Register(R/W) More...
#define | Sn_TTL(n) Sn_TTLR(n)
For compatible ioLibrary. Refer to Sn_TTLR. More...
#define | Sn_TX_WRSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x20)
SOCKETn TX write size register(R/W) More...
#define | Sn_TX_FSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0024)
Transmit free memory size register(R) More...
#define | Sn_RX_RSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0028)
Received data size register(R) More...
#define | Sn_FRAGR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x002C)
Fragment field value in IP header register(R/W) More...
#define | Sn_FRAG(n) Sn_FRAGR(n)
#define | Sn_TX_FIFOR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x2E)
SOCKET n TX FIFO regsiter. More...
#define | Sn_RX_FIFOR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x30)
SOCKET n RX FIFO register. More...
#define | MR_DBW (1 << 15)
#define | MR_MPF (1 << 14)
#define | MR_WDF(X) ((X & 0x07) << 11)
#define | MR_RDH (1 << 10)
#define | MR_FS (1 << 8)
#define | MR_RST (1 << 7)
#define | MR_MT (1 << 5)
#define | MR_PB (1 << 4)
#define | MR_PPPoE (1 << 3)
#define | MR_DBS (1 << 2)
#define | MR_IND (1 << 0)
#define | IR_IPCF (1 << 15)
#define | IR_DPUR (1 << 14)
#define | IR_PPPT (1 << 13)
#define | IR_FMTU (1 << 12)
#define | IR_SnINT(n) (0x01 << n)
#define | Pn_PEN (1 << 7)
#define | Pn_MT (1 << 6)
#define | Pn_PPL (1 << 5)
#define | Pn_SN(n) ((n & 0x07) << 0)
#define | Sn_MR_ALIGN (1 << 8)
Alignment bit of Sn_MR. More...
#define | Sn_MR_MULTI (1 << 7)
Multicasting bit of Sn_MR. More...
#define | Sn_MR_MF (1 << 6)
MAC filter bit of Sn_MR. More...
#define | Sn_MR_IGMPv (1 << 5)
IGMP version bit of Sn_MR details It is valid in case of Sn_MR_MULTI='1' and UDP(Sn_MR_UDP). It configures IGMP version to send IGMP message such as Join/Leave/Report to multicast-group.
0 : IGMPv2, 1 : IGMPv1. More...
#define | Sn_MR_MC Sn_MR_IGMPv
For compatible ioLibrary. More...
#define | Sn_MR_ND (1 << 5)
No delayed ack bit of Sn_MR. More...
#define | Sn_MR_CLOSE 0x00
No mode. More...
#define | Sn_MR_TCP 0x01
TCP mode. More...
#define | Sn_MR_UDP 0x02
UDP mode. More...
#define | Sn_MR_IPRAW 0x03
IP LAYER RAW mode. More...
#define | Sn_MR_MACRAW 0x04
MAC LAYER RAW mode. More...
#define | Sn_MR_PPPoE 0x05
PPPoE mode. More...
#define | SOCK_STREAM Sn_MR_TCP
#define | SOCK_DGRAM Sn_MR_UDP
#define | Sn_CR_OPEN 0x01
Initialize or open a socket. More...
#define | Sn_CR_LISTEN 0x02
Wait connection request in TCP mode(Server mode) More...
#define | Sn_CR_CONNECT 0x04
Send connection request in TCP mode(Client mode) More...
#define | Sn_CR_DISCON 0x08
Send closing request in TCP mode. More...
#define | Sn_CR_CLOSE 0x10
Close socket. More...
#define | Sn_CR_SEND 0x20
Update TX buffer pointer and send data. More...
#define | Sn_CR_SEND_MAC 0x21
Send data with MAC address, so without ARP process. More...
#define | Sn_CR_SEND_KEEP 0x22
Send keep alive message. More...
#define | Sn_CR_RECV 0x40
Update RX buffer pointer and receive data. More...
#define | Sn_CR_PCON 0x23
#define | Sn_CR_PDISCON 0x24
#define | Sn_CR_PCR 0x25
#define | Sn_CR_PCN 0x26
#define | Sn_CR_PCJ 0x27
#define | Sn_IR_PRECV 0x80
#define | Sn_IR_PFAIL 0x40
#define | Sn_IR_PNEXT 0x20
#define | Sn_IR_SENDOK 0x10
#define | Sn_IR_TIMEOUT 0x08
#define | Sn_IR_RECV 0x04
#define | Sn_IR_DISCON 0x02
#define | Sn_IR_CON 0x01
#define | SOCK_CLOSED 0x00
The state of SOCKET intialized or closed. More...
#define | SOCK_ARP 0x01
The state of ARP process. More...
#define | SOCK_INIT 0x13
Initiate state in TCP. More...
#define | SOCK_LISTEN 0x14
Listen state. More...
#define | SOCK_SYNSENT 0x15
Connection state. More...
#define | SOCK_SYNRECV 0x16
Connection state. More...
#define | SOCK_ESTABLISHED 0x17
Success to connect. More...
#define | SOCK_FIN_WAIT 0x18
Closing state. More...
#define | SOCK_CLOSING 0x1A
Closing state. More...
#define | SOCK_TIME_WAIT 0x1B
Closing state. More...
#define | SOCK_CLOSE_WAIT 0x1C
Closing state. More...
#define | SOCK_LAST_ACK 0x1D
Closing state. More...
#define | SOCK_UDP 0x22
UDP socket. More...
#define | SOCK_IPRAW 0x32
IP raw mode socket. More...
#define | SOCK_MACRAW 0x42
MAC raw mode socket. More...
#define | SOCK_PPPoE 0x5F
PPPoE mode socket. More...
#define | IPPROTO_IP 0
#define | IPPROTO_ICMP 1
#define | IPPROTO_IGMP 2
#define | IPPROTO_GGP 3
#define | IPPROTO_TCP 6
#define | IPPROTO_PUP 12
#define | IPPROTO_UDP 17
#define | IPPROTO_IDP 22
#define | IPPROTO_ND 77
#define | IPPROTO_RAW 255
#define | WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
Enter a critical section. More...
#define | WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
Exit a critical section. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, ir & 0xF0FF)
Set Mode Register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xF0FF)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr & 0xF0FF)
Set IMR register. More...
#define | getIMR() (WIZCHIP_READ(_IMR_) & 0xF0FF)
Get IMR register. More...
#define | setSHAR(shar)
Set local MAC address. More...
#define | getSHAR(shar)
Get local MAC address. More...
#define | setGAR(gar)
Set gateway IP address. More...
#define | getGAR(gar)
Get gateway IP address. More...
#define | setSUBR(subr)
Set subnet mask address. More...
#define | getSUBR(subr)
Get subnet mask address. More...
#define | setSIPR(sipr)
Set local IP address. More...
#define | getSIPR(sipr)
Get local IP address. More...
#define | setRTR(rtr) WIZCHIP_WRITE(_RTR_, rtr)
Set RTR register. More...
#define | getRTR() WIZCHIP_READ(_RTR_)
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, ((uint16_t)rcr)&0x00FF)
Set RCR register. More...
#define | getRCR() ((uint8_t)(WIZCHIP_READ(_RCR_) & 0x00FF))
Get RCR register. More...
#define | setTMS01R(tms01r) WIZCHIP_WRITE(TMS01R,tms01r)
Set TMS01R register. More...
#define | getTMS01R() WIZCHIP_READ(TMS01R)
Get TMS01R register. More...
#define | setTMS23R(tms23r) WIZCHIP_WRITE(TMS23R,tms23r)
Set TMS23R register. More...
#define | getTMS23R() WIZCHIP_READ(TMS23R)
Get TMS23R register. More...
#define | setTMS45R(tms45r) WIZCHIP_WRITE(TMS45R,tms45r)
Set TMS45R register. More...
#define | getTMS45R() WIZCHIP_READ(TMS45R)
Get TMS45R register. More...
#define | setTMS67R(tms67r) WIZCHIP_WRITE(TMS67R,tms67r)
Set TMS67R register. More...
#define | getTMS67R() WIZCHIP_READ(TMS67R)
Get TMS67R register. More...
#define | setSn_TXBUF_SIZE(sn, tmsr) setTMSR(sn, tmsr)
For compatible ioLibrary. More...
#define | getSn_TXBUF_SIZE(sn) getTMSR(sn)
For compatible ioLibrary. More...
#define | setRMS01R(rms01r) WIZCHIP_WRITE(RMS01R,rms01r)
Set RMS01R register. More...
#define | getRMS01R() WIZCHIP_READ(RMS01R)
Get RMS01R register. More...
#define | setRMS23R(rms23r) WIZCHIP_WRITE(RMS23R,rms23r)
Set RMS23R register. More...
#define | getRMS23R() WIZCHIP_READ(RMS23R)
Get RMS23R register. More...
#define | setRMS45R(rms45r) WIZCHIP_WRITE(RMS45R,rms45r)
Set RMS45R register. More...
#define | getRMS45R() WIZCHIP_READ(RMS45R)
Get RMS45R register. More...
#define | setRMS67R(rms67r) WIZCHIP_WRITE(RMS67R,rms67r)
Set RMS67R register. More...
#define | getRMS67R() WIZCHIP_READ(RMS67R)
Get RMS67R register. More...
#define | setSn_RXBUF_SIZE(sn, rmsr) setRMSR(sn, rmsr)
For compatible ioLibrary. More...
#define | getSn_RXBUF_SIZE(sn) getRMSR(sn)
For compatible ioLibrary. More...
#define | setMTYPER(mtype) WIZCHIP_WRITE(MTYPER, mtype)
Set MTYPER register. More...
#define | getMTYPER() WIZCHIP_READ(MTYPER)
Get MTYPER register. More...
#define | getPATR() WIZCHIP_READ(PATR)
Get RATR register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ((uint16_t)ptimer) & 0x00FF)
Set PTIMER register. More...
#define | getPTIMER() ((uint8_t)(WIZCHIP_READ(PTIMER) & 0x00FF))
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, ((uint16_t)pmagic) & 0x00FF)
Set PMAGIC register. More...
#define | getPMAGIC() ((uint8_t)(WIZCHIP_READ(PMAGIC) & 0x00FF))
Get PMAGIC register. More...
#define | getPSIDR() WIZCHIP_READ(PSIDR)
Get PSID register. More...
#define | getPDHAR(pdhar)
Get PDHAR register. More...
#define | getUIPR(uipr)
Get unreachable IP address. UIPR. More...
#define | getUPORTR() WIZCHIP_READ(UPORTR)
Get UPORTR register. More...
#define | getFMTUR() WIZCHIP_READ(FMTUR)
Get FMTUR register. More...
#define | getPn_BRDYR(p) ((uint8_t)(WIZCHIP_READ(Pn_BRDYR(p)) & 0x00FF))
Get Pn_BRDYR register. More...
#define | setPn_BRDYR(p, brdyr) WIZCHIP_WRITE(Pn_BRDYR(p), brdyr & 0x00E7)
Set Pn_BRDYR register. More...
#define | getPn_BDPTHR(p) WIZCHIP_READ(Pn_BDPTHR(p))
Get Pn_BDPTHR register. More...
#define | setPn_BDPTHR(p, bdpthr) WIZCHIP_WRITE(Pn_BDPTHR(p),bdpthr)
Set Pn_BDPTHR register. More...
#define | getIDR() WIZCHIP_READ(IDR)
Get IDR register. More...
#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), ((uint16_t)cr) & 0x00FF)
Set Sn_CR register. More...
#define | getSn_CR(sn) ((uint8_t)WIZCHIP_READ(Sn_CR(sn)))
Get Sn_CR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), ((uint16_t)imr) & 0x00FF)
Set Sn_IMR register. More...
#define | getSn_IMR(sn) ((uint8_t)WIZCHIP_READ(Sn_IMR(sn)))
Get Sn_IMR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), ((uint16_t)ir) & 0x00FF)
Set Sn_IR register. More...
#define | getSn_IR(sn) ((uint8_t)WIZCHIP_READ(Sn_IR(sn)))
Get Sn_IR register. More...
#define | getSn_SSR(sn) ((uint8_t)WIZCHIP_READ(Sn_SR(sn)))
Get Sn_SR register. More...
#define | getSn_SR(sn) getSn_SSR(sn)
For compatible ioLibrary. Refer to getSn_SSR(). More...
#define | setSn_PORTR(sn, port) WIZCHIP_WRITE(Sn_PORTR(sn), port)
Set Sn_PORTR register. More...
#define | setSn_PORT(sn, port) setSn_PORTR(sn, port)
For compatible ioLibrary. More...
#define | getSn_PORTR(sn, port) WIZCHIP_READ(Sn_PORTR(sn))
Get Sn_PORTR register. More...
#define | getSn_PORT(sn) getSn_PORTR(sn)
For compatible ioLibrary. More...
#define | setSn_DHAR(sn, dhar)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar)
Get Sn_MR register. More...
#define | setSn_DPORTR(sn, dport) WIZCHIP_WRITE(Sn_DPORTR(sn),dport)
Set Sn_DPORT register. More...
#define | setSn_DPORT(sn, dport) setSn_DPORTR(sn,dport)
For compatible ioLibrary. Refer to Sn_DPORTR. More...
#define | getSn_DPORTR(sn) WIZCHIP_READ(Sn_DPORTR(sn))
Get Sn_DPORT register. More...
#define | getSn_DPORT(sn) getSn_DPORTR(sn)
For compatible ioLibrary. Refer to Sn_DPORTR. More...
#define | setSn_DIPR(sn, dipr)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr)
Get Sn_DIPR register. More...
#define | setSn_MSSR(sn, mss) WIZCHIP_WRITE(Sn_MSSR(sn), mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) WIZCHIP_READ(Sn_MSSR(sn))
Get Sn_MSSR register. More...
#define | setSn_KPALVTR(sn, kpalvt) WIZCHIP_WRITE(Sn_KPALVTR(sn), (WIZCHIP_READ(Sn_KPALVTR(sn)) & 0x00FF) | (((uint16_t)kpalvt)<<8))
Set Sn_KPALVTR register. More...
#define | getSn_KPALVTR(sn) ((uint8_t)(WIZCHIP_READ(Sn_KPALVTR(sn)) >> 8))
Get Sn_KPALVTR register. More...
#define | setSn_PROTOR(sn, proto) WIZCHIP_WRITE(Sn_PROTOR(sn),(WIZCHIP_READ(Sn_PROTOR(sn) & 0xFF00) | (((uint16_t)proto) & 0x00FF))
Set Sn_PROTOR register. More...
#define | setSn_PROTO(sn, proto) setSn_PROTOR(sn,proto)
For compatible ioLibrary. More...
#define | getSn_PROTOR(sn) ((uint8_t)WIZCHIP_READ(Sn_PROTOR(sn)))
Get Sn_PROTOR register. More...
#define | getSn_PROTO(sn) getSn_PROTOR(sn)
For compatible ioLibrary. More...
#define | setSn_TX_WRSR(sn, txwrs)
Set Sn_TX_WRSR register. More...
#define | getSn_TX_WRSR(sn) ( (((uint32_t)WIZCHIP_READ(Sn_TX_WRSR(sn))) << 16) + (((uint32_t)WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WRSR(sn),1))) & 0x0000FFFF) )
Get Sn_TX_WRSR register. More...
#define | setSn_TX_FIFOR(sn, txfifo) WIZCHIP_WRITE(Sn_TX_FIFOR(sn), txfifo);
Set Sn_TX_FIFOR register. More...
#define | getSn_RX_FIFOR(sn) WIZCHIP_READ(Sn_RX_FIFOR(sn));
Get Sn_RX_FIFOR register. More...
#define | setSn_TOSR(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), ((uint16_t)tos) & 0x00FF)
Set Sn_TOSR register. More...
#define | setSn_TOS(sn, tos) setSn_TOSR(sn,tos)
For compatible ioLibrar. More...
#define | getSn_TOSR(sn) ((uint8_t)WIZCHIP_READ(Sn_TOSR(sn)))
Get Sn_TOSR register. More...
#define | getSn_TOS(sn) getSn_TOSR(sn)
For compatible ioLibrar. More...
#define | setSn_TTLR(sn, ttl) WIZCHIP_WRITE(Sn_TTLR(sn), ((uint16_t)ttl) & 0x00FF)
Set Sn_TTLR register. More...
#define | setSn_TTL(sn, ttl) setSn_TTLR(sn,ttl)
For compatible ioLibrary. More...
#define | getSn_TTLR(sn) ((uint8_t)WIZCHIP_READ(Sn_TTL(sn)))
Get Sn_TTLR register. More...
#define | getSn_TTL(sn) getSn_TTLR(sn)
For compatible ioLibrary. More...
#define | setSn_FRAGR(sn, frag) WIZCHIP_WRITE(Sn_FRAGR(sn), (uint16_t)(frag >>8))
Set Sn_FRAGR register. More...
#define | setSn_FRAG(sn, frag) setSn_FRAGR(sn,flag)
#define | getSn_FRAGR(sn) (WIZCHIP_READ(Sn_FRAG(sn)) << 8)
Get Sn_FRAGR register. More...
#define | getSn_FRAG(sn) getSn_FRAGR(sn)
#define | getSn_RxMAX(sn) (((uint32_t)getSn_RXBUF_SIZE(sn)) << 10)
Socket_register_access_function_W5300. More...
#define | getSn_TxMAX(sn) (((uint32_t)getSn_TXBUF_SIZE(sn)) << 10)
Socket_register_access_function_W5300. More...

Functions

uint16_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint16_t wb)
It writes 1 byte value to a register. More...
void | setTMSR (uint8_t sn, uint8_t tmsr)
Set TMSR0 ~ TMSR7 register. More...
uint8_t | getTMSR (uint8_t sn)
Get TMSR0 ~ TMSR7 register. More...
void | setRMSR (uint8_t sn, uint8_t rmsr)
Set RMS01R ~ RMS67R register. More...
uint8_t | getRMSR (uint8_t sn)
Get RMS01R ~ RMS67R register. More...
uint32_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint32_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint32_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint32_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint32_t len)
It discard the received data in RX memory. More...

Detailed Description

W5300 HAL implement File.

W5300 HAL Header File.

Version
1.0.0
Date
2015/05/01
Revision history
<2015/05/01> 1st Released for integrating with ioLibrary Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. >> https://github.com/Wiznet/ioLibrary_Driver
Author
MidnightCow
Copyright

Copyright (c) 2015, 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 w5300.h.

Macro Definition Documentation

◆ _W5300_IO_BASE_

#define _W5300_IO_BASE_ _WIZCHIP_IO_BASE_

Definition at line 63 of file w5300.h.

◆ _WIZCHIP_SN_BASE_

#define _WIZCHIP_SN_BASE_ (0x0200)

Definition at line 53 of file w5300.h.

◆ _WIZCHIP_SN_SIZE_

#define _WIZCHIP_SN_SIZE_ (0x0040)

Definition at line 54 of file w5300.h.

◆ getSn_DPORT

#define getSn_DPORT ( sn ) getSn_DPORTR(sn)

For compatible ioLibrary. Refer to Sn_DPORTR.

Definition at line 2047 of file w5300.h.

◆ getSn_FRAG

#define getSn_FRAG ( sn ) getSn_FRAGR(sn)

Definition at line 2257 of file w5300.h.

◆ getSn_PORT

#define getSn_PORT ( sn ) getSn_PORTR(sn)

For compatible ioLibrary.

Definition at line 1993 of file w5300.h.

◆ getSn_PROTO

#define getSn_PROTO ( sn ) getSn_PROTOR(sn)

For compatible ioLibrary.

Definition at line 2135 of file w5300.h.

◆ getSn_RXBUF_SIZE

#define getSn_RXBUF_SIZE ( sn ) getRMSR(sn)

For compatible ioLibrary.

Definition at line 1719 of file w5300.h.

◆ getSn_RxMAX

#define getSn_RxMAX ( sn ) (((uint32_t)getSn_RXBUF_SIZE(sn)) << 10)

Socket_register_access_function_W5300.

Gets the max buffer size of socket sn passed as parameter.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint32_t. Value of Socket n RX max buffer size.

Definition at line 2270 of file w5300.h.

◆ getSn_SR

#define getSn_SR ( sn ) getSn_SSR(sn)

For compatible ioLibrary. Refer to getSn_SSR().

Definition at line 1971 of file w5300.h.

◆ getSn_TOS

#define getSn_TOS ( sn ) getSn_TOSR(sn)

For compatible ioLibrar.

Definition at line 2213 of file w5300.h.

◆ getSn_TTL

#define getSn_TTL ( sn ) getSn_TTLR(sn)

For compatible ioLibrary.

Definition at line 2235 of file w5300.h.

◆ getSn_TXBUF_SIZE

#define getSn_TXBUF_SIZE ( sn ) getTMSR(sn)

For compatible ioLibrary.

Definition at line 1627 of file w5300.h.

◆ getSn_TxMAX

#define getSn_TxMAX ( sn ) (((uint32_t)getSn_TXBUF_SIZE(sn)) << 10)

Socket_register_access_function_W5300.

Gets the max buffer size of socket sn passed as parameters.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint32_t. Value of Socket n TX max buffer size.

Definition at line 2279 of file w5300.h.

◆ IINCHIP_READ

#define IINCHIP_READ ( ADDR ) WIZCHIP_READ(ADDR)

The defined for legacy chip driver.

Definition at line 75 of file w5300.h.

◆ IINCHIP_WRITE

#define IINCHIP_WRITE | ( | ADDR,
 |  | VAL
 | ) | WIZCHIP_WRITE(ADDR,VAL)

The defined for legacy chip driver.

Definition at line 76 of file w5300.h.

◆ IPPROTO_GGP

#define IPPROTO_GGP 3

Definition at line 1263 of file w5300.h.

◆ IPPROTO_ICMP

#define IPPROTO_ICMP 1

Definition at line 1261 of file w5300.h.

◆ IPPROTO_IDP

#define IPPROTO_IDP 22

Definition at line 1267 of file w5300.h.

◆ IPPROTO_IGMP

#define IPPROTO_IGMP 2

Definition at line 1262 of file w5300.h.

◆ IPPROTO_IP

#define IPPROTO_IP 0

Definition at line 1260 of file w5300.h.

◆ IPPROTO_ND

#define IPPROTO_ND 77

Definition at line 1268 of file w5300.h.

◆ IPPROTO_PUP

#define IPPROTO_PUP 12

Definition at line 1265 of file w5300.h.

◆ IPPROTO_RAW

#define IPPROTO_RAW 255

Definition at line 1269 of file w5300.h.

◆ IPPROTO_TCP

#define IPPROTO_TCP 6

Definition at line 1264 of file w5300.h.

◆ IPPROTO_UDP

#define IPPROTO_UDP 17

Definition at line 1266 of file w5300.h.

◆ IR_DPUR

#define IR_DPUR (1 << 14)

Destination port unreachable bit of IR. To clear, Write the bit to '1'.

Definition at line 906 of file w5300.h.

◆ IR_FMTU

#define IR_FMTU (1 << 12)

Fragment MTU bit of IR. To clear, Write the bit to '1'.

Definition at line 908 of file w5300.h.

◆ IR_IPCF

#define IR_IPCF (1 << 15)

IP conflict bit of IR. To clear, Write the bit to '1'.

Definition at line 905 of file w5300.h.

◆ IR_PPPT

#define IR_PPPT (1 << 13)

PPPoE terminate bit of IR. To clear, Write the bit to '1'.

Definition at line 907 of file w5300.h.

◆ IR_SnINT

#define IR_SnINT ( n ) (0x01 << n)

SOCKETn interrupt occurrence bit of IR. To clear, Clear Sn_IR

Definition at line 909 of file w5300.h.

◆ MR_DBS

#define MR_DBS (1 << 2)

Data bus swap of MR. Valid only 16bit mode (0 : No swap, 1 : Swap)

Definition at line 898 of file w5300.h.

◆ MR_DBW

#define MR_DBW (1 << 15)

Data bus width bit of MR. Read Only. (0 : 8Bit, 1 : 16Bit)

Definition at line 889 of file w5300.h.

◆ MR_FS

#define MR_FS (1 << 8)

FIFO swap bit of MR. Swap MSB & LSB of Sn_TX_FIFOR & Sn_RX_FIFOR (0 : No swap, 1 : Swap)

Definition at line 893 of file w5300.h.

◆ MR_IND

#define MR_IND (1 << 0)

Indirect mode bit of MR. (0 : Direct mode, 1 : Indirect mode)

Definition at line 899 of file w5300.h.

◆ MR_MPF

#define MR_MPF (1 << 14)

Mac layer pause frame bit of MR. (0 : Disable, 1 : Enable)

Definition at line 890 of file w5300.h.

◆ MR_MT

#define MR_MT (1 << 5)

Memory test bit of MR. (0 : Normal, 1 : Internal Socket memory write & read Test)

Definition at line 895 of file w5300.h.

◆ MR_PB

#define MR_PB (1 << 4)

Ping block bit of MR. (0 : Unblock, 1 : Block)

Definition at line 896 of file w5300.h.

◆ MR_PPPoE

#define MR_PPPoE (1 << 3)

PPPoE bit of MR. (0 : No use PPPoE, 1: Use PPPoE)

Definition at line 897 of file w5300.h.

◆ MR_RDH

#define MR_RDH (1 << 10)

Read data hold time bit of MR. Hold Data on DATA bus during 2 * PLL_CLK after CS high

Definition at line 892 of file w5300.h.

◆ MR_RST

#define MR_RST (1 << 7)

S/W reset bit of MR. (0 : Normal Operation, 1 : Reset (automatically clear after reset))

Definition at line 894 of file w5300.h.

◆ MR_WDF

#define MR_WDF ( X ) ((X & 0x07) << 11)

Write data fetch time bit of MR. Fetch Data from DATA bus after PLL_CLK * MR_WDF[2:0]

Definition at line 891 of file w5300.h.

◆ Pn_MT

#define Pn_MT (1 << 6)

PIN memory type bit of Pn_BRDYR.

Definition at line 915 of file w5300.h.

◆ Pn_PEN

#define Pn_PEN (1 << 7)

PIN 'BRDYn' enable bit of Pn_BRDYR.

Definition at line 914 of file w5300.h.

◆ Pn_PPL

#define Pn_PPL (1 << 5)

PIN Polarity bit of Pn_BRDYR.

Definition at line 916 of file w5300.h.

◆ Pn_SN

#define Pn_SN ( n ) ((n & 0x07) << 0)

What socket to monitor.

Definition at line 917 of file w5300.h.

◆ RMSR2

#define RMSR2 (RMSR0 + 2)

RX memory size of SOCKET 2.

refer to RMS01R

Definition at line 445 of file w5300.h.

◆ setSn_DPORT

#define setSn_DPORT | ( | sn,
 |  | dport
 | ) | setSn_DPORTR(sn,dport)

For compatible ioLibrary. Refer to Sn_DPORTR.

Definition at line 2033 of file w5300.h.

◆ setSn_FRAG

#define setSn_FRAG | ( | sn,
 |  | frag
 | ) | setSn_FRAGR(sn,flag)

Definition at line 2246 of file w5300.h.

◆ setSn_PORT

#define setSn_PORT | ( | sn,
 |  | port
 | ) | setSn_PORTR(sn, port)

For compatible ioLibrary.

Definition at line 1982 of file w5300.h.

◆ setSn_PROTO

#define setSn_PROTO | ( | sn,
 |  | proto
 | ) | setSn_PROTOR(sn,proto)

For compatible ioLibrary.

Definition at line 2124 of file w5300.h.

◆ setSn_RXBUF_SIZE

#define setSn_RXBUF_SIZE | ( | sn,
 |  | rmsr
 | ) | setRMSR(sn, rmsr)

For compatible ioLibrary.

Definition at line 1709 of file w5300.h.

◆ setSn_TOS

#define setSn_TOS | ( | sn,
 |  | tos
 | ) | setSn_TOSR(sn,tos)

For compatible ioLibrar.

Definition at line 2202 of file w5300.h.

◆ setSn_TTL

#define setSn_TTL | ( | sn,
 |  | ttl
 | ) | setSn_TTLR(sn,ttl)

For compatible ioLibrary.

Definition at line 2224 of file w5300.h.

◆ setSn_TXBUF_SIZE

#define setSn_TXBUF_SIZE | ( | sn,
 |  | tmsr
 | ) | setTMSR(sn, tmsr)

For compatible ioLibrary.

Definition at line 1617 of file w5300.h.

◆ Sn_CR_CLOSE

#define Sn_CR_CLOSE 0x10

Close socket.

Sn_SR is changed to SOCK_CLOSED.

Definition at line 1076 of file w5300.h.

◆ Sn_CR_CONNECT

#define Sn_CR_CONNECT 0x04

Send connection request in TCP mode(Client mode)

To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by Sn_DIPR & Sn_DPORT(destination address & port). If the connect-request is successful, the Sn_SR is changed to SOCK_ESTABLISHED and the Sn_IR(0) becomes

The connect-request fails in the following three cases.

  1. When a ARPTO occurs (Sn_IR[3] = '1') because destination hardware address is not acquired through the ARP-process.
  2. When a SYN/ACK packet is not received and TCPTO (Sn_IR(3) = )
  3. When a RST packet is received instead of a SYN/ACK packet. In these cases, Sn_SR is changed to SOCK_CLOSED.
    Note
    This is valid only in TCP mode and operates when Socket n acts as TCP client

Definition at line 1057 of file w5300.h.

◆ Sn_CR_DISCON

#define Sn_CR_DISCON 0x08

Send closing request in TCP mode.

Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.

Active close
it transmits disconnect-request(FIN packet) to the connected peer
Passive close
When FIN packet is received from peer, a FIN packet is replied back to the peer.

When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), Sn_SR is changed to SOCK_CLOSED.
Otherwise, TCPTO occurs (Sn_IR[3]='1') and then Sn_SR is changed to SOCK_CLOSED.

Note
Valid only in TCP mode.

Definition at line 1070 of file w5300.h.

◆ Sn_CR_LISTEN

#define Sn_CR_LISTEN 0x02

Wait connection request in TCP mode(Server mode)

This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP). In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client The Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN. When a TCP clientconnection request is successfully established, the Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes But when a TCP clientconnection request is failed, Sn_IR(3) becomes and the status of Sn_SR changes to SOCK_CLOSED.

Definition at line 1045 of file w5300.h.

◆ Sn_CR_OPEN

#define Sn_CR_OPEN 0x01

Initialize or open a socket.

Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). The table below shows the value of Sn_SR corresponding to Sn_MR.

Sn_MR (P[3:0]) | Sn_SR
Sn_MR_CLOSE (000) |
Sn_MR_TCP (001) | SOCK_INIT (0x13)
Sn_MR_UDP (010) | SOCK_UDP (0x22)
Sn_MR_IPRAW (010) | SOCK_IPRAW (0x32)
Sn_MR_MACRAW (100) | SOCK_MACRAW (0x42)
Sn_MR_PPPoE (101) | SOCK_PPPoE (0x5F)

Definition at line 1034 of file w5300.h.

◆ Sn_CR_PCJ

#define Sn_CR_PCJ 0x27

In each phase, it transmits REJECT message. Refer to Sn_CR

Definition at line 1114 of file w5300.h.

◆ Sn_CR_PCN

#define Sn_CR_PCN 0x26

In each phase, it transmits NAK message. Refer to Sn_CR

Definition at line 1113 of file w5300.h.

◆ Sn_CR_PCON

#define Sn_CR_PCON 0x23

PPPoE connection begins by transmitting PPPoE discovery packet. Refer to Sn_CR

Definition at line 1110 of file w5300.h.

◆ Sn_CR_PCR

#define Sn_CR_PCR 0x25

In each phase, it transmits REQ message. Refer to Sn_CR

Definition at line 1112 of file w5300.h.

◆ Sn_CR_PDISCON

#define Sn_CR_PDISCON 0x24

Closes PPPoE connection. Refer to Sn_CR

Definition at line 1111 of file w5300.h.

◆ Sn_CR_RECV

#define Sn_CR_RECV 0x40

Update RX buffer pointer and receive data.

RECV completes the processing of the received data in Socket n RX Buffer thru Sn_RX_FIFOR).
For more details, refer to Socket n RX Received Size Register (Sn_RX_RSR) & Sn_RX_FIFOR.RECV command value of Sn_CR

Definition at line 1108 of file w5300.h.

◆ Sn_CR_SEND

#define Sn_CR_SEND 0x20

Update TX buffer pointer and send data.

SEND command transmits all the data in the Socket n TX buffer thru Sn_TX_FIFOR.
For more details, please refer to Socket n TX Free Size Register (Sn_TX_FSR) and Socket TX Write Size register (Sn_TX_WRSR).

Definition at line 1083 of file w5300.h.

◆ Sn_CR_SEND_KEEP

#define Sn_CR_SEND_KEEP 0x22

Send keep alive message.

It checks the connection status by sending 1byte keep-alive packet.
If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur.

Note
Valid only in TCP mode.

Definition at line 1101 of file w5300.h.

◆ Sn_CR_SEND_MAC

#define Sn_CR_SEND_MAC 0x21

Send data with MAC address, so without ARP process.

The basic operation is same as SEND.
Normally SEND command transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).
But SEND_MAC command transmits data without the automatic ARP-process.
In this case, the destination hardware address is acquired from Sn_DHAR configured by host, instead of APR-process.

Note
Valid only in UDP mode.

Definition at line 1093 of file w5300.h.

◆ Sn_DPORT

#define Sn_DPORT ( n ) Sn_DPORTR(n)

For compatible ioLibrary. Refer to Sn_DPORTR.

Definition at line 754 of file w5300.h.

◆ Sn_FRAG

#define Sn_FRAG ( n ) Sn_FRAGR(n)

Definition at line 849 of file w5300.h.

◆ Sn_IR_CON

#define Sn_IR_CON 0x01

It is set one time when the connection is successful and then Sn_SR is changed to SOCK_ESTABLISHED.

Definition at line 1127 of file w5300.h.

◆ Sn_IR_DISCON

#define Sn_IR_DISCON 0x02

It is set when FIN or FIN/ACK packet is received from a peer. Refer to Sn_IR

Definition at line 1126 of file w5300.h.

◆ Sn_IR_PFAIL

#define Sn_IR_PFAIL 0x40

It is set in the case that PAP authentication is failed. Refer to Sn_IR

Definition at line 1121 of file w5300.h.

◆ Sn_IR_PNEXT

#define Sn_IR_PNEXT 0x20

It is set in the case that the phase is changed during PPPoE connection process. Sn_IR

Definition at line 1122 of file w5300.h.

◆ Sn_IR_PRECV

#define Sn_IR_PRECV 0x80

It is set in the case that option data which is not supported is received. Refer to Sn_IR

Definition at line 1120 of file w5300.h.

◆ Sn_IR_RECV

#define Sn_IR_RECV 0x04

It is set whenever data is received from a peer. Refer to Sn_IR

Definition at line 1125 of file w5300.h.

◆ Sn_IR_SENDOK

#define Sn_IR_SENDOK 0x10

It is set when SEND command is completed. Refer to Sn_IR

Definition at line 1123 of file w5300.h.

◆ Sn_IR_TIMEOUT

#define Sn_IR_TIMEOUT 0x08

It is set when ARPTO or TCPTO is occured. Refer to Sn_IR

Definition at line 1124 of file w5300.h.

◆ Sn_MR_ALIGN

#define Sn_MR_ALIGN (1 << 8)

Alignment bit of Sn_MR.

It is valid only in the TCP (Sn_MR_TCP) with TCP communication, when every the received DATA packet size is of even number and set as '1', data receiving performance can be improved by removing PACKET-INFO(data size) that is attached to every the received DATA packet.

Definition at line 929 of file w5300.h.

◆ Sn_MR_CLOSE

#define Sn_MR_CLOSE 0x00

No mode.

This configures the protocol mode of Socket n.

See also
Sn_MR

Definition at line 973 of file w5300.h.

◆ Sn_MR_IGMPv

#define Sn_MR_IGMPv (1 << 5)

IGMP version bit of Sn_MR details It is valid in case of Sn_MR_MULTI='1' and UDP(Sn_MR_UDP). It configures IGMP version to send IGMP message such as Join/Leave/Report to multicast-group.
0 : IGMPv2, 1 : IGMPv1.

Definition at line 955 of file w5300.h.

◆ Sn_MR_IPRAW

#define Sn_MR_IPRAW 0x03

IP LAYER RAW mode.

This configures the protocol mode of Socket n.

See also
Sn_MR Protocol bits of Sn_MR.

Definition at line 994 of file w5300.h.

◆ Sn_MR_MACRAW

#define Sn_MR_MACRAW 0x04

MAC LAYER RAW mode.

This configures the protocol mode of Socket 0.

See also
Sn_MR
Note
MACRAW mode should be only used in Socket 0.

Definition at line 1002 of file w5300.h.

◆ Sn_MR_MC

#define Sn_MR_MC Sn_MR_IGMPv

For compatible ioLibrary.

Definition at line 956 of file w5300.h.

◆ Sn_MR_MF

#define Sn_MR_MF (1 << 6)

MAC filter bit of Sn_MR.

It is valid in MACRAW(Sn_MR_MACRAW). When this bit is set as ‘1’, W5300 can receive packet that is belong in itself or broadcasting. When this bit is set as ‘0’, W5300 can receive all packets on Ethernet. When using the hybrid TCP/IP stack, it is recommended to be set as ‘1’ for reducing the receiving overhead of host.
0 : Disable, 1 : Enable

Definition at line 947 of file w5300.h.

◆ Sn_MR_MULTI

#define Sn_MR_MULTI (1 << 7)

Multicasting bit of Sn_MR.

It is valid only in UDP (Sn_MR_UDP). In order to implement multicasting, set the IP address and port number in Sn_DIPR and Sn_DPORTR respectively before "OPEN" command(Sn_CR_OPEN).
0 : Disable, 1 : Enable

Definition at line 937 of file w5300.h.

◆ Sn_MR_ND

#define Sn_MR_ND (1 << 5)

No delayed ack bit of Sn_MR.

It is valid in TCP(Sn_MR_TCP). In case that it is set as '1', ACK packet is transmitted right after receiving DATA packet from the peer. It is recommended to be set as '1' for TCP performance improvement. In case that it is set as '0', ACK packet is transmitted after the time set in RTR regardless of DATA packet receipt.
0 : No use, 1 : Use

Definition at line 966 of file w5300.h.

◆ Sn_MR_PPPoE

#define Sn_MR_PPPoE 0x05

PPPoE mode.

This configures the protocol mode of Socket 0.

See also
Sn_MR
Note
PPPoE mode should be only used in Socket 0.Protocol bits of Sn_MR.

Definition at line 1010 of file w5300.h.

◆ Sn_MR_TCP

#define Sn_MR_TCP 0x01

TCP mode.

This configures the protocol mode of Socket n.

See also
Sn_MR

Definition at line 980 of file w5300.h.

◆ Sn_MR_UDP

#define Sn_MR_UDP 0x02

UDP mode.

This configures the protocol mode of Socket n.

See also
Sn_MRProtocol bits of Sn_MR.

Definition at line 987 of file w5300.h.

◆ Sn_PORT

#define Sn_PORT ( n ) Sn_PORTR(n)

For compatible ioLibrary. Refer to Sn_PORTR(n).

Definition at line 735 of file w5300.h.

◆ Sn_RX_RSR

#define Sn_RX_RSR ( n ) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0028)

Received data size register(R)

Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. Sn_RX_RSR does not exceed the RMSR such as RMS01SR and is calculated as the difference between ?Socket n RX Write Pointer (Sn_RX_WR)and Socket n RX Read Pointer (Sn_RX_RD)

Definition at line 841 of file w5300.h.

◆ Sn_SR

#define Sn_SR ( n ) Sn_SSR(n)

For Compatible ioLibrary. Refer to Sn_SSR(n)

Definition at line 726 of file w5300.h.

◆ Sn_TOS

#define Sn_TOS ( n ) Sn_TOSR(n)

For compatible ioLibrary. Refer to Sn_TOSR.

Definition at line 803 of file w5300.h.

◆ Sn_TTL

#define Sn_TTL ( n ) Sn_TTLR(n)

For compatible ioLibrary. Refer to Sn_TTLR.

Definition at line 812 of file w5300.h.

◆ SOCK_ARP

#define SOCK_ARP 0x01

The state of ARP process.

It is temporary state for getting a peer MAC address when TCP connect or UDP Data Send
When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to SOCK_CLOSED regardless of previous status.ARP-request is transmitted in order to acquire destination hardware address.

Definition at line 1144 of file w5300.h.

◆ SOCK_CLOSE_WAIT

#define SOCK_CLOSE_WAIT 0x1C

Closing state.

This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.
This is half-closing status, and data can be transferred.
For full-closing, Sn_CR_DISCON command is used. But For just-closing, Sn_CR_CLOSE command is used.

Definition at line 1218 of file w5300.h.

◆ SOCK_CLOSED

#define SOCK_CLOSED 0x00

The state of SOCKET intialized or closed.

This indicates that Socket n is released.
When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to SOCK_CLOSED regardless of previous status.

Definition at line 1137 of file w5300.h.

◆ SOCK_CLOSING

#define SOCK_CLOSING 0x1A

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1202 of file w5300.h.

◆ SOCK_DGRAM

#define SOCK_DGRAM Sn_MR_UDP

For Berkeley Socket API, Refer to Sn_MR_UDP

Definition at line 1013 of file w5300.h.

◆ SOCK_ESTABLISHED

#define SOCK_ESTABLISHED 0x17

Success to connect.

This indicates the status of the connection of Socket n.
It changes to SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring SOCK_LISTEN, or when the Sn_CR_CONNECT command is successful.
During SOCK_ESTABLISHED, DATA packet can be transferred using Sn_CR_SEND or Sn_CR_RECV command.

Definition at line 1186 of file w5300.h.

◆ SOCK_FIN_WAIT

#define SOCK_FIN_WAIT 0x18

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout(Sn_CR_TIMTEOUT = '1') is occurred, these change to SOCK_CLOSED.

Definition at line 1194 of file w5300.h.

◆ SOCK_INIT

#define SOCK_INIT 0x13

Initiate state in TCP.

This indicates Socket n is opened with TCP mode.
It is changed to SOCK_INIT when Sn_MR(P[3:0]) = '001' and OPEN command(Sn_CR_OPEN) is ordered.
After SOCK_INIT, user can use LISTEN(Sn_CR_LISTEN)/CONNECT(Sn_CR_CONNET) command.

Definition at line 1152 of file w5300.h.

◆ SOCK_IPRAW

#define SOCK_IPRAW 0x32

IP raw mode socket.

TThe socket is opened in IPRAW mode. The SOCKET status is change to SOCK_IPRAW when Sn_MR (P3:P0) is Sn_MR_IPRAW and Sn_CR_OPEN command is used.
IP Packet can be transferred without a connection similar to the UDP mode.

Definition at line 1241 of file w5300.h.

◆ SOCK_LAST_ACK

#define SOCK_LAST_ACK 0x1D

Closing state.

This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.
It changes to SOCK_CLOSED when Socket n received the response successfully, or when timeout (Sn_IR_TIMEOUT = '1') is occurred.

Definition at line 1225 of file w5300.h.

◆ SOCK_LISTEN

#define SOCK_LISTEN 0x14

Listen state.

This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.
It will change to SOCK_ESTALBLISHED when the connection-request is successfully accepted.
Otherwise it will change to SOCK_CLOSED after TCPTO (Sn_IR_TIMEOUT = '1') is occurred.

Definition at line 1160 of file w5300.h.

◆ SOCK_MACRAW

#define SOCK_MACRAW 0x42

MAC raw mode socket.

This indicates Socket 0 is opened in MACRAW mode (Sn_MR(P[3:0]) = '100' and n = 0) and is valid only in Socket 0.
It changes to SOCK_MACRAW when Sn_MR(P[3:0] = 100)and @ ref Sn_CR_OPEN command is ordered.
Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process.SOCKET0 is open as MACRAW mode.

Definition at line 1249 of file w5300.h.

◆ SOCK_PPPoE

#define SOCK_PPPoE 0x5F

PPPoE mode socket.

It is the status that SOCKET0 is opened as PPPoE mode. It is changed to SOCK_PPPoE in case of Sn_CR_OPEN command is ordered and Sn_MR(P3:P0)= Sn_MR_PPPoE
It is temporarily used at the PPPoE connection.SOCKET0 is open as PPPoE mode.

Definition at line 1257 of file w5300.h.

◆ SOCK_STREAM

#define SOCK_STREAM Sn_MR_TCP

For Berkeley Socket API, Refer to Sn_MR_TCP

Definition at line 1012 of file w5300.h.

◆ SOCK_SYNRECV

#define SOCK_SYNRECV 0x16

Connection state.

It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to SOCK_ESTABLISHED.
If not, it changes to SOCK_CLOSED after timeout (Sn_IR_TIMEOUT = '1') is occurred.

Definition at line 1177 of file w5300.h.

◆ SOCK_SYNSENT

#define SOCK_SYNSENT 0x15

Connection state.

This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
It is temporarily shown when Sn_SR is changed from SOCK_INIT to SOCK_ESTABLISHED by Sn_CR_CONNECT command.
If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to SOCK_ESTABLISHED.
Otherwise, it changes to SOCK_CLOSED after TCPTO (Sn_IR_TIMEOUT = '1') is occurred.

Definition at line 1169 of file w5300.h.

◆ SOCK_TIME_WAIT

#define SOCK_TIME_WAIT 0x1B

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1210 of file w5300.h.

◆ SOCK_UDP

#define SOCK_UDP 0x22

UDP socket.

This indicates Socket n is opened in UDP mode(Sn_MR(P[3:0]) = '010').
It changes to SOCK_UDP when Sn_MR(P[3:0]) = '010' and Sn_CR_OPEN command is ordered.
Unlike TCP mode, data can be transfered without the connection-process.

Definition at line 1233 of file w5300.h.

◆ VERSIONR

#define VERSIONR IDR

Definition at line 602 of file w5300.h.

◆ WIZCHIP_CREG_BLOCK

#define WIZCHIP_CREG_BLOCK 0x00

Common register block.

Definition at line 57 of file w5300.h.

◆ WIZCHIP_CRITICAL_ENTER

#define WIZCHIP_CRITICAL_ENTER ( ) WIZCHIP.CRIS._enter()

Enter a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE()
WIZCHIP_CRITICAL_EXIT()

Definition at line 1283 of file w5300.h.

◆ WIZCHIP_CRITICAL_EXIT

#define WIZCHIP_CRITICAL_EXIT ( ) WIZCHIP.CRIS._exit()

Exit a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE()
WIZCHIP_CRITICAL_ENTER()

Definition at line 1300 of file w5300.h.

◆ WIZCHIP_OFFSET_INC

#define WIZCHIP_OFFSET_INC | ( | ADDR,
 |  | N
 | ) | (ADDR + N)

Increase offset address.

Definition at line 60 of file w5300.h.

◆ WIZCHIP_SREG_BLOCK

#define WIZCHIP_SREG_BLOCK ( N ) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)

Socket N register block.

Definition at line 58 of file w5300.h.


ioLibrary: Ethernet/W5500 Directory Reference

  • Ethernet
  • W5500
W5500 Directory Reference
Directory dependency graph for W5500:

Files

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


ioLibrary: 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

◆ _W5500_SPI_FDM_OP_LEN1_

#define _W5500_SPI_FDM_OP_LEN1_ 0x01

Definition at line 58 of file w5500.c.

◆ _W5500_SPI_FDM_OP_LEN2_

#define _W5500_SPI_FDM_OP_LEN2_ 0x02

Definition at line 59 of file w5500.c.

◆ _W5500_SPI_FDM_OP_LEN4_

#define _W5500_SPI_FDM_OP_LEN4_ 0x03

Definition at line 60 of file w5500.c.

◆ _W5500_SPI_VDM_OP_

#define _W5500_SPI_VDM_OP_ 0x00

Definition at line 57 of file w5500.c.


ioLibrary: Ethernet/W5500/w5500.h File Reference

  • Ethernet
  • W5500
Macros | Functions
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.

Macros

#define | _W5500_IO_BASE_ 0x00000000
#define | _W5500_SPI_READ_ (0x00 << 2)
#define | _W5500_SPI_WRITE_ (0x01 << 2)
#define | WIZCHIP_CREG_BLOCK 0x00
#define | WIZCHIP_SREG_BLOCK(N) (1+4*N)
#define | WIZCHIP_TXBUF_BLOCK(N) (2+4*N)
#define | WIZCHIP_RXBUF_BLOCK(N) (3+4*N)
#define | WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8))
#define | IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE(ADDR, VAL) WIZCHIP_WRITE(ADDR,VAL)
The defined for legacy chip driver. More...
#define | IINCHIP_READ_BUF(ADDR, BUF, LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | IINCHIP_WRITE_BUF(ADDR, BUF, LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
The defined for legacy chip driver. More...
#define | MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Mode Register address(R/W)
MR is used for S/W reset, ping block mode, PPPoE mode and etc. More...
#define | GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Gateway IP Register address(R/W) More...
#define | SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Subnet mask Register address(R/W) More...
#define | SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Source MAC Register address(R/W) More...
#define | SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3))
Source IP Register address(R/W) More...
#define | INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Set Interrupt low level timer register address(R/W) More...
#define | IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Interrupt Register(R/W) More...
#define | _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Interrupt mask register(R/W) More...
#define | SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Socket Interrupt Register(R/W) More...
#define | SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Socket Interrupt Mask Register(R/W) More...
#define | _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Timeout register address( 1 is 100us )(R/W) More...
#define | _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))
Retry count register(R/W) More...
#define | PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP LCP Request Timer register in PPPoE mode(R/W) More...
#define | PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP LCP Magic number register in PPPoE mode(R/W) More...
#define | PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP Destination MAC Register address(R/W) More...
#define | PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP Session Identification Register(R/W) More...
#define | PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3))
PPP Maximum Segment Size(MSS) register(R/W) More...
#define | UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3))
Unreachable IP register address in UDP mode(R) More...
#define | UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3))
Unreachable Port register address in UDP mode(R) More...
#define | PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3))
PHY Status Register(R/W) More...
#define | VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3))
chip version register address(R) More...
#define | Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
socket Mode register(R/W) More...
#define | Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Socket command register(R/W) More...
#define | Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Socket interrupt register(R) More...
#define | Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Socket status register(R) More...
#define | Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
source port register(R/W) More...
#define | Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Peer MAC register address(R/W) More...
#define | Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Peer IP register address(R/W) More...
#define | Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Peer port register address(R/W) More...
#define | Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Maximum Segment Size(Sn_MSSR0) register address(R/W) More...
#define | Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
IP Type of Service(TOS) Register(R/W) More...
#define | Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
IP Time to live(TTL) Register(R/W) More...
#define | Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Receive memory size register(R/W) More...
#define | Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit memory size register(R/W) More...
#define | Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit free memory size register(R) More...
#define | Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit memory read pointer register address(R) More...
#define | Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Transmit memory write pointer register address(R/W) More...
#define | Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Received data size register(R) More...
#define | Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Read point of Receive memory(R/W) More...
#define | Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Write point of Receive memory(R) More...
#define | Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
socket interrupt mask register(R) More...
#define | Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Fragment field value in IP header register(R/W) More...
#define | Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
Keep Alive Timer register(R/W) More...
#define | MR_RST 0x80
Reset. More...
#define | MR_WOL 0x20
Wake on LAN. More...
#define | MR_PB 0x10
Ping block. More...
#define | MR_PPPOE 0x08
Enable PPPoE. More...
#define | MR_FARP 0x02
Enable UDP_FORCE_ARP CHECHK. More...
#define | IR_CONFLICT 0x80
Check IP conflict. More...
#define | IR_UNREACH 0x40
Get the destination unreachable message in UDP sending. More...
#define | IR_PPPoE 0x20
Get the PPPoE close message. More...
#define | IR_MP 0x10
Get the magic packet interrupt. More...
#define | PHYCFGR_RST ~(1<<7)
#define | PHYCFGR_OPMD (1<<6)
#define | PHYCFGR_OPMDC_ALLA (7<<3)
#define | PHYCFGR_OPMDC_PDOWN (6<<3)
#define | PHYCFGR_OPMDC_NA (5<<3)
#define | PHYCFGR_OPMDC_100FA (4<<3)
#define | PHYCFGR_OPMDC_100F (3<<3)
#define | PHYCFGR_OPMDC_100H (2<<3)
#define | PHYCFGR_OPMDC_10F (1<<3)
#define | PHYCFGR_OPMDC_10H (0<<3)
#define | PHYCFGR_DPX_FULL (1<<2)
#define | PHYCFGR_DPX_HALF (0<<2)
#define | PHYCFGR_SPD_100 (1<<1)
#define | PHYCFGR_SPD_10 (0<<1)
#define | PHYCFGR_LNK_ON (1<<0)
#define | PHYCFGR_LNK_OFF (0<<0)
#define | IM_IR7 0x80
IP Conflict Interrupt Mask. More...
#define | IM_IR6 0x40
Destination unreachable Interrupt Mask. More...
#define | IM_IR5 0x20
PPPoE Close Interrupt Mask. More...
#define | IM_IR4 0x10
Magic Packet Interrupt Mask. More...
#define | Sn_MR_MULTI 0x80
Support UDP Multicasting. More...
#define | Sn_MR_BCASTB 0x40
Broadcast block in UDP Multicasting. More...
#define | Sn_MR_ND 0x20
No Delayed Ack(TCP), Multicast flag. More...
#define | Sn_MR_UCASTB 0x10
Unicast Block in UDP Multicasting. More...
#define | Sn_MR_MACRAW 0x04
MAC LAYER RAW SOCK. More...
#define | Sn_MR_IPRAW 0x03
#define | Sn_MR_UDP 0x02
UDP. More...
#define | Sn_MR_TCP 0x01
TCP. More...
#define | Sn_MR_CLOSE 0x00
Unused socket. More...
#define | Sn_MR_MFEN Sn_MR_MULTI
MAC filter enable in Sn_MR_MACRAW mode. More...
#define | Sn_MR_MMB Sn_MR_ND
Multicast Blocking in Sn_MR_MACRAW mode. More...
#define | Sn_MR_MIP6B Sn_MR_UCASTB
IPv6 packet Blocking in Sn_MR_MACRAW mode. More...
#define | Sn_MR_MC Sn_MR_ND
IGMP version used in UDP mulitcasting. More...
#define | SOCK_STREAM Sn_MR_TCP
For Berkeley Socket API. More...
#define | SOCK_DGRAM Sn_MR_UDP
For Berkeley Socket API. More...
#define | Sn_CR_OPEN 0x01
Initialize or open socket. More...
#define | Sn_CR_LISTEN 0x02
Wait connection request in TCP mode(Server mode) More...
#define | Sn_CR_CONNECT 0x04
Send connection request in TCP mode(Client mode) More...
#define | Sn_CR_DISCON 0x08
Send closing request in TCP mode. More...
#define | Sn_CR_CLOSE 0x10
Close socket. More...
#define | Sn_CR_SEND 0x20
Update TX buffer pointer and send data. More...
#define | Sn_CR_SEND_MAC 0x21
Send data with MAC address, so without ARP process. More...
#define | Sn_CR_SEND_KEEP 0x22
Send keep alive message. More...
#define | Sn_CR_RECV 0x40
Update RX buffer pointer and receive data. More...
#define | Sn_IR_SENDOK 0x10
SEND_OK Interrupt. More...
#define | Sn_IR_TIMEOUT 0x08
TIMEOUT Interrupt. More...
#define | Sn_IR_RECV 0x04
RECV Interrupt. More...
#define | Sn_IR_DISCON 0x02
DISCON Interrupt. More...
#define | Sn_IR_CON 0x01
CON Interrupt. More...
#define | SOCK_CLOSED 0x00
Closed. More...
#define | SOCK_INIT 0x13
Initiate state. More...
#define | SOCK_LISTEN 0x14
Listen state. More...
#define | SOCK_SYNSENT 0x15
Connection state. More...
#define | SOCK_SYNRECV 0x16
Connection state. More...
#define | SOCK_ESTABLISHED 0x17
Success to connect. More...
#define | SOCK_FIN_WAIT 0x18
Closing state. More...
#define | SOCK_CLOSING 0x1A
Closing state. More...
#define | SOCK_TIME_WAIT 0x1B
Closing state. More...
#define | SOCK_CLOSE_WAIT 0x1C
Closing state. More...
#define | SOCK_LAST_ACK 0x1D
Closing state. More...
#define | SOCK_UDP 0x22
UDP socket. More...
#define | SOCK_IPRAW 0x32
#define | SOCK_MACRAW 0x42
MAC raw mode socket. More...
#define | IPPROTO_IP 0
#define | IPPROTO_ICMP 1
#define | IPPROTO_IGMP 2
#define | IPPROTO_GGP 3
#define | IPPROTO_TCP 6
#define | IPPROTO_PUP 12
#define | IPPROTO_UDP 17
#define | IPPROTO_IDP 22
#define | IPPROTO_ND 77
#define | IPPROTO_RAW 255
#define | WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
Enter a critical section. More...
#define | WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
Exit a critical section. More...
#define | setMR(mr) WIZCHIP_WRITE(MR,mr)
Set Mode Register. More...
#define | getMR() WIZCHIP_READ(MR)
Get Mode Register. More...
#define | setGAR(gar) WIZCHIP_WRITE_BUF(GAR,gar,4)
Set gateway IP address. More...
#define | getGAR(gar) WIZCHIP_READ_BUF(GAR,gar,4)
Get gateway IP address. More...
#define | setSUBR(subr) WIZCHIP_WRITE_BUF(SUBR, subr,4)
Set subnet mask address. More...
#define | getSUBR(subr) WIZCHIP_READ_BUF(SUBR, subr, 4)
Get subnet mask address. More...
#define | setSHAR(shar) WIZCHIP_WRITE_BUF(SHAR, shar, 6)
Set local MAC address. More...
#define | getSHAR(shar) WIZCHIP_READ_BUF(SHAR, shar, 6)
Get local MAC address. More...
#define | setSIPR(sipr) WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
Set local IP address. More...
#define | getSIPR(sipr) WIZCHIP_READ_BUF(SIPR, sipr, 4)
Get local IP address. More...
#define | setINTLEVEL(intlevel)
Set INTLEVEL register. More...
#define | getINTLEVEL() (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
Get INTLEVEL register. More...
#define | setIR(ir) WIZCHIP_WRITE(IR, (ir & 0xF0))
Set IR register. More...
#define | getIR() (WIZCHIP_READ(IR) & 0xF0)
Get IR register. More...
#define | setIMR(imr) WIZCHIP_WRITE(_IMR_, imr)
Set IMR register. More...
#define | getIMR() WIZCHIP_READ(_IMR_)
Get IMR register. More...
#define | setSIR(sir) WIZCHIP_WRITE(SIR, sir)
Set SIR register. More...
#define | getSIR() WIZCHIP_READ(SIR)
Get SIR register. More...
#define | setSIMR(simr) WIZCHIP_WRITE(SIMR, simr)
Set SIMR register. More...
#define | getSIMR() WIZCHIP_READ(SIMR)
Get SIMR register. More...
#define | setRTR(rtr)
Set RTR register. More...
#define | getRTR() (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
Get RTR register. More...
#define | setRCR(rcr) WIZCHIP_WRITE(_RCR_, rcr)
Set RCR register. More...
#define | getRCR() WIZCHIP_READ(_RCR_)
Get RCR register. More...
#define | setPTIMER(ptimer) WIZCHIP_WRITE(PTIMER, ptimer)
Set PTIMER register. More...
#define | getPTIMER() WIZCHIP_READ(PTIMER)
Get PTIMER register. More...
#define | setPMAGIC(pmagic) WIZCHIP_WRITE(PMAGIC, pmagic)
Set PMAGIC register. More...
#define | getPMAGIC() WIZCHIP_READ(PMAGIC)
Get PMAGIC register. More...
#define | setPHAR(phar) WIZCHIP_WRITE_BUF(PHAR, phar, 6)
Set PHAR address. More...
#define | getPHAR(phar) WIZCHIP_READ_BUF(PHAR, phar, 6)
Get PHAR address. More...
#define | setPSID(psid)
Set PSID register. More...
#define | getPSID() (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))
Get PSID register. More...
#define | setPMRU(pmru)
Set PMRU register. More...
#define | getPMRU() (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))
Get PMRU register. More...
#define | getUIPR(uipr) WIZCHIP_READ_BUF(UIPR,uipr,4)
Get unreachable IP address. More...
#define | getUPORTR() (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))
Get UPORTR register. More...
#define | setPHYCFGR(phycfgr) WIZCHIP_WRITE(PHYCFGR, phycfgr)
Set PHYCFGR register. More...
#define | getPHYCFGR() WIZCHIP_READ(PHYCFGR)
Get PHYCFGR register. More...
#define | getVERSIONR() WIZCHIP_READ(VERSIONR)
Get VERSIONR register. More...
#define | setSn_MR(sn, mr) WIZCHIP_WRITE(Sn_MR(sn),mr)
Set Sn_MR register. More...
#define | getSn_MR(sn) WIZCHIP_READ(Sn_MR(sn))
Get Sn_MR register. More...
#define | setSn_CR(sn, cr) WIZCHIP_WRITE(Sn_CR(sn), cr)
Set Sn_CR register. More...
#define | getSn_CR(sn) WIZCHIP_READ(Sn_CR(sn))
Get Sn_CR register. More...
#define | setSn_IR(sn, ir) WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F))
Set Sn_IR register. More...
#define | getSn_IR(sn) (WIZCHIP_READ(Sn_IR(sn)) & 0x1F)
Get Sn_IR register. More...
#define | setSn_IMR(sn, imr) WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F))
Set Sn_IMR register. More...
#define | getSn_IMR(sn) (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F)
Get Sn_IMR register. More...
#define | getSn_SR(sn) WIZCHIP_READ(Sn_SR(sn))
Get Sn_SR register. More...
#define | setSn_PORT(sn, port)
Set Sn_PORT register. More...
#define | getSn_PORT(sn) (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
Get Sn_PORT register. More...
#define | setSn_DHAR(sn, dhar) WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
Set Sn_DHAR register. More...
#define | getSn_DHAR(sn, dhar) WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
Get Sn_MR register. More...
#define | setSn_DIPR(sn, dipr) WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
Set Sn_DIPR register. More...
#define | getSn_DIPR(sn, dipr) WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
Get Sn_DIPR register. More...
#define | setSn_DPORT(sn, dport)
Set Sn_DPORT register. More...
#define | getSn_DPORT(sn) (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
Get Sn_DPORT register. More...
#define | setSn_MSSR(sn, mss)
Set Sn_MSSR register. More...
#define | getSn_MSSR(sn) (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
Get Sn_MSSR register. More...
#define | setSn_TOS(sn, tos) WIZCHIP_WRITE(Sn_TOS(sn), tos)
Set Sn_TOS register. More...
#define | getSn_TOS(sn) WIZCHIP_READ(Sn_TOS(sn))
Get Sn_TOS register. More...
#define | setSn_TTL(sn, ttl) WIZCHIP_WRITE(Sn_TTL(sn), ttl)
Set Sn_TTL register. More...
#define | getSn_TTL(sn) WIZCHIP_READ(Sn_TTL(sn))
Get Sn_TTL register. More...
#define | setSn_RXBUF_SIZE(sn, rxbufsize) WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize)
Set Sn_RXBUF_SIZE register. More...
#define | getSn_RXBUF_SIZE(sn) WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
Get Sn_RXBUF_SIZE register. More...
#define | setSn_TXBUF_SIZE(sn, txbufsize) WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize)
Set Sn_TXBUF_SIZE register. More...
#define | getSn_TXBUF_SIZE(sn) WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
Get Sn_TXBUF_SIZE register. More...
#define | getSn_TX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
Get Sn_TX_RD register. More...
#define | setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register. More...
#define | getSn_TX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
Get Sn_TX_WR register. More...
#define | setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register. More...
#define | getSn_RX_RD(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
Get Sn_RX_RD register. More...
#define | getSn_RX_WR(sn) (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
Get Sn_RX_WR register. More...
#define | setSn_FRAG(sn, frag)
Set Sn_FRAG register. More...
#define | getSn_FRAG(sn) (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
Get Sn_FRAG register. More...
#define | setSn_KPALVTR(sn, kpalvt) WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt)
Set Sn_KPALVTR register. More...
#define | getSn_KPALVTR(sn) WIZCHIP_READ(Sn_KPALVTR(sn))
Get Sn_KPALVTR register. More...
#define | getSn_RxMAX(sn) (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10)
Socket_register_access_function. More...
#define | getSn_TxMAX(sn) (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10)
Socket_register_access_function. More...

Functions

uint8_t | WIZCHIP_READ (uint32_t AddrSel)
It reads 1 byte value from a register. More...
void | WIZCHIP_WRITE (uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register. More...
void | WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers. More...
void | WIZCHIP_WRITE_BUF (uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers. More...
uint16_t | getSn_TX_FSR (uint8_t sn)
Get Sn_TX_FSR register. More...
uint16_t | getSn_RX_RSR (uint8_t sn)
Get Sn_RX_RSR register. More...
void | wiz_send_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory. More...
void | wiz_recv_data (uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory. More...
void | wiz_recv_ignore (uint8_t sn, uint16_t len)
It discard the received data in RX memory. More...

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.

Macro Definition Documentation

◆ _W5500_IO_BASE_

#define _W5500_IO_BASE_ 0x00000000

Definition at line 58 of file w5500.h.

◆ _W5500_SPI_READ_

#define _W5500_SPI_READ_ (0x00 << 2)

Definition at line 60 of file w5500.h.

◆ _W5500_SPI_WRITE_

#define _W5500_SPI_WRITE_ (0x01 << 2)

Definition at line 61 of file w5500.h.

◆ getSn_RxMAX

#define getSn_RxMAX ( sn ) (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10)

Socket_register_access_function.

Gets the max buffer size of socket sn passed as parameter.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Socket n RX max buffer size.

Definition at line 2093 of file w5500.h.

◆ getSn_TxMAX

#define getSn_TxMAX ( sn ) (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10)

Socket_register_access_function.

Gets the max buffer size of socket sn passed as parameters.

Parameters
(uint8_t)sn Socket number. It should be 0 ~ 7.
Returns
uint16_t. Value of Socket n TX max buffer size.

Definition at line 2107 of file w5500.h.

◆ IINCHIP_READ

#define IINCHIP_READ ( ADDR ) WIZCHIP_READ(ADDR)

The defined for legacy chip driver.

Definition at line 74 of file w5500.h.

◆ IINCHIP_READ_BUF

#define IINCHIP_READ_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_READ_BUF(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 76 of file w5500.h.

◆ IINCHIP_WRITE

#define IINCHIP_WRITE | ( | ADDR,
 |  | VAL
 | ) | WIZCHIP_WRITE(ADDR,VAL)

The defined for legacy chip driver.

Definition at line 75 of file w5500.h.

◆ IINCHIP_WRITE_BUF

#define IINCHIP_WRITE_BUF | ( | ADDR,
 |  | BUF,
 |  | LEN
 | ) | WIZCHIP_WRITE(ADDR,BUF,LEN)

The defined for legacy chip driver.

Definition at line 77 of file w5500.h.

◆ IM_IR4

#define IM_IR4 0x10

Magic Packet Interrupt Mask.

0: Disable Magic Packet Interrupt
1: Enable Magic Packet Interrupt

Definition at line 806 of file w5500.h.

◆ IM_IR5

#define IM_IR5 0x20

PPPoE Close Interrupt Mask.

0: Disable PPPoE Close Interrupt
1: Enable PPPoE Close Interrupt

Definition at line 799 of file w5500.h.

◆ IM_IR6

#define IM_IR6 0x40

Destination unreachable Interrupt Mask.

0: Disable Destination unreachable Interrupt
1: Enable Destination unreachable Interrupt

Definition at line 792 of file w5500.h.

◆ IM_IR7

#define IM_IR7 0x80

IP Conflict Interrupt Mask.

0: Disable IP Conflict Interrupt
1: Enable IP Conflict Interrupt

Definition at line 785 of file w5500.h.

◆ IPPROTO_GGP

#define IPPROTO_GGP 3

Definition at line 1159 of file w5500.h.

◆ IPPROTO_ICMP

#define IPPROTO_ICMP 1

Definition at line 1157 of file w5500.h.

◆ IPPROTO_IDP

#define IPPROTO_IDP 22

Definition at line 1163 of file w5500.h.

◆ IPPROTO_IGMP

#define IPPROTO_IGMP 2

Definition at line 1158 of file w5500.h.

◆ IPPROTO_IP

#define IPPROTO_IP 0

Definition at line 1156 of file w5500.h.

◆ IPPROTO_ND

#define IPPROTO_ND 77

Definition at line 1164 of file w5500.h.

◆ IPPROTO_PUP

#define IPPROTO_PUP 12

Definition at line 1161 of file w5500.h.

◆ IPPROTO_RAW

#define IPPROTO_RAW 255

Definition at line 1165 of file w5500.h.

◆ IPPROTO_TCP

#define IPPROTO_TCP 6

Definition at line 1160 of file w5500.h.

◆ IPPROTO_UDP

#define IPPROTO_UDP 17

Definition at line 1162 of file w5500.h.

◆ IR_CONFLICT

#define IR_CONFLICT 0x80

Check IP conflict.

Bit is set as when own source IP address is same with the sender IP address in the received ARP request.

Definition at line 739 of file w5500.h.

◆ IR_MP

#define IR_MP 0x10

Get the magic packet interrupt.

When WOL mode is enabled and receives the magic packet over UDP, this bit is set.

Definition at line 758 of file w5500.h.

◆ IR_PPPoE

#define IR_PPPoE 0x20

Get the PPPoE close message.

When PPPoE is disconnected during PPPoE mode, this bit is set.

Definition at line 752 of file w5500.h.

◆ IR_UNREACH

#define IR_UNREACH 0x40

Get the destination unreachable message in UDP sending.

When receiving the ICMP (Destination port unreachable) packet, this bit is set as When this bit is Destination Information such as IP address and Port number may be checked with the corresponding UIPR & UPORTR.

Definition at line 746 of file w5500.h.

◆ MR_FARP

#define MR_FARP 0x02

Enable UDP_FORCE_ARP CHECHK.

0 : Disable Force ARP mode
1 : Enable Force ARP mode
In Force ARP mode, It forces on sending ARP Request whenever data is sent.

Definition at line 732 of file w5500.h.

◆ MR_PB

#define MR_PB 0x10

Ping block.

0 : Disable Ping block
1 : Enable Ping block
If the bit is it blocks the response to a ping request.

Definition at line 716 of file w5500.h.

◆ MR_PPPOE

#define MR_PPPOE 0x08

Enable PPPoE.

0 : DisablePPPoE mode
1 : EnablePPPoE mode
If you use ADSL, this bit should be

Definition at line 724 of file w5500.h.

◆ MR_RST

#define MR_RST 0x80

Reset.

If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset.

Definition at line 697 of file w5500.h.

◆ MR_WOL

#define MR_WOL 0x20

Wake on LAN.

0 : Disable WOL mode
1 : Enable WOL mode
If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (Sn_MR) for opening Socket.)

Note
The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode.

Definition at line 708 of file w5500.h.

◆ PHYCFGR_DPX_FULL

#define PHYCFGR_DPX_FULL (1<<2)

Definition at line 772 of file w5500.h.

◆ PHYCFGR_DPX_HALF

#define PHYCFGR_DPX_HALF (0<<2)

Definition at line 773 of file w5500.h.

◆ PHYCFGR_LNK_OFF

#define PHYCFGR_LNK_OFF (0<<0)

Definition at line 777 of file w5500.h.

◆ PHYCFGR_LNK_ON

#define PHYCFGR_LNK_ON (1<<0)

Definition at line 776 of file w5500.h.

◆ PHYCFGR_OPMD

#define PHYCFGR_OPMD (1<<6)

Definition at line 763 of file w5500.h.

◆ PHYCFGR_OPMDC_100F

#define PHYCFGR_OPMDC_100F (3<<3)

Definition at line 768 of file w5500.h.

◆ PHYCFGR_OPMDC_100FA

#define PHYCFGR_OPMDC_100FA (4<<3)

Definition at line 767 of file w5500.h.

◆ PHYCFGR_OPMDC_100H

#define PHYCFGR_OPMDC_100H (2<<3)

Definition at line 769 of file w5500.h.

◆ PHYCFGR_OPMDC_10F

#define PHYCFGR_OPMDC_10F (1<<3)

Definition at line 770 of file w5500.h.

◆ PHYCFGR_OPMDC_10H

#define PHYCFGR_OPMDC_10H (0<<3)

Definition at line 771 of file w5500.h.

◆ PHYCFGR_OPMDC_ALLA

#define PHYCFGR_OPMDC_ALLA (7<<3)

Definition at line 764 of file w5500.h.

◆ PHYCFGR_OPMDC_NA

#define PHYCFGR_OPMDC_NA (5<<3)

Definition at line 766 of file w5500.h.

◆ PHYCFGR_OPMDC_PDOWN

#define PHYCFGR_OPMDC_PDOWN (6<<3)

Definition at line 765 of file w5500.h.

◆ PHYCFGR_RST

#define PHYCFGR_RST ~(1<<7)

Definition at line 762 of file w5500.h.

◆ PHYCFGR_SPD_10

#define PHYCFGR_SPD_10 (0<<1)

Definition at line 775 of file w5500.h.

◆ PHYCFGR_SPD_100

#define PHYCFGR_SPD_100 (1<<1)

Definition at line 774 of file w5500.h.

◆ Sn_CR_CLOSE

#define Sn_CR_CLOSE 0x10

Close socket.

Sn_SR is changed to SOCK_CLOSED.

Definition at line 979 of file w5500.h.

◆ Sn_CR_CONNECT

#define Sn_CR_CONNECT 0x04

Send connection request in TCP mode(Client mode)

To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by Sn_DIPR & Sn_DPORT(destination address & port). If the connect-request is successful, the Sn_SR is changed to SOCK_ESTABLISHED and the Sn_IR(0) becomes

The connect-request fails in the following three cases.

  1. When a ARPTO occurs (Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.
  2. When a SYN/ACK packet is not received and TCPTO (Sn_IR(3) = )
  3. When a RST packet is received instead of a SYN/ACK packet. In these cases, Sn_SR is changed to SOCK_CLOSED.
    Note
    This is valid only in TCP mode and operates when Socket n acts as TCP client

Definition at line 960 of file w5500.h.

◆ Sn_CR_DISCON

#define Sn_CR_DISCON 0x08

Send closing request in TCP mode.

Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.

Active close
it transmits disconnect-request(FIN packet) to the connected peer
Passive close
When FIN packet is received from peer, a FIN packet is replied back to the peer.

When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), Sn_SR is changed to SOCK_CLOSED.
Otherwise, TCPTO occurs (Sn_IR(3)='1') and then Sn_SR is changed to SOCK_CLOSED.

Note
Valid only in TCP mode.

Definition at line 973 of file w5500.h.

◆ Sn_CR_LISTEN

#define Sn_CR_LISTEN 0x02

Wait connection request in TCP mode(Server mode)

This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP). In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client The Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN. When a TCP clientconnection request is successfully established, the Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes But when a TCP clientconnection request is failed, Sn_IR(3) becomes and the status of Sn_SR changes to SOCK_CLOSED.

Definition at line 948 of file w5500.h.

◆ Sn_CR_OPEN

#define Sn_CR_OPEN 0x01

Initialize or open socket.

Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). The table below shows the value of Sn_SR corresponding to Sn_MR.

Sn_MR (P[3:0]) | Sn_SR
Sn_MR_CLOSE (000) |
Sn_MR_TCP (001) | SOCK_INIT (0x13)
Sn_MR_UDP (010) | SOCK_UDP (0x22)
S0_MR_MACRAW (100) | SOCK_MACRAW (0x02)

Definition at line 937 of file w5500.h.

◆ Sn_CR_RECV

#define Sn_CR_RECV 0x40

Update RX buffer pointer and receive data.

RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (Sn_RX_RD).
For more details, refer to Socket n RX Received Size Register (Sn_RX_RSR), Socket n RX Write Pointer Register (Sn_RX_WR), and Socket n RX Read Pointer Register (Sn_RX_RD).

Definition at line 1013 of file w5500.h.

◆ Sn_CR_SEND

#define Sn_CR_SEND 0x20

Update TX buffer pointer and send data.

SEND transmits all the data in the Socket n TX buffer.
For more details, please refer to Socket n TX Free Size Register (Sn_TX_FSR), Socket n, TX Write Pointer Register(Sn_TX_WR), and Socket n TX Read Pointer Register(Sn_TX_RD).

Definition at line 987 of file w5500.h.

◆ Sn_CR_SEND_KEEP

#define Sn_CR_SEND_KEEP 0x22

Send keep alive message.

It checks the connection status by sending 1byte keep-alive packet.
If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur.

Note
Valid only in TCP mode.

Definition at line 1005 of file w5500.h.

◆ Sn_CR_SEND_MAC

#define Sn_CR_SEND_MAC 0x21

Send data with MAC address, so without ARP process.

The basic operation is same as SEND.
Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).
But SEND_MAC transmits data without the automatic ARP-process.
In this case, the destination hardware address is acquired from Sn_DHAR configured by host, instead of APR-process.

Note
Valid only in UDP mode.

Definition at line 997 of file w5500.h.

◆ Sn_IR_CON

#define Sn_IR_CON 0x01

CON Interrupt.

This is issued one time when the connection with peer is successful and then Sn_SR is changed to SOCK_ESTABLISHED.

Definition at line 1044 of file w5500.h.

◆ Sn_IR_DISCON

#define Sn_IR_DISCON 0x02

DISCON Interrupt.

This is issued when FIN or FIN/ACK packet is received from a peer.

Definition at line 1038 of file w5500.h.

◆ Sn_IR_RECV

#define Sn_IR_RECV 0x04

RECV Interrupt.

This is issued whenever data is received from a peer.

Definition at line 1032 of file w5500.h.

◆ Sn_IR_SENDOK

#define Sn_IR_SENDOK 0x10

SEND_OK Interrupt.

This is issued when SEND command is completed.

Definition at line 1020 of file w5500.h.

◆ Sn_IR_TIMEOUT

#define Sn_IR_TIMEOUT 0x08

TIMEOUT Interrupt.

This is issued when ARPTO or TCPTO occurs.

Definition at line 1026 of file w5500.h.

◆ Sn_MR_BCASTB

#define Sn_MR_BCASTB 0x40

Broadcast block in UDP Multicasting.

0 : disable Broadcast Blocking
1 : enable Broadcast Blocking
This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010. In addition, This bit does when MACRAW mode(P[3:0] = 100

Definition at line 826 of file w5500.h.

◆ Sn_MR_CLOSE

#define Sn_MR_CLOSE 0x00

Unused socket.

This configures the protocol mode of Socket n.

Definition at line 871 of file w5500.h.

◆ Sn_MR_IPRAW

#define Sn_MR_IPRAW 0x03

IP LAYER RAW SOCK

Definition at line 853 of file w5500.h.

◆ Sn_MR_MACRAW

#define Sn_MR_MACRAW 0x04

MAC LAYER RAW SOCK.

This configures the protocol mode of Socket n.

Note
MACRAW mode should be only used in Socket 0.

Definition at line 851 of file w5500.h.

◆ Sn_MR_MC

#define Sn_MR_MC Sn_MR_ND

IGMP version used in UDP mulitcasting.

0 : disable Multicast Blocking
1 : enable Multicast Blocking
This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address.

Definition at line 910 of file w5500.h.

◆ Sn_MR_MFEN

#define Sn_MR_MFEN Sn_MR_MULTI

MAC filter enable in Sn_MR_MACRAW mode.

0 : disable MAC Filtering
1 : enable MAC Filtering
This bit is applied only during MACRAW mode(P[3:0] = 100.
When set as W5500 can only receive broadcasting packet or packet sent to itself. When this bit is W5500 can receive all packets on Ethernet. If user wants to implement Hybrid TCP/IP stack, it is recommended that this bit is set as for reducing host overhead to process the all received packets.

Definition at line 884 of file w5500.h.

◆ Sn_MR_MIP6B

#define Sn_MR_MIP6B Sn_MR_UCASTB

IPv6 packet Blocking in Sn_MR_MACRAW mode.

0 : disable IPv6 Blocking
1 : enable IPv6 Blocking
This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet.

Definition at line 901 of file w5500.h.

◆ Sn_MR_MMB

#define Sn_MR_MMB Sn_MR_ND

Multicast Blocking in Sn_MR_MACRAW mode.

0 : using IGMP version 2
1 : using IGMP version 1
This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = It configures the version for IGMP messages (Join/Leave/Report).

Definition at line 893 of file w5500.h.

◆ Sn_MR_MULTI

#define Sn_MR_MULTI 0x80

Support UDP Multicasting.

0 : disable Multicasting
1 : enable Multicasting
This bit is applied only during UDP mode(P[3:0] = 010.
To use multicasting, Sn_DIPR & Sn_DPORT should be respectively configured with the multicast group IP address & port number before Socket n is opened by OPEN command of Sn_CR.

Definition at line 817 of file w5500.h.

◆ Sn_MR_ND

#define Sn_MR_ND 0x20

No Delayed Ack(TCP), Multicast flag.

0 : Disable No Delayed ACK option
1 : Enable No Delayed ACK option
This bit is applied only during TCP mode (P[3:0] = 001.
When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.
When this bit is It sends the ACK packet after waiting for the timeout time configured by RTR.

Definition at line 836 of file w5500.h.

◆ Sn_MR_TCP

#define Sn_MR_TCP 0x01

TCP.

This configures the protocol mode of Socket n.

Definition at line 865 of file w5500.h.

◆ Sn_MR_UCASTB

#define Sn_MR_UCASTB 0x10

Unicast Block in UDP Multicasting.

0 : disable Unicast Blocking
1 : enable Unicast Blocking
This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI =

Definition at line 844 of file w5500.h.

◆ Sn_MR_UDP

#define Sn_MR_UDP 0x02

UDP.

This configures the protocol mode of Socket n.

Definition at line 859 of file w5500.h.

◆ SOCK_CLOSE_WAIT

#define SOCK_CLOSE_WAIT 0x1C

Closing state.

This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.
This is half-closing status, and data can be transferred.
For full-closing, DISCON command is used. But For just-closing, CLOSE command is used.

Definition at line 1126 of file w5500.h.

◆ SOCK_CLOSED

#define SOCK_CLOSED 0x00

Closed.

This indicates that Socket n is released.
When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to SOCK_CLOSED regardless of previous status.

Definition at line 1052 of file w5500.h.

◆ SOCK_CLOSING

#define SOCK_CLOSING 0x1A

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1110 of file w5500.h.

◆ SOCK_DGRAM

#define SOCK_DGRAM Sn_MR_UDP

For Berkeley Socket API.

Definition at line 921 of file w5500.h.

◆ SOCK_ESTABLISHED

#define SOCK_ESTABLISHED 0x17

Success to connect.

This indicates the status of the connection of Socket n.
It changes to SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring SOCK_LISTEN, or when the CONNECT command is successful.
During SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command.

Definition at line 1094 of file w5500.h.

◆ SOCK_FIN_WAIT

#define SOCK_FIN_WAIT 0x18

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1102 of file w5500.h.

◆ SOCK_INIT

#define SOCK_INIT 0x13

Initiate state.

This indicates Socket n is opened with TCP mode.
It is changed to SOCK_INIT when Sn_MR(P[3:0]) = 001 and OPEN command is ordered.
After SOCK_INIT, user can use LISTEN /CONNECT command.

Definition at line 1060 of file w5500.h.

◆ SOCK_IPRAW

#define SOCK_IPRAW 0x32

IP raw mode socket

Definition at line 1143 of file w5500.h.

◆ SOCK_LAST_ACK

#define SOCK_LAST_ACK 0x1D

Closing state.

This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.
It changes to SOCK_CLOSED when Socket n received the response successfully, or when timeout(Sn_IR[TIMEOUT] = '1') is occurred.

Definition at line 1133 of file w5500.h.

◆ SOCK_LISTEN

#define SOCK_LISTEN 0x14

Listen state.

This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.
It will change to SOCK_ESTALBLISHED when the connection-request is successfully accepted.
Otherwise it will change to SOCK_CLOSED after TCPTO Sn_IR(TIMEOUT) = '1') is occurred.

Definition at line 1068 of file w5500.h.

◆ SOCK_MACRAW

#define SOCK_MACRAW 0x42

MAC raw mode socket.

This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.
It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.
Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process.

Definition at line 1151 of file w5500.h.

◆ SOCK_STREAM

#define SOCK_STREAM Sn_MR_TCP

For Berkeley Socket API.

Definition at line 916 of file w5500.h.

◆ SOCK_SYNRECV

#define SOCK_SYNRECV 0x16

Connection state.

It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to SOCK_ESTABLISHED.
If not, it changes to SOCK_CLOSED after timeout (Sn_IR[TIMEOUT] = '1') is occurred.

Definition at line 1085 of file w5500.h.

◆ SOCK_SYNSENT

#define SOCK_SYNSENT 0x15

Connection state.

This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
It is temporarily shown when Sn_SR is changed from SOCK_INIT to SOCK_ESTABLISHED by CONNECT command.
If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to SOCK_ESTABLISHED.
Otherwise, it changes to SOCK_CLOSED after TCPTO (Sn_IR[TIMEOUT] = '1') is occurred.

Definition at line 1077 of file w5500.h.

◆ SOCK_TIME_WAIT

#define SOCK_TIME_WAIT 0x1B

Closing state.

These indicate Socket n is closing.
These are shown in disconnect-process such as active-close and passive-close.
When Disconnect-process is successfully completed, or when timeout occurs, these change to SOCK_CLOSED.

Definition at line 1118 of file w5500.h.

◆ SOCK_UDP

#define SOCK_UDP 0x22

UDP socket.

This indicates Socket n is opened in UDP mode(Sn_MR(P[3:0]) = '010').
It changes to SOCK_UDP when Sn_MR(P[3:0]) = '010' and Sn_CR_OPEN command is ordered.
Unlike TCP mode, data can be transfered without the connection-process.

Definition at line 1141 of file w5500.h.

◆ WIZCHIP_CREG_BLOCK

#define WIZCHIP_CREG_BLOCK 0x00

Definition at line 63 of file w5500.h.

◆ WIZCHIP_CRITICAL_ENTER

#define WIZCHIP_CRITICAL_ENTER ( ) WIZCHIP.CRIS._enter()

Enter a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_EXIT()

Definition at line 1179 of file w5500.h.

◆ WIZCHIP_CRITICAL_EXIT

#define WIZCHIP_CRITICAL_EXIT ( ) WIZCHIP.CRIS._exit()

Exit a critical section.

It is provided to protect your shared code which are executed without distribution.

In non-OS environment, It can be just implemented by disabling whole interrupt.
In OS environment, You can replace it to critical section api supported by OS.

See also
WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
WIZCHIP_CRITICAL_ENTER()

Definition at line 1196 of file w5500.h.

◆ WIZCHIP_OFFSET_INC

#define WIZCHIP_OFFSET_INC | ( | ADDR,
 |  | N
 | ) | (ADDR + (N<<8))

Definition at line 68 of file w5500.h.

◆ WIZCHIP_RXBUF_BLOCK

#define WIZCHIP_RXBUF_BLOCK ( N ) (3+4*N)

Definition at line 66 of file w5500.h.

◆ WIZCHIP_SREG_BLOCK

#define WIZCHIP_SREG_BLOCK ( N ) (1+4*N)

Definition at line 64 of file w5500.h.

◆ WIZCHIP_TXBUF_BLOCK

#define WIZCHIP_TXBUF_BLOCK ( N ) (2+4*N)

Definition at line 65 of file w5500.h.


ioLibrary: Ethernet/socket.c File Reference

  • Ethernet
Macros | Functions | Variables
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...

Variables

uint8_t sock_pack_info [_WIZCHIP_SOCK_NUM_] = {0,}

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

◆ CHECK_SOCKDATA

#define CHECK_SOCKDATA ( )
Value:
do{ \
if(len == 0) return SOCKERR_DATALEN; \
}while(0); \
SOCKERR_DATALEN
#define SOCKERR_DATALEN
Data length is zero or greater than buffer max size.
Definition: socket.h:108

Definition at line 98 of file socket.c.

◆ CHECK_SOCKINIT

#define CHECK_SOCKINIT ( )
Value:
do{ \
if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \
}while(0); \
SOCKERR_SOCKINIT
#define SOCKERR_SOCKINIT
Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP.
Definition: socket.h:99
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
SOCK_INIT
#define SOCK_INIT
Initiate state.
Definition: w5100.h:901

Definition at line 93 of file socket.c.

◆ CHECK_SOCKMODE

#define CHECK_SOCKMODE ( mode )
Value:
do{ \
if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \
}while(0); \
SOCKERR_SOCKMODE
#define SOCKERR_SOCKMODE
Invalid socket mode for socket operation.
Definition: socket.h:101
getSn_MR
#define getSn_MR(sn)
Get Sn_MR register.
Definition: w5100.h:1377

Definition at line 88 of file socket.c.

◆ CHECK_SOCKNUM

#define CHECK_SOCKNUM ( )
Value:
do{ \
if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \
}while(0); \
_WIZCHIP_SOCK_NUM_
#define _WIZCHIP_SOCK_NUM_
The count of independant socket of WIZCHIP.
Definition: wizchip_conf.h:212
SOCKERR_SOCKNUM
#define SOCKERR_SOCKNUM
Invalid socket number.
Definition: socket.h:97

Definition at line 83 of file socket.c.

◆ SOCK_ANY_PORT_NUM

#define SOCK_ANY_PORT_NUM 0xC000

Definition at line 60 of file socket.c.

Variable Documentation

◆ sock_pack_info

uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}

Definition at line 70 of file socket.c.


ioLibrary: 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. (When W5300, This flag can be applied) More...
#define | PACK_REMAINED 0x01
In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) More...
#define | PACK_COMPLETED 0x00
In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) More...
#define | PACK_FIFOBYTE 0x02
Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. 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

◆ PACK_COMPLETED

#define PACK_COMPLETED 0x00

In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied)

Definition at line 140 of file socket.h.

◆ PACK_FIFOBYTE

#define PACK_FIFOBYTE 0x02

Valid only W5300, It indicate to have read already the Sn_RX_FIFOR.

Definition at line 142 of file socket.h.

◆ PACK_FIRST

#define PACK_FIRST 0x80

In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied)

Definition at line 138 of file socket.h.

◆ PACK_REMAINED

#define PACK_REMAINED 0x01

In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied)

Definition at line 139 of file socket.h.

◆ SF_BROAD_BLOCK

#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.

◆ SF_ETHER_OWN

#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.

◆ SF_IGMP_VER2

#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.

◆ SF_IO_NONBLOCK

#define SF_IO_NONBLOCK 0x01

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

Definition at line 133 of file socket.h.

◆ SF_IPv6_BLOCK

#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.

◆ SF_MULTI_BLOCK

#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.

◆ SF_MULTI_ENABLE

#define SF_MULTI_ENABLE (Sn_MR_MULTI)

In Sn_MR_UDP, Enable multicast mode.

Definition at line 119 of file socket.h.

◆ SF_TCP_NODELAY

#define SF_TCP_NODELAY (Sn_MR_ND)

In Sn_MR_TCP, Use to nodelayed ack.

Definition at line 118 of file socket.h.

◆ SF_UNI_BLOCK

#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.

◆ SOCK_BUSY

#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.

◆ SOCK_ERROR

#define SOCK_ERROR 0

Definition at line 96 of file socket.h.

◆ SOCK_FATAL

#define SOCK_FATAL -1000

Result is fatal error about socket process.

Definition at line 94 of file socket.h.

◆ SOCK_IO_BLOCK

#define SOCK_IO_BLOCK 0

Socket Block IO Mode in setsockopt().

Definition at line 333 of file socket.h.

◆ SOCK_IO_NONBLOCK

#define SOCK_IO_NONBLOCK 1

Socket Non-block IO Mode in setsockopt().

Definition at line 334 of file socket.h.

◆ SOCK_OK

#define SOCK_OK 1

Result is OK about socket process.

Definition at line 92 of file socket.h.

◆ SOCKERR_ARG

#define SOCKERR_ARG (SOCK_ERROR - 10)

Invalid argument.

Definition at line 104 of file socket.h.

◆ SOCKERR_BUFFER

#define SOCKERR_BUFFER (SOCK_ERROR - 15)

Socket buffer is not enough for data communication.

Definition at line 109 of file socket.h.

◆ SOCKERR_DATALEN

#define SOCKERR_DATALEN (SOCK_ERROR - 14)

Data length is zero or greater than buffer max size.

Definition at line 108 of file socket.h.

◆ SOCKERR_IPINVALID

#define SOCKERR_IPINVALID (SOCK_ERROR - 12)

Invalid IP address.

Definition at line 106 of file socket.h.

◆ SOCKERR_PORTZERO

#define SOCKERR_PORTZERO (SOCK_ERROR - 11)

Port number is zero.

Definition at line 105 of file socket.h.

◆ SOCKERR_SOCKCLOSED

#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4)

Socket unexpectedly closed.

Definition at line 100 of file socket.h.

◆ SOCKERR_SOCKFLAG

#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6)

Invalid socket flag.

Definition at line 102 of file socket.h.

◆ SOCKERR_SOCKINIT

#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.

◆ SOCKERR_SOCKMODE

#define SOCKERR_SOCKMODE (SOCK_ERROR - 5)

Invalid socket mode for socket operation.

Definition at line 101 of file socket.h.

◆ SOCKERR_SOCKNUM

#define SOCKERR_SOCKNUM (SOCK_ERROR - 1)

Invalid socket number.

Definition at line 97 of file socket.h.

◆ SOCKERR_SOCKOPT

#define SOCKERR_SOCKOPT (SOCK_ERROR - 2)

Invalid socket option.

Definition at line 98 of file socket.h.

◆ SOCKERR_SOCKSTATUS

#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7)

Invalid socket status for socket operation.

Definition at line 103 of file socket.h.

◆ SOCKERR_TIMEOUT

#define SOCKERR_TIMEOUT (SOCK_ERROR - 13)

Timeout occurred.

Definition at line 107 of file socket.h.

◆ SOCKET

#define SOCKET uint8_t

SOCKET type define for legacy driver.

Definition at line 90 of file socket.h.

◆ SOCKFATAL_PACKLEN

#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1)

Invalid packet length. Fatal Error.

Definition at line 111 of file socket.h.


ioLibrary: 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...
iodata_t | wizchip_bus_readdata (uint32_t AddrSel)
Default function to read in direct or indirect interface. More...
void | wizchip_bus_writedata (uint32_t AddrSel, iodata_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 (iodata_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, iodata_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_readdata() & wizchip_bus_writedata()

Definition in file wizchip_conf.c.

Function Documentation

◆ reg_wizchip_bus_cbfunc()

void reg_wizchip_bus_cbfunc | ( | iodata_t(*)(uint32_t addr) | bus_rb,
 |  | void(*)(uint32_t addr, iodata_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 216 of file wizchip_conf.c.

◆ reg_wizchip_cris_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.

◆ reg_wizchip_cs_cbfunc()

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.

◆ reg_wizchip_spi_cbfunc()

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 244 of file wizchip_conf.c.

◆ reg_wizchip_spiburst_cbfunc()

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 261 of file wizchip_conf.c.

◆ wizchip_bus_readdata()

iodata_t wizchip_bus_readdata ( 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 100 of file wizchip_conf.c.

◆ wizchip_bus_writedata()

void wizchip_bus_writedata | ( | uint32_t | AddrSel,
 |  | iodata_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 109 of file wizchip_conf.c.

◆ wizchip_cris_enter()

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.

◆ wizchip_cris_exit()

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.

◆ wizchip_cs_deselect()

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.

◆ wizchip_cs_select()

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.

◆ wizchip_spi_readburst()

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 133 of file wizchip_conf.c.

◆ wizchip_spi_readbyte()

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 117 of file wizchip_conf.c.

◆ wizchip_spi_writeburst()

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 141 of file wizchip_conf.c.

◆ wizchip_spi_writebyte()

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 125 of file wizchip_conf.c.

◆ wizphy_getphylink()

int8_t wizphy_getphylink ( void )

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

Definition at line 600 of file wizchip_conf.c.

◆ wizphy_getphypmode()

int8_t wizphy_getphypmode ( void )

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

Definition at line 625 of file wizchip_conf.c.

◆ wizphy_reset()

void wizphy_reset ( void )

Reset phy. Vailid only in W5500.

Definition at line 728 of file wizchip_conf.c.

Variable Documentation

◆ WIZCHIP

_WIZCHIP WIZCHIP
Initial value:
=
{
_WIZCHIP_IO_MODE_,
_WIZCHIP_ID_ ,
wizchip_cris_enter,
wizchip_cris_exit,
wizchip_cs_select,
wizchip_cs_deselect,
wizchip_bus_readdata,
wizchip_bus_writedata,
}
wizchip_cs_select
void wizchip_cs_select(void)
Default function to select chip.
Definition: wizchip_conf.c:83
wizchip_cs_deselect
void wizchip_cs_deselect(void)
Default function to deselect chip.
Definition: wizchip_conf.c:91
_WIZCHIP_ID_
#define _WIZCHIP_ID_
Definition: wizchip_conf.h:132
wizchip_bus_readdata
iodata_t wizchip_bus_readdata(uint32_t AddrSel)
Default function to read in direct or indirect interface.
Definition: wizchip_conf.c:100
_WIZCHIP_IO_MODE_
#define _WIZCHIP_IO_MODE_
Define interface mode. .
Definition: wizchip_conf.h:149
wizchip_cris_enter
void wizchip_cris_enter(void)
Default function to enable interrupt.
Definition: wizchip_conf.c:67
wizchip_cris_exit
void wizchip_cris_exit(void)
Default function to disable interrupt.
Definition: wizchip_conf.c:75
wizchip_bus_writedata
void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb)
Default function to write in direct or indirect interface.
Definition: wizchip_conf.c:109

\ref _WIZCHIP instance

Definition at line 165 of file wizchip_conf.c.


ioLibrary: Ethernet/wizchip_conf.h File Reference

  • Ethernet
Data Structures | 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.

Data Structures

struct | __WIZCHIP
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions. More...
struct | __WIZCHIP::_CRIS
struct | __WIZCHIP::_CS
union | __WIZCHIP::_IF
struct | wiz_PhyConf_t
struct | wiz_NetInfo_t
struct | wiz_NetTimeout_t

Macros

#define | W5100 5100
Select WIZCHIP. More...
#define | W5100S 5100+5
#define | W5200 5200
#define | W5300 5300
#define | W5500 5500
#define | _WIZCHIP_ W5500
#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_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3)
#define | _WIZCHIP_ID_ "W5500\0"
#define | _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
Define interface mode.
. More...
#define | _WIZCHIP_IO_BASE_ 0x60000000
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 uint8_t | iodata_t
typedef struct __WIZCHIP | _WIZCHIP
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions. 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 (iodata_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, iodata_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

◆ _WIZCHIP_

#define _WIZCHIP_ W5500

Definition at line 71 of file wizchip_conf.h.

◆ _WIZCHIP_ID_

#define _WIZCHIP_ID_ "W5500\0"

Definition at line 132 of file wizchip_conf.h.

◆ _WIZCHIP_IO_BASE_

#define _WIZCHIP_IO_BASE_ 0x60000000

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 196 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_

#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_ == W5500
    -_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in _WIZCHIP_ == W5500
  • _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 149 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_BUS_

#define _WIZCHIP_IO_MODE_BUS_ 0x0100

Bus interface mode

Definition at line 75 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_BUS_DIR_

#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1)

BUS interface mode for direct

Definition at line 82 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_BUS_INDIR_

#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2)

BUS interface mode for indirect

Definition at line 83 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_NONE_

#define _WIZCHIP_IO_MODE_NONE_ 0x0000

Definition at line 74 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_SPI_

#define _WIZCHIP_IO_MODE_SPI_ 0x0200

SPI interface mode

Definition at line 76 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_SPI_5500_

#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3)

SPI interface mode for fixed length data mode

Definition at line 87 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_SPI_FDM_

#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2)

SPI interface mode for fixed length data mode

Definition at line 86 of file wizchip_conf.h.

◆ _WIZCHIP_IO_MODE_SPI_VDM_

#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1)

SPI interface mode for variable length data

Definition at line 85 of file wizchip_conf.h.

◆ _WIZCHIP_SOCK_NUM_

#define _WIZCHIP_SOCK_NUM_ 8

The count of independant socket of WIZCHIP.

Definition at line 212 of file wizchip_conf.h.

◆ PHY_CONFBY_HW

#define PHY_CONFBY_HW 0

Configured PHY operation mode by HW pin.

Definition at line 367 of file wizchip_conf.h.

◆ PHY_CONFBY_SW

#define PHY_CONFBY_SW 1

Configured PHY operation mode by SW register.

Definition at line 368 of file wizchip_conf.h.

◆ PHY_DUPLEX_FULL

#define PHY_DUPLEX_FULL 1

Link Full-Duplex.

Definition at line 374 of file wizchip_conf.h.

◆ PHY_DUPLEX_HALF

#define PHY_DUPLEX_HALF 0

Link Half-Duplex.

Definition at line 373 of file wizchip_conf.h.

◆ PHY_LINK_OFF

#define PHY_LINK_OFF 0

Link Off.

Definition at line 375 of file wizchip_conf.h.

◆ PHY_LINK_ON

#define PHY_LINK_ON 1

Link On.

Definition at line 376 of file wizchip_conf.h.

◆ PHY_MODE_AUTONEGO

#define PHY_MODE_AUTONEGO 1

Configured PHY operation mode with auto-negotiation.

Definition at line 370 of file wizchip_conf.h.

◆ PHY_MODE_MANUAL

#define PHY_MODE_MANUAL 0

Configured PHY operation mode with user setting.

Definition at line 369 of file wizchip_conf.h.

◆ PHY_POWER_DOWN

#define PHY_POWER_DOWN 1

PHY power down mode.

Definition at line 378 of file wizchip_conf.h.

◆ PHY_POWER_NORM

#define PHY_POWER_NORM 0

PHY power normal mode.

Definition at line 377 of file wizchip_conf.h.

◆ PHY_SPEED_10

#define PHY_SPEED_10 0

Link Speed 10.

Definition at line 371 of file wizchip_conf.h.

◆ PHY_SPEED_100

#define PHY_SPEED_100 1

Link Speed 100.

Definition at line 372 of file wizchip_conf.h.

◆ W5100

#define W5100 5100

Select WIZCHIP.

Todo:
You should select one, W5100, W5100S, W5200, W5300, W5500 or etc.

ex> #define _WIZCHIP_ W5500

Definition at line 64 of file wizchip_conf.h.

◆ W5100S

#define W5100S 5100+5

Definition at line 65 of file wizchip_conf.h.

◆ W5200

#define W5200 5200

Definition at line 66 of file wizchip_conf.h.

◆ W5300

#define W5300 5300

Definition at line 67 of file wizchip_conf.h.

◆ W5500

#define W5500 5500

Definition at line 68 of file wizchip_conf.h.

Typedef Documentation

◆ iodata_t

typedef uint8_t iodata_t

Definition at line 152 of file wizchip_conf.h.

Function Documentation

◆ reg_wizchip_bus_cbfunc()

void reg_wizchip_bus_cbfunc | ( | iodata_t(*)(uint32_t addr) | bus_rb,
 |  | void(*)(uint32_t addr, iodata_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 216 of file wizchip_conf.c.

◆ reg_wizchip_cris_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.

◆ reg_wizchip_cs_cbfunc()

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.

◆ reg_wizchip_spi_cbfunc()

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 244 of file wizchip_conf.c.

◆ reg_wizchip_spiburst_cbfunc()

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 261 of file wizchip_conf.c.

◆ wizphy_getphylink()

int8_t wizphy_getphylink ( void )

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

Definition at line 600 of file wizchip_conf.c.

◆ wizphy_getphypmode()

int8_t wizphy_getphypmode ( void )

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

Definition at line 625 of file wizchip_conf.c.

◆ wizphy_reset()

void wizphy_reset ( void )

Reset phy. Vailid only in W5500.

Definition at line 728 of file wizchip_conf.c.

Variable Documentation

◆ WIZCHIP

_WIZCHIP WIZCHIP

\ref _WIZCHIP instance

Definition at line 165 of file wizchip_conf.c.


ioLibrary: image Directory Reference

  • image
image Directory Reference

Files

file | Berkeley_SOCKET.jpg [code]
file | w5100_w5200_w5500.jpg [code]
file | w5100_w5200_w5500_w5100s.jpg [code]
file | w5200_w5500.jpg [code]
file | w5500.jpg [code]
file | WIZnet_SOCKET.jpg [code]


ioLibrary: image/Berkeley_SOCKET.jpg File Reference

  • image
Berkeley_SOCKET.jpg File Reference

Go to the source code of this file.


ioLibrary: image/w5100_w5200_w5500.jpg File Reference

  • image
w5100_w5200_w5500.jpg File Reference

Go to the source code of this file.


ioLibrary: image/w5100_w5200_w5500_w5100s.jpg File Reference

  • image
w5100_w5200_w5500_w5100s.jpg File Reference

Go to the source code of this file.


ioLibrary: image/w5200_w5500.jpg File Reference

  • image
w5200_w5500.jpg File Reference

Go to the source code of this file.


ioLibrary: image/w5500.jpg File Reference

  • image
w5500.jpg File Reference

Go to the source code of this file.


ioLibrary: image/WIZnet_SOCKET.jpg File Reference

  • image
WIZnet_SOCKET.jpg File Reference

Go to the source code of this file.


ioLibrary: Internet Directory Reference

  • Internet
Internet Directory Reference
Directory dependency graph for Internet:

Directories

directory | DHCP
directory | DNS
directory | FTPClient
directory | FTPServer
directory | httpServer
directory | MQTT
directory | SNMP
directory | SNTP
directory | TFTP


ioLibrary: Internet/DHCP Directory Reference

  • Internet
  • DHCP
DHCP Directory Reference
Directory dependency graph for DHCP:

Files

file | dhcp.c [code]
DHCP APIs implement file.
file | dhcp.h [code]
DHCP APIs Header file.


ioLibrary: Internet/DHCP/dhcp.c File Reference

  • Internet
  • DHCP
Data Structures | Macros | Enumerations | Functions | Variables
dhcp.c File Reference

DHCP APIs implement file. More...

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

Go to the source code of this file.

Data Structures

struct RIP_MSG

Macros

#define | STATE_DHCP_INIT 0
Initialize. More...
#define | STATE_DHCP_DISCOVER 1
send DISCOVER and wait OFFER More...
#define | STATE_DHCP_REQUEST 2
send REQEUST and wait ACK or NACK More...
#define | STATE_DHCP_LEASED 3
ReceiveD ACK and IP leased. More...
#define | STATE_DHCP_REREQUEST 4
send REQUEST for maintaining leased IP More...
#define | STATE_DHCP_RELEASE 5
No use. More...
#define | STATE_DHCP_STOP 6
Stop procssing DHCP. More...
#define | DHCP_FLAGSBROADCAST 0x8000
The broadcast value of flags in RIP_MSG. More...
#define | DHCP_FLAGSUNICAST 0x0000
The unicast value of flags in RIP_MSG. More...
#define | DHCP_BOOTREQUEST 1
Request Message used in op of RIP_MSG. More...
#define | DHCP_BOOTREPLY 2
Reply Message used i op of RIP_MSG. More...
#define | DHCP_DISCOVER 1
DISCOVER message in OPT of RIP_MSG. More...
#define | DHCP_OFFER 2
OFFER message in OPT of RIP_MSG. More...
#define | DHCP_REQUEST 3
REQUEST message in OPT of RIP_MSG. More...
#define | DHCP_DECLINE 4
DECLINE message in OPT of RIP_MSG. More...
#define | DHCP_ACK 5
ACK message in OPT of RIP_MSG. More...
#define | DHCP_NAK 6
NACK message in OPT of RIP_MSG. More...
#define | DHCP_RELEASE 7
RELEASE message in OPT of RIP_MSG. No use. More...
#define | DHCP_INFORM 8
INFORM message in OPT of RIP_MSG. No use. More...
#define | DHCP_HTYPE10MB 1
Used in type of RIP_MSG. More...
#define | DHCP_HTYPE100MB 2
Used in type of RIP_MSG. More...
#define | DHCP_HLENETHERNET 6
Used in hlen of RIP_MSG. More...
#define | DHCP_HOPS 0
Used in hops of RIP_MSG. More...
#define | DHCP_SECS 0
Used in secs of RIP_MSG. More...
#define | INFINITE_LEASETIME 0xffffffff
Infinite lease time. More...
#define | OPT_SIZE 312
#define | RIP_MSG_SIZE (236+OPT_SIZE)

Enumerations

enum {
padOption = 0, subnetMask = 1, timerOffset = 2, routersOnSubnet = 3,
timeServer = 4, nameServer = 5, dns = 6, logServer = 7,
cookieServer = 8, lprServer = 9, impressServer = 10, resourceLocationServer = 11,
hostName = 12, bootFileSize = 13, meritDumpFile = 14, domainName = 15,
swapServer = 16, rootPath = 17, extentionsPath = 18, IPforwarding = 19,
nonLocalSourceRouting = 20, policyFilter = 21, maxDgramReasmSize = 22, defaultIPTTL = 23,
pathMTUagingTimeout = 24, pathMTUplateauTable = 25, ifMTU = 26, allSubnetsLocal = 27,
broadcastAddr = 28, performMaskDiscovery = 29, maskSupplier = 30, performRouterDiscovery = 31,
routerSolicitationAddr = 32, staticRoute = 33, trailerEncapsulation = 34, arpCacheTimeout = 35,
ethernetEncapsulation = 36, tcpDefaultTTL = 37, tcpKeepaliveInterval = 38, tcpKeepaliveGarbage = 39,
nisDomainName = 40, nisServers = 41, ntpServers = 42, vendorSpecificInfo = 43,
netBIOSnameServer = 44, netBIOSdgramDistServer = 45, netBIOSnodeType = 46, netBIOSscope = 47,
xFontServer = 48, xDisplayManager = 49, dhcpRequestedIPaddr = 50, dhcpIPaddrLeaseTime = 51,
dhcpOptionOverload = 52, dhcpMessageType = 53, dhcpServerIdentifier = 54, dhcpParamRequest = 55,
dhcpMsg = 56, dhcpMaxMsgSize = 57, dhcpT1value = 58, dhcpT2value = 59,
dhcpClassIdentifier = 60, dhcpClientIdentifier = 61, endOption = 255
}

Functions

void | default_ip_assign (void)
void | default_ip_update (void)
void | default_ip_conflict (void)
void | reg_dhcp_cbfunc (void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void))
void | makeDHCPMSG (void)
void | send_DHCP_DISCOVER (void)
void | send_DHCP_REQUEST (void)
void | send_DHCP_DECLINE (void)
int8_t | parseDHCPMSG (void)
uint8_t | DHCP_run (void)
void | DHCP_stop (void)
uint8_t | check_DHCP_timeout (void)
int8_t | check_DHCP_leasedIP (void)
void | DHCP_init (uint8_t s, uint8_t *buf)
void | reset_DHCP_timeout (void)
void | DHCP_time_handler (void)
void | getIPfromDHCP (uint8_t *ip)
void | getGWfromDHCP (uint8_t *ip)
void | getSNfromDHCP (uint8_t *ip)
void | getDNSfromDHCP (uint8_t *ip)
uint32_t | getDHCPLeasetime (void)

Variables

uint8_t | DHCP_SOCKET
uint8_t | DHCP_SIP [4]
uint8_t | OLD_allocated_ip [4] = {0, }
uint8_t | DHCP_allocated_ip [4] = {0, }
uint8_t | DHCP_allocated_gw [4] = {0, }
uint8_t | DHCP_allocated_sn [4] = {0, }
uint8_t | DHCP_allocated_dns [4] = {0, }
int8_t | dhcp_state = STATE_DHCP_INIT
int8_t | dhcp_retry_count = 0
uint32_t | dhcp_lease_time = INFINITE_LEASETIME
volatile uint32_t | dhcp_tick_1s = 0
uint32_t | dhcp_tick_next = DHCP_WAIT_TIME
uint32_t | DHCP_XID
RIP_MSG * pDHCPMSG
uint8_t | HOST_NAME [] = DCHP_HOST_NAME
uint8_t | DHCP_CHADDR [6]
void(* | dhcp_ip_assign )(void)

Detailed Description

DHCP APIs implement file.

Processig DHCP protocol as DISCOVER, OFFER, REQUEST, ACK, NACK and DECLINE.

Version
1.1.0
Date
2013/11/18
Revision history
<2013/11/18> 1st Release <2012/12/20> V1.1.0
  1. Optimize code
  2. Add reg_dhcp_cbfunc()
  3. Add DHCP_stop()
  4. Integrate check_DHCP_state() & DHCP_run() to DHCP_run()
  5. Don't care system endian
  6. Add comments <2012/12/26> V1.1.1
  1. Modify variable declaration: dhcp_tick_1s is declared volatile for code optimization
Author
Eric Jung & 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 dhcp.c.

Macro Definition Documentation

◆ DHCP_ACK

#define DHCP_ACK 5

ACK message in OPT of RIP_MSG.

Definition at line 82 of file dhcp.c.

◆ DHCP_BOOTREPLY

#define DHCP_BOOTREPLY 2

Reply Message used i op of RIP_MSG.

Definition at line 75 of file dhcp.c.

◆ DHCP_BOOTREQUEST

#define DHCP_BOOTREQUEST 1

Request Message used in op of RIP_MSG.

Definition at line 74 of file dhcp.c.

◆ DHCP_DECLINE

#define DHCP_DECLINE 4

DECLINE message in OPT of RIP_MSG.

Definition at line 81 of file dhcp.c.

◆ DHCP_DISCOVER

#define DHCP_DISCOVER 1

DISCOVER message in OPT of RIP_MSG.

Definition at line 78 of file dhcp.c.

◆ DHCP_FLAGSBROADCAST

#define DHCP_FLAGSBROADCAST 0x8000

The broadcast value of flags in RIP_MSG.

Definition at line 70 of file dhcp.c.

◆ DHCP_FLAGSUNICAST

#define DHCP_FLAGSUNICAST 0x0000

The unicast value of flags in RIP_MSG.

Definition at line 71 of file dhcp.c.

◆ DHCP_HLENETHERNET

#define DHCP_HLENETHERNET 6

Used in hlen of RIP_MSG.

Definition at line 90 of file dhcp.c.

◆ DHCP_HOPS

#define DHCP_HOPS 0

Used in hops of RIP_MSG.

Definition at line 91 of file dhcp.c.

◆ DHCP_HTYPE100MB

#define DHCP_HTYPE100MB 2

Used in type of RIP_MSG.

Definition at line 88 of file dhcp.c.

◆ DHCP_HTYPE10MB

#define DHCP_HTYPE10MB 1

Used in type of RIP_MSG.

Definition at line 87 of file dhcp.c.

◆ DHCP_INFORM

#define DHCP_INFORM 8

INFORM message in OPT of RIP_MSG. No use.

Definition at line 85 of file dhcp.c.

◆ DHCP_NAK

#define DHCP_NAK 6

NACK message in OPT of RIP_MSG.

Definition at line 83 of file dhcp.c.

◆ DHCP_OFFER

#define DHCP_OFFER 2

OFFER message in OPT of RIP_MSG.

Definition at line 79 of file dhcp.c.

◆ DHCP_RELEASE

#define DHCP_RELEASE 7

RELEASE message in OPT of RIP_MSG. No use.

Definition at line 84 of file dhcp.c.

◆ DHCP_REQUEST

#define DHCP_REQUEST 3

REQUEST message in OPT of RIP_MSG.

Definition at line 80 of file dhcp.c.

◆ DHCP_SECS

#define DHCP_SECS 0

Used in secs of RIP_MSG.

Definition at line 92 of file dhcp.c.

◆ INFINITE_LEASETIME

#define INFINITE_LEASETIME 0xffffffff

Infinite lease time.

Definition at line 94 of file dhcp.c.

◆ OPT_SIZE

#define OPT_SIZE 312

Definition at line 96 of file dhcp.c.

◆ RIP_MSG_SIZE

#define RIP_MSG_SIZE (236+OPT_SIZE)

Definition at line 97 of file dhcp.c.

◆ STATE_DHCP_DISCOVER

#define STATE_DHCP_DISCOVER 1

send DISCOVER and wait OFFER

Definition at line 63 of file dhcp.c.

◆ STATE_DHCP_INIT

#define STATE_DHCP_INIT 0

Initialize.

Definition at line 62 of file dhcp.c.

◆ STATE_DHCP_LEASED

#define STATE_DHCP_LEASED 3

ReceiveD ACK and IP leased.

Definition at line 65 of file dhcp.c.

◆ STATE_DHCP_RELEASE

#define STATE_DHCP_RELEASE 5

No use.

Definition at line 67 of file dhcp.c.

◆ STATE_DHCP_REQUEST

#define STATE_DHCP_REQUEST 2

send REQEUST and wait ACK or NACK

Definition at line 64 of file dhcp.c.

◆ STATE_DHCP_REREQUEST

#define STATE_DHCP_REREQUEST 4

send REQUEST for maintaining leased IP

Definition at line 66 of file dhcp.c.

◆ STATE_DHCP_STOP

#define STATE_DHCP_STOP 6

Stop procssing DHCP.

Definition at line 68 of file dhcp.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
padOption
subnetMask
timerOffset
routersOnSubnet
timeServer
nameServer
dns
logServer
cookieServer
lprServer
impressServer
resourceLocationServer
hostName
bootFileSize
meritDumpFile
domainName
swapServer
rootPath
extentionsPath
IPforwarding
nonLocalSourceRouting
policyFilter
maxDgramReasmSize
defaultIPTTL
pathMTUagingTimeout
pathMTUplateauTable
ifMTU
allSubnetsLocal
broadcastAddr
performMaskDiscovery
maskSupplier
performRouterDiscovery
routerSolicitationAddr
staticRoute
trailerEncapsulation
arpCacheTimeout
ethernetEncapsulation
tcpDefaultTTL
tcpKeepaliveInterval
tcpKeepaliveGarbage
nisDomainName
nisServers
ntpServers
vendorSpecificInfo
netBIOSnameServer
netBIOSdgramDistServer
netBIOSnodeType
netBIOSscope
xFontServer
xDisplayManager
dhcpRequestedIPaddr
dhcpIPaddrLeaseTime
dhcpOptionOverload
dhcpMessageType
dhcpServerIdentifier
dhcpParamRequest
dhcpMsg
dhcpMaxMsgSize
dhcpT1value
dhcpT2value
dhcpClassIdentifier
dhcpClientIdentifier
endOption

Definition at line 102 of file dhcp.c.

Function Documentation

◆ check_DHCP_leasedIP()

int8_t check_DHCP_leasedIP ( void )

Definition at line 859 of file dhcp.c.

◆ check_DHCP_timeout()

uint8_t check_DHCP_timeout ( void )

Definition at line 806 of file dhcp.c.

◆ default_ip_assign()

void default_ip_assign ( void )

◆ default_ip_conflict()

void default_ip_conflict ( void )

Definition at line 272 of file dhcp.c.

◆ default_ip_update()

void default_ip_update ( void )

Definition at line 262 of file dhcp.c.

◆ DHCP_init()

void DHCP_init | ( | uint8_t | s,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 894 of file dhcp.c.

◆ DHCP_run()

uint8_t DHCP_run ( void )

Definition at line 670 of file dhcp.c.

◆ DHCP_stop()

void DHCP_stop ( void )

Definition at line 800 of file dhcp.c.

◆ DHCP_time_handler()

void DHCP_time_handler ( void )

Definition at line 932 of file dhcp.c.

◆ getDHCPLeasetime()

uint32_t getDHCPLeasetime ( void )

Definition at line 969 of file dhcp.c.

◆ getDNSfromDHCP()

void getDNSfromDHCP ( uint8_t * ip )

Definition at line 961 of file dhcp.c.

◆ getGWfromDHCP()

void getGWfromDHCP ( uint8_t * ip )

Definition at line 945 of file dhcp.c.

◆ getIPfromDHCP()

void getIPfromDHCP ( uint8_t * ip )

Definition at line 937 of file dhcp.c.

◆ getSNfromDHCP()

void getSNfromDHCP ( uint8_t * ip )

Definition at line 953 of file dhcp.c.

◆ makeDHCPMSG()

void makeDHCPMSG ( void )

Definition at line 292 of file dhcp.c.

◆ parseDHCPMSG()

int8_t parseDHCPMSG ( void )

Definition at line 569 of file dhcp.c.

◆ reg_dhcp_cbfunc()

void reg_dhcp_cbfunc | ( | void(*)(void) | ip_assign,
 |  | void(*)(void) | ip_update,
 |  | void(*)(void) | ip_conflict
 | ) |  |

Definition at line 281 of file dhcp.c.

◆ reset_DHCP_timeout()

void reset_DHCP_timeout ( void )

Definition at line 925 of file dhcp.c.

◆ send_DHCP_DECLINE()

void send_DHCP_DECLINE ( void )

Definition at line 509 of file dhcp.c.

◆ send_DHCP_DISCOVER()

void send_DHCP_DISCOVER ( void )

Definition at line 351 of file dhcp.c.

◆ send_DHCP_REQUEST()

void send_DHCP_REQUEST ( void )

Definition at line 413 of file dhcp.c.

Variable Documentation

◆ DHCP_allocated_dns

uint8_t DHCP_allocated_dns[4] = {0, }

Definition at line 201 of file dhcp.c.

◆ DHCP_allocated_gw

uint8_t DHCP_allocated_gw[4] = {0, }

Definition at line 199 of file dhcp.c.

◆ DHCP_allocated_ip

uint8_t DHCP_allocated_ip[4] = {0, }

Definition at line 198 of file dhcp.c.

◆ DHCP_allocated_sn

uint8_t DHCP_allocated_sn[4] = {0, }

Definition at line 200 of file dhcp.c.

◆ DHCP_CHADDR

uint8_t DHCP_CHADDR[6]

Definition at line 217 of file dhcp.c.

◆ dhcp_ip_assign

void(* dhcp_ip_assign) (void)
default

Definition at line 225 of file dhcp.c.

◆ dhcp_lease_time

uint32_t dhcp_lease_time = INFINITE_LEASETIME

Definition at line 207 of file dhcp.c.

◆ dhcp_retry_count

int8_t dhcp_retry_count = 0

Definition at line 205 of file dhcp.c.

◆ DHCP_SIP

uint8_t DHCP_SIP[4]

Definition at line 194 of file dhcp.c.

◆ DHCP_SOCKET

uint8_t DHCP_SOCKET

Definition at line 192 of file dhcp.c.

◆ dhcp_state

int8_t dhcp_state = STATE_DHCP_INIT

Definition at line 204 of file dhcp.c.

◆ dhcp_tick_1s

volatile uint32_t dhcp_tick_1s = 0

Definition at line 208 of file dhcp.c.

◆ dhcp_tick_next

uint32_t dhcp_tick_next = DHCP_WAIT_TIME

Definition at line 209 of file dhcp.c.

◆ DHCP_XID

uint32_t DHCP_XID

Definition at line 211 of file dhcp.c.

◆ HOST_NAME

uint8_t HOST_NAME[] = DCHP_HOST_NAME

Definition at line 215 of file dhcp.c.

◆ OLD_allocated_ip

uint8_t OLD_allocated_ip[4] = {0, }

Definition at line 197 of file dhcp.c.

◆ pDHCPMSG

RIP_MSG* pDHCPMSG

Definition at line 213 of file dhcp.c.


ioLibrary: Internet/DHCP/dhcp.h File Reference

  • Internet
  • DHCP
Macros | Enumerations | Functions
dhcp.h File Reference

DHCP APIs Header file. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | MAX_DHCP_RETRY 2
Maxium retry count. More...
#define | DHCP_WAIT_TIME 10
Wait Time 10s. More...
#define | DHCP_SERVER_PORT 67
DHCP server port number. More...
#define | DHCP_CLIENT_PORT 68
DHCP client port number. More...
#define | MAGIC_COOKIE 0x63825363
Any number. You can be modifyed it any number. More...
#define | DCHP_HOST_NAME "WIZnet\0"

Enumerations

enum {
DHCP_FAILED = 0, DHCP_RUNNING, DHCP_IP_ASSIGN, DHCP_IP_CHANGED,
DHCP_IP_LEASED, DHCP_STOPPED
}

Functions

void | DHCP_init (uint8_t s, uint8_t *buf)
void | DHCP_time_handler (void)
void | reg_dhcp_cbfunc (void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void))
uint8_t | DHCP_run (void)
void | DHCP_stop (void)
void | getIPfromDHCP (uint8_t *ip)
void | getGWfromDHCP (uint8_t *ip)
void | getSNfromDHCP (uint8_t *ip)
void | getDNSfromDHCP (uint8_t *ip)
uint32_t | getDHCPLeasetime (void)

Detailed Description

DHCP APIs Header file.

Processig DHCP protocol as DISCOVER, OFFER, REQUEST, ACK, NACK and DECLINE.

Version
1.1.0
Date
2013/11/18
Revision history
<2013/11/18> 1st Release <2012/12/20> V1.1.0
  1. Move unreferenced DEFINE to dhcp.c <2012/12/26> V1.1.1
Author
Eric Jung & 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 dhcp.h.

Macro Definition Documentation

◆ DCHP_HOST_NAME

#define DCHP_HOST_NAME "WIZnet\0"

Definition at line 68 of file dhcp.h.

◆ DHCP_CLIENT_PORT

#define DHCP_CLIENT_PORT 68

DHCP client port number.

Definition at line 63 of file dhcp.h.

◆ DHCP_SERVER_PORT

#define DHCP_SERVER_PORT 67

DHCP server port number.

Definition at line 62 of file dhcp.h.

◆ DHCP_WAIT_TIME

#define DHCP_WAIT_TIME 10

Wait Time 10s.

Definition at line 58 of file dhcp.h.

◆ MAGIC_COOKIE

#define MAGIC_COOKIE 0x63825363

Any number. You can be modifyed it any number.

Definition at line 66 of file dhcp.h.

◆ MAX_DHCP_RETRY

#define MAX_DHCP_RETRY 2

Maxium retry count.

Definition at line 57 of file dhcp.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DHCP_FAILED | Procssing Fail.
DHCP_RUNNING | Procssing DHCP proctocol.
DHCP_IP_ASSIGN | First Occupy IP from DHPC server (if cbfunc == null, act as default default_ip_assign)
DHCP_IP_CHANGED | Change IP address by new ip from DHCP (if cbfunc == null, act as default default_ip_update)
DHCP_IP_LEASED | Stand by.
DHCP_STOPPED | Stop procssing DHCP protocol.

Definition at line 73 of file dhcp.h.

Function Documentation

◆ DHCP_init()

void DHCP_init | ( | uint8_t | s,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 894 of file dhcp.c.

◆ DHCP_run()

uint8_t DHCP_run ( void )

Definition at line 670 of file dhcp.c.

◆ DHCP_stop()

void DHCP_stop ( void )

Definition at line 800 of file dhcp.c.

◆ DHCP_time_handler()

void DHCP_time_handler ( void )

Definition at line 932 of file dhcp.c.

◆ getDHCPLeasetime()

uint32_t getDHCPLeasetime ( void )

Definition at line 969 of file dhcp.c.

◆ getDNSfromDHCP()

void getDNSfromDHCP ( uint8_t * ip )

Definition at line 961 of file dhcp.c.

◆ getGWfromDHCP()

void getGWfromDHCP ( uint8_t * ip )

Definition at line 945 of file dhcp.c.

◆ getIPfromDHCP()

void getIPfromDHCP ( uint8_t * ip )

Definition at line 937 of file dhcp.c.

◆ getSNfromDHCP()

void getSNfromDHCP ( uint8_t * ip )

Definition at line 953 of file dhcp.c.

◆ reg_dhcp_cbfunc()

void reg_dhcp_cbfunc | ( | void(*)(void) | ip_assign,
 |  | void(*)(void) | ip_update,
 |  | void(*)(void) | ip_conflict
 | ) |  |

Definition at line 281 of file dhcp.c.


ioLibrary: Internet/DNS Directory Reference

  • Internet
  • DNS
DNS Directory Reference
Directory dependency graph for DNS:

Files

file | dns.c [code]
DNS APIs Implement file.
file | dns.h [code]
DNS APIs Header file.


ioLibrary: Internet/DNS/dns.c File Reference

  • Internet
  • DNS
Data Structures | Macros | Functions | Variables
dns.c File Reference

DNS APIs Implement file. More...

#include <string.h>
#include <stdlib.h>
#include "socket.h"
#include "dns.h"
Include dependency graph for dns.c:

Go to the source code of this file.

Data Structures

struct dhdr

Macros

#define | INITRTT 2000L /* Initial smoothed response time */
#define | MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */
#define | TYPE_A 1 /* Host address */
#define | TYPE_NS 2 /* Name server */
#define | TYPE_MD 3 /* Mail destination (obsolete) */
#define | TYPE_MF 4 /* Mail forwarder (obsolete) */
#define | TYPE_CNAME 5 /* Canonical name */
#define | TYPE_SOA 6 /* Start of Authority */
#define | TYPE_MB 7 /* Mailbox name (experimental) */
#define | TYPE_MG 8 /* Mail group member (experimental) */
#define | TYPE_MR 9 /* Mail rename name (experimental) */
#define | TYPE_NULL 10 /* Null (experimental) */
#define | TYPE_WKS 11 /* Well-known sockets */
#define | TYPE_PTR 12 /* Pointer record */
#define | TYPE_HINFO 13 /* Host information */
#define | TYPE_MINFO 14 /* Mailbox information (experimental)*/
#define | TYPE_MX 15 /* Mail exchanger */
#define | TYPE_TXT 16 /* Text strings */
#define | TYPE_ANY 255 /* Matches any type */
#define | CLASS_IN 1 /* The ARPA Internet */
#define | AGAIN 8 /* Average RTT gain = 1/8 */
#define | LAGAIN 3 /* Log2(AGAIN) */
#define | DGAIN 4 /* Mean deviation gain = 1/4 */
#define | LDGAIN 2 /* log2(DGAIN) */
#define | QUERY 0
#define | RESPONSE 1
#define | IQUERY 1
#define | NO_ERROR 0
#define | FORMAT_ERROR 1
#define | SERVER_FAIL 2
#define | NAME_ERROR 3
#define | NOT_IMPL 4
#define | REFUSED 5

Functions

uint16_t | get16 (uint8_t *s)
uint8_t * | put16 (uint8_t *s, uint16_t i)
int | parse_name (uint8_t *msg, uint8_t *compressed, char *buf, int16_t len)
uint8_t * | dns_question (uint8_t *msg, uint8_t *cp)
uint8_t * | dns_answer (uint8_t *msg, uint8_t *cp, uint8_t *ip_from_dns)
int8_t | parseDNSMSG (struct dhdr *pdhdr, uint8_t *pbuf, uint8_t *ip_from_dns)
int16_t | dns_makequery (uint16_t op, char *name, uint8_t *buf, uint16_t len)
int8_t | check_DNS_timeout (void)
void | DNS_init (uint8_t s, uint8_t *buf)
int8_t | DNS_run (uint8_t *dns_ip, uint8_t *name, uint8_t *ip_from_dns)
void | DNS_time_handler (void)

Variables

uint8_t * | pDNSMSG
uint8_t | DNS_SOCKET
uint16_t | DNS_MSGID
uint32_t | dns_1s_tick

Detailed Description

DNS APIs Implement file.

Send DNS query & Receive DNS reponse.
It depends on stdlib.h & string.h in ansi-c library

Version
1.1.0
Date
2013/11/18
Revision history
<2013/10/21> 1st Release <2013/12/20> V1.1.0
  1. Remove secondary DNS server in DNS_run If 1st DNS_run failed, call DNS_run with 2nd DNS again
  2. DNS_timerHandler -> DNS_time_handler
  3. Remove the unused define
  4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c <2013/12/20> V1.1.0
Author
Eric Jung & 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 dns.c.

Macro Definition Documentation

◆ AGAIN

#define AGAIN 8 /* Average RTT gain = 1/8 */

Definition at line 86 of file dns.c.

◆ CLASS_IN

#define CLASS_IN 1 /* The ARPA Internet */

Definition at line 83 of file dns.c.

◆ DGAIN

#define DGAIN 4 /* Mean deviation gain = 1/4 */

Definition at line 88 of file dns.c.

◆ FORMAT_ERROR

#define FORMAT_ERROR 1

Definition at line 106 of file dns.c.

◆ INITRTT

#define INITRTT 2000L /* Initial smoothed response time */

Definition at line 62 of file dns.c.

◆ IQUERY

#define IQUERY 1

Definition at line 99 of file dns.c.

◆ LAGAIN

#define LAGAIN 3 /* Log2(AGAIN) */

Definition at line 87 of file dns.c.

◆ LDGAIN

#define LDGAIN 2 /* log2(DGAIN) */

Definition at line 89 of file dns.c.

◆ MAXCNAME

#define MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */

Definition at line 63 of file dns.c.

◆ NAME_ERROR

#define NAME_ERROR 3

Definition at line 108 of file dns.c.

◆ NO_ERROR

#define NO_ERROR 0

Definition at line 105 of file dns.c.

◆ NOT_IMPL

#define NOT_IMPL 4

Definition at line 109 of file dns.c.

◆ QUERY

#define QUERY 0

Definition at line 96 of file dns.c.

◆ REFUSED

#define REFUSED 5

Definition at line 110 of file dns.c.

◆ RESPONSE

#define RESPONSE 1

Definition at line 97 of file dns.c.

◆ SERVER_FAIL

#define SERVER_FAIL 2

Definition at line 107 of file dns.c.

◆ TYPE_A

#define TYPE_A 1 /* Host address */

Definition at line 65 of file dns.c.

◆ TYPE_ANY

#define TYPE_ANY 255 /* Matches any type */

Definition at line 81 of file dns.c.

◆ TYPE_CNAME

#define TYPE_CNAME 5 /* Canonical name */

Definition at line 69 of file dns.c.

◆ TYPE_HINFO

#define TYPE_HINFO 13 /* Host information */

Definition at line 77 of file dns.c.

◆ TYPE_MB

#define TYPE_MB 7 /* Mailbox name (experimental) */

Definition at line 71 of file dns.c.

◆ TYPE_MD

#define TYPE_MD 3 /* Mail destination (obsolete) */

Definition at line 67 of file dns.c.

◆ TYPE_MF

#define TYPE_MF 4 /* Mail forwarder (obsolete) */

Definition at line 68 of file dns.c.

◆ TYPE_MG

#define TYPE_MG 8 /* Mail group member (experimental) */

Definition at line 72 of file dns.c.

◆ TYPE_MINFO

#define TYPE_MINFO 14 /* Mailbox information (experimental)*/

Definition at line 78 of file dns.c.

◆ TYPE_MR

#define TYPE_MR 9 /* Mail rename name (experimental) */

Definition at line 73 of file dns.c.

◆ TYPE_MX

#define TYPE_MX 15 /* Mail exchanger */

Definition at line 79 of file dns.c.

◆ TYPE_NS

#define TYPE_NS 2 /* Name server */

Definition at line 66 of file dns.c.

◆ TYPE_NULL

#define TYPE_NULL 10 /* Null (experimental) */

Definition at line 74 of file dns.c.

◆ TYPE_PTR

#define TYPE_PTR 12 /* Pointer record */

Definition at line 76 of file dns.c.

◆ TYPE_SOA

#define TYPE_SOA 6 /* Start of Authority */

Definition at line 70 of file dns.c.

◆ TYPE_TXT

#define TYPE_TXT 16 /* Text strings */

Definition at line 80 of file dns.c.

◆ TYPE_WKS

#define TYPE_WKS 11 /* Well-known sockets */

Definition at line 75 of file dns.c.

Function Documentation

◆ check_DNS_timeout()

int8_t check_DNS_timeout ( void )

Definition at line 473 of file dns.c.

◆ dns_answer()

uint8_t* dns_answer | ( | uint8_t * | msg,
 |  | uint8_t * | cp,
 |  | uint8_t * | ip_from_dns
 | ) |  |

Definition at line 239 of file dns.c.

◆ DNS_init()

void DNS_init | ( | uint8_t | s,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 494 of file dns.c.

◆ dns_makequery()

int16_t dns_makequery | ( | uint16_t | op,
 |  | char * | name,
 |  | uint8_t * | buf,
 |  | uint16_t | len
 | ) |  |

Definition at line 412 of file dns.c.

◆ dns_question()

uint8_t* dns_question | ( | uint8_t * | msg,
 |  | uint8_t * | cp
 | ) |  |

Definition at line 213 of file dns.c.

◆ DNS_run()

int8_t DNS_run | ( | uint8_t * | dns_ip,
 |  | uint8_t * | name,
 |  | uint8_t * | ip_from_dns
 | ) |  |

Definition at line 502 of file dns.c.

◆ DNS_time_handler()

void DNS_time_handler ( void )

Definition at line 557 of file dns.c.

◆ get16()

uint16_t get16 ( uint8_t * s )

Definition at line 125 of file dns.c.

◆ parse_name()

int parse_name | ( | uint8_t * | msg,
 |  | uint8_t * | compressed,
 |  | char * | buf,
 |  | int16_t | len
 | ) |  |

Definition at line 152 of file dns.c.

◆ parseDNSMSG()

int8_t parseDNSMSG | ( | struct dhdr * | pdhdr,
 |  | uint8_t * | pbuf,
 |  | uint8_t * | ip_from_dns
 | ) |  |

Definition at line 334 of file dns.c.

◆ put16()

uint8_t* put16 | ( | uint8_t * | s,
 |  | uint16_t | i
 | ) |  |

Definition at line 134 of file dns.c.

Variable Documentation

◆ dns_1s_tick

uint32_t dns_1s_tick

Definition at line 122 of file dns.c.

◆ DNS_MSGID

uint16_t DNS_MSGID

Definition at line 120 of file dns.c.

◆ DNS_SOCKET

uint8_t DNS_SOCKET

Definition at line 119 of file dns.c.

◆ pDNSMSG

uint8_t* pDNSMSG

Definition at line 118 of file dns.c.


ioLibrary: Internet/DNS/dns.h File Reference

  • Internet
  • DNS
Macros | Functions
dns.h File Reference

DNS APIs Header file. More...

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

Go to the source code of this file.

Macros

#define | MAX_DNS_BUF_SIZE 256
maximum size of DNS buffer. */ More...
#define | MAX_DOMAIN_NAME 16
#define | MAX_DNS_RETRY 2
Requery Count. More...
#define | DNS_WAIT_TIME 3
Wait response time. unit 1s. More...
#define | IPPORT_DOMAIN 53
DNS server port number. More...
#define | DNS_MSG_ID 0x1122
ID for DNS message. You can be modifyed it any number. More...

Functions

void | DNS_init (uint8_t s, uint8_t *buf)
int8_t | DNS_run (uint8_t *dns_ip, uint8_t *name, uint8_t *ip_from_dns)
void | DNS_time_handler (void)

Detailed Description

DNS APIs Header file.

Send DNS query & Receive DNS reponse.

Version
1.1.0
Date
2013/11/18
Revision history
<2013/10/21> 1st Release <2013/12/20> V1.1.0
  1. Remove secondary DNS server in DNS_run If 1st DNS_run failed, call DNS_run with 2nd DNS again
  2. DNS_timerHandler -> DNS_time_handler
  3. Move the no reference define to dns.c
  4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c <2013/12/20> V1.1.0
Author
Eric Jung & 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 dns.h.

Macro Definition Documentation

◆ DNS_MSG_ID

#define DNS_MSG_ID 0x1122

ID for DNS message. You can be modifyed it any number.

Definition at line 74 of file dns.h.

◆ DNS_WAIT_TIME

#define DNS_WAIT_TIME 3

Wait response time. unit 1s.

Definition at line 70 of file dns.h.

◆ IPPORT_DOMAIN

#define IPPORT_DOMAIN 53

DNS server port number.

Definition at line 72 of file dns.h.

◆ MAX_DNS_BUF_SIZE

#define MAX_DNS_BUF_SIZE 256

maximum size of DNS buffer. */

Definition at line 61 of file dns.h.

◆ MAX_DNS_RETRY

#define MAX_DNS_RETRY 2

Requery Count.

Definition at line 69 of file dns.h.

◆ MAX_DOMAIN_NAME

#define MAX_DOMAIN_NAME 16

Definition at line 67 of file dns.h.

Function Documentation

◆ DNS_init()

void DNS_init | ( | uint8_t | s,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 494 of file dns.c.

◆ DNS_run()

int8_t DNS_run | ( | uint8_t * | dns_ip,
 |  | uint8_t * | name,
 |  | uint8_t * | ip_from_dns
 | ) |  |

Definition at line 502 of file dns.c.

◆ DNS_time_handler()

void DNS_time_handler ( void )

Definition at line 557 of file dns.c.


ioLibrary: Internet/FTPClient Directory Reference

  • Internet
  • FTPClient
FTPClient Directory Reference
Directory dependency graph for FTPClient:

Files

file | ftpc.c [code]
file | ftpc.h [code]
file | stdio_private.h [code]


ioLibrary: Internet/FTPClient/ftpc.c File Reference

  • Internet
  • FTPClient
Functions | Variables
ftpc.c File Reference
#include "ftpc.h"
Include dependency graph for ftpc.c:

Go to the source code of this file.

Functions

void | ftpc_init (uint8_t *src_ip)
uint8_t | ftpc_run (uint8_t *dbuf)
char | proc_ftpc (char *buf)
int | pportc (char *arg)
uint8_t * | User_Keyboard_MSG ()

Variables

un_l2cval remote_ip
uint16_t | remote_port
un_l2cval local_ip
uint16_t | local_port
uint8_t | connect_state_control_ftpc = 0
uint8_t | connect_state_data_ftpc = 0
uint8_t | gModeActivePassiveflag = 0
uint8_t | FTP_destip [4] = {192, 168, 10, 230}
uint16_t | FTP_destport = 21
uint8_t | gMenuStart = 0
uint8_t | gDataSockReady = 0
uint8_t | gDataPutGetStart = 0
struct ftpc | ftpc
struct Command | Command

Function Documentation

◆ ftpc_init()

void ftpc_init ( uint8_t * src_ip )

Definition at line 20 of file ftpc.c.

◆ ftpc_run()

uint8_t ftpc_run ( uint8_t * dbuf )

Definition at line 32 of file ftpc.c.

◆ pportc()

int pportc ( char * arg )

Definition at line 547 of file ftpc.c.

◆ proc_ftpc()

char proc_ftpc ( char * buf )

Definition at line 468 of file ftpc.c.

◆ User_Keyboard_MSG()

uint8_t* User_Keyboard_MSG ( )

Definition at line 575 of file ftpc.c.

Variable Documentation

◆ Command

struct Command Command

Definition at line 18 of file ftpc.c.

◆ connect_state_control_ftpc

uint8_t connect_state_control_ftpc = 0

Definition at line 7 of file ftpc.c.

◆ connect_state_data_ftpc

uint8_t connect_state_data_ftpc = 0

Definition at line 8 of file ftpc.c.

◆ FTP_destip

uint8_t FTP_destip[4] = {192, 168, 10, 230}

Definition at line 10 of file ftpc.c.

◆ FTP_destport

uint16_t FTP_destport = 21

Definition at line 11 of file ftpc.c.

◆ ftpc

struct ftpc ftpc

Definition at line 17 of file ftpc.c.

◆ gDataPutGetStart

uint8_t gDataPutGetStart = 0

Definition at line 14 of file ftpc.c.

◆ gDataSockReady

uint8_t gDataSockReady = 0

Definition at line 13 of file ftpc.c.

◆ gMenuStart

uint8_t gMenuStart = 0

Definition at line 12 of file ftpc.c.

◆ gModeActivePassiveflag

uint8_t gModeActivePassiveflag = 0

Definition at line 9 of file ftpc.c.

◆ local_ip

un_l2cval local_ip

Definition at line 5 of file ftpc.c.

◆ local_port

uint16_t local_port

Definition at line 6 of file ftpc.c.

◆ remote_ip

un_l2cval remote_ip

Definition at line 3 of file ftpc.c.

◆ remote_port

uint16_t remote_port

Definition at line 4 of file ftpc.c.


ioLibrary: Internet/FTPClient/ftpc.h File Reference

  • Internet
  • FTPClient
Data Structures | Macros | Typedefs | Enumerations | Functions
ftpc.h File Reference
#include <stdint.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <stdarg.h>
#include "stdio_private.h"
#include "socket.h"
Include dependency graph for ftpc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct | Command
struct | ftpc
union | _un_l2cval

Macros

#define | F_APP_FTPC
#define | Need_UARTGetCharBlocking_func
#define | LINELEN 100
#define | _MAX_SS 512
#define | CTRL_SOCK 2
#define | DATA_SOCK 3
#define | R_150 150 /* File status ok; opening data conn */
#define | R_200 200 /* 'Generic' command ok */
#define | R_220 220 /* Service ready for new user. */
#define | R_226 226 /* Closing data connection. File transfer/abort successful */
#define | R_227 227 /* Entering passive mode (h1,h2,h3,h4,p1,p2) */
#define | R_230 230 /* User logged in, proceed */
#define | R_331 331 /* User name okay, need password. */
#define | TransferAscii 'A'
#define | TransferBinary 'I'

Typedefs

typedef union _un_l2cval un_l2cval

Enumerations

enum | ftpc_type { ASCII_TYPE, IMAGE_TYPE }
enum | ftpc_datasock_state { DATASOCK_IDLE, DATASOCK_READY, DATASOCK_START }
enum | ftpc_datasock_mode { PASSIVE_MODE, ACTIVE_MODE }
enum | CommandFirst { f_nocmd, f_dir, f_put, f_get }
enum | CommandSecond { s_nocmd, s_dir, s_put, s_get }

Functions

void | ftpc_init (uint8_t *src_ip)
uint8_t | ftpc_run (uint8_t *dbuf)
char | proc_ftpc (char *buf)
int | pportc (char *arg)
uint8_t * | User_Keyboard_MSG ()

Macro Definition Documentation

◆ _MAX_SS

#define _MAX_SS 512

Definition at line 39 of file ftpc.h.

◆ CTRL_SOCK

#define CTRL_SOCK 2

Definition at line 42 of file ftpc.h.

◆ DATA_SOCK

#define DATA_SOCK 3

Definition at line 43 of file ftpc.h.

◆ F_APP_FTPC

#define F_APP_FTPC

Definition at line 13 of file ftpc.h.

◆ LINELEN

#define LINELEN 100

Definition at line 37 of file ftpc.h.

◆ Need_UARTGetCharBlocking_func

#define Need_UARTGetCharBlocking_func

Definition at line 28 of file ftpc.h.

◆ R_150

#define R_150 150 /* File status ok; opening data conn */

Definition at line 46 of file ftpc.h.

◆ R_200

#define R_200 200 /* 'Generic' command ok */

Definition at line 47 of file ftpc.h.

◆ R_220

#define R_220 220 /* Service ready for new user. */

Definition at line 48 of file ftpc.h.

◆ R_226

#define R_226 226 /* Closing data connection. File transfer/abort successful */

Definition at line 49 of file ftpc.h.

◆ R_227

#define R_227 227 /* Entering passive mode (h1,h2,h3,h4,p1,p2) */

Definition at line 50 of file ftpc.h.

◆ R_230

#define R_230 230 /* User logged in, proceed */

Definition at line 51 of file ftpc.h.

◆ R_331

#define R_331 331 /* User name okay, need password. */

Definition at line 52 of file ftpc.h.

◆ TransferAscii

#define TransferAscii 'A'

Definition at line 54 of file ftpc.h.

◆ TransferBinary

#define TransferBinary 'I'

Definition at line 55 of file ftpc.h.

Typedef Documentation

◆ un_l2cval

typedef union _un_l2cval un_l2cval

Enumeration Type Documentation

◆ CommandFirst

enum CommandFirst
Enumerator
f_nocmd
f_dir
f_put
f_get

Definition at line 72 of file ftpc.h.

◆ CommandSecond

enum CommandSecond
Enumerator
s_nocmd
s_dir
s_put
s_get

Definition at line 78 of file ftpc.h.

◆ ftpc_datasock_mode

enum ftpc_datasock_mode
Enumerator
PASSIVE_MODE
ACTIVE_MODE

Definition at line 68 of file ftpc.h.

◆ ftpc_datasock_state

enum ftpc_datasock_state
Enumerator
DATASOCK_IDLE
DATASOCK_READY
DATASOCK_START

Definition at line 62 of file ftpc.h.

◆ ftpc_type

enum ftpc_type
Enumerator
ASCII_TYPE
IMAGE_TYPE

Definition at line 57 of file ftpc.h.

Function Documentation

◆ ftpc_init()

void ftpc_init ( uint8_t * src_ip )

Definition at line 20 of file ftpc.c.

◆ ftpc_run()

uint8_t ftpc_run ( uint8_t * dbuf )

Definition at line 32 of file ftpc.c.

◆ pportc()

int pportc ( char * arg )

Definition at line 547 of file ftpc.c.

◆ proc_ftpc()

char proc_ftpc ( char * buf )

Definition at line 468 of file ftpc.c.

◆ User_Keyboard_MSG()

uint8_t* User_Keyboard_MSG ( )

Definition at line 575 of file ftpc.c.


ioLibrary: Internet/FTPClient/stdio_private.h File Reference

  • Internet
  • FTPClient
Data Structures | Macros
stdio_private.h File Reference
#include <stdint.h>
#include <stdio.h>
Include dependency graph for stdio_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct __file

Macros

#define | __SRD 0x0001 /* OK to read */
#define | __SWR 0x0002 /* OK to write */
#define | __SSTR 0x0004 /* this is an sprintf/snprintf string */
#define | __SPGM 0x0008 /* fmt string is in progmem */
#define | __SERR 0x0010 /* found error */
#define | __SEOF 0x0020 /* found EOF */
#define | __SUNGET 0x040 /* ungetc() happened */
#define | PRINTF_MIN 1
#define | PRINTF_STD 2
#define | PRINTF_FLT 3
#define | SCANF_MIN 1
#define | SCANF_STD 2
#define | SCANF_FLT 3

Macro Definition Documentation

◆ __SEOF

#define __SEOF 0x0020 /* found EOF */

Definition at line 44 of file stdio_private.h.

◆ __SERR

#define __SERR 0x0010 /* found error */

Definition at line 43 of file stdio_private.h.

◆ __SPGM

#define __SPGM 0x0008 /* fmt string is in progmem */

Definition at line 42 of file stdio_private.h.

◆ __SRD

#define __SRD 0x0001 /* OK to read */

Definition at line 39 of file stdio_private.h.

◆ __SSTR

#define __SSTR 0x0004 /* this is an sprintf/snprintf string */

Definition at line 41 of file stdio_private.h.

◆ __SUNGET

#define __SUNGET 0x040 /* ungetc() happened */

Definition at line 45 of file stdio_private.h.

◆ __SWR

#define __SWR 0x0002 /* OK to write */

Definition at line 40 of file stdio_private.h.

◆ PRINTF_FLT

#define PRINTF_FLT 3

Definition at line 62 of file stdio_private.h.

◆ PRINTF_MIN

#define PRINTF_MIN 1

Definition at line 60 of file stdio_private.h.

◆ PRINTF_STD

#define PRINTF_STD 2

Definition at line 61 of file stdio_private.h.

◆ SCANF_FLT

#define SCANF_FLT 3

Definition at line 67 of file stdio_private.h.

◆ SCANF_MIN

#define SCANF_MIN 1

Definition at line 65 of file stdio_private.h.

◆ SCANF_STD

#define SCANF_STD 2

Definition at line 66 of file stdio_private.h.


ioLibrary: Internet/FTPServer Directory Reference

  • Internet
  • FTPServer
FTPServer Directory Reference
Directory dependency graph for FTPServer:

Files

file | ftpd.c [code]
file | ftpd.h [code]
file | stdio_private.h [code]


ioLibrary: Internet/FTPServer/ftpd.c File Reference

  • Internet
  • FTPServer
Functions | Variables
ftpd.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <stdarg.h>
#include "stdio_private.h"
#include "socket.h"
#include "ftpd.h"
Include dependency graph for ftpd.c:

Go to the source code of this file.

Functions

int | fsprintf (uint8_t s, const char *format,...)
void | ftpd_init (uint8_t *src_ip)
uint8_t | ftpd_run (uint8_t *dbuf)
char | proc_ftpd (char *buf)
char | ftplogin (char *pass)
int | pport (char *arg)

Variables

un_l2cval remote_ip
uint16_t | remote_port
un_l2cval local_ip
uint16_t | local_port
uint8_t | connect_state_control = 0
uint8_t | connect_state_data = 0
struct ftpd | ftp
int | current_year = 2014
int | current_month = 12
int | current_day = 31
int | current_hour = 10
int | current_min = 10
int | current_sec = 30

Function Documentation

◆ fsprintf()

int fsprintf | ( | uint8_t | s,
 |  | const char * | format,
 |  |  | ...
 | ) |  |

Definition at line 108 of file ftpd.c.

◆ ftpd_init()

void ftpd_init ( uint8_t * src_ip )

Definition at line 129 of file ftpd.c.

◆ ftpd_run()

uint8_t ftpd_run ( uint8_t * dbuf )

Definition at line 146 of file ftpd.c.

◆ ftplogin()

char ftplogin ( char * pass )

Definition at line 906 of file ftpd.c.

◆ pport()

int pport ( char * arg )

Definition at line 924 of file ftpd.c.

◆ proc_ftpd()

char proc_ftpd ( char * buf )

Definition at line 557 of file ftpd.c.

Variable Documentation

◆ connect_state_control

uint8_t connect_state_control = 0

Definition at line 96 of file ftpd.c.

◆ connect_state_data

uint8_t connect_state_data = 0

Definition at line 97 of file ftpd.c.

◆ current_day

int current_day = 31

Definition at line 103 of file ftpd.c.

◆ current_hour

int current_hour = 10

Definition at line 104 of file ftpd.c.

◆ current_min

int current_min = 10

Definition at line 105 of file ftpd.c.

◆ current_month

int current_month = 12

Definition at line 102 of file ftpd.c.

◆ current_sec

int current_sec = 30

Definition at line 106 of file ftpd.c.

◆ current_year

int current_year = 2014

Definition at line 101 of file ftpd.c.

◆ ftp

struct ftpd ftp

Definition at line 99 of file ftpd.c.

◆ local_ip

un_l2cval local_ip

Definition at line 94 of file ftpd.c.

◆ local_port

uint16_t local_port

Definition at line 95 of file ftpd.c.

◆ remote_ip

un_l2cval remote_ip

Definition at line 92 of file ftpd.c.

◆ remote_port

uint16_t remote_port

Definition at line 93 of file ftpd.c.


ioLibrary: Internet/FTPServer/ftpd.h File Reference

  • Internet
  • FTPServer
Data Structures | Macros | Typedefs | Enumerations | Functions
ftpd.h File Reference
#include <stdint.h>
Include dependency graph for ftpd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct | ftpd
union | _un_l2cval

Macros

#define | F_APP_FTP
#define | _FTP_DEBUG_
#define | LINELEN 100
#define | _MAX_SS 512
#define | CTRL_SOCK 2
#define | DATA_SOCK 3
#define | IPPORT_FTPD 20 /* FTP Data port */
#define | IPPORT_FTP 21 /* FTP Control port */
#define | HOSTNAME "iinChip"
#define | VERSION "1.0"
#define | FILENAME "a.txt"

Typedefs

typedef union _un_l2cval un_l2cval

Enumerations

enum ftp_cmd {
USER_CMD, ACCT_CMD, PASS_CMD, TYPE_CMD,
LIST_CMD, CWD_CMD, DELE_CMD, NAME_CMD,
QUIT_CMD, RETR_CMD, STOR_CMD, PORT_CMD,
NLST_CMD, PWD_CMD, XPWD_CMD, MKD_CMD,
XMKD_CMD, XRMD_CMD, RMD_CMD, STRU_CMD,
MODE_CMD, SYST_CMD, XMD5_CMD, XCWD_CMD,
FEAT_CMD, PASV_CMD, SIZE_CMD, MLSD_CMD,
APPE_CMD, NO_CMD
}
enum | ftp_type { ASCII_TYPE, IMAGE_TYPE, LOGICAL_TYPE }
enum | ftp_state { FTPS_NOT_LOGIN, FTPS_LOGIN }
enum | datasock_state { DATASOCK_IDLE, DATASOCK_READY, DATASOCK_START }
enum | datasock_mode { PASSIVE_MODE, ACTIVE_MODE }

Functions

void | ftpd_init (uint8_t *src_ip)
uint8_t | ftpd_run (uint8_t *dbuf)
char | proc_ftpd (char *buf)
char | ftplogin (char *pass)
int | pport (char *arg)
int | sendit (char *command)
int | recvit (char *command)
long | sendfile (uint8_t s, char *command)
long | recvfile (uint8_t s)

Macro Definition Documentation

◆ _FTP_DEBUG_

#define _FTP_DEBUG_

Definition at line 24 of file ftpd.h.

◆ _MAX_SS

#define _MAX_SS 512

Definition at line 30 of file ftpd.h.

◆ CTRL_SOCK

#define CTRL_SOCK 2

Definition at line 33 of file ftpd.h.

◆ DATA_SOCK

#define DATA_SOCK 3

Definition at line 34 of file ftpd.h.

◆ F_APP_FTP

#define F_APP_FTP

Definition at line 23 of file ftpd.h.

◆ FILENAME

#define FILENAME "a.txt"

Definition at line 42 of file ftpd.h.

◆ HOSTNAME

#define HOSTNAME "iinChip"

Definition at line 39 of file ftpd.h.

◆ IPPORT_FTP

#define IPPORT_FTP 21 /* FTP Control port */

Definition at line 37 of file ftpd.h.

◆ IPPORT_FTPD

#define IPPORT_FTPD 20 /* FTP Data port */

Definition at line 36 of file ftpd.h.

◆ LINELEN

#define LINELEN 100

Definition at line 27 of file ftpd.h.

◆ VERSION

#define VERSION "1.0"

Definition at line 40 of file ftpd.h.

Typedef Documentation

◆ un_l2cval

typedef union _un_l2cval un_l2cval

Enumeration Type Documentation

◆ datasock_mode

enum datasock_mode
Enumerator
PASSIVE_MODE
ACTIVE_MODE

Definition at line 95 of file ftpd.h.

◆ datasock_state

enum datasock_state
Enumerator
DATASOCK_IDLE
DATASOCK_READY
DATASOCK_START

Definition at line 89 of file ftpd.h.

◆ ftp_cmd

enum ftp_cmd
Enumerator
USER_CMD
ACCT_CMD
PASS_CMD
TYPE_CMD
LIST_CMD
CWD_CMD
DELE_CMD
NAME_CMD
QUIT_CMD
RETR_CMD
STOR_CMD
PORT_CMD
NLST_CMD
PWD_CMD
XPWD_CMD
MKD_CMD
XMKD_CMD
XRMD_CMD
RMD_CMD
STRU_CMD
MODE_CMD
SYST_CMD
XMD5_CMD
XCWD_CMD
FEAT_CMD
PASV_CMD
SIZE_CMD
MLSD_CMD
APPE_CMD
NO_CMD

Definition at line 45 of file ftpd.h.

◆ ftp_state

enum ftp_state
Enumerator
FTPS_NOT_LOGIN
FTPS_LOGIN

Definition at line 84 of file ftpd.h.

◆ ftp_type

enum ftp_type
Enumerator
ASCII_TYPE
IMAGE_TYPE
LOGICAL_TYPE

Definition at line 78 of file ftpd.h.

Function Documentation

◆ ftpd_init()

void ftpd_init ( uint8_t * src_ip )

Definition at line 129 of file ftpd.c.

◆ ftpd_run()

uint8_t ftpd_run ( uint8_t * dbuf )

Definition at line 146 of file ftpd.c.

◆ ftplogin()

char ftplogin ( char * pass )

Definition at line 906 of file ftpd.c.

◆ pport()

int pport ( char * arg )

Definition at line 924 of file ftpd.c.

◆ proc_ftpd()

char proc_ftpd ( char * buf )

Definition at line 557 of file ftpd.c.

◆ recvfile()

long recvfile ( uint8_t s )

◆ recvit()

int recvit ( char * command )

◆ sendfile()

long sendfile | ( | uint8_t | s,
 |  | char * | command
 | ) |  |

◆ sendit()

int sendit ( char * command )


ioLibrary: Internet/FTPServer/stdio_private.h File Reference

  • Internet
  • FTPServer
Data Structures | Macros
stdio_private.h File Reference
#include <stdint.h>
#include <stdio.h>
Include dependency graph for stdio_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct __file

Macros

#define | __SRD 0x0001 /* OK to read */
#define | __SWR 0x0002 /* OK to write */
#define | __SSTR 0x0004 /* this is an sprintf/snprintf string */
#define | __SPGM 0x0008 /* fmt string is in progmem */
#define | __SERR 0x0010 /* found error */
#define | __SEOF 0x0020 /* found EOF */
#define | __SUNGET 0x040 /* ungetc() happened */
#define | PRINTF_MIN 1
#define | PRINTF_STD 2
#define | PRINTF_FLT 3
#define | SCANF_MIN 1
#define | SCANF_STD 2
#define | SCANF_FLT 3

Macro Definition Documentation

◆ __SEOF

#define __SEOF 0x0020 /* found EOF */

Definition at line 44 of file stdio_private.h.

◆ __SERR

#define __SERR 0x0010 /* found error */

Definition at line 43 of file stdio_private.h.

◆ __SPGM

#define __SPGM 0x0008 /* fmt string is in progmem */

Definition at line 42 of file stdio_private.h.

◆ __SRD

#define __SRD 0x0001 /* OK to read */

Definition at line 39 of file stdio_private.h.

◆ __SSTR

#define __SSTR 0x0004 /* this is an sprintf/snprintf string */

Definition at line 41 of file stdio_private.h.

◆ __SUNGET

#define __SUNGET 0x040 /* ungetc() happened */

Definition at line 45 of file stdio_private.h.

◆ __SWR

#define __SWR 0x0002 /* OK to write */

Definition at line 40 of file stdio_private.h.

◆ PRINTF_FLT

#define PRINTF_FLT 3

Definition at line 62 of file stdio_private.h.

◆ PRINTF_MIN

#define PRINTF_MIN 1

Definition at line 60 of file stdio_private.h.

◆ PRINTF_STD

#define PRINTF_STD 2

Definition at line 61 of file stdio_private.h.

◆ SCANF_FLT

#define SCANF_FLT 3

Definition at line 67 of file stdio_private.h.

◆ SCANF_MIN

#define SCANF_MIN 1

Definition at line 65 of file stdio_private.h.

◆ SCANF_STD

#define SCANF_STD 2

Definition at line 66 of file stdio_private.h.


ioLibrary: Internet/httpServer Directory Reference

  • Internet
  • httpServer
httpServer Directory Reference
Directory dependency graph for httpServer:

Files

file | httpParser.c [code]
file | httpParser.h [code]
file | httpServer.c [code]
file | httpServer.h [code]
Define constants and functions related HTTP Web server.
file | httpUtil.c [code]
HTTP Server Utilities

file | httpUtil.h [code]
Header File for HTTP Server Utilities.


ioLibrary: Internet/httpServer/httpParser.c File Reference

  • Internet
  • httpServer
Functions | Variables
httpParser.c File Reference
#include <stdio.h>
#include <string.h>
#include "socket.h"
#include "httpParser.h"
Include dependency graph for httpParser.c:

Go to the source code of this file.

Functions

void | unescape_http_url (char *url)
convert escape characters(XX) to ASCII character More...
void | make_http_response_head (char *buf, char type, uint32_t len)
make response header such as html, gif, jpeg,etc. More...
void | find_http_uri_type (uint8_t *type, uint8_t *buff)
find MIME type of a file More...
void | parse_http_request (st_http_request *request, uint8_t *buf)
parse http request from a peer More...
uint8_t * | get_http_param_value (char *uri, char *param_name)
get next parameter value in the request More...
uint8_t | get_http_uri_name (uint8_t *uri, uint8_t *uri_buf)
void | inet_addr_ (uint8_t *addr, uint8_t *ip)
uint16_t | ATOI (uint8_t *str, uint8_t base)
CONVERT STRING INTO INTEGER. More...
void | mid (char *src, char *s1, char *s2, char *sub)
Check strings and then execute callback function by each string. More...

Variables

uint8_t BUFPUB [256]

Function Documentation

◆ ATOI()

uint16_t ATOI | ( | uint8_t * | str,
 |  | uint8_t | base
 | ) |  |

CONVERT STRING INTO INTEGER.

Returns
a integer number
Parameters
str | is a pointer to convert
base | is a base value (must be in the range 2 - 16)

Definition at line 327 of file httpParser.c.

◆ find_http_uri_type()

void find_http_uri_type | ( | uint8_t * | type,
 |  | uint8_t * | buff
 | ) |  |

find MIME type of a file

Parameters
type | type to be returned
buff | file name

Definition at line 92 of file httpParser.c.

◆ get_http_param_value()

uint8_t* get_http_param_value | ( | char * | uri,
 |  | char * | param_name
 | ) |  |

get next parameter value in the request

Definition at line 204 of file httpParser.c.

◆ get_http_uri_name()

uint8_t get_http_uri_name | ( | uint8_t * | uri,
 |  | uint8_t * | uri_buf
 | ) |  |

Definition at line 281 of file httpParser.c.

◆ inet_addr_()

void inet_addr_ | ( | uint8_t * | addr,
 |  | uint8_t * | ip
 | ) |  |

Definition at line 302 of file httpParser.c.

◆ make_http_response_head()

void make_http_response_head | ( | char * | buf,
 |  | char | type,
 |  | uint32_t | len
 | ) |  |

make response header such as html, gif, jpeg,etc.

Parameters
buf | pointer to response header to be made
type | response type
len | size of response header

Definition at line 45 of file httpParser.c.

◆ mid()

void mid | ( | char * | src,
 |  | char * | s1,
 |  | char * | s2,
 |  | char * | sub
 | ) |  |

Check strings and then execute callback function by each string.

Parameters
src | The information of URI
s1 | The start string to be researched
s2 | The end string to be researched
sub | The string between s1 and s2
Returns
The length value atfer working

Definition at line 348 of file httpParser.c.

◆ parse_http_request()

void parse_http_request | ( | st_http_request * | request,
 |  | uint8_t * | buf
 | ) |  |

parse http request from a peer

Parameters
request | request to be returned
buf | pointer to be parsed

Definition at line 127 of file httpParser.c.

◆ unescape_http_url()

void unescape_http_url ( char * url )

convert escape characters(XX) to ASCII character

Parameters
url pointer to be converted ( escape characters )

Definition at line 26 of file httpParser.c.

Variable Documentation

◆ BUFPUB

uint8_t BUFPUB[256]

Definition at line 15 of file httpParser.c.


ioLibrary: Internet/httpServer/httpParser.h File Reference

  • Internet
  • httpServer
Data Structures | Macros | Typedefs | Functions
httpParser.h File Reference
#include <stdint.h>
Include dependency graph for httpParser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct _st_http_request

Macros

#define | HTTP_SERVER_PORT 80
#define | METHOD_ERR 0
#define | METHOD_GET 1
#define | METHOD_HEAD 2
#define | METHOD_POST 3
#define | PTYPE_ERR 0
#define | PTYPE_HTML 1
#define | PTYPE_GIF 2
#define | PTYPE_TEXT 3
#define | PTYPE_JPEG 4
#define | PTYPE_FLASH 5
#define | PTYPE_MPEG 6
#define | PTYPE_PDF 7
#define | PTYPE_CGI 8
#define | PTYPE_XML 9
#define | PTYPE_CSS 10
#define | PTYPE_JS 11
#define | PTYPE_JSON 12
#define | PTYPE_PNG 13
#define | PTYPE_ICO 14
#define | PTYPE_TTF 20
#define | PTYPE_OTF 21
#define | PTYPE_WOFF 22
#define | PTYPE_EOT 23
#define | PTYPE_SVG 24
#define | STATUS_OK 200
#define | STATUS_CREATED 201
#define | STATUS_ACCEPTED 202
#define | STATUS_NO_CONTENT 204
#define | STATUS_MV_PERM 301
#define | STATUS_MV_TEMP 302
#define | STATUS_NOT_MODIF 304
#define | STATUS_BAD_REQ 400
#define | STATUS_UNAUTH 401
#define | STATUS_FORBIDDEN 403
#define | STATUS_NOT_FOUND 404
#define | STATUS_INT_SERR 500
#define | STATUS_NOT_IMPL 501
#define | STATUS_BAD_GATEWAY 502
#define | STATUS_SERV_UNAVAIL 503
#define | HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "
#define | RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: "
#define | RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: "
#define | RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: "
#define | RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: "
#define | RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: "
#define | RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: "
#define | RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: "
#define | RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: "
#define | RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: "
#define | RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: "
#define | RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: "
#define | RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "
#define | RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: "
#define | RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: "
#define | RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: "
#define | RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: "
#define | RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: "
#define | MAX_URI_SIZE 512
Structure of HTTP REQUEST. More...

Typedefs

typedef struct _st_http_request st_http_request

Functions

void | unescape_http_url (char *url)
convert escape characters(XX) to ASCII character More...
void | parse_http_request (st_http_request *, uint8_t *)
parse http request from a peer More...
void | find_http_uri_type (uint8_t *, uint8_t *)
find MIME type of a file More...
void | make_http_response_head (char *, char, uint32_t)
make response header such as html, gif, jpeg,etc. More...
uint8_t * | get_http_param_value (char *uri, char *param_name)
get next parameter value in the request More...
uint8_t | get_http_uri_name (uint8_t *uri, uint8_t *uri_buf)
uint16_t | ATOI (uint8_t *str, uint8_t base)
CONVERT STRING INTO INTEGER. More...
void | mid (char *src, char *s1, char *s2, char *sub)
Check strings and then execute callback function by each string. More...
void | inet_addr_ (uint8_t *addr, uint8_t *ip)

Macro Definition Documentation

◆ HTML_HEADER

#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "

Definition at line 67 of file httpParser.h.

◆ HTTP_SERVER_PORT

#define HTTP_SERVER_PORT 80

HTTP server well-known port number

Definition at line 13 of file httpParser.h.

◆ MAX_URI_SIZE

#define MAX_URI_SIZE 512

Structure of HTTP REQUEST.

Definition at line 125 of file httpParser.h.

◆ METHOD_ERR

#define METHOD_ERR 0

Error Method.

Definition at line 16 of file httpParser.h.

◆ METHOD_GET

#define METHOD_GET 1

GET Method.

Definition at line 17 of file httpParser.h.

◆ METHOD_HEAD

#define METHOD_HEAD 2

HEAD Method.

Definition at line 18 of file httpParser.h.

◆ METHOD_POST

#define METHOD_POST 3

POST Method.

Definition at line 19 of file httpParser.h.

◆ PTYPE_CGI

#define PTYPE_CGI 8

CGI file.

Definition at line 30 of file httpParser.h.

◆ PTYPE_CSS

#define PTYPE_CSS 10

CSS file.

Definition at line 32 of file httpParser.h.

◆ PTYPE_EOT

#define PTYPE_EOT 23

Font type: EOT file.

Definition at line 41 of file httpParser.h.

◆ PTYPE_ERR

#define PTYPE_ERR 0

Error file.

Definition at line 22 of file httpParser.h.

◆ PTYPE_FLASH

#define PTYPE_FLASH 5

FLASH file.

Definition at line 27 of file httpParser.h.

◆ PTYPE_GIF

#define PTYPE_GIF 2

GIF file.

Definition at line 24 of file httpParser.h.

◆ PTYPE_HTML

#define PTYPE_HTML 1

HTML file.

Definition at line 23 of file httpParser.h.

◆ PTYPE_ICO

#define PTYPE_ICO 14

ICON file.

Definition at line 36 of file httpParser.h.

◆ PTYPE_JPEG

#define PTYPE_JPEG 4

JPEG file.

Definition at line 26 of file httpParser.h.

◆ PTYPE_JS

#define PTYPE_JS 11

JavaScript file.

Definition at line 33 of file httpParser.h.

◆ PTYPE_JSON

#define PTYPE_JSON 12

JSON (JavaScript Standard Object Notation) file.

Definition at line 34 of file httpParser.h.

◆ PTYPE_MPEG

#define PTYPE_MPEG 6

MPEG file.

Definition at line 28 of file httpParser.h.

◆ PTYPE_OTF

#define PTYPE_OTF 21

Font type: OTF file.

Definition at line 39 of file httpParser.h.

◆ PTYPE_PDF

#define PTYPE_PDF 7

PDF file.

Definition at line 29 of file httpParser.h.

◆ PTYPE_PNG

#define PTYPE_PNG 13

PNG file.

Definition at line 35 of file httpParser.h.

◆ PTYPE_SVG

#define PTYPE_SVG 24

Font type: SVG file.

Definition at line 42 of file httpParser.h.

◆ PTYPE_TEXT

#define PTYPE_TEXT 3

TEXT file.

Definition at line 25 of file httpParser.h.

◆ PTYPE_TTF

#define PTYPE_TTF 20

Font type: TTF file.

Definition at line 38 of file httpParser.h.

◆ PTYPE_WOFF

#define PTYPE_WOFF 22

Font type: WOFF file.

Definition at line 40 of file httpParser.h.

◆ PTYPE_XML

#define PTYPE_XML 9

XML file.

Definition at line 31 of file httpParser.h.

◆ RES_CGIHEAD_OK

#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "

Definition at line 103 of file httpParser.h.

◆ RES_CSSHEAD_OK

#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: "

Definition at line 91 of file httpParser.h.

◆ RES_EOTHEAD_OK

#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: "

Definition at line 115 of file httpParser.h.

◆ RES_FLASHHEAD_OK

#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: "

Definition at line 85 of file httpParser.h.

◆ RES_GIFHEAD_OK

#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: "

Definition at line 76 of file httpParser.h.

◆ RES_HTMLHEAD_OK

#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: "

Definition at line 70 of file httpParser.h.

◆ RES_ICOHEAD_OK

#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: "

Definition at line 100 of file httpParser.h.

◆ RES_JPEGHEAD_OK

#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: "

Definition at line 79 of file httpParser.h.

◆ RES_JSHEAD_OK

#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: "

Definition at line 94 of file httpParser.h.

◆ RES_JSONHEAD_OK

#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: "

Definition at line 97 of file httpParser.h.

◆ RES_OTFHEAD_OK

#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: "

Definition at line 109 of file httpParser.h.

◆ RES_PNGHEAD_OK

#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: "

Definition at line 82 of file httpParser.h.

◆ RES_SVGHEAD_OK

#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: "

Definition at line 118 of file httpParser.h.

◆ RES_TEXTHEAD_OK

#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: "

Definition at line 73 of file httpParser.h.

◆ RES_TTFHEAD_OK

#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: "

Definition at line 106 of file httpParser.h.

◆ RES_WOFFHEAD_OK

#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: "

Definition at line 112 of file httpParser.h.

◆ RES_XMLHEAD_OK

#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: "

Definition at line 88 of file httpParser.h.

◆ STATUS_ACCEPTED

#define STATUS_ACCEPTED 202

Definition at line 48 of file httpParser.h.

◆ STATUS_BAD_GATEWAY

#define STATUS_BAD_GATEWAY 502

Definition at line 59 of file httpParser.h.

◆ STATUS_BAD_REQ

#define STATUS_BAD_REQ 400

Definition at line 53 of file httpParser.h.

◆ STATUS_CREATED

#define STATUS_CREATED 201

Definition at line 47 of file httpParser.h.

◆ STATUS_FORBIDDEN

#define STATUS_FORBIDDEN 403

Definition at line 55 of file httpParser.h.

◆ STATUS_INT_SERR

#define STATUS_INT_SERR 500

Definition at line 57 of file httpParser.h.

◆ STATUS_MV_PERM

#define STATUS_MV_PERM 301

Definition at line 50 of file httpParser.h.

◆ STATUS_MV_TEMP

#define STATUS_MV_TEMP 302

Definition at line 51 of file httpParser.h.

◆ STATUS_NO_CONTENT

#define STATUS_NO_CONTENT 204

Definition at line 49 of file httpParser.h.

◆ STATUS_NOT_FOUND

#define STATUS_NOT_FOUND 404

Definition at line 56 of file httpParser.h.

◆ STATUS_NOT_IMPL

#define STATUS_NOT_IMPL 501

Definition at line 58 of file httpParser.h.

◆ STATUS_NOT_MODIF

#define STATUS_NOT_MODIF 304

Definition at line 52 of file httpParser.h.

◆ STATUS_OK

#define STATUS_OK 200

Definition at line 46 of file httpParser.h.

◆ STATUS_SERV_UNAVAIL

#define STATUS_SERV_UNAVAIL 503

Definition at line 60 of file httpParser.h.

◆ STATUS_UNAUTH

#define STATUS_UNAUTH 401

Definition at line 54 of file httpParser.h.

Typedef Documentation

◆ st_http_request

typedef struct _st_http_request st_http_request

Function Documentation

◆ ATOI()

uint16_t ATOI | ( | uint8_t * | str,
 |  | uint8_t | base
 | ) |  |

CONVERT STRING INTO INTEGER.

Returns
a integer number
Parameters
str | is a pointer to convert
base | is a base value (must be in the range 2 - 16)

Definition at line 327 of file httpParser.c.

◆ find_http_uri_type()

void find_http_uri_type | ( | uint8_t * | ,
 |  | uint8_t * |
 | ) |  |

find MIME type of a file

Definition at line 92 of file httpParser.c.

◆ get_http_param_value()

uint8_t* get_http_param_value | ( | char * | uri,
 |  | char * | param_name
 | ) |  |

get next parameter value in the request

Definition at line 204 of file httpParser.c.

◆ get_http_uri_name()

uint8_t get_http_uri_name | ( | uint8_t * | uri,
 |  | uint8_t * | uri_buf
 | ) |  |

Definition at line 281 of file httpParser.c.

◆ inet_addr_()

void inet_addr_ | ( | uint8_t * | addr,
 |  | uint8_t * | ip
 | ) |  |

Definition at line 302 of file httpParser.c.

◆ make_http_response_head()

void make_http_response_head | ( | char * | ,
 |  | char | ,
 |  | uint32_t |
 | ) |  |

make response header such as html, gif, jpeg,etc.

Definition at line 45 of file httpParser.c.

◆ mid()

void mid | ( | char * | src,
 |  | char * | s1,
 |  | char * | s2,
 |  | char * | sub
 | ) |  |

Check strings and then execute callback function by each string.

Parameters
src | The information of URI
s1 | The start string to be researched
s2 | The end string to be researched
sub | The string between s1 and s2
Returns
The length value atfer working

Definition at line 348 of file httpParser.c.

◆ parse_http_request()

void parse_http_request | ( | st_http_request * | ,
 |  | uint8_t * |
 | ) |  |

parse http request from a peer

Definition at line 127 of file httpParser.c.

◆ unescape_http_url()

void unescape_http_url ( char * url )

convert escape characters(XX) to ASCII character

Parameters
url pointer to be converted ( escape characters )

Definition at line 26 of file httpParser.c.


ioLibrary: Internet/httpServer/httpServer.c File Reference

  • Internet
  • httpServer
Macros | Functions | Variables
httpServer.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "socket.h"
#include "wizchip_conf.h"
#include "httpServer.h"
#include "httpParser.h"
#include "httpUtil.h"
Include dependency graph for httpServer.c:

Go to the source code of this file.

Macros

#define DATA_BUF_SIZE 2048

Functions

void | httpServer_Sockinit (uint8_t cnt, uint8_t *socklist)
void | default_mcu_reset (void)
void | default_wdt_reset (void)
void | httpServer_init (uint8_t *tx_buf, uint8_t *rx_buf, uint8_t cnt, uint8_t *socklist)
void | reg_httpServer_cbfunc (void(*mcu_reset)(void), void(*wdt_reset)(void))
void | httpServer_run (uint8_t seqnum)
void | httpServer_time_handler (void)
uint32_t | get_httpServer_timecount (void)
void | reg_httpServer_webContent (uint8_t *content_name, uint8_t *content)
uint8_t | display_reg_webContent_list (void)
uint8_t | find_userReg_webContent (uint8_t *content_name, uint16_t *content_num, uint32_t *file_len)
uint16_t | read_userReg_webContent (uint16_t content_num, uint8_t *buf, uint32_t offset, uint16_t size)

Variables

uint8_t * | pHTTP_TX
uint8_t * | pHTTP_RX
volatile uint32_t | httpServer_tick_1s = 0
st_http_socket HTTPSock_Status [_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }
httpServer_webContent web_content [MAX_CONTENT_CALLBACK]
void(* | HTTPServer_ReStart )(void)

Macro Definition Documentation

◆ DATA_BUF_SIZE

#define DATA_BUF_SIZE 2048

Definition at line 17 of file httpServer.c.

Function Documentation

◆ default_mcu_reset()

void default_mcu_reset ( void )

Definition at line 65 of file httpServer.c.

◆ default_wdt_reset()

void default_wdt_reset ( void )

Definition at line 66 of file httpServer.c.

◆ display_reg_webContent_list()

uint8_t display_reg_webContent_list ( void )

Definition at line 686 of file httpServer.c.

◆ find_userReg_webContent()

uint8_t find_userReg_webContent | ( | uint8_t * | content_name,
 |  | uint16_t * | content_num,
 |  | uint32_t * | file_len
 | ) |  |

Definition at line 715 of file httpServer.c.

◆ get_httpServer_timecount()

uint32_t get_httpServer_timecount ( void )

Definition at line 656 of file httpServer.c.

◆ httpServer_init()

void httpServer_init | ( | uint8_t * | tx_buf,
 |  | uint8_t * | rx_buf,
 |  | uint8_t | cnt,
 |  | uint8_t * | socklist
 | ) |  |

Definition at line 97 of file httpServer.c.

◆ httpServer_run()

void httpServer_run ( uint8_t seqnum )

Definition at line 117 of file httpServer.c.

◆ httpServer_Sockinit()

void httpServer_Sockinit | ( | uint8_t | cnt,
 |  | uint8_t * | socklist
 | ) |  |

◆ httpServer_time_handler()

void httpServer_time_handler ( void )

Definition at line 651 of file httpServer.c.

◆ read_userReg_webContent()

uint16_t read_userReg_webContent | ( | uint16_t | content_num,
 |  | uint8_t * | buf,
 |  | uint32_t | offset,
 |  | uint16_t | size
 | ) |  |

Definition at line 734 of file httpServer.c.

◆ reg_httpServer_cbfunc()

void reg_httpServer_cbfunc | ( | void(*)(void) | mcu_reset,
 |  | void(*)(void) | wdt_reset
 | ) |  |

Definition at line 109 of file httpServer.c.

◆ reg_httpServer_webContent()

void reg_httpServer_webContent | ( | uint8_t * | content_name,
 |  | uint8_t * | content
 | ) |  |

Definition at line 661 of file httpServer.c.

Variable Documentation

◆ HTTPServer_ReStart

void(* HTTPServer_ReStart) (void)
default

Definition at line 67 of file httpServer.c.

◆ httpServer_tick_1s

volatile uint32_t httpServer_tick_1s = 0

Definition at line 39 of file httpServer.c.

◆ HTTPSock_Status

st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }

Definition at line 40 of file httpServer.c.

◆ pHTTP_RX

uint8_t* pHTTP_RX

Definition at line 37 of file httpServer.c.

◆ pHTTP_TX

uint8_t* pHTTP_TX

Definition at line 36 of file httpServer.c.

◆ web_content

httpServer_webContent web_content[MAX_CONTENT_CALLBACK]

Definition at line 41 of file httpServer.c.


ioLibrary: Internet/httpServer/httpServer.h File Reference

  • Internet
  • httpServer
Data Structures | Macros | Typedefs | Enumerations | Functions
httpServer.h File Reference

Define constants and functions related HTTP Web server. More...

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

Go to the source code of this file.

Data Structures

struct | _st_http_socket
struct | _httpServer_webContent

Macros

#define | _HTTPSERVER_DEBUG_
#define | INITIAL_WEBPAGE "index.html"
#define | M_INITIAL_WEBPAGE "m/index.html"
#define | MOBILE_INITIAL_WEBPAGE "mobile/index.html"
#define | _NOTUSED_STORAGE_
#define | STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */
#define | STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */
#define | STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */
#define | STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */
#define | STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */
#define | HTTP_FAILED 0
#define | HTTP_OK 1
#define | HTTP_RESET 2
#define | MAX_CONTENT_NAME_LEN 128
#define | HTTP_MAX_TIMEOUT_SEC 3
#define | MAX_CONTENT_CALLBACK 20

Typedefs

typedef struct _st_http_socket | st_http_socket
typedef struct _httpServer_webContent | httpServer_webContent

Enumerations

enum StorageType { NONE, CODEFLASH, SDCARD, DATAFLASH }

Functions

void | httpServer_init (uint8_t *tx_buf, uint8_t *rx_buf, uint8_t cnt, uint8_t *socklist)
void | reg_httpServer_cbfunc (void(*mcu_reset)(void), void(*wdt_reset)(void))
void | httpServer_run (uint8_t seqnum)
void | reg_httpServer_webContent (uint8_t *content_name, uint8_t *content)
uint8_t | find_userReg_webContent (uint8_t *content_name, uint16_t *content_num, uint32_t *file_len)
uint16_t | read_userReg_webContent (uint16_t content_num, uint8_t *buf, uint32_t offset, uint16_t size)
uint8_t | display_reg_webContent_list (void)
void | httpServer_time_handler (void)
uint32_t | get_httpServer_timecount (void)

Detailed Description

Define constants and functions related HTTP Web server.

Definition in file httpServer.h.

Macro Definition Documentation

◆ _HTTPSERVER_DEBUG_

#define _HTTPSERVER_DEBUG_

Definition at line 12 of file httpServer.h.

◆ _NOTUSED_STORAGE_

#define _NOTUSED_STORAGE_

Definition at line 25 of file httpServer.h.

◆ HTTP_FAILED

#define HTTP_FAILED 0

Definition at line 44 of file httpServer.h.

◆ HTTP_MAX_TIMEOUT_SEC

#define HTTP_MAX_TIMEOUT_SEC 3

Definition at line 56 of file httpServer.h.

◆ HTTP_OK

#define HTTP_OK 1

Definition at line 45 of file httpServer.h.

◆ HTTP_RESET

#define HTTP_RESET 2

Definition at line 46 of file httpServer.h.

◆ INITIAL_WEBPAGE

#define INITIAL_WEBPAGE "index.html"

Definition at line 14 of file httpServer.h.

◆ M_INITIAL_WEBPAGE

#define M_INITIAL_WEBPAGE "m/index.html"

Definition at line 15 of file httpServer.h.

◆ MAX_CONTENT_CALLBACK

#define MAX_CONTENT_CALLBACK 20

Definition at line 77 of file httpServer.h.

◆ MAX_CONTENT_NAME_LEN

#define MAX_CONTENT_NAME_LEN 128

Definition at line 51 of file httpServer.h.

◆ MOBILE_INITIAL_WEBPAGE

#define MOBILE_INITIAL_WEBPAGE "mobile/index.html"

Definition at line 16 of file httpServer.h.

◆ STATE_HTTP_IDLE

#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */

Definition at line 35 of file httpServer.h.

◆ STATE_HTTP_REQ_DONE

#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */

Definition at line 37 of file httpServer.h.

◆ STATE_HTTP_REQ_INPROC

#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */

Definition at line 36 of file httpServer.h.

◆ STATE_HTTP_RES_DONE

#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */

Definition at line 39 of file httpServer.h.

◆ STATE_HTTP_RES_INPROC

#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */

Definition at line 38 of file httpServer.h.

Typedef Documentation

◆ httpServer_webContent

typedef struct _httpServer_webContent httpServer_webContent

◆ st_http_socket

typedef struct _st_http_socket st_http_socket

Enumeration Type Documentation

◆ StorageType

enum StorageType
Enumerator
NONE | Web storage none.
CODEFLASH | Code flash memory.
SDCARD | SD card.
DATAFLASH | External data flash memory.

Definition at line 58 of file httpServer.h.

Function Documentation

◆ display_reg_webContent_list()

uint8_t display_reg_webContent_list ( void )

Definition at line 686 of file httpServer.c.

◆ find_userReg_webContent()

uint8_t find_userReg_webContent | ( | uint8_t * | content_name,
 |  | uint16_t * | content_num,
 |  | uint32_t * | file_len
 | ) |  |

Definition at line 715 of file httpServer.c.

◆ get_httpServer_timecount()

uint32_t get_httpServer_timecount ( void )

Definition at line 656 of file httpServer.c.

◆ httpServer_init()

void httpServer_init | ( | uint8_t * | tx_buf,
 |  | uint8_t * | rx_buf,
 |  | uint8_t | cnt,
 |  | uint8_t * | socklist
 | ) |  |

Definition at line 97 of file httpServer.c.

◆ httpServer_run()

void httpServer_run ( uint8_t seqnum )

Definition at line 117 of file httpServer.c.

◆ httpServer_time_handler()

void httpServer_time_handler ( void )

Definition at line 651 of file httpServer.c.

◆ read_userReg_webContent()

uint16_t read_userReg_webContent | ( | uint16_t | content_num,
 |  | uint8_t * | buf,
 |  | uint32_t | offset,
 |  | uint16_t | size
 | ) |  |

Definition at line 734 of file httpServer.c.

◆ reg_httpServer_cbfunc()

void reg_httpServer_cbfunc | ( | void(*)(void) | mcu_reset,
 |  | void(*)(void) | wdt_reset
 | ) |  |

Definition at line 109 of file httpServer.c.

◆ reg_httpServer_webContent()

void reg_httpServer_webContent | ( | uint8_t * | content_name,
 |  | uint8_t * | content
 | ) |  |

Definition at line 661 of file httpServer.c.


ioLibrary: Internet/httpServer/httpUtil.c File Reference

  • Internet
  • httpServer
Functions
httpUtil.c File Reference

HTTP Server Utilities
More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "httpUtil.h"
Include dependency graph for httpUtil.c:

Go to the source code of this file.

Functions

uint8_t | http_get_cgi_handler (uint8_t *uri_name, uint8_t *buf, uint32_t *file_len)
uint8_t | http_post_cgi_handler (uint8_t *uri_name, st_http_request *p_http_request, uint8_t *buf, uint32_t *file_len)

Detailed Description

HTTP Server Utilities

Version
1.0
Date
2014/07/15
Revision
2014/07/15 - 1.0 Release
Author

Copyright (C) 1998 - 2014 WIZnet. All rights reserved.

Definition in file httpUtil.c.

Function Documentation

◆ http_get_cgi_handler()

uint8_t http_get_cgi_handler | ( | uint8_t * | uri_name,
 |  | uint8_t * | buf,
 |  | uint32_t * | file_len
 | ) |  |

Definition at line 17 of file httpUtil.c.

◆ http_post_cgi_handler()

uint8_t http_post_cgi_handler | ( | uint8_t * | uri_name,
 |  | st_http_request * | p_http_request,
 |  | uint8_t * | buf,
 |  | uint32_t * | file_len
 | ) |  |

Definition at line 41 of file httpUtil.c.


ioLibrary: Internet/httpServer/httpUtil.h File Reference

  • Internet
  • httpServer
Functions
httpUtil.h File Reference

Header File for HTTP Server Utilities. More...

#include "httpServer.h"
#include "httpParser.h"
Include dependency graph for httpUtil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint8_t | http_get_cgi_handler (uint8_t *uri_name, uint8_t *buf, uint32_t *file_len)
uint8_t | http_post_cgi_handler (uint8_t *uri_name, st_http_request *p_http_request, uint8_t *buf, uint32_t *file_len)
uint8_t | predefined_get_cgi_processor (uint8_t *uri_name, uint8_t *buf, uint16_t *len)
uint8_t | predefined_set_cgi_processor (uint8_t *uri_name, uint8_t *uri, uint8_t *buf, uint16_t *len)

Detailed Description

Header File for HTTP Server Utilities.

Version
1.0
Date
2014/07/15
Revision
2014/07/15 - 1.0 Release
Author

Copyright (C) 1998 - 2014 WIZnet. All rights reserved.

Definition in file httpUtil.h.

Function Documentation

◆ http_get_cgi_handler()

uint8_t http_get_cgi_handler | ( | uint8_t * | uri_name,
 |  | uint8_t * | buf,
 |  | uint32_t * | file_len
 | ) |  |

Definition at line 17 of file httpUtil.c.

◆ http_post_cgi_handler()

uint8_t http_post_cgi_handler | ( | uint8_t * | uri_name,
 |  | st_http_request * | p_http_request,
 |  | uint8_t * | buf,
 |  | uint32_t * | file_len
 | ) |  |

Definition at line 41 of file httpUtil.c.

◆ predefined_get_cgi_processor()

uint8_t predefined_get_cgi_processor | ( | uint8_t * | uri_name,
 |  | uint8_t * | buf,
 |  | uint16_t * | len
 | ) |  |

◆ predefined_set_cgi_processor()

uint8_t predefined_set_cgi_processor | ( | uint8_t * | uri_name,
 |  | uint8_t * | uri,
 |  | uint8_t * | buf,
 |  | uint16_t * | len
 | ) |  |


ioLibrary: Internet/MQTT Directory Reference

  • Internet
  • MQTT
MQTT Directory Reference
Directory dependency graph for MQTT:

Directories

directory MQTTPacket

Files

file | mqtt_interface.c [code]
Paho MQTT to WIZnet Chip interface implement file.
file | mqtt_interface.h [code]
Paho MQTT to WIZnet Chip interface Header file.
file | MQTTClient.c [code]
file | MQTTClient.h [code]


ioLibrary: Internet/MQTT/MQTTPacket Directory Reference

  • Internet
  • MQTT
  • MQTTPacket
MQTTPacket Directory Reference

Directories

directory src


ioLibrary: Internet/MQTT/MQTTPacket/src Directory Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
src Directory Reference

Files

file | MQTTConnect.h [code]
file | MQTTConnectClient.c [code]
file | MQTTConnectServer.c [code]
file | MQTTDeserializePublish.c [code]
file | MQTTFormat.c [code]
file | MQTTFormat.h [code]
file | MQTTPacket.c [code]
file | MQTTPacket.h [code]
file | MQTTPublish.h [code]
file | MQTTSerializePublish.c [code]
file | MQTTSubscribe.h [code]
file | MQTTSubscribeClient.c [code]
file | MQTTSubscribeServer.c [code]
file | MQTTUnsubscribe.h [code]
file | MQTTUnsubscribeClient.c [code]
file | MQTTUnsubscribeServer.c [code]
file | StackTrace.h [code]


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTConnect.h File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Data Structures | Macros | Functions
MQTTConnect.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union | MQTTConnectFlags
struct | MQTTPacket_willOptions
struct | MQTTPacket_connectData
union | MQTTConnackFlags

Macros

#define | DLLImport
#define | DLLExport
#define | MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 }
#define | MQTTPacket_connectData_initializer

Functions

DLLExport int | MQTTSerialize_connect (unsigned char *buf, int buflen, MQTTPacket_connectData *options)
DLLExport int | MQTTDeserialize_connect (MQTTPacket_connectData *data, unsigned char *buf, int len)
DLLExport int | MQTTSerialize_connack (unsigned char *buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
DLLExport int | MQTTDeserialize_connack (unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
DLLExport int | MQTTSerialize_disconnect (unsigned char *buf, int buflen)
DLLExport int | MQTTSerialize_pingreq (unsigned char *buf, int buflen)

Macro Definition Documentation

◆ DLLExport

#define DLLExport

Definition at line 25 of file MQTTConnect.h.

◆ DLLImport

#define DLLImport

Definition at line 22 of file MQTTConnect.h.

◆ MQTTPacket_connectData_initializer

#define MQTTPacket_connectData_initializer
Value:
{ {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \
MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }

Definition at line 124 of file MQTTConnect.h.

◆ MQTTPacket_willOptions_initializer

#define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 }

Definition at line 85 of file MQTTConnect.h.

Function Documentation

◆ MQTTDeserialize_connack()

DLLExport int MQTTDeserialize_connack | ( | unsigned char * | sessionPresent,
 |  | unsigned char * | connack_rc,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into connack data - return code

Parameters
sessionPresent | the session present flag returned (only for MQTT 3.1.1)
connack_rc | returned integer value of the connack return code
buf | the raw buffer data, of the correct length determined by the remaining length field
len | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 132 of file MQTTConnectClient.c.

◆ MQTTDeserialize_connect()

DLLExport int MQTTDeserialize_connect | ( | MQTTPacket_connectData * | data,
 |  | unsigned char * | buf,
 |  | int | len
 | ) |  |

Deserializes the supplied (wire) buffer into connect data structure

Parameters
data | the connect data structure to be filled out
buf | the raw buffer data, of the correct length determined by the remaining length field
len | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 51 of file MQTTConnectServer.c.

◆ MQTTSerialize_connack()

DLLExport int MQTTSerialize_connack | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | connack_rc,
 |  | unsigned char | sessionPresent
 | ) |  |

Serializes the connack packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
connack_rc | the integer connack return code to be used
sessionPresent | the MQTT 3.1.1 sessionPresent flag
Returns
serialized length, or error if 0

Definition at line 119 of file MQTTConnectServer.c.

◆ MQTTSerialize_connect()

DLLExport int MQTTSerialize_connect | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | MQTTPacket_connectData * | options
 | ) |  |

Serializes the connect options into the buffer.

Parameters
buf | the buffer into which the packet will be serialized
len | the length in bytes of the supplied buffer
options | the options to be used to build the connect packet
Returns
serialized length, or error if 0

Definition at line 58 of file MQTTConnectClient.c.

◆ MQTTSerialize_disconnect()

DLLExport int MQTTSerialize_disconnect | ( | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Serializes a disconnect packet into the supplied buffer, ready for writing to a socket

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer, to avoid overruns
Returns
serialized length, or error if 0

Definition at line 199 of file MQTTConnectClient.c.

◆ MQTTSerialize_pingreq()

DLLExport int MQTTSerialize_pingreq | ( | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Serializes a disconnect packet into the supplied buffer, ready for writing to a socket

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer, to avoid overruns
Returns
serialized length, or error if 0

Definition at line 211 of file MQTTConnectClient.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTConnectClient.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions
MQTTConnectClient.c File Reference
#include "MQTTPacket.h"
#include "StackTrace.h"
#include <string.h>
Include dependency graph for MQTTConnectClient.c:

Go to the source code of this file.

Functions

int | MQTTSerialize_connectLength (MQTTPacket_connectData *options)
int | MQTTSerialize_connect (unsigned char *buf, int buflen, MQTTPacket_connectData *options)
int | MQTTDeserialize_connack (unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
int | MQTTSerialize_zero (unsigned char *buf, int buflen, unsigned char packettype)
int | MQTTSerialize_disconnect (unsigned char *buf, int buflen)
int | MQTTSerialize_pingreq (unsigned char *buf, int buflen)

Function Documentation

◆ MQTTDeserialize_connack()

int MQTTDeserialize_connack | ( | unsigned char * | sessionPresent,
 |  | unsigned char * | connack_rc,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into connack data - return code

Parameters
sessionPresent | the session present flag returned (only for MQTT 3.1.1)
connack_rc | returned integer value of the connack return code
buf | the raw buffer data, of the correct length determined by the remaining length field
len | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 132 of file MQTTConnectClient.c.

◆ MQTTSerialize_connect()

int MQTTSerialize_connect | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | MQTTPacket_connectData * | options
 | ) |  |

Serializes the connect options into the buffer.

Parameters
buf | the buffer into which the packet will be serialized
len | the length in bytes of the supplied buffer
options | the options to be used to build the connect packet
Returns
serialized length, or error if 0

Definition at line 58 of file MQTTConnectClient.c.

◆ MQTTSerialize_connectLength()

int MQTTSerialize_connectLength ( MQTTPacket_connectData * options )

Determines the length of the MQTT connect packet that would be produced using the supplied connect options.

Parameters
options the options to be used to build the connect packet
Returns
the length of buffer needed to contain the serialized version of the packet

Definition at line 27 of file MQTTConnectClient.c.

◆ MQTTSerialize_disconnect()

int MQTTSerialize_disconnect | ( | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Serializes a disconnect packet into the supplied buffer, ready for writing to a socket

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer, to avoid overruns
Returns
serialized length, or error if 0

Definition at line 199 of file MQTTConnectClient.c.

◆ MQTTSerialize_pingreq()

int MQTTSerialize_pingreq | ( | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Serializes a disconnect packet into the supplied buffer, ready for writing to a socket

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer, to avoid overruns
Returns
serialized length, or error if 0

Definition at line 211 of file MQTTConnectClient.c.

◆ MQTTSerialize_zero()

int MQTTSerialize_zero | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | packettype
 | ) |  |

Serializes a 0-length packet into the supplied buffer, ready for writing to a socket

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer, to avoid overruns
packettype | the message type
Returns
serialized length, or error if 0

Definition at line 169 of file MQTTConnectClient.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTConnectServer.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Macros | Functions
MQTTConnectServer.c File Reference
#include "StackTrace.h"
#include "MQTTPacket.h"
#include <string.h>
Include dependency graph for MQTTConnectServer.c:

Go to the source code of this file.

Macros

#define min(a, b) ((a < b) ? a : b)

Functions

int | MQTTPacket_checkVersion (MQTTString *protocol, int version)
int | MQTTDeserialize_connect (MQTTPacket_connectData *data, unsigned char *buf, int len)
int | MQTTSerialize_connack (unsigned char *buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)

Macro Definition Documentation

◆ min

#define min | ( | a,
 |  | b
 | ) | ((a < b) ? a : b)

Definition at line 21 of file MQTTConnectServer.c.

Function Documentation

◆ MQTTDeserialize_connect()

int MQTTDeserialize_connect | ( | MQTTPacket_connectData * | data,
 |  | unsigned char * | buf,
 |  | int | len
 | ) |  |

Deserializes the supplied (wire) buffer into connect data structure

Parameters
data | the connect data structure to be filled out
buf | the raw buffer data, of the correct length determined by the remaining length field
len | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 51 of file MQTTConnectServer.c.

◆ MQTTPacket_checkVersion()

int MQTTPacket_checkVersion | ( | MQTTString * | protocol,
 |  | int | version
 | ) |  |

Validates MQTT protocol name and version combinations

Parameters
protocol | the MQTT protocol name as an MQTTString
version | the MQTT protocol version number, as in the connect packet
Returns
correct MQTT combination? 1 is true, 0 is false

Definition at line 30 of file MQTTConnectServer.c.

◆ MQTTSerialize_connack()

int MQTTSerialize_connack | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | connack_rc,
 |  | unsigned char | sessionPresent
 | ) |  |

Serializes the connack packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
connack_rc | the integer connack return code to be used
sessionPresent | the MQTT 3.1.1 sessionPresent flag
Returns
serialized length, or error if 0

Definition at line 119 of file MQTTConnectServer.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTDeserializePublish.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Macros | Functions
MQTTDeserializePublish.c File Reference
#include "StackTrace.h"
#include "MQTTPacket.h"
#include <string.h>
Include dependency graph for MQTTDeserializePublish.c:

Go to the source code of this file.

Macros

#define min(a, b) ((a < b) ? 1 : 0)

Functions

int | MQTTDeserialize_publish (unsigned char *dup, int *qos, unsigned char *retained, unsigned short *packetid, MQTTString *topicName, unsigned char **payload, int *payloadlen, unsigned char *buf, int buflen)
int | MQTTDeserialize_ack (unsigned char *packettype, unsigned char *dup, unsigned short *packetid, unsigned char *buf, int buflen)

Macro Definition Documentation

◆ min

#define min | ( | a,
 |  | b
 | ) | ((a < b) ? 1 : 0)

Definition at line 21 of file MQTTDeserializePublish.c.

Function Documentation

◆ MQTTDeserialize_ack()

int MQTTDeserialize_ack | ( | unsigned char * | packettype,
 |  | unsigned char * | dup,
 |  | unsigned short * | packetid,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into an ack

Parameters
packettype | returned integer - the MQTT packet type
dup | returned integer - the MQTT dup flag
packetid | returned integer - the MQTT packet identifier
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 82 of file MQTTDeserializePublish.c.

◆ MQTTDeserialize_publish()

int MQTTDeserialize_publish | ( | unsigned char * | dup,
 |  | int * | qos,
 |  | unsigned char * | retained,
 |  | unsigned short * | packetid,
 |  | MQTTString * | topicName,
 |  | unsigned char ** | payload,
 |  | int * | payloadlen,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into publish data

Parameters
dup | returned integer - the MQTT dup flag
qos | returned integer - the MQTT QoS value
retained | returned integer - the MQTT retained flag
packetid | returned integer - the MQTT packet identifier
topicName | returned MQTTString - the MQTT topic in the publish
payload | returned byte buffer - the MQTT publish payload
payloadlen | returned integer - the length of the MQTT payload
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success

Definition at line 36 of file MQTTDeserializePublish.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTFormat.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions | Variables
MQTTFormat.c File Reference
#include "StackTrace.h"
#include "MQTTPacket.h"
#include <string.h>
Include dependency graph for MQTTFormat.c:

Go to the source code of this file.

Functions

const char * | MQTTPacket_getName (unsigned short packetid)
int | MQTTStringFormat_connect (char *strbuf, int strbuflen, MQTTPacket_connectData *data)
int | MQTTStringFormat_connack (char *strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent)
int | MQTTStringFormat_publish (char *strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
int | MQTTStringFormat_ack (char *strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
int | MQTTStringFormat_subscribe (char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
int | MQTTStringFormat_suback (char *strbuf, int strbuflen, unsigned short packetid, int count, int *grantedQoSs)
int | MQTTStringFormat_unsubscribe (char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
char * | MQTTFormat_toClientString (char *strbuf, int strbuflen, unsigned char *buf, int buflen)
char * | MQTTFormat_toServerString (char *strbuf, int strbuflen, unsigned char *buf, int buflen)

Variables

const char * MQTTPacket_names []

Function Documentation

◆ MQTTFormat_toClientString()

char* MQTTFormat_toClientString | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Definition at line 117 of file MQTTFormat.c.

◆ MQTTFormat_toServerString()

char* MQTTFormat_toServerString | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Definition at line 185 of file MQTTFormat.c.

◆ MQTTPacket_getName()

const char* MQTTPacket_getName ( unsigned short packetid )

Definition at line 31 of file MQTTFormat.c.

◆ MQTTStringFormat_ack()

int MQTTStringFormat_ack | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | packettype,
 |  | unsigned char | dup,
 |  | unsigned short | packetid
 | ) |  |

Definition at line 80 of file MQTTFormat.c.

◆ MQTTStringFormat_connack()

int MQTTStringFormat_connack | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | connack_rc,
 |  | unsigned char | sessionPresent
 | ) |  |

Definition at line 61 of file MQTTFormat.c.

◆ MQTTStringFormat_connect()

int MQTTStringFormat_connect | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | MQTTPacket_connectData * | data
 | ) |  |

Definition at line 37 of file MQTTFormat.c.

◆ MQTTStringFormat_publish()

int MQTTStringFormat_publish | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | dup,
 |  | int | qos,
 |  | unsigned char | retained,
 |  | unsigned short | packetid,
 |  | MQTTString | topicName,
 |  | unsigned char * | payload,
 |  | int | payloadlen
 | ) |  |

Definition at line 68 of file MQTTFormat.c.

◆ MQTTStringFormat_suback()

int MQTTStringFormat_suback | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | int * | grantedQoSs
 | ) |  |

Definition at line 100 of file MQTTFormat.c.

◆ MQTTStringFormat_subscribe()

int MQTTStringFormat_subscribe | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[],
 |  | int | requestedQoSs[]
 | ) |  |

Definition at line 89 of file MQTTFormat.c.

◆ MQTTStringFormat_unsubscribe()

int MQTTStringFormat_unsubscribe | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[]
 | ) |  |

Definition at line 107 of file MQTTFormat.c.

Variable Documentation

◆ MQTTPacket_names

const char* MQTTPacket_names[]
Initial value:
=
{
"RESERVED", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC", "PUBREL",
"PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK",
"PINGREQ", "PINGRESP", "DISCONNECT"
}

Definition at line 23 of file MQTTFormat.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTFormat.h File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions
MQTTFormat.h File Reference
#include "StackTrace.h"
#include "MQTTPacket.h"
Include dependency graph for MQTTFormat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const char * | MQTTPacket_getName (unsigned short packetid)
int | MQTTStringFormat_connect (char *strbuf, int strbuflen, MQTTPacket_connectData *data)
int | MQTTStringFormat_connack (char *strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent)
int | MQTTStringFormat_publish (char *strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
int | MQTTStringFormat_ack (char *strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
int | MQTTStringFormat_subscribe (char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
int | MQTTStringFormat_suback (char *strbuf, int strbuflen, unsigned short packetid, int count, int *grantedQoSs)
int | MQTTStringFormat_unsubscribe (char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
char * | MQTTFormat_toClientString (char *strbuf, int strbuflen, unsigned char *buf, int buflen)
char * | MQTTFormat_toServerString (char *strbuf, int strbuflen, unsigned char *buf, int buflen)

Function Documentation

◆ MQTTFormat_toClientString()

char* MQTTFormat_toClientString | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Definition at line 117 of file MQTTFormat.c.

◆ MQTTFormat_toServerString()

char* MQTTFormat_toServerString | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Definition at line 185 of file MQTTFormat.c.

◆ MQTTPacket_getName()

const char* MQTTPacket_getName ( unsigned short packetid )

Definition at line 31 of file MQTTFormat.c.

◆ MQTTStringFormat_ack()

int MQTTStringFormat_ack | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | packettype,
 |  | unsigned char | dup,
 |  | unsigned short | packetid
 | ) |  |

Definition at line 80 of file MQTTFormat.c.

◆ MQTTStringFormat_connack()

int MQTTStringFormat_connack | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | connack_rc,
 |  | unsigned char | sessionPresent
 | ) |  |

Definition at line 61 of file MQTTFormat.c.

◆ MQTTStringFormat_connect()

int MQTTStringFormat_connect | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | MQTTPacket_connectData * | data
 | ) |  |

Definition at line 37 of file MQTTFormat.c.

◆ MQTTStringFormat_publish()

int MQTTStringFormat_publish | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | dup,
 |  | int | qos,
 |  | unsigned char | retained,
 |  | unsigned short | packetid,
 |  | MQTTString | topicName,
 |  | unsigned char * | payload,
 |  | int | payloadlen
 | ) |  |

Definition at line 68 of file MQTTFormat.c.

◆ MQTTStringFormat_suback()

int MQTTStringFormat_suback | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | int * | grantedQoSs
 | ) |  |

Definition at line 100 of file MQTTFormat.c.

◆ MQTTStringFormat_subscribe()

int MQTTStringFormat_subscribe | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[],
 |  | int | requestedQoSs[]
 | ) |  |

Definition at line 89 of file MQTTFormat.c.

◆ MQTTStringFormat_unsubscribe()

int MQTTStringFormat_unsubscribe | ( | char * | strbuf,
 |  | int | strbuflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[]
 | ) |  |

Definition at line 107 of file MQTTFormat.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTPacket.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Macros | Functions
MQTTPacket.c File Reference
#include "StackTrace.h"
#include "MQTTPacket.h"
#include <string.h>
Include dependency graph for MQTTPacket.c:

Go to the source code of this file.

Macros

#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4

Functions

int | MQTTPacket_encode (unsigned char *buf, int length)
int | MQTTPacket_decode (int(*getcharfn)(unsigned char *, int), int *value)
int | MQTTPacket_len (int rem_len)
int | bufchar (unsigned char *c, int count)
int | MQTTPacket_decodeBuf (unsigned char *buf, int *value)
int | readInt (unsigned char **pptr)
char | readChar (unsigned char **pptr)
void | writeChar (unsigned char **pptr, char c)
void | writeInt (unsigned char **pptr, int anInt)
void | writeCString (unsigned char **pptr, const char *string)
int | getLenStringLen (char *ptr)
void | writeMQTTString (unsigned char **pptr, MQTTString mqttstring)
int | readMQTTLenString (MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
int | MQTTstrlen (MQTTString mqttstring)
int | MQTTPacket_equals (MQTTString *a, char *bptr)
int | MQTTPacket_read (unsigned char *buf, int buflen, int(*getfn)(unsigned char *, int))
int | MQTTPacket_readnb (unsigned char *buf, int buflen, MQTTTransport *trp)

Macro Definition Documentation

◆ MAX_NO_OF_REMAINING_LENGTH_BYTES

#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4

Function Documentation

◆ bufchar()

int bufchar | ( | unsigned char * | c,
 |  | int | count
 | ) |  |

Definition at line 103 of file MQTTPacket.c.

◆ getLenStringLen()

int getLenStringLen ( char * ptr )

Definition at line 187 of file MQTTPacket.c.

◆ MQTTPacket_decode()

int MQTTPacket_decode | ( | int(*)(unsigned char *, int) | getcharfn,
 |  | int * | value
 | ) |  |

Decodes the message length according to the MQTT algorithm

Parameters
getcharfn | pointer to function to read the next character from the data source
value | the decoded length returned
Returns
the number of bytes read from the socket

Definition at line 54 of file MQTTPacket.c.

◆ MQTTPacket_decodeBuf()

int MQTTPacket_decodeBuf | ( | unsigned char * | buf,
 |  | int * | value
 | ) |  |

Definition at line 113 of file MQTTPacket.c.

◆ MQTTPacket_encode()

int MQTTPacket_encode | ( | unsigned char * | buf,
 |  | int | length
 | ) |  |

Encodes the message length according to the MQTT algorithm

Parameters
buf | the buffer into which the encoded data is written
length | the length to be encoded
Returns
the number of bytes written to buffer

Definition at line 29 of file MQTTPacket.c.

◆ MQTTPacket_equals()

int MQTTPacket_equals | ( | MQTTString * | a,
 |  | char * | bptr
 | ) |  |

Compares an MQTTString to a C string

Parameters
a | the MQTTString to compare
bptr | the C string to compare
Returns
boolean - equal or not

Definition at line 260 of file MQTTPacket.c.

◆ MQTTPacket_len()

int MQTTPacket_len ( int rem_len )

Definition at line 84 of file MQTTPacket.c.

◆ MQTTPacket_read()

int MQTTPacket_read | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | int(*)(unsigned char *, int) | getfn
 | ) |  |

Helper function to read packet data from some source into a buffer

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
getfn | pointer to a function which will read any number of bytes from the needed source
Returns
integer MQTT packet type, or -1 on error
Note
the whole message must fit into the caller's buffer

Definition at line 290 of file MQTTPacket.c.

◆ MQTTPacket_readnb()

int MQTTPacket_readnb | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | MQTTTransport * | trp
 | ) |  |

Helper function to read packet data from some source into a buffer, non-blocking

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
trp | pointer to a transport structure holding what is needed to solve getting data from it
Returns
integer MQTT packet type, 0 for call again, or -1 on error
Note
the whole message must fit into the caller's buffer

Definition at line 361 of file MQTTPacket.c.

◆ MQTTstrlen()

int MQTTstrlen ( MQTTString mqttstring )

Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string

Parameters
mqttstring the string to return the length of
Returns
the length of the string

Definition at line 242 of file MQTTPacket.c.

◆ readChar()

char readChar ( unsigned char ** pptr )

Reads one character from the input buffer.

Parameters
pptr pointer to the input buffer - incremented by the number of bytes used & returned
Returns
the character read

Definition at line 139 of file MQTTPacket.c.

◆ readInt()

int readInt ( unsigned char ** pptr )

Calculates an integer from two bytes read from the input buffer

Parameters
pptr pointer to the input buffer - incremented by the number of bytes used & returned
Returns
the integer value calculated

Definition at line 125 of file MQTTPacket.c.

◆ readMQTTLenString()

int readMQTTLenString | ( | MQTTString * | mqttstring,
 |  | unsigned char ** | pptr,
 |  | unsigned char * | enddata
 | ) |  |
Parameters
mqttstring | the MQTTString structure into which the data is to be read
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
enddata | pointer to the end of the data: do not read beyond
Returns
1 if successful, 0 if not

Definition at line 215 of file MQTTPacket.c.

◆ writeChar()

void writeChar | ( | unsigned char ** | pptr,
 |  | char | c
 | ) |  |

Writes one character to an output buffer.

Parameters
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
c | the character to write

Definition at line 152 of file MQTTPacket.c.

◆ writeCString()

void writeCString | ( | unsigned char ** | pptr,
 |  | const char * | string
 | ) |  |

Writes a "UTF" string to an output buffer. Converts C string to length-delimited.

Parameters
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
string | the C string to write

Definition at line 178 of file MQTTPacket.c.

◆ writeInt()

void writeInt | ( | unsigned char ** | pptr,
 |  | int | anInt
 | ) |  |

Writes an integer as 2 bytes to an output buffer.

Parameters
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
anInt | the integer to write

Definition at line 164 of file MQTTPacket.c.

◆ writeMQTTString()

void writeMQTTString | ( | unsigned char ** | pptr,
 |  | MQTTString | mqttstring
 | ) |  |

Definition at line 194 of file MQTTPacket.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTPacket.h File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Data Structures | Macros | Enumerations | Functions
MQTTPacket.h File Reference
#include "MQTTConnect.h"
#include "MQTTPublish.h"
#include "MQTTSubscribe.h"
#include "MQTTUnsubscribe.h"
#include "MQTTFormat.h"
Include dependency graph for MQTTPacket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union | MQTTHeader
struct | MQTTLenString
struct | MQTTString
struct | MQTTTransport

Macros

#define | DLLImport
#define | DLLExport
#define | MQTTString_initializer {NULL, {0, NULL}}

Enumerations

enum errors { MQTTPACKET_BUFFER_TOO_SHORT = -2, MQTTPACKET_READ_ERROR = -1, MQTTPACKET_READ_COMPLETE }
enum msgTypes {
CONNECT = 1, CONNACK, PUBLISH, PUBACK,
PUBREC, PUBREL, PUBCOMP, SUBSCRIBE,
SUBACK, UNSUBSCRIBE, UNSUBACK, PINGREQ,
PINGRESP, DISCONNECT
}

Functions

int | MQTTstrlen (MQTTString mqttstring)
int | MQTTSerialize_ack (unsigned char *buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid)
int | MQTTDeserialize_ack (unsigned char *packettype, unsigned char *dup, unsigned short *packetid, unsigned char *buf, int buflen)
int | MQTTPacket_len (int rem_len)
int | MQTTPacket_equals (MQTTString *a, char *b)
int | MQTTPacket_encode (unsigned char *buf, int length)
int | MQTTPacket_decode (int(*getcharfn)(unsigned char *, int), int *value)
int | MQTTPacket_decodeBuf (unsigned char *buf, int *value)
int | readInt (unsigned char **pptr)
char | readChar (unsigned char **pptr)
void | writeChar (unsigned char **pptr, char c)
void | writeInt (unsigned char **pptr, int anInt)
int | readMQTTLenString (MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
void | writeCString (unsigned char **pptr, const char *string)
void | writeMQTTString (unsigned char **pptr, MQTTString mqttstring)
DLLExport int | MQTTPacket_read (unsigned char *buf, int buflen, int(*getfn)(unsigned char *, int))
int | MQTTPacket_readnb (unsigned char *buf, int buflen, MQTTTransport *trp)

Macro Definition Documentation

◆ DLLExport

#define DLLExport

Definition at line 33 of file MQTTPacket.h.

◆ DLLImport

#define DLLImport

Definition at line 32 of file MQTTPacket.h.

◆ MQTTString_initializer

#define MQTTString_initializer {NULL, {0, NULL}}

Definition at line 87 of file MQTTPacket.h.

Enumeration Type Documentation

◆ errors

enum errors
Enumerator
MQTTPACKET_BUFFER_TOO_SHORT
MQTTPACKET_READ_ERROR
MQTTPACKET_READ_COMPLETE

Definition at line 36 of file MQTTPacket.h.

◆ msgTypes

enum msgTypes
Enumerator
CONNECT
CONNACK
PUBLISH
PUBACK
PUBREC
PUBREL
PUBCOMP
SUBSCRIBE
SUBACK
UNSUBSCRIBE
UNSUBACK
PINGREQ
PINGRESP
DISCONNECT

Definition at line 43 of file MQTTPacket.h.

Function Documentation

◆ MQTTDeserialize_ack()

int MQTTDeserialize_ack | ( | unsigned char * | packettype,
 |  | unsigned char * | dup,
 |  | unsigned short * | packetid,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into an ack

Parameters
packettype | returned integer - the MQTT packet type
dup | returned integer - the MQTT dup flag
packetid | returned integer - the MQTT packet identifier
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 82 of file MQTTDeserializePublish.c.

◆ MQTTPacket_decode()

int MQTTPacket_decode | ( | int(*)(unsigned char *, int) | getcharfn,
 |  | int * | value
 | ) |  |

Decodes the message length according to the MQTT algorithm

Parameters
getcharfn | pointer to function to read the next character from the data source
value | the decoded length returned
Returns
the number of bytes read from the socket

Definition at line 54 of file MQTTPacket.c.

◆ MQTTPacket_decodeBuf()

int MQTTPacket_decodeBuf | ( | unsigned char * | buf,
 |  | int * | value
 | ) |  |

Definition at line 113 of file MQTTPacket.c.

◆ MQTTPacket_encode()

int MQTTPacket_encode | ( | unsigned char * | buf,
 |  | int | length
 | ) |  |

Encodes the message length according to the MQTT algorithm

Parameters
buf | the buffer into which the encoded data is written
length | the length to be encoded
Returns
the number of bytes written to buffer

Definition at line 29 of file MQTTPacket.c.

◆ MQTTPacket_equals()

int MQTTPacket_equals | ( | MQTTString * | a,
 |  | char * | bptr
 | ) |  |

Compares an MQTTString to a C string

Parameters
a | the MQTTString to compare
bptr | the C string to compare
Returns
boolean - equal or not

Definition at line 260 of file MQTTPacket.c.

◆ MQTTPacket_len()

int MQTTPacket_len ( int rem_len )

Definition at line 84 of file MQTTPacket.c.

◆ MQTTPacket_read()

DLLExport int MQTTPacket_read | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | int(*)(unsigned char *, int) | getfn
 | ) |  |

Helper function to read packet data from some source into a buffer

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
getfn | pointer to a function which will read any number of bytes from the needed source
Returns
integer MQTT packet type, or -1 on error
Note
the whole message must fit into the caller's buffer

Definition at line 290 of file MQTTPacket.c.

◆ MQTTPacket_readnb()

int MQTTPacket_readnb | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | MQTTTransport * | trp
 | ) |  |

Helper function to read packet data from some source into a buffer, non-blocking

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
trp | pointer to a transport structure holding what is needed to solve getting data from it
Returns
integer MQTT packet type, 0 for call again, or -1 on error
Note
the whole message must fit into the caller's buffer

Definition at line 361 of file MQTTPacket.c.

◆ MQTTSerialize_ack()

int MQTTSerialize_ack | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | packettype,
 |  | unsigned char | dup,
 |  | unsigned short | packetid
 | ) |  |

Serializes the ack packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
type | the MQTT packet type
dup | the MQTT dup flag
packetid | the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 104 of file MQTTSerializePublish.c.

◆ MQTTstrlen()

int MQTTstrlen ( MQTTString mqttstring )

Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string

Parameters
mqttstring the string to return the length of
Returns
the length of the string

Definition at line 242 of file MQTTPacket.c.

◆ readChar()

char readChar ( unsigned char ** pptr )

Reads one character from the input buffer.

Parameters
pptr pointer to the input buffer - incremented by the number of bytes used & returned
Returns
the character read

Definition at line 139 of file MQTTPacket.c.

◆ readInt()

int readInt ( unsigned char ** pptr )

Calculates an integer from two bytes read from the input buffer

Parameters
pptr pointer to the input buffer - incremented by the number of bytes used & returned
Returns
the integer value calculated

Definition at line 125 of file MQTTPacket.c.

◆ readMQTTLenString()

int readMQTTLenString | ( | MQTTString * | mqttstring,
 |  | unsigned char ** | pptr,
 |  | unsigned char * | enddata
 | ) |  |
Parameters
mqttstring | the MQTTString structure into which the data is to be read
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
enddata | pointer to the end of the data: do not read beyond
Returns
1 if successful, 0 if not

Definition at line 215 of file MQTTPacket.c.

◆ writeChar()

void writeChar | ( | unsigned char ** | pptr,
 |  | char | c
 | ) |  |

Writes one character to an output buffer.

Parameters
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
c | the character to write

Definition at line 152 of file MQTTPacket.c.

◆ writeCString()

void writeCString | ( | unsigned char ** | pptr,
 |  | const char * | string
 | ) |  |

Writes a "UTF" string to an output buffer. Converts C string to length-delimited.

Parameters
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
string | the C string to write

Definition at line 178 of file MQTTPacket.c.

◆ writeInt()

void writeInt | ( | unsigned char ** | pptr,
 |  | int | anInt
 | ) |  |

Writes an integer as 2 bytes to an output buffer.

Parameters
pptr | pointer to the output buffer - incremented by the number of bytes used & returned
anInt | the integer to write

Definition at line 164 of file MQTTPacket.c.

◆ writeMQTTString()

void writeMQTTString | ( | unsigned char ** | pptr,
 |  | MQTTString | mqttstring
 | ) |  |

Definition at line 194 of file MQTTPacket.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTPublish.h File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Macros | Functions
MQTTPublish.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | DLLImport
#define | DLLExport

Functions

DLLExport int | MQTTSerialize_publish (unsigned char *buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
DLLExport int | MQTTDeserialize_publish (unsigned char *dup, int *qos, unsigned char *retained, unsigned short *packetid, MQTTString *topicName, unsigned char **payload, int *payloadlen, unsigned char *buf, int len)
DLLExport int | MQTTSerialize_puback (unsigned char *buf, int buflen, unsigned short packetid)
DLLExport int | MQTTSerialize_pubrel (unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid)
DLLExport int | MQTTSerialize_pubcomp (unsigned char *buf, int buflen, unsigned short packetid)

Macro Definition Documentation

◆ DLLExport

#define DLLExport

Definition at line 25 of file MQTTPublish.h.

◆ DLLImport

#define DLLImport

Definition at line 22 of file MQTTPublish.h.

Function Documentation

◆ MQTTDeserialize_publish()

DLLExport int MQTTDeserialize_publish | ( | unsigned char * | dup,
 |  | int * | qos,
 |  | unsigned char * | retained,
 |  | unsigned short * | packetid,
 |  | MQTTString * | topicName,
 |  | unsigned char ** | payload,
 |  | int * | payloadlen,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into publish data

Parameters
dup | returned integer - the MQTT dup flag
qos | returned integer - the MQTT QoS value
retained | returned integer - the MQTT retained flag
packetid | returned integer - the MQTT packet identifier
topicName | returned MQTTString - the MQTT topic in the publish
payload | returned byte buffer - the MQTT publish payload
payloadlen | returned integer - the length of the MQTT payload
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success

Definition at line 36 of file MQTTDeserializePublish.c.

◆ MQTTSerialize_puback()

DLLExport int MQTTSerialize_puback | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid
 | ) |  |

Serializes a puback packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 137 of file MQTTSerializePublish.c.

◆ MQTTSerialize_pubcomp()

DLLExport int MQTTSerialize_pubcomp | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid
 | ) |  |

Serializes a pubrel packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 164 of file MQTTSerializePublish.c.

◆ MQTTSerialize_publish()

DLLExport int MQTTSerialize_publish | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | int | qos,
 |  | unsigned char | retained,
 |  | unsigned short | packetid,
 |  | MQTTString | topicName,
 |  | unsigned char * | payload,
 |  | int | payloadlen
 | ) |  |

Serializes the supplied publish data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
dup | integer - the MQTT dup flag
qos | integer - the MQTT QoS value
retained | integer - the MQTT retained flag
packetid | integer - the MQTT packet identifier
topicName | MQTTString - the MQTT topic in the publish
payload | byte buffer - the MQTT publish payload
payloadlen | integer - the length of the MQTT payload
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 55 of file MQTTSerializePublish.c.

◆ MQTTSerialize_pubrel()

DLLExport int MQTTSerialize_pubrel | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid
 | ) |  |

Serializes a pubrel packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
dup | integer - the MQTT dup flag
packetid | integer - the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 151 of file MQTTSerializePublish.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSerializePublish.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions
MQTTSerializePublish.c File Reference
#include "MQTTPacket.h"
#include "StackTrace.h"
#include <string.h>
Include dependency graph for MQTTSerializePublish.c:

Go to the source code of this file.

Functions

int | MQTTSerialize_publishLength (int qos, MQTTString topicName, int payloadlen)
int | MQTTSerialize_publish (unsigned char *buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
int | MQTTSerialize_ack (unsigned char *buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
int | MQTTSerialize_puback (unsigned char *buf, int buflen, unsigned short packetid)
int | MQTTSerialize_pubrel (unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid)
int | MQTTSerialize_pubcomp (unsigned char *buf, int buflen, unsigned short packetid)

Function Documentation

◆ MQTTSerialize_ack()

int MQTTSerialize_ack | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | packettype,
 |  | unsigned char | dup,
 |  | unsigned short | packetid
 | ) |  |

Serializes the ack packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
type | the MQTT packet type
dup | the MQTT dup flag
packetid | the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 104 of file MQTTSerializePublish.c.

◆ MQTTSerialize_puback()

int MQTTSerialize_puback | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid
 | ) |  |

Serializes a puback packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 137 of file MQTTSerializePublish.c.

◆ MQTTSerialize_pubcomp()

int MQTTSerialize_pubcomp | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid
 | ) |  |

Serializes a pubrel packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 164 of file MQTTSerializePublish.c.

◆ MQTTSerialize_publish()

int MQTTSerialize_publish | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | int | qos,
 |  | unsigned char | retained,
 |  | unsigned short | packetid,
 |  | MQTTString | topicName,
 |  | unsigned char * | payload,
 |  | int | payloadlen
 | ) |  |

Serializes the supplied publish data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
dup | integer - the MQTT dup flag
qos | integer - the MQTT QoS value
retained | integer - the MQTT retained flag
packetid | integer - the MQTT packet identifier
topicName | MQTTString - the MQTT topic in the publish
payload | byte buffer - the MQTT publish payload
payloadlen | integer - the length of the MQTT payload
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 55 of file MQTTSerializePublish.c.

◆ MQTTSerialize_publishLength()

int MQTTSerialize_publishLength | ( | int | qos,
 |  | MQTTString | topicName,
 |  | int | payloadlen
 | ) |  |

Determines the length of the MQTT publish packet that would be produced using the supplied parameters

Parameters
qos | the MQTT QoS of the publish (packetid is omitted for QoS 0)
topicName the topic name to be used in the publish
payloadlen | the length of the payload to be sent
Returns
the length of buffer needed to contain the serialized version of the packet

Definition at line 31 of file MQTTSerializePublish.c.

◆ MQTTSerialize_pubrel()

int MQTTSerialize_pubrel | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid
 | ) |  |

Serializes a pubrel packet into the supplied buffer.

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
dup | integer - the MQTT dup flag
packetid | integer - the MQTT packet identifier
Returns
serialized length, or error if 0

Definition at line 151 of file MQTTSerializePublish.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSubscribe.h File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Macros | Functions
MQTTSubscribe.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | DLLImport
#define | DLLExport

Functions

DLLExport int | MQTTSerialize_subscribe (unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
DLLExport int | MQTTDeserialize_subscribe (unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], unsigned char *buf, int len)
DLLExport int | MQTTSerialize_suback (unsigned char *buf, int buflen, unsigned short packetid, int count, int *grantedQoSs)
DLLExport int | MQTTDeserialize_suback (unsigned short *packetid, int maxcount, int *count, int grantedQoSs[], unsigned char *buf, int len)

Macro Definition Documentation

◆ DLLExport

#define DLLExport

Definition at line 25 of file MQTTSubscribe.h.

◆ DLLImport

#define DLLImport

Definition at line 22 of file MQTTSubscribe.h.

Function Documentation

◆ MQTTDeserialize_suback()

DLLExport int MQTTDeserialize_suback | ( | unsigned short * | packetid,
 |  | int | maxcount,
 |  | int * | count,
 |  | int | grantedQoSs[],
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into suback data

Parameters
packetid | returned integer - the MQTT packet identifier
maxcount | - the maximum number of members allowed in the grantedQoSs array
count | returned integer - number of members in the grantedQoSs array
grantedQoSs | returned array of integers - the granted qualities of service
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 100 of file MQTTSubscribeClient.c.

◆ MQTTDeserialize_subscribe()

DLLExport int MQTTDeserialize_subscribe | ( | unsigned char * | dup,
 |  | unsigned short * | packetid,
 |  | int | maxcount,
 |  | int * | count,
 |  | MQTTString | topicFilters[],
 |  | int | requestedQoSs[],
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into subscribe data

Parameters
dup | integer returned - the MQTT dup flag
packetid | integer returned - the MQTT packet identifier
maxcount | - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
count | - number of members in the topicFilters and requestedQoSs arrays
topicFilters | - array of topic filter names
requestedQoSs | - array of requested QoS
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 35 of file MQTTSubscribeServer.c.

◆ MQTTSerialize_suback()

DLLExport int MQTTSerialize_suback | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | int * | grantedQoSs
 | ) |  |

Serializes the supplied suback data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
count | - number of members in the grantedQoSs array
grantedQoSs | - array of granted QoS
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 82 of file MQTTSubscribeServer.c.

◆ MQTTSerialize_subscribe()

DLLExport int MQTTSerialize_subscribe | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[],
 |  | int | requestedQoSs[]
 | ) |  |

Serializes the supplied subscribe data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied bufferr
dup | integer - the MQTT dup flag
packetid | integer - the MQTT packet identifier
count | - number of members in the topicFilters and reqQos arrays
topicFilters | - array of topic filter names
requestedQoSs | - array of requested QoS
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 50 of file MQTTSubscribeClient.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSubscribeClient.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions
MQTTSubscribeClient.c File Reference
#include "MQTTPacket.h"
#include "StackTrace.h"
#include <string.h>
Include dependency graph for MQTTSubscribeClient.c:

Go to the source code of this file.

Functions

int | MQTTSerialize_subscribeLength (int count, MQTTString topicFilters[])
int | MQTTSerialize_subscribe (unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
int | MQTTDeserialize_suback (unsigned short *packetid, int maxcount, int *count, int grantedQoSs[], unsigned char *buf, int buflen)

Function Documentation

◆ MQTTDeserialize_suback()

int MQTTDeserialize_suback | ( | unsigned short * | packetid,
 |  | int | maxcount,
 |  | int * | count,
 |  | int | grantedQoSs[],
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into suback data

Parameters
packetid | returned integer - the MQTT packet identifier
maxcount | - the maximum number of members allowed in the grantedQoSs array
count | returned integer - number of members in the grantedQoSs array
grantedQoSs | returned array of integers - the granted qualities of service
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 100 of file MQTTSubscribeClient.c.

◆ MQTTSerialize_subscribe()

int MQTTSerialize_subscribe | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[],
 |  | int | requestedQoSs[]
 | ) |  |

Serializes the supplied subscribe data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied bufferr
dup | integer - the MQTT dup flag
packetid | integer - the MQTT packet identifier
count | - number of members in the topicFilters and reqQos arrays
topicFilters | - array of topic filter names
requestedQoSs | - array of requested QoS
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 50 of file MQTTSubscribeClient.c.

◆ MQTTSerialize_subscribeLength()

int MQTTSerialize_subscribeLength | ( | int | count,
 |  | MQTTString | topicFilters[]
 | ) |  |

Determines the length of the MQTT subscribe packet that would be produced using the supplied parameters

Parameters
count | the number of topic filter strings in topicFilters
topicFilters | the array of topic filter strings to be used in the publish
Returns
the length of buffer needed to contain the serialized version of the packet

Definition at line 28 of file MQTTSubscribeClient.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSubscribeServer.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions
MQTTSubscribeServer.c File Reference
#include "MQTTPacket.h"
#include "StackTrace.h"
#include <string.h>
Include dependency graph for MQTTSubscribeServer.c:

Go to the source code of this file.

Functions

int | MQTTDeserialize_subscribe (unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], unsigned char *buf, int buflen)
int | MQTTSerialize_suback (unsigned char *buf, int buflen, unsigned short packetid, int count, int *grantedQoSs)

Function Documentation

◆ MQTTDeserialize_subscribe()

int MQTTDeserialize_subscribe | ( | unsigned char * | dup,
 |  | unsigned short * | packetid,
 |  | int | maxcount,
 |  | int * | count,
 |  | MQTTString | topicFilters[],
 |  | int | requestedQoSs[],
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into subscribe data

Parameters
dup | integer returned - the MQTT dup flag
packetid | integer returned - the MQTT packet identifier
maxcount | - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
count | - number of members in the topicFilters and requestedQoSs arrays
topicFilters | - array of topic filter names
requestedQoSs | - array of requested QoS
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 35 of file MQTTSubscribeServer.c.

◆ MQTTSerialize_suback()

int MQTTSerialize_suback | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | int * | grantedQoSs
 | ) |  |

Serializes the supplied suback data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
count | - number of members in the grantedQoSs array
grantedQoSs | - array of granted QoS
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 82 of file MQTTSubscribeServer.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTUnsubscribe.h File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Macros | Functions
MQTTUnsubscribe.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | DLLImport
#define | DLLExport

Functions

DLLExport int | MQTTSerialize_unsubscribe (unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
DLLExport int | MQTTDeserialize_unsubscribe (unsigned char *dup, unsigned short *packetid, int max_count, int *count, MQTTString topicFilters[], unsigned char *buf, int len)
DLLExport int | MQTTSerialize_unsuback (unsigned char *buf, int buflen, unsigned short packetid)
DLLExport int | MQTTDeserialize_unsuback (unsigned short *packetid, unsigned char *buf, int len)

Macro Definition Documentation

◆ DLLExport

#define DLLExport

Definition at line 25 of file MQTTUnsubscribe.h.

◆ DLLImport

#define DLLImport

Definition at line 22 of file MQTTUnsubscribe.h.

Function Documentation

◆ MQTTDeserialize_unsuback()

DLLExport int MQTTDeserialize_unsuback | ( | unsigned short * | packetid,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into unsuback data

Parameters
packetid | returned integer - the MQTT packet identifier
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 92 of file MQTTUnsubscribeClient.c.

◆ MQTTDeserialize_unsubscribe()

DLLExport int MQTTDeserialize_unsubscribe | ( | unsigned char * | dup,
 |  | unsigned short * | packetid,
 |  | int | maxcount,
 |  | int * | count,
 |  | MQTTString | topicFilters[],
 |  | unsigned char * | buf,
 |  | int | len
 | ) |  |

Deserializes the supplied (wire) buffer into unsubscribe data

Parameters
dup | integer returned - the MQTT dup flag
packetid | integer returned - the MQTT packet identifier
maxcount | - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
count | - number of members in the topicFilters and requestedQoSs arrays
topicFilters | - array of topic filter names
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 34 of file MQTTUnsubscribeServer.c.

◆ MQTTSerialize_unsuback()

DLLExport int MQTTSerialize_unsuback | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid
 | ) |  |

Serializes the supplied unsuback data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 76 of file MQTTUnsubscribeServer.c.

◆ MQTTSerialize_unsubscribe()

DLLExport int MQTTSerialize_unsubscribe | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[]
 | ) |  |

Serializes the supplied unsubscribe data into the supplied buffer, ready for sending

Parameters
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
dup | integer - the MQTT dup flag
packetid | integer - the MQTT packet identifier
count | - number of members in the topicFilters array
topicFilters | - array of topic filter names
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 49 of file MQTTUnsubscribeClient.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeClient.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions
MQTTUnsubscribeClient.c File Reference
#include "MQTTPacket.h"
#include "StackTrace.h"
#include <string.h>
Include dependency graph for MQTTUnsubscribeClient.c:

Go to the source code of this file.

Functions

int | MQTTSerialize_unsubscribeLength (int count, MQTTString topicFilters[])
int | MQTTSerialize_unsubscribe (unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
int | MQTTDeserialize_unsuback (unsigned short *packetid, unsigned char *buf, int buflen)

Function Documentation

◆ MQTTDeserialize_unsuback()

int MQTTDeserialize_unsuback | ( | unsigned short * | packetid,
 |  | unsigned char * | buf,
 |  | int | buflen
 | ) |  |

Deserializes the supplied (wire) buffer into unsuback data

Parameters
packetid | returned integer - the MQTT packet identifier
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure

Definition at line 92 of file MQTTUnsubscribeClient.c.

◆ MQTTSerialize_unsubscribe()

int MQTTSerialize_unsubscribe | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned char | dup,
 |  | unsigned short | packetid,
 |  | int | count,
 |  | MQTTString | topicFilters[]
 | ) |  |

Serializes the supplied unsubscribe data into the supplied buffer, ready for sending

Parameters
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
dup | integer - the MQTT dup flag
packetid | integer - the MQTT packet identifier
count | - number of members in the topicFilters array
topicFilters | - array of topic filter names
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 49 of file MQTTUnsubscribeClient.c.

◆ MQTTSerialize_unsubscribeLength()

int MQTTSerialize_unsubscribeLength | ( | int | count,
 |  | MQTTString | topicFilters[]
 | ) |  |

Determines the length of the MQTT unsubscribe packet that would be produced using the supplied parameters

Parameters
count | the number of topic filter strings in topicFilters
topicFilters | the array of topic filter strings to be used in the publish
Returns
the length of buffer needed to contain the serialized version of the packet

Definition at line 28 of file MQTTUnsubscribeClient.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeServer.c File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Functions
MQTTUnsubscribeServer.c File Reference
#include "MQTTPacket.h"
#include "StackTrace.h"
#include <string.h>
Include dependency graph for MQTTUnsubscribeServer.c:

Go to the source code of this file.

Functions

int | MQTTDeserialize_unsubscribe (unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], unsigned char *buf, int len)
int | MQTTSerialize_unsuback (unsigned char *buf, int buflen, unsigned short packetid)

Function Documentation

◆ MQTTDeserialize_unsubscribe()

int MQTTDeserialize_unsubscribe | ( | unsigned char * | dup,
 |  | unsigned short * | packetid,
 |  | int | maxcount,
 |  | int * | count,
 |  | MQTTString | topicFilters[],
 |  | unsigned char * | buf,
 |  | int | len
 | ) |  |

Deserializes the supplied (wire) buffer into unsubscribe data

Parameters
dup | integer returned - the MQTT dup flag
packetid | integer returned - the MQTT packet identifier
maxcount | - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
count | - number of members in the topicFilters and requestedQoSs arrays
topicFilters | - array of topic filter names
buf | the raw buffer data, of the correct length determined by the remaining length field
buflen | the length in bytes of the data in the supplied buffer
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 34 of file MQTTUnsubscribeServer.c.

◆ MQTTSerialize_unsuback()

int MQTTSerialize_unsuback | ( | unsigned char * | buf,
 |  | int | buflen,
 |  | unsigned short | packetid
 | ) |  |

Serializes the supplied unsuback data into the supplied buffer, ready for sending

Parameters
buf | the buffer into which the packet will be serialized
buflen | the length in bytes of the supplied buffer
packetid | integer - the MQTT packet identifier
Returns
the length of the serialized data. <= 0 indicates error

Definition at line 76 of file MQTTUnsubscribeServer.c.


ioLibrary: Internet/MQTT/MQTTPacket/src/StackTrace.h File Reference

  • Internet
  • MQTT
  • MQTTPacket
  • src
Macros
StackTrace.h File Reference
#include <stdio.h>
Include dependency graph for StackTrace.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | NOSTACKTRACE 1
#define | FUNC_ENTRY
#define | FUNC_ENTRY_NOLOG
#define | FUNC_ENTRY_MED
#define | FUNC_ENTRY_MAX
#define | FUNC_EXIT
#define | FUNC_EXIT_NOLOG
#define | FUNC_EXIT_MED
#define | FUNC_EXIT_MAX
#define | FUNC_EXIT_RC(x)
#define | FUNC_EXIT_MED_RC(x)
#define | FUNC_EXIT_MAX_RC(x)

Macro Definition Documentation

◆ FUNC_ENTRY

#define FUNC_ENTRY

Definition at line 25 of file StackTrace.h.

◆ FUNC_ENTRY_MAX

#define FUNC_ENTRY_MAX

Definition at line 28 of file StackTrace.h.

◆ FUNC_ENTRY_MED

#define FUNC_ENTRY_MED

Definition at line 27 of file StackTrace.h.

◆ FUNC_ENTRY_NOLOG

#define FUNC_ENTRY_NOLOG

Definition at line 26 of file StackTrace.h.

◆ FUNC_EXIT

#define FUNC_EXIT

Definition at line 29 of file StackTrace.h.

◆ FUNC_EXIT_MAX

#define FUNC_EXIT_MAX

Definition at line 32 of file StackTrace.h.

◆ FUNC_EXIT_MAX_RC

#define FUNC_EXIT_MAX_RC ( x )

Definition at line 35 of file StackTrace.h.

◆ FUNC_EXIT_MED

#define FUNC_EXIT_MED

Definition at line 31 of file StackTrace.h.

◆ FUNC_EXIT_MED_RC

#define FUNC_EXIT_MED_RC ( x )

Definition at line 34 of file StackTrace.h.

◆ FUNC_EXIT_NOLOG

#define FUNC_EXIT_NOLOG

Definition at line 30 of file StackTrace.h.

◆ FUNC_EXIT_RC

#define FUNC_EXIT_RC ( x )

Definition at line 33 of file StackTrace.h.

◆ NOSTACKTRACE

#define NOSTACKTRACE 1

Definition at line 22 of file StackTrace.h.


ioLibrary: Internet/MQTT/mqtt_interface.c File Reference

  • Internet
  • MQTT
Functions | Variables
mqtt_interface.c File Reference

Paho MQTT to WIZnet Chip interface implement file. More...

#include "mqtt_interface.h"
#include "wizchip_conf.h"
Include dependency graph for mqtt_interface.c:

Go to the source code of this file.

Functions

void | MilliTimer_Handler (void)
void | TimerInit (Timer *timer)
char | TimerIsExpired (Timer *timer)
void | TimerCountdownMS (Timer *timer, unsigned int timeout)
void | TimerCountdown (Timer *timer, unsigned int timeout)
int | TimerLeftMS (Timer *timer)
void | NewNetwork (Network *n, int sn)
int | w5x00_read (Network *n, unsigned char *buffer, int len)
int | w5x00_write (Network *n, unsigned char *buffer, int len)
void | w5x00_disconnect (Network *n)
int | ConnectNetwork (Network *n, char *ip, int port)

Variables

unsigned long MilliTimer

Detailed Description

Paho MQTT to WIZnet Chip interface implement file.

The process of porting an interface to use paho MQTT.

Version
1.0.0
Date
2016/12/06
Revision history
<2016/12/06> 1st Release
Author
Peter Bang & Justin Kim
Copyright

Copyright (c) 2016, 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 mqtt_interface.c.

Function Documentation

◆ ConnectNetwork()

int ConnectNetwork | ( | Network * | n,
 |  | char * | ip,
 |  | int | port
 | ) |  |

Definition at line 163 of file mqtt_interface.c.

◆ MilliTimer_Handler()

void MilliTimer_Handler ( void )

Definition at line 52 of file mqtt_interface.c.

◆ NewNetwork()

void NewNetwork | ( | Network * | n,
 |  | int | sn
 | ) |  |

Definition at line 112 of file mqtt_interface.c.

◆ TimerCountdown()

void TimerCountdown | ( | Timer * | timer,
 |  | unsigned int | timeout
 | ) |  |

Definition at line 91 of file mqtt_interface.c.

◆ TimerCountdownMS()

void TimerCountdownMS | ( | Timer * | timer,
 |  | unsigned int | timeout
 | ) |  |

Definition at line 81 of file mqtt_interface.c.

◆ TimerInit()

void TimerInit ( Timer * timer )

Definition at line 61 of file mqtt_interface.c.

◆ TimerIsExpired()

char TimerIsExpired ( Timer * timer )

Definition at line 70 of file mqtt_interface.c.

◆ TimerLeftMS()

int TimerLeftMS ( Timer * timer )

Definition at line 100 of file mqtt_interface.c.

◆ w5x00_disconnect()

void w5x00_disconnect ( Network * n )

Definition at line 151 of file mqtt_interface.c.

◆ w5x00_read()

int w5x00_read | ( | Network * | n,
 |  | unsigned char * | buffer,
 |  | int | len
 | ) |  |

Definition at line 126 of file mqtt_interface.c.

◆ w5x00_write()

int w5x00_write | ( | Network * | n,
 |  | unsigned char * | buffer,
 |  | int | len
 | ) |  |

Definition at line 140 of file mqtt_interface.c.

Variable Documentation

◆ MilliTimer

unsigned long MilliTimer

Definition at line 46 of file mqtt_interface.c.


ioLibrary: Internet/MQTT/mqtt_interface.h File Reference

  • Internet
  • MQTT
Data Structures | Typedefs | Functions
mqtt_interface.h File Reference

Paho MQTT to WIZnet Chip interface Header file. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct | Timer
struct | Network

Typedefs

typedef struct Timer | Timer
typedef struct Network | Network

Functions

void | MilliTimer_Handler (void)
void | TimerInit (Timer *)
char | TimerIsExpired (Timer *)
void | TimerCountdownMS (Timer *, unsigned int)
void | TimerCountdown (Timer *, unsigned int)
int | TimerLeftMS (Timer *)
int | w5x00_read (Network *, unsigned char *, int)
int | w5x00_write (Network *, unsigned char *, int)
void | w5x00_disconnect (Network *)
void | NewNetwork (Network *n, int sn)
int | ConnectNetwork (Network *, char *, int)

Detailed Description

Paho MQTT to WIZnet Chip interface Header file.

The process of porting an interface to use paho MQTT.

Version
1.0.0
Date
2016/12/06
Revision history
<2016/12/06> 1st Release
Author
Peter Bang & Justin Kim
Copyright

Copyright (c) 2016, 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 mqtt_interface.h.

Typedef Documentation

◆ Network

typedef struct Network Network

Definition at line 233 of file mqtt_interface.h.

◆ Timer

typedef struct Timer Timer

Definition at line 224 of file mqtt_interface.h.

Function Documentation

◆ ConnectNetwork()

int ConnectNetwork | ( | Network * | ,
 |  | char * | ,
 |  | int |
 | ) |  |

Definition at line 163 of file mqtt_interface.c.

◆ MilliTimer_Handler()

void MilliTimer_Handler ( void )

Definition at line 52 of file mqtt_interface.c.

◆ NewNetwork()

void NewNetwork | ( | Network * | n,
 |  | int | sn
 | ) |  |

Definition at line 112 of file mqtt_interface.c.

◆ TimerCountdown()

void TimerCountdown | ( | Timer * | ,
 |  | unsigned | int
 | ) |  |

Definition at line 91 of file mqtt_interface.c.

◆ TimerCountdownMS()

void TimerCountdownMS | ( | Timer * | ,
 |  | unsigned | int
 | ) |  |

Definition at line 81 of file mqtt_interface.c.

◆ TimerInit()

void TimerInit ( Timer * )

Definition at line 61 of file mqtt_interface.c.

◆ TimerIsExpired()

char TimerIsExpired ( Timer * )

Definition at line 70 of file mqtt_interface.c.

◆ TimerLeftMS()

int TimerLeftMS ( Timer * )

Definition at line 100 of file mqtt_interface.c.

◆ w5x00_disconnect()

void w5x00_disconnect ( Network * )

Definition at line 151 of file mqtt_interface.c.

◆ w5x00_read()

int w5x00_read | ( | Network * | ,
 |  | unsigned char * | ,
 |  | int |
 | ) |  |

Definition at line 126 of file mqtt_interface.c.

◆ w5x00_write()

int w5x00_write | ( | Network * | ,
 |  | unsigned char * | ,
 |  | int |
 | ) |  |

Definition at line 140 of file mqtt_interface.c.


ioLibrary: Internet/MQTT/MQTTClient.c File Reference

  • Internet
  • MQTT
Functions
MQTTClient.c File Reference
#include "MQTTClient.h"
Include dependency graph for MQTTClient.c:

Go to the source code of this file.

Functions

void | MQTTClientInit (MQTTClient *c, Network *network, unsigned int command_timeout_ms, unsigned char *sendbuf, size_t sendbuf_size, unsigned char *readbuf, size_t readbuf_size)
int | deliverMessage (MQTTClient *c, MQTTString *topicName, MQTTMessage *message)
int | keepalive (MQTTClient *c)
int | cycle (MQTTClient *c, Timer *timer)
int | MQTTYield (MQTTClient *c, int timeout_ms)
void | MQTTRun (void *parm)
int | waitfor (MQTTClient *c, int packet_type, Timer *timer)
int | MQTTConnect (MQTTClient *c, MQTTPacket_connectData *options)
int | MQTTSubscribe (MQTTClient *c, const char *topicFilter, enum QoS qos, messageHandler messageHandler)
int | MQTTUnsubscribe (MQTTClient *c, const char *topicFilter)
int | MQTTPublish (MQTTClient *c, const char *topicName, MQTTMessage *message)
int | MQTTDisconnect (MQTTClient *c)

Function Documentation

◆ cycle()

int cycle | ( | MQTTClient * | c,
 |  | Timer * | timer
 | ) |  |

Definition at line 223 of file MQTTClient.c.

◆ deliverMessage()

int deliverMessage | ( | MQTTClient * | c,
 |  | MQTTString * | topicName,
 |  | MQTTMessage * | message
 | ) |  |

Definition at line 162 of file MQTTClient.c.

◆ keepalive()

int keepalive ( MQTTClient * c )

Definition at line 195 of file MQTTClient.c.

◆ MQTTClientInit()

void MQTTClientInit | ( | MQTTClient * | client,
 |  | Network * | network,
 |  | unsigned int | command_timeout_ms,
 |  | unsigned char * | sendbuf,
 |  | size_t | sendbuf_size,
 |  | unsigned char * | readbuf,
 |  | size_t | readbuf_size
 | ) |  |

Create an MQTT client object

Parameters
client
network
command_timeout_ms

Definition at line 52 of file MQTTClient.c.

◆ MQTTConnect()

int MQTTConnect | ( | MQTTClient * | client,
 |  | MQTTPacket_connectData * | options
 | ) |  |

MQTT Connect - send an MQTT connect packet down the network and wait for a Connack The nework object must be connected to the network endpoint before calling this

Parameters
options - connect options
Returns
success code

Definition at line 355 of file MQTTClient.c.

◆ MQTTDisconnect()

int MQTTDisconnect ( MQTTClient * client )

MQTT Disconnect - send an MQTT disconnect packet and close the connection

Parameters
client - the client object to use
Returns
success code

Definition at line 560 of file MQTTClient.c.

◆ MQTTPublish()

int MQTTPublish | ( | MQTTClient * | client,
 |  | const char * | ,
 |  | MQTTMessage * |
 | ) |  |

MQTT Publish - send an MQTT publish packet and wait for all acks to complete for all QoSs

Parameters
client | - the client object to use
topic | - the topic to publish to
message | - the message to send
Returns
success code

Definition at line 500 of file MQTTClient.c.

◆ MQTTRun()

void MQTTRun ( void * parm )

Definition at line 311 of file MQTTClient.c.

◆ MQTTSubscribe()

int MQTTSubscribe | ( | MQTTClient * | client,
 |  | const char * | topicFilter,
 |  | enum | QoS,
 |  | messageHandler |
 | ) |  |

MQTT Subscribe - send an MQTT subscribe packet and wait for suback before returning.

Parameters
client | - the client object to use
topicFilter | - the topic filter to subscribe to
message | - the message to send
Returns
success code

Definition at line 406 of file MQTTClient.c.

◆ MQTTUnsubscribe()

int MQTTUnsubscribe | ( | MQTTClient * | client,
 |  | const char * | topicFilter
 | ) |  |

MQTT Subscribe - send an MQTT unsubscribe packet and wait for unsuback before returning.

Parameters
client | - the client object to use
topicFilter | - the topic filter to unsubscribe from
Returns
success code

Definition at line 461 of file MQTTClient.c.

◆ MQTTYield()

int MQTTYield | ( | MQTTClient * | client,
 |  | int | time
 | ) |  |

MQTT Yield - MQTT background

Parameters
client | - the client object to use
time | - the time, in milliseconds, to yield for
Returns
success code

Definition at line 290 of file MQTTClient.c.

◆ waitfor()

int waitfor | ( | MQTTClient * | c,
 |  | int | packet_type,
 |  | Timer * | timer
 | ) |  |

Definition at line 340 of file MQTTClient.c.


ioLibrary: Internet/MQTT/MQTTClient.h File Reference

  • Internet
  • MQTT
Data Structures | Macros | Typedefs | Enumerations | Functions
MQTTClient.h File Reference
#include "./MQTTPacket/src/MQTTPacket.h"
#include "stdio.h"
#include "mqtt_interface.h"
Include dependency graph for MQTTClient.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct | MQTTMessage
struct | MessageData
struct | MQTTClient
struct | MQTTClient::MessageHandlers

Macros

#define | DLLImport
#define | DLLExport
#define | MAX_PACKET_ID 65535 /* according to the MQTT specification - do not change! */
#define | MAX_MESSAGE_HANDLERS 5 /* redefinable - how many subscriptions do you want? */
#define | DefaultClient {0, 0, 0, 0, NULL, NULL, 0, 0, 0}

Typedefs

typedef struct MQTTMessage | MQTTMessage
typedef struct MessageData | MessageData
typedef void(* | messageHandler) (MessageData *)
typedef struct MQTTClient | MQTTClient

Enumerations

enum | QoS { QOS0, QOS1, QOS2 }
enum | returnCode { BUFFER_OVERFLOW = -2, FAILURE = -1, SUCCESSS = 0 }

Functions

void | TimerInit (Timer *)
char | TimerIsExpired (Timer *)
void | TimerCountdownMS (Timer *, unsigned int)
void | TimerCountdown (Timer *, unsigned int)
int | TimerLeftMS (Timer *)
DLLExport void | MQTTClientInit (MQTTClient *client, Network *network, unsigned int command_timeout_ms, unsigned char *sendbuf, size_t sendbuf_size, unsigned char *readbuf, size_t readbuf_size)
DLLExport int | MQTTConnect (MQTTClient *client, MQTTPacket_connectData *options)
DLLExport int | MQTTPublish (MQTTClient *client, const char *, MQTTMessage *)
DLLExport int | MQTTSubscribe (MQTTClient *client, const char *topicFilter, enum QoS, messageHandler)
DLLExport int | MQTTUnsubscribe (MQTTClient *client, const char *topicFilter)
DLLExport int | MQTTDisconnect (MQTTClient *client)
DLLExport int | MQTTYield (MQTTClient *client, int time)

Macro Definition Documentation

◆ DefaultClient

#define DefaultClient {0, 0, 0, 0, NULL, NULL, 0, 0, 0}

Definition at line 114 of file MQTTClient.h.

◆ DLLExport

#define DLLExport

Definition at line 33 of file MQTTClient.h.

◆ DLLImport

#define DLLImport

Definition at line 32 of file MQTTClient.h.

◆ MAX_MESSAGE_HANDLERS

#define MAX_MESSAGE_HANDLERS 5 /* redefinable - how many subscriptions do you want? */

Definition at line 43 of file MQTTClient.h.

◆ MAX_PACKET_ID

#define MAX_PACKET_ID 65535 /* according to the MQTT specification - do not change! */

Definition at line 40 of file MQTTClient.h.

Typedef Documentation

◆ MessageData

typedef struct MessageData MessageData

◆ messageHandler

typedef void(* messageHandler) (MessageData *)

Definition at line 84 of file MQTTClient.h.

◆ MQTTClient

typedef struct MQTTClient MQTTClient

◆ MQTTMessage

typedef struct MQTTMessage MQTTMessage

Enumeration Type Documentation

◆ QoS

enum QoS
Enumerator
QOS0
QOS1
QOS2

Definition at line 46 of file MQTTClient.h.

◆ returnCode

enum returnCode
Enumerator
BUFFER_OVERFLOW
FAILURE
SUCCESSS

Definition at line 49 of file MQTTClient.h.

Function Documentation

◆ MQTTClientInit()

DLLExport void MQTTClientInit | ( | MQTTClient * | client,
 |  | Network * | network,
 |  | unsigned int | command_timeout_ms,
 |  | unsigned char * | sendbuf,
 |  | size_t | sendbuf_size,
 |  | unsigned char * | readbuf,
 |  | size_t | readbuf_size
 | ) |  |

Create an MQTT client object

Parameters
client
network
command_timeout_ms

Definition at line 52 of file MQTTClient.c.

◆ MQTTConnect()

DLLExport int MQTTConnect | ( | MQTTClient * | client,
 |  | MQTTPacket_connectData * | options
 | ) |  |

MQTT Connect - send an MQTT connect packet down the network and wait for a Connack The nework object must be connected to the network endpoint before calling this

Parameters
options - connect options
Returns
success code

Definition at line 355 of file MQTTClient.c.

◆ MQTTDisconnect()

DLLExport int MQTTDisconnect ( MQTTClient * client )

MQTT Disconnect - send an MQTT disconnect packet and close the connection

Parameters
client - the client object to use
Returns
success code

Definition at line 560 of file MQTTClient.c.

◆ MQTTPublish()

DLLExport int MQTTPublish | ( | MQTTClient * | client,
 |  | const char * | ,
 |  | MQTTMessage * |
 | ) |  |

MQTT Publish - send an MQTT publish packet and wait for all acks to complete for all QoSs

Parameters
client | - the client object to use
topic | - the topic to publish to
message | - the message to send
Returns
success code

Definition at line 500 of file MQTTClient.c.

◆ MQTTSubscribe()

DLLExport int MQTTSubscribe | ( | MQTTClient * | client,
 |  | const char * | topicFilter,
 |  | enum | QoS,
 |  | messageHandler |
 | ) |  |

MQTT Subscribe - send an MQTT subscribe packet and wait for suback before returning.

Parameters
client | - the client object to use
topicFilter | - the topic filter to subscribe to
message | - the message to send
Returns
success code

Definition at line 406 of file MQTTClient.c.

◆ MQTTUnsubscribe()

DLLExport int MQTTUnsubscribe | ( | MQTTClient * | client,
 |  | const char * | topicFilter
 | ) |  |

MQTT Subscribe - send an MQTT unsubscribe packet and wait for unsuback before returning.

Parameters
client | - the client object to use
topicFilter | - the topic filter to unsubscribe from
Returns
success code

Definition at line 461 of file MQTTClient.c.

◆ MQTTYield()

DLLExport int MQTTYield | ( | MQTTClient * | client,
 |  | int | time
 | ) |  |

MQTT Yield - MQTT background

Parameters
client | - the client object to use
time | - the time, in milliseconds, to yield for
Returns
success code

Definition at line 290 of file MQTTClient.c.

◆ TimerCountdown()

void TimerCountdown | ( | Timer * | ,
 |  | unsigned | int
 | ) |  |

Definition at line 91 of file mqtt_interface.c.

◆ TimerCountdownMS()

void TimerCountdownMS | ( | Timer * | ,
 |  | unsigned | int
 | ) |  |

Definition at line 81 of file mqtt_interface.c.

◆ TimerInit()

void TimerInit ( Timer * )

Definition at line 61 of file mqtt_interface.c.

◆ TimerIsExpired()

char TimerIsExpired ( Timer * )

Definition at line 70 of file mqtt_interface.c.

◆ TimerLeftMS()

int TimerLeftMS ( Timer * )

Definition at line 100 of file mqtt_interface.c.


ioLibrary: Internet/SNMP Directory Reference

  • Internet
  • SNMP
SNMP Directory Reference
Directory dependency graph for SNMP:

Files

file | snmp.c [code]
file | snmp.h [code]
file | snmp_custom.c [code]
file | snmp_custom.h [code]


ioLibrary: Internet/SNMP/snmp.c File Reference

  • Internet
  • SNMP
Functions | Variables
snmp.c File Reference
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <time.h>
#include "socket.h"
#include "snmp.h"
#include "snmp_custom.h"
Include dependency graph for snmp.c:

Go to the source code of this file.

Functions

int32_t | findEntry (uint8_t *oid, int32_t len)
int32_t | getOID (int32_t id, uint8_t *oid, uint8_t *len)
int32_t | getValue (uint8_t *vptr, int32_t vlen)
int32_t | getEntry (int32_t id, uint8_t *dataType, void *ptr, int32_t *len)
int32_t | setEntry (int32_t id, void *val, int32_t vlen, uint8_t dataType, int32_t index)
int32_t | makeTrapVariableBindings (dataEntryType *oid_data, void *ptr, uint32_t *len)
int32_t | parseLength (const uint8_t *msg, int32_t *len)
int32_t | parseTLV (const uint8_t *msg, int32_t index, tlvStructType *tlv)
void | insertRespLen (int32_t reqStart, int32_t respStart, int32_t size)
int32_t | parseVarBind (int32_t reqType, int32_t index)
int32_t | parseSequence (int32_t reqType, int32_t index)
int32_t | parseSequenceOf (int32_t reqType)
int32_t | parseRequest ()
int32_t | parseCommunity ()
int32_t | parseVersion ()
int32_t | parseSNMPMessage ()
void | dumpCode (uint8_t *header, uint8_t *tail, uint8_t *buff, int32_t len)
void | ipToByteArray (int8_t *ip, uint8_t *pDes)
void | currentUptime (void *ptr, uint8_t *len)
void | SNMP_time_handler (void)
uint32_t | getSNMPTimeTick (void)
void | snmpd_init (uint8_t *managerIP, uint8_t *agentIP, uint8_t sn_agent, uint8_t sn_trap)
int32_t | snmpd_run (void)
int32_t | snmp_sendTrap (uint8_t *managerIP, uint8_t *agentIP, int8_t *community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count,...)

Variables

struct messageStruct | request_msg
struct messageStruct | response_msg
volatile uint32_t | snmp_tick_10ms = 0
uint8_t | packet_trap [MAX_TRAPMSG_LEN] = {0,}
uint8_t | errorStatus
uint8_t | errorIndex

Function Documentation

◆ currentUptime()

void currentUptime | ( | void * | ptr,
 |  | uint8_t * | len
 | ) |  |

Definition at line 63 of file snmp.c.

◆ getSNMPTimeTick()

uint32_t getSNMPTimeTick ( void )

Definition at line 78 of file snmp.c.

◆ SNMP_time_handler()

void SNMP_time_handler ( void )

Definition at line 72 of file snmp.c.

Variable Documentation

◆ errorIndex

uint8_t errorIndex

Definition at line 57 of file snmp.c.

◆ errorStatus

uint8_t errorStatus

Definition at line 57 of file snmp.c.

◆ packet_trap

uint8_t packet_trap[MAX_TRAPMSG_LEN] = {0,}

Definition at line 56 of file snmp.c.

◆ request_msg

struct messageStruct request_msg

Definition at line 45 of file snmp.c.

◆ response_msg

struct messageStruct response_msg

Definition at line 46 of file snmp.c.

◆ snmp_tick_10ms

volatile uint32_t snmp_tick_10ms = 0

Definition at line 50 of file snmp.c.


ioLibrary: Internet/SNMP/snmp.h File Reference

  • Internet
  • SNMP
Data Structures | Macros | Functions
snmp.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct | dataEntryType
struct | messageStruct
struct | tlvStructType

Macros

#define | _SNMP_DEBUG_
#define | PORT_SNMP_AGENT 161
#define | PORT_SNMP_TRAP 162
#define | SNMP_V1 0
#define | MAX_OID 12
#define | MAX_STRING 64
#define | MAX_SNMPMSG_LEN 512
#define | MAX_TRAPMSG_LEN 512
#define | SNMP_SUCCESS 0
#define | OID_NOT_FOUND -1
#define | TABLE_FULL -2
#define | ILLEGAL_LENGTH -3
#define | INVALID_ENTRY_ID -4
#define | INVALID_DATA_TYPE -5
#define | NO_SUCH_NAME 2
#define | BAD_VALUE 3
#define | GET_REQUEST 0xa0
#define | GET_NEXT_REQUEST 0xa1
#define | GET_RESPONSE 0xa2
#define | SET_REQUEST 0xa3
#define | VALID_REQUEST(x) ((x == GET_REQUEST) || (x == GET_NEXT_REQUEST) || (x == SET_REQUEST))
#define | SNMPDTYPE_INTEGER 0x02
#define | SNMPDTYPE_OCTET_STRING 0x04
#define | SNMPDTYPE_NULL_ITEM 0x05
#define | SNMPDTYPE_OBJ_ID 0x06
#define | SNMPDTYPE_SEQUENCE 0x30
#define | SNMPDTYPE_SEQUENCE_OF SNMPDTYPE_SEQUENCE
#define | SNMPDTYPE_COUNTER 0x41
#define | SNMPDTYPE_GAUGE 0x42
#define | SNMPDTYPE_TIME_TICKS 0x43
#define | SNMPDTYPE_OPAQUE 0x44
#define | SNMPTRAP_COLDSTART 0x00
#define | SNMPTRAP_WARMSTART 0x01
#define | SNMPTRAP_LINKDOWN 0x02
#define | SNMPTRAP_LINKUP 0x03
#define | SNMPTRAP_AUTHENTICATION 0x04
#define | SNMPTRAP_EGPNEIGHBORLOSS 0x05
#define | COPY_SEGMENT(x)
#define | HTONL(x)

Functions

void | snmpd_init (uint8_t *managerIP, uint8_t *agentIP, uint8_t sn_agent, uint8_t sn_trap)
int32_t | snmpd_run (void)
int32_t | snmp_sendTrap (uint8_t *managerIP, uint8_t *agentIP, int8_t *community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count,...)
void | SNMP_time_handler (void)
uint32_t | getSNMPTimeTick (void)
void | currentUptime (void *ptr, uint8_t *len)

Macro Definition Documentation

◆ _SNMP_DEBUG_

#define _SNMP_DEBUG_

Definition at line 5 of file snmp.h.

◆ BAD_VALUE

#define BAD_VALUE 3

Definition at line 26 of file snmp.h.

◆ COPY_SEGMENT

#define COPY_SEGMENT ( x )
Value:
{ \
request_msg.index += seglen; \
memcpy(&response_msg.buffer[response_msg.index], &request_msg.buffer[x.start], seglen ); \
response_msg.index += seglen; \
}
request_msg
struct messageStruct request_msg
Definition: snmp.c:45
response_msg
struct messageStruct response_msg
Definition: snmp.c:46
messageStruct::buffer
uint8_t buffer[MAX_SNMPMSG_LEN]
Definition: snmp.h:88
messageStruct::index
int32_t index
Definition: snmp.h:90

Definition at line 59 of file snmp.h.

◆ GET_NEXT_REQUEST

#define GET_NEXT_REQUEST 0xa1

Definition at line 30 of file snmp.h.

◆ GET_REQUEST

#define GET_REQUEST 0xa0

Definition at line 29 of file snmp.h.

◆ GET_RESPONSE

#define GET_RESPONSE 0xa2

Definition at line 31 of file snmp.h.

◆ HTONL

#define HTONL ( x )
Value:
((((x) >> 24) & 0x000000ff) | \
(((x) >> 8) & 0x0000ff00) | \
(((x) << 8) & 0x00ff0000) | \
(((x) << 24) & 0xff000000))

Definition at line 67 of file snmp.h.

◆ ILLEGAL_LENGTH

#define ILLEGAL_LENGTH -3

Definition at line 21 of file snmp.h.

◆ INVALID_DATA_TYPE

#define INVALID_DATA_TYPE -5

Definition at line 23 of file snmp.h.

◆ INVALID_ENTRY_ID

#define INVALID_ENTRY_ID -4

Definition at line 22 of file snmp.h.

◆ MAX_OID

#define MAX_OID 12

Definition at line 12 of file snmp.h.

◆ MAX_SNMPMSG_LEN

#define MAX_SNMPMSG_LEN 512

Definition at line 14 of file snmp.h.

◆ MAX_STRING

#define MAX_STRING 64

Definition at line 13 of file snmp.h.

◆ MAX_TRAPMSG_LEN

#define MAX_TRAPMSG_LEN 512

Definition at line 15 of file snmp.h.

◆ NO_SUCH_NAME

#define NO_SUCH_NAME 2

Definition at line 25 of file snmp.h.

◆ OID_NOT_FOUND

#define OID_NOT_FOUND -1

Definition at line 19 of file snmp.h.

◆ PORT_SNMP_AGENT

#define PORT_SNMP_AGENT 161

Definition at line 7 of file snmp.h.

◆ PORT_SNMP_TRAP

#define PORT_SNMP_TRAP 162

Definition at line 8 of file snmp.h.

◆ SET_REQUEST

#define SET_REQUEST 0xa3

Definition at line 32 of file snmp.h.

◆ SNMP_SUCCESS

#define SNMP_SUCCESS 0

Definition at line 18 of file snmp.h.

◆ SNMP_V1

#define SNMP_V1 0

Definition at line 10 of file snmp.h.

◆ SNMPDTYPE_COUNTER

#define SNMPDTYPE_COUNTER 0x41

Definition at line 45 of file snmp.h.

◆ SNMPDTYPE_GAUGE

#define SNMPDTYPE_GAUGE 0x42

Definition at line 46 of file snmp.h.

◆ SNMPDTYPE_INTEGER

#define SNMPDTYPE_INTEGER 0x02

Definition at line 38 of file snmp.h.

◆ SNMPDTYPE_NULL_ITEM

#define SNMPDTYPE_NULL_ITEM 0x05

Definition at line 40 of file snmp.h.

◆ SNMPDTYPE_OBJ_ID

#define SNMPDTYPE_OBJ_ID 0x06

Definition at line 41 of file snmp.h.

◆ SNMPDTYPE_OCTET_STRING

#define SNMPDTYPE_OCTET_STRING 0x04

Definition at line 39 of file snmp.h.

◆ SNMPDTYPE_OPAQUE

#define SNMPDTYPE_OPAQUE 0x44

Definition at line 48 of file snmp.h.

◆ SNMPDTYPE_SEQUENCE

#define SNMPDTYPE_SEQUENCE 0x30

Definition at line 42 of file snmp.h.

◆ SNMPDTYPE_SEQUENCE_OF

#define SNMPDTYPE_SEQUENCE_OF SNMPDTYPE_SEQUENCE

Definition at line 43 of file snmp.h.

◆ SNMPDTYPE_TIME_TICKS

#define SNMPDTYPE_TIME_TICKS 0x43

Definition at line 47 of file snmp.h.

◆ SNMPTRAP_AUTHENTICATION

#define SNMPTRAP_AUTHENTICATION 0x04

Definition at line 55 of file snmp.h.

◆ SNMPTRAP_COLDSTART

#define SNMPTRAP_COLDSTART 0x00

Definition at line 51 of file snmp.h.

◆ SNMPTRAP_EGPNEIGHBORLOSS

#define SNMPTRAP_EGPNEIGHBORLOSS 0x05

Definition at line 56 of file snmp.h.

◆ SNMPTRAP_LINKDOWN

#define SNMPTRAP_LINKDOWN 0x02

Definition at line 53 of file snmp.h.

◆ SNMPTRAP_LINKUP

#define SNMPTRAP_LINKUP 0x03

Definition at line 54 of file snmp.h.

◆ SNMPTRAP_WARMSTART

#define SNMPTRAP_WARMSTART 0x01

Definition at line 52 of file snmp.h.

◆ TABLE_FULL

#define TABLE_FULL -2

Definition at line 20 of file snmp.h.

◆ VALID_REQUEST

#define VALID_REQUEST ( x ) ((x == GET_REQUEST) || (x == GET_NEXT_REQUEST) || (x == SET_REQUEST))

Definition at line 35 of file snmp.h.

Function Documentation

◆ currentUptime()

void currentUptime | ( | void * | ptr,
 |  | uint8_t * | len
 | ) |  |

Definition at line 63 of file snmp.c.

◆ getSNMPTimeTick()

uint32_t getSNMPTimeTick ( void )

Definition at line 78 of file snmp.c.

◆ SNMP_time_handler()

void SNMP_time_handler ( void )

Definition at line 72 of file snmp.c.


ioLibrary: Internet/SNMP/snmp_custom.c File Reference

  • Internet
  • SNMP
Functions | Variables
snmp_custom.c File Reference
#include "snmp_custom.h"
Include dependency graph for snmp_custom.c:

Go to the source code of this file.

Functions

void | initTable ()
void | initial_Trap (uint8_t *managerIP, uint8_t *agentIP)

Variables

dataEntryType snmpData []
const int32_t maxData = (sizeof(snmpData) / sizeof(dataEntryType))

Function Documentation

◆ initial_Trap()

void initial_Trap | ( | uint8_t * | managerIP,
 |  | uint8_t * | agentIP
 | ) |  |

Definition at line 137 of file snmp_custom.c.

◆ initTable()

void initTable ( )

Definition at line 96 of file snmp_custom.c.

Variable Documentation

◆ maxData

const int32_t maxData = (sizeof(snmpData) / sizeof(dataEntryType))

Definition at line 94 of file snmp_custom.c.

◆ snmpData

dataEntryType snmpData[]

Definition at line 18 of file snmp_custom.c.


ioLibrary: Internet/SNMP/snmp_custom.h File Reference

  • Internet
  • SNMP
Macros | Functions | Variables
snmp_custom.h File Reference
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
#include "snmp.h"
Include dependency graph for snmp_custom.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | COMMUNITY "public\0"
#define | COMMUNITY_SIZE (strlen(COMMUNITY))

Functions

void | initTable ()
void | initial_Trap (uint8_t *managerIP, uint8_t *agentIP)

Variables

dataEntryType snmpData []
const int32_t maxData

Macro Definition Documentation

◆ COMMUNITY

#define COMMUNITY "public\0"

Definition at line 17 of file snmp_custom.h.

◆ COMMUNITY_SIZE

#define COMMUNITY_SIZE (strlen(COMMUNITY))

Definition at line 18 of file snmp_custom.h.

Function Documentation

◆ initial_Trap()

void initial_Trap | ( | uint8_t * | managerIP,
 |  | uint8_t * | agentIP
 | ) |  |

Definition at line 137 of file snmp_custom.c.

◆ initTable()

void initTable ( )

Definition at line 96 of file snmp_custom.c.

Variable Documentation

◆ maxData

const int32_t maxData

Definition at line 94 of file snmp_custom.c.

◆ snmpData

dataEntryType snmpData[]

Definition at line 18 of file snmp_custom.c.


ioLibrary: Internet/SNTP Directory Reference

  • Internet
  • SNTP
SNTP Directory Reference
Directory dependency graph for SNTP:

Files

file | sntp.c [code]
file | sntp.h [code]


ioLibrary: Internet/SNTP/sntp.c File Reference

  • Internet
  • SNTP
Functions | Variables
sntp.c File Reference
#include <string.h>
#include "sntp.h"
#include "socket.h"
Include dependency graph for sntp.c:

Go to the source code of this file.

Functions

void | get_seconds_from_ntp_server (uint8_t *buf, uint16_t idx)
void | SNTP_init (uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf)
int8_t | SNTP_run (datetime *time)
void | calcdatetime (tstamp seconds)
tstamp | changedatetime_to_seconds (void)

Variables

ntpformat NTPformat
datetime Nowdatetime
uint8_t | ntpmessage [48]
uint8_t * | data_buf
uint8_t | NTP_SOCKET
uint8_t | time_zone
uint16_t | ntp_retry_cnt =0

Function Documentation

◆ calcdatetime()

void calcdatetime ( tstamp seconds )

Definition at line 316 of file sntp.c.

◆ changedatetime_to_seconds()

tstamp changedatetime_to_seconds ( void )

Definition at line 402 of file sntp.c.

◆ get_seconds_from_ntp_server()

void get_seconds_from_ntp_server | ( | uint8_t * | buf,
 |  | uint16_t | idx
 | ) |  |

Definition at line 74 of file sntp.c.

◆ SNTP_init()

void SNTP_init | ( | uint8_t | s,
 |  | uint8_t * | ntp_server,
 |  | uint8_t | tz,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 218 of file sntp.c.

◆ SNTP_run()

int8_t SNTP_run ( datetime * time )

Definition at line 250 of file sntp.c.

Variable Documentation

◆ data_buf

uint8_t* data_buf

Definition at line 17 of file sntp.c.

◆ Nowdatetime

datetime Nowdatetime

Definition at line 15 of file sntp.c.

◆ ntp_retry_cnt

uint16_t ntp_retry_cnt =0

Definition at line 20 of file sntp.c.

◆ NTP_SOCKET

uint8_t NTP_SOCKET

Definition at line 18 of file sntp.c.

◆ NTPformat

ntpformat NTPformat

Definition at line 14 of file sntp.c.

◆ ntpmessage

uint8_t ntpmessage[48]

Definition at line 16 of file sntp.c.

◆ time_zone

uint8_t time_zone

Definition at line 19 of file sntp.c.


ioLibrary: Internet/SNTP/sntp.h File Reference

  • Internet
  • SNTP
Data Structures | Macros | Typedefs | Functions
sntp.h File Reference
#include <stdint.h>
Include dependency graph for sntp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct | _ntpformat
struct | _datetime

Macros

#define | MAX_SNTP_BUF_SIZE sizeof(ntpformat)
maximum size of DNS buffer. */ More...
#define | ntp_port 123
#define | SECS_PERDAY 86400UL
#define | UTC_ADJ_HRS 9
#define | EPOCH 1900

Typedefs

typedef signed char | s_char
typedef unsigned long long | tstamp
typedef unsigned int | tdist
typedef struct _ntpformat | ntpformat
typedef struct _datetime | datetime

Functions

void | get_seconds_from_ntp_server (uint8_t *buf, uint16_t idx)
void | SNTP_init (uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf)
int8_t | SNTP_run (datetime *time)
tstamp | changedatetime_to_seconds (void)
void | calcdatetime (tstamp seconds)

Macro Definition Documentation

◆ EPOCH

#define EPOCH 1900

Definition at line 60 of file sntp.h.

◆ MAX_SNTP_BUF_SIZE

#define MAX_SNTP_BUF_SIZE sizeof(ntpformat)

maximum size of DNS buffer. */

Definition at line 19 of file sntp.h.

◆ ntp_port

#define ntp_port 123

Definition at line 57 of file sntp.h.

◆ SECS_PERDAY

#define SECS_PERDAY 86400UL

Definition at line 58 of file sntp.h.

◆ UTC_ADJ_HRS

#define UTC_ADJ_HRS 9

Definition at line 59 of file sntp.h.

Typedef Documentation

◆ datetime

typedef struct _datetime datetime

◆ ntpformat

typedef struct _ntpformat ntpformat

◆ s_char

typedef signed char s_char

Definition at line 22 of file sntp.h.

◆ tdist

typedef unsigned int tdist

Definition at line 24 of file sntp.h.

◆ tstamp

typedef unsigned long long tstamp

Definition at line 23 of file sntp.h.

Function Documentation

◆ calcdatetime()

void calcdatetime ( tstamp seconds )

Definition at line 316 of file sntp.c.

◆ changedatetime_to_seconds()

tstamp changedatetime_to_seconds ( void )

Definition at line 402 of file sntp.c.

◆ get_seconds_from_ntp_server()

void get_seconds_from_ntp_server | ( | uint8_t * | buf,
 |  | uint16_t | idx
 | ) |  |

Definition at line 74 of file sntp.c.

◆ SNTP_init()

void SNTP_init | ( | uint8_t | s,
 |  | uint8_t * | ntp_server,
 |  | uint8_t | tz,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 218 of file sntp.c.

◆ SNTP_run()

int8_t SNTP_run ( datetime * time )

Definition at line 250 of file sntp.c.


ioLibrary: Internet/TFTP Directory Reference

  • Internet
  • TFTP
TFTP Directory Reference
Directory dependency graph for TFTP:

Files

file | netutil.c [code]
file | netutil.h [code]
file | tftp.c [code]
TFTP Source File.
file | tftp.h [code]
TFTP Header File.


ioLibrary: Internet/TFTP/netutil.c File Reference

  • Internet
  • TFTP
Functions
netutil.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "netutil.h"
Include dependency graph for netutil.c:

Go to the source code of this file.

Functions

int8_t * | inet_ntoa (uint32_t addr)
int8_t * | inet_ntoa_pad (uint32_t addr)
uint32_t | inet_addr (uint8_t *addr)
uint16_t | swaps (uint16_t i)
uint32_t | swapl (uint32_t l)
uint16_t | htons (uint16_t hostshort)
uint32_t | htonl (uint32_t hostlong)
uint32_t | ntohs (uint16_t netshort)
uint32_t | ntohl (uint32_t netlong)

Function Documentation

◆ htonl()

uint32_t htonl ( uint32_t hostlong )

htonl function converts a unsigned long from host to TCP/IP network byte order (which is big-endian).

Parameters
hostlong The value to convert.
Returns
The value in TCP/IP network byte order.

Definition at line 115 of file netutil.c.

◆ htons()

uint16_t htons ( uint16_t hostshort )

htons function converts a unsigned short from host to TCP/IP network byte order (which is big-endian).

Parameters
hostshort The value to convert.
Returns
The value in TCP/IP network byte order.

Definition at line 99 of file netutil.c.

◆ inet_addr()

uint32_t inet_addr ( uint8_t * addr )

Converts a string containing an (Ipv4) Internet Protocol decimal dotted address into a 32bit address.

Parameters
addr Dotted Decimal Format string.
Returns
32bit address.

Definition at line 41 of file netutil.c.

◆ inet_ntoa()

int8_t* inet_ntoa ( uint32_t addr )

Convert a 32bit Address into a Dotted Decimal Format string.

Parameters
addr 32bit address.
Returns
Dotted Decimal Format string.

Definition at line 12 of file netutil.c.

◆ inet_ntoa_pad()

int8_t* inet_ntoa_pad ( uint32_t addr )

Convert a 32bit Address into a Dotted Decimal Format string. This is differ from inet_ntoa in fixed length.

Parameters
addr 32bit address.
Returns
Dotted Decimal Format string.

Definition at line 27 of file netutil.c.

◆ ntohl()

uint32_t ntohl ( uint32_t netlong )

converts a unsigned long from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).

Parameters
netlong The value to convert.
Returns
A 16-bit number in host byte order

Definition at line 148 of file netutil.c.

◆ ntohs()

uint32_t ntohs ( uint16_t netshort )

ntohs function converts a unsigned short from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).

Parameters
netshort The value to convert.
Returns
A 16-bit number in host byte order

Definition at line 132 of file netutil.c.

◆ swapl()

uint32_t swapl ( uint32_t l )

Swap the byte order of 32bit(long) wide variable.

Parameters
l 32bit value to convert
Returns
Swapped value

Definition at line 83 of file netutil.c.

◆ swaps()

uint16_t swaps ( uint16_t i )

Swap the byte order of 16bit(short) wide variable.

Parameters
i 16bit value to swap
Returns
Swapped value

Definition at line 69 of file netutil.c.


ioLibrary: Internet/TFTP/netutil.h File Reference

  • Internet
  • TFTP
Macros | Functions
netutil.h File Reference
#include <stdint.h>
Include dependency graph for netutil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SYSTEM_LITTLE_ENDIAN

Functions

int8_t * | inet_ntoa (uint32_t addr)
int8_t * | inet_ntoa_pad (uint32_t addr)
uint32_t | inet_addr (uint8_t *addr)
uint16_t | swaps (uint16_t i)
uint32_t | swapl (uint32_t l)
uint16_t | htons (uint16_t hostshort)
uint32_t | htonl (uint32_t hostlong)
uint32_t | ntohs (uint16_t netshort)
uint32_t | ntohl (uint32_t netlong)

Macro Definition Documentation

◆ SYSTEM_LITTLE_ENDIAN

#define SYSTEM_LITTLE_ENDIAN

Definition at line 7 of file netutil.h.

Function Documentation

◆ htonl()

uint32_t htonl ( uint32_t hostlong )

htonl function converts a unsigned long from host to TCP/IP network byte order (which is big-endian).

Parameters
hostlong The value to convert.
Returns
The value in TCP/IP network byte order.

Definition at line 115 of file netutil.c.

◆ htons()

uint16_t htons ( uint16_t hostshort )

htons function converts a unsigned short from host to TCP/IP network byte order (which is big-endian).

Parameters
hostshort The value to convert.
Returns
The value in TCP/IP network byte order.

Definition at line 99 of file netutil.c.

◆ inet_addr()

uint32_t inet_addr ( uint8_t * addr )

Converts a string containing an (Ipv4) Internet Protocol decimal dotted address into a 32bit address.

Parameters
addr Dotted Decimal Format string.
Returns
32bit address.

Definition at line 41 of file netutil.c.

◆ inet_ntoa()

int8_t* inet_ntoa ( uint32_t addr )

Convert a 32bit Address into a Dotted Decimal Format string.

Parameters
addr 32bit address.
Returns
Dotted Decimal Format string.

Definition at line 12 of file netutil.c.

◆ inet_ntoa_pad()

int8_t* inet_ntoa_pad ( uint32_t addr )

Convert a 32bit Address into a Dotted Decimal Format string. This is differ from inet_ntoa in fixed length.

Parameters
addr 32bit address.
Returns
Dotted Decimal Format string.

Definition at line 27 of file netutil.c.

◆ ntohl()

uint32_t ntohl ( uint32_t netlong )

converts a unsigned long from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).

Parameters
netlong The value to convert.
Returns
A 16-bit number in host byte order

Definition at line 148 of file netutil.c.

◆ ntohs()

uint32_t ntohs ( uint16_t netshort )

ntohs function converts a unsigned short from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).

Parameters
netshort The value to convert.
Returns
A 16-bit number in host byte order

Definition at line 132 of file netutil.c.

◆ swapl()

uint32_t swapl ( uint32_t l )

Swap the byte order of 32bit(long) wide variable.

Parameters
l 32bit value to convert
Returns
Swapped value

Definition at line 83 of file netutil.c.

◆ swaps()

uint16_t swaps ( uint16_t i )

Swap the byte order of 16bit(short) wide variable.

Parameters
i 16bit value to swap
Returns
Swapped value

Definition at line 69 of file netutil.c.


ioLibrary: Internet/TFTP/tftp.c File Reference

  • Internet
  • TFTP
Functions | Variables
tftp.c File Reference

TFTP Source File. More...

#include <string.h>
#include "tftp.h"
#include "socket.h"
#include "netutil.h"
Include dependency graph for tftp.c:

Go to the source code of this file.

Functions

void | save_data (uint8_t *data, uint32_t data_len, uint16_t block_number)
void | TFTP_init (uint8_t socket, uint8_t *buf)
void | TFTP_exit (void)
int | TFTP_run (void)
void | TFTP_read_request (uint32_t server_ip, uint8_t *filename)
void | tftp_timeout_handler (void)

Variables

uint8_t | g_progress_state = TFTP_PROGRESS
int | dbg_level = (INFO_DBG | ERROR_DBG | IPC_DBG)

Detailed Description

TFTP Source File.

Version
0.1.0
Author
Sang-sik Kim

Definition in file tftp.c.

Function Documentation

◆ save_data()

void save_data | ( | uint8_t * | data,
 |  | uint32_t | data_len,
 |  | uint16_t | block_number
 | ) |  |

◆ TFTP_exit()

void TFTP_exit ( void )

Definition at line 583 of file tftp.c.

◆ TFTP_init()

void TFTP_init | ( | uint8_t | socket,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 575 of file tftp.c.

◆ TFTP_read_request()

void TFTP_read_request | ( | uint32_t | server_ip,
 |  | uint8_t * | filename
 | ) |  |

Definition at line 645 of file tftp.c.

◆ TFTP_run()

int TFTP_run ( void )

Definition at line 593 of file tftp.c.

◆ tftp_timeout_handler()

void tftp_timeout_handler ( void )

Definition at line 656 of file tftp.c.

Variable Documentation

◆ dbg_level

int dbg_level = (INFO_DBG | ERROR_DBG | IPC_DBG)

Definition at line 52 of file tftp.c.

◆ g_progress_state

uint8_t g_progress_state = TFTP_PROGRESS

Definition at line 49 of file tftp.c.


ioLibrary: Internet/TFTP/tftp.h File Reference

  • Internet
  • TFTP
Data Structures | Macros | Typedefs | Functions | Variables
tftp.h File Reference

TFTP Header File. More...

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

Go to the source code of this file.

Data Structures

struct | tftp_data
struct | tftp_error
struct | tftp_option

Macros

#define | F_APP_TFTP
#define | __TFTP_DEBUG__
#define | F_STORAGE
#define | SOCK_TFTP 1
#define | INFO_DBG 0x01
#define | ERROR_DBG 0x02
#define | DEBUG_DBG 0x04
#define | IPC_DBG 0x08
#define | DBG_PRINT(level, format, args...)
#define | NORMAL_MODE 0
#define | TFTP_MODE 1
#define | TFTP_RRQ 1
#define | TFTP_WRQ 2
#define | TFTP_DATA 3
#define | TFTP_ACK 4
#define | TFTP_ERROR 5
#define | TFTP_OACK 6
#define | STATE_NONE 0
#define | STATE_RRQ 1
#define | STATE_WRQ 2
#define | STATE_DATA 3
#define | STATE_ACK 4
#define | STATE_OACK 5
#define | TRANS_ASCII "netascii"
#define | TRANS_BINARY "octet"
#define | TFTP_PROGRESS 0
#define | TFTP_FAIL 1
#define | TFTP_SUCCESS 2
#define | TFTP_SERVER_PORT 69
#define | TFTP_TEMP_PORT 51000
#define | TFTP_BLK_SIZE 512
#define | MAX_MTU_SIZE 1514
#define | FILE_NAME_SIZE 20

Typedefs

typedef struct tftp_data | TFTP_DATA_T
typedef struct tftp_error | TFTP_ERROR_T
typedef struct tftp_option | TFTP_OPTION

Functions

void | TFTP_init (uint8_t socket, uint8_t *buf)
void | TFTP_exit (void)
int | TFTP_run (void)
void | TFTP_read_request (uint32_t server_ip, uint8_t *filename)
void | tftp_timeout_handler (void)

Variables

int dbg_level

Detailed Description

TFTP Header File.

Version
0.1.0
Author
Sang-sik Kim

Definition in file tftp.h.

Macro Definition Documentation

◆ __TFTP_DEBUG__

#define __TFTP_DEBUG__

Definition at line 13 of file tftp.h.

◆ DBG_PRINT

#define DBG_PRINT | ( | level,
 |  | format,
 |  | args...
 | ) |
Value:
{ \
if(dbg_level & level) \
printf(format, ##args); \
}
dbg_level
int dbg_level
Definition: tftp.c:52

Definition at line 24 of file tftp.h.

◆ DEBUG_DBG

#define DEBUG_DBG 0x04

Definition at line 21 of file tftp.h.

◆ ERROR_DBG

#define ERROR_DBG 0x02

Definition at line 20 of file tftp.h.

◆ F_APP_TFTP

#define F_APP_TFTP

Definition at line 12 of file tftp.h.

◆ F_STORAGE

#define F_STORAGE

Definition at line 15 of file tftp.h.

◆ FILE_NAME_SIZE

#define FILE_NAME_SIZE 20

Definition at line 64 of file tftp.h.

◆ INFO_DBG

#define INFO_DBG 0x01

Definition at line 19 of file tftp.h.

◆ IPC_DBG

#define IPC_DBG 0x08

Definition at line 22 of file tftp.h.

◆ MAX_MTU_SIZE

#define MAX_MTU_SIZE 1514

Definition at line 63 of file tftp.h.

◆ NORMAL_MODE

#define NORMAL_MODE 0

Definition at line 29 of file tftp.h.

◆ SOCK_TFTP

#define SOCK_TFTP 1

Definition at line 17 of file tftp.h.

◆ STATE_ACK

#define STATE_ACK 4

Definition at line 47 of file tftp.h.

◆ STATE_DATA

#define STATE_DATA 3

Definition at line 46 of file tftp.h.

◆ STATE_NONE

#define STATE_NONE 0

Definition at line 43 of file tftp.h.

◆ STATE_OACK

#define STATE_OACK 5

Definition at line 48 of file tftp.h.

◆ STATE_RRQ

#define STATE_RRQ 1

Definition at line 44 of file tftp.h.

◆ STATE_WRQ

#define STATE_WRQ 2

Definition at line 45 of file tftp.h.

◆ TFTP_ACK

#define TFTP_ACK 4

Definition at line 38 of file tftp.h.

◆ TFTP_BLK_SIZE

#define TFTP_BLK_SIZE 512

Definition at line 62 of file tftp.h.

◆ TFTP_DATA

#define TFTP_DATA 3

Definition at line 37 of file tftp.h.

◆ TFTP_ERROR

#define TFTP_ERROR 5

Definition at line 39 of file tftp.h.

◆ TFTP_FAIL

#define TFTP_FAIL 1

Definition at line 56 of file tftp.h.

◆ TFTP_MODE

#define TFTP_MODE 1

Definition at line 30 of file tftp.h.

◆ TFTP_OACK

#define TFTP_OACK 6

Definition at line 40 of file tftp.h.

◆ TFTP_PROGRESS

#define TFTP_PROGRESS 0

Definition at line 55 of file tftp.h.

◆ TFTP_RRQ

#define TFTP_RRQ 1

Definition at line 35 of file tftp.h.

◆ TFTP_SERVER_PORT

#define TFTP_SERVER_PORT 69

Definition at line 60 of file tftp.h.

◆ TFTP_SUCCESS

#define TFTP_SUCCESS 2

Definition at line 57 of file tftp.h.

◆ TFTP_TEMP_PORT

#define TFTP_TEMP_PORT 51000

Definition at line 61 of file tftp.h.

◆ TFTP_WRQ

#define TFTP_WRQ 2

Definition at line 36 of file tftp.h.

◆ TRANS_ASCII

#define TRANS_ASCII "netascii"

Definition at line 51 of file tftp.h.

◆ TRANS_BINARY

#define TRANS_BINARY "octet"

Definition at line 52 of file tftp.h.

Typedef Documentation

◆ TFTP_DATA_T

typedef struct tftp_data TFTP_DATA_T

◆ TFTP_ERROR_T

typedef struct tftp_error TFTP_ERROR_T

◆ TFTP_OPTION

typedef struct tftp_option TFTP_OPTION

Function Documentation

◆ TFTP_exit()

void TFTP_exit ( void )

Definition at line 583 of file tftp.c.

◆ TFTP_init()

void TFTP_init | ( | uint8_t | socket,
 |  | uint8_t * | buf
 | ) |  |

Definition at line 575 of file tftp.c.

◆ TFTP_read_request()

void TFTP_read_request | ( | uint32_t | server_ip,
 |  | uint8_t * | filename
 | ) |  |

Definition at line 645 of file tftp.c.

◆ TFTP_run()

int TFTP_run ( void )

Definition at line 593 of file tftp.c.

◆ tftp_timeout_handler()

void tftp_timeout_handler ( void )

Definition at line 656 of file tftp.c.

Variable Documentation

◆ dbg_level

int dbg_level

Definition at line 52 of file tftp.c.


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- _ -

  • __SEOF : stdio_private.h
  • __SERR : stdio_private.h
  • __SPGM : stdio_private.h
  • __SRD : stdio_private.h
  • __SSTR : stdio_private.h
  • __SUNGET : stdio_private.h
  • __SWR : stdio_private.h
  • __TFTP_DEBUG__ : tftp.h
  • _FTP_DEBUG_ : ftpd.h
  • _HTTPSERVER_DEBUG_ : httpServer.h
  • _IMR_ : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • _LOOPBACK_DEBUG_ : loopback.h
  • _MAX_SS : ftpc.h , ftpd.h
  • _NOTUSED_STORAGE_ : httpServer.h
  • _RCR_ : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • _RTR_ : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • _SNMP_DEBUG_ : snmp.h
  • _W5100_IO_BASE_ : w5100.h
  • _W5100S_IO_BASE_ : w5100s.h
  • _W5200_SPI_READ_ : w5200.h
  • _W5200_SPI_WRITE_ : w5200.h
  • _W5300_IO_BASE_ : w5300.h
  • _W5500_IO_BASE_ : w5500.h
  • _W5500_SPI_FDM_OP_LEN1_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN2_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN4_ : w5500.c
  • _W5500_SPI_READ_ : w5500.h
  • _W5500_SPI_VDM_OP_ : w5500.c
  • _W5500_SPI_WRITE_ : w5500.h
  • _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_5500_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_FDM_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_VDM_ : wizchip_conf.h
  • _WIZCHIP_IO_RXBUF_ : w5100s.h , w5200.h , w5100.h
  • _WIZCHIP_IO_TXBUF_ : w5200.h , w5100.h , w5100s.h
  • _WIZCHIP_SN_BASE_ : w5100s.h , w5100.h , w5200.h , w5300.h
  • _WIZCHIP_SN_SIZE_ : w5200.h , w5100s.h , w5300.h , w5100.h
  • _WIZCHIP_SOCK_NUM_ : wizchip_conf.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- a -

  • ACCT_CMD : ftpd.h
  • ACTIVE_MODE : ftpc.h , ftpd.h
  • AGAIN : dns.c
  • allSubnetsLocal : dhcp.c
  • APPE_CMD : ftpd.h
  • arpCacheTimeout : dhcp.c
  • ASCII_TYPE : ftpd.h , ftpc.h
  • ATOI() : httpParser.c , httpParser.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- b -

  • BAD_VALUE : snmp.h
  • BMCR_AUTONEGO : w5100s.h
  • BMCR_COLTEST : w5100s.h
  • BMCR_DUP : w5100s.h
  • BMCR_ISOLATE : w5100s.h
  • BMCR_MLOOPBACK : w5100s.h
  • BMCR_PWDN : w5100s.h
  • BMCR_RESET : w5100s.h
  • BMCR_RSTNEGO : w5100s.h
  • BMCR_SPEED : w5100s.h
  • BMSR_AUTONEGO_COMPL : w5100s.h
  • BMSR_JAB_DETECT : w5100s.h
  • BMSR_LINK_STATUS : w5100s.h
  • BMSR_REMOTE_FAULT : w5100s.h
  • bootFileSize : dhcp.c
  • broadcastAddr : dhcp.c
  • bufchar() : MQTTPacket.c
  • BUFFER_OVERFLOW : MQTTClient.h
  • BUFPUB : httpParser.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- c -

  • calcdatetime() : sntp.c , sntp.h
  • changedatetime_to_seconds() : sntp.h , sntp.c
  • charge : license.txt
  • check_DHCP_leasedIP() : dhcp.c
  • check_DHCP_timeout() : dhcp.c
  • check_DNS_timeout() : dns.c
  • CHECK_SOCKDATA : socket.c
  • CHECK_SOCKINIT : socket.c
  • CHECK_SOCKMODE : socket.c
  • CHECK_SOCKNUM : socket.c
  • CHIPLCKR : w5100s.h
  • CHIPLOCK : w5100s.h
  • CHIPUNLOCK : w5100s.h
  • CLAIM : license.txt
  • CLASS_IN : dns.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
  • CODEFLASH : httpServer.h
  • Command : ftpc.c
  • CommandFirst : ftpc.h
  • CommandSecond : ftpc.h
  • COMMUNITY : snmp_custom.h
  • COMMUNITY_SIZE : snmp_custom.h
  • conditions : license.txt
  • CONNACK : MQTTPacket.h
  • CONNECT : MQTTPacket.h
  • connect() : socket.c , socket.h
  • connect_state_control : ftpd.c
  • connect_state_control_ftpc : ftpc.c
  • connect_state_data : ftpd.c
  • connect_state_data_ftpc : ftpc.c
  • ConnectNetwork() : mqtt_interface.c , mqtt_interface.h
  • CONTRACT : license.txt
  • cookieServer : dhcp.c
  • copy : license.txt
  • COPY_SEGMENT : snmp.h
  • Copyright() : license.txt
  • 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.h , wizchip_conf.c
  • ctlwizchip_type : wizchip_conf.h
  • CTRL_SOCK : ftpc.h , ftpd.h
  • current_day : ftpd.c
  • current_hour : ftpd.c
  • current_min : ftpd.c
  • current_month : ftpd.c
  • current_sec : ftpd.c
  • current_year : ftpd.c
  • currentUptime() : snmp.h , snmp.c
  • 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
  • CWD_CMD : ftpd.h
  • cycle() : MQTTClient.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- d -

  • data_buf : sntp.c
  • DATA_BUF_SIZE : loopback.h , httpServer.c
  • DATA_SOCK : ftpc.h , ftpd.h
  • DATAFLASH : httpServer.h
  • DATASOCK_IDLE : ftpd.h , ftpc.h
  • datasock_mode : ftpd.h
  • DATASOCK_READY : ftpc.h , ftpd.h
  • DATASOCK_START : ftpc.h , ftpd.h
  • datasock_state : ftpd.h
  • datetime : sntp.h
  • dbg_level : tftp.c , tftp.h
  • DBG_PRINT : tftp.h
  • DBGOUT : w5100s.h
  • DCHP_HOST_NAME : dhcp.h
  • DEBUG_DBG : tftp.h
  • default_ip_assign() : dhcp.c
  • default_ip_conflict() : dhcp.c
  • default_ip_update() : dhcp.c
  • default_mcu_reset() : httpServer.c
  • default_wdt_reset() : httpServer.c
  • DefaultClient : MQTTClient.h
  • defaultIPTTL : dhcp.c
  • DELE_CMD : ftpd.h
  • deliverMessage() : MQTTClient.c
  • DGAIN : dns.c
  • DHCP_ACK : dhcp.c
  • DHCP_allocated_dns : dhcp.c
  • DHCP_allocated_gw : dhcp.c
  • DHCP_allocated_ip : dhcp.c
  • DHCP_allocated_sn : dhcp.c
  • DHCP_BOOTREPLY : dhcp.c
  • DHCP_BOOTREQUEST : dhcp.c
  • DHCP_CHADDR : dhcp.c
  • DHCP_CLIENT_PORT : dhcp.h
  • DHCP_DECLINE : dhcp.c
  • DHCP_DISCOVER : dhcp.c
  • DHCP_FAILED : dhcp.h
  • DHCP_FLAGSBROADCAST : dhcp.c
  • DHCP_FLAGSUNICAST : dhcp.c
  • DHCP_HLENETHERNET : dhcp.c
  • DHCP_HOPS : dhcp.c
  • DHCP_HTYPE100MB : dhcp.c
  • DHCP_HTYPE10MB : dhcp.c
  • DHCP_INFORM : dhcp.c
  • DHCP_init() : dhcp.c , dhcp.h
  • dhcp_ip_assign : dhcp.c
  • DHCP_IP_ASSIGN : dhcp.h
  • DHCP_IP_CHANGED : dhcp.h
  • DHCP_IP_LEASED : dhcp.h
  • dhcp_lease_time : dhcp.c
  • dhcp_mode : wizchip_conf.h
  • DHCP_NAK : dhcp.c
  • DHCP_OFFER : dhcp.c
  • DHCP_RELEASE : dhcp.c
  • DHCP_REQUEST : dhcp.c
  • dhcp_retry_count : dhcp.c
  • DHCP_run() : dhcp.c , dhcp.h
  • DHCP_RUNNING : dhcp.h
  • DHCP_SECS : dhcp.c
  • DHCP_SERVER_PORT : dhcp.h
  • DHCP_SIP : dhcp.c
  • DHCP_SOCKET : dhcp.c
  • dhcp_state : dhcp.c
  • DHCP_stop() : dhcp.c , dhcp.h
  • DHCP_STOPPED : dhcp.h
  • dhcp_tick_1s : dhcp.c
  • dhcp_tick_next : dhcp.c
  • DHCP_time_handler() : dhcp.c , dhcp.h
  • DHCP_WAIT_TIME : dhcp.h
  • DHCP_XID : dhcp.c
  • dhcpClassIdentifier : dhcp.c
  • dhcpClientIdentifier : dhcp.c
  • dhcpIPaddrLeaseTime : dhcp.c
  • dhcpMaxMsgSize : dhcp.c
  • dhcpMessageType : dhcp.c
  • dhcpMsg : dhcp.c
  • dhcpOptionOverload : dhcp.c
  • dhcpParamRequest : dhcp.c
  • dhcpRequestedIPaddr : dhcp.c
  • dhcpServerIdentifier : dhcp.c
  • dhcpT1value : dhcp.c
  • dhcpT2value : dhcp.c
  • disconnect() : socket.h
  • DISCONNECT : MQTTPacket.h
  • disconnect() : socket.c
  • display_reg_webContent_list() : httpServer.c , httpServer.h
  • distribute : license.txt
  • DLLExport : MQTTPacket.h , MQTTConnect.h , MQTTUnsubscribe.h , MQTTClient.h , MQTTPublish.h , MQTTSubscribe.h
  • DLLImport : MQTTUnsubscribe.h , MQTTConnect.h , MQTTPacket.h , MQTTPublish.h , MQTTSubscribe.h , MQTTClient.h
  • dns : dhcp.c
  • dns_1s_tick : dns.c
  • dns_answer() : dns.c
  • DNS_init() : dns.h , dns.c
  • dns_makequery() : dns.c
  • DNS_MSG_ID : dns.h
  • DNS_MSGID : dns.c
  • dns_question() : dns.c
  • DNS_run() : dns.c , dns.h
  • DNS_SOCKET : dns.c
  • DNS_time_handler() : dns.c , dns.h
  • DNS_WAIT_TIME : dns.h
  • domainName : dhcp.c
  • dumpCode() : snmp.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- e -

  • endOption : dhcp.c
  • EPOCH : sntp.h
  • ERROR_DBG : tftp.h
  • errorIndex : snmp.c
  • errors : MQTTPacket.h
  • errorStatus : snmp.c
  • ethernetEncapsulation : dhcp.c
  • EXTENDED_CAPA : w5100s.h
  • extentionsPath : dhcp.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- f -

  • F_APP_FTP : ftpd.h
  • F_APP_FTPC : ftpc.h
  • F_APP_TFTP : tftp.h
  • f_dir : ftpc.h
  • f_get : ftpc.h
  • f_nocmd : ftpc.h
  • f_put : ftpc.h
  • F_STORAGE : tftp.h
  • FAILURE : MQTTClient.h
  • FEAT_CMD : ftpd.h
  • FILE_NAME_SIZE : tftp.h
  • FILENAME : ftpd.h
  • files() : license.txt
  • find_http_uri_type() : httpParser.c , httpParser.h
  • find_userReg_webContent() : httpServer.c , httpServer.h
  • findEntry() : snmp.c
  • FMTUR : w5300.h
  • FORMAT_ERROR : dns.c
  • FROM : license.txt
  • fsprintf() : ftpd.c
  • ftp : ftpd.c
  • ftp_cmd : ftpd.h
  • FTP_destip : ftpc.c
  • FTP_destport : ftpc.c
  • ftp_state : ftpd.h
  • ftp_type : ftpd.h
  • ftpc : ftpc.c
  • ftpc_datasock_mode : ftpc.h
  • ftpc_datasock_state : ftpc.h
  • ftpc_init() : ftpc.c , ftpc.h
  • ftpc_run() : ftpc.c , ftpc.h
  • ftpc_type : ftpc.h
  • ftpd_init() : ftpd.c , ftpd.h
  • ftpd_run() : ftpd.c , ftpd.h
  • ftplogin() : ftpd.h , ftpd.c
  • FTPS_LOGIN : ftpd.h
  • FTPS_NOT_LOGIN : ftpd.h
  • FUNC_ENTRY : StackTrace.h
  • FUNC_ENTRY_MAX : StackTrace.h
  • FUNC_ENTRY_MED : StackTrace.h
  • FUNC_ENTRY_NOLOG : StackTrace.h
  • FUNC_EXIT : StackTrace.h
  • FUNC_EXIT_MAX : StackTrace.h
  • FUNC_EXIT_MAX_RC : StackTrace.h
  • FUNC_EXIT_MED : StackTrace.h
  • FUNC_EXIT_MED_RC : StackTrace.h
  • FUNC_EXIT_NOLOG : StackTrace.h
  • FUNC_EXIT_RC : StackTrace.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- g -

  • g_progress_state : tftp.c
  • GAR : w5100.h , w5200.h , w5300.h , w5100s.h , w5500.h
  • gDataPutGetStart : ftpc.c
  • gDataSockReady : ftpc.c
  • get16() : dns.c
  • get_http_param_value() : httpParser.c , httpParser.h
  • get_http_uri_name() : httpParser.c , httpParser.h
  • get_httpServer_timecount() : httpServer.c , httpServer.h
  • GET_NEXT_REQUEST : snmp.h
  • GET_REQUEST : snmp.h
  • GET_RESPONSE : snmp.h
  • get_seconds_from_ntp_server() : sntp.c , sntp.h
  • getDHCPLeasetime() : dhcp.c , dhcp.h
  • getDNSfromDHCP() : dhcp.c , dhcp.h
  • getEntry() : snmp.c
  • getFMTUR : w5300.h
  • getGAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getGWfromDHCP() : dhcp.c , dhcp.h
  • getIDR : w5300.h
  • getIMR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getIMR2 : w5100s.h , w5200.h
  • getINTLEVEL : w5200.h , w5500.h
  • getIPfromDHCP() : dhcp.c , dhcp.h
  • getIR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getIR2 : w5100s.h , w5200.h
  • getLenStringLen() : MQTTPacket.c
  • getMR : w5100.h , w5100s.h , w5200.h , w5500.h
  • getMR2 : w5100s.h
  • getMTYPER : w5300.h
  • getNICMAXCOLR : w5100s.h
  • getOID() : snmp.c
  • getPATR : w5200.h , w5300.h , w5100.h , w5100s.h
  • getPDHAR : w5300.h
  • getPHAR : w5100s.h , w5500.h
  • getPHYACR : w5100s.h
  • getPHYAR : w5100s.h
  • getPHYCFGR : w5500.h
  • getPHYCR0 : w5100s.h
  • getPHYCR1 : w5100s.h
  • getPHYDIR : w5100s.h
  • getPHYDIVR : w5100s.h
  • getPHYDOR : w5100s.h
  • getPHYRAR : w5100s.h
  • getPHYSR : w5100s.h
  • getPHYSR1 : w5100s.h
  • getPHYSTATUS : w5200.h
  • getPINGIDR : w5100s.h
  • getPINGSEQR : w5100s.h
  • getPMAGIC : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getPMRU : w5500.h
  • getPMRUR : w5100s.h
  • getPn_BDPTHR : w5300.h
  • getPn_BRDYR : w5300.h
  • getPPPALGO : w5100.h , w5100s.h , w5200.h
  • getPSID : w5500.h
  • getPSIDR : w5100s.h , w5300.h
  • getPTIMER : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getRCR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getRMS01R : w5300.h
  • getRMS23R : w5300.h
  • getRMS45R : w5300.h
  • getRMS67R : w5300.h
  • getRMSR : w5100.h , w5100s.h , w5300.h
  • getRTR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSIMR : w5200.h , w5500.h
  • getSIPR : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • getSIR : w5200.h , w5500.h
  • getSLCR : w5100s.h
  • getSLIMR : w5100s.h
  • getSLIR : w5100s.h
  • getSLPHAR : w5100s.h
  • getSLPIPR : w5100s.h
  • getSLRCR : w5100s.h
  • getSLRTR : w5100s.h
  • getSn_CR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_DHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_DIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_DPORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_DPORTR : w5300.h
  • getSn_FRAG : w5100.h , w5200.h , w5300.h , w5500.h
  • getSn_FRAGR : w5300.h , w5100s.h
  • getSn_IMR : w5300.h , w5100s.h , w5200.h , w5500.h
  • getSn_IR : w5200.h , w5100.h , w5100s.h , w5300.h , w5500.h
  • getSn_KPALVTR : w5100s.h , w5300.h , w5500.h
  • getSn_MR : w5200.h , w5100.h , w5100s.h , w5300.h , w5500.h
  • getSn_MR2 : w5100s.h
  • getSn_MSSR : w5500.h , w5100.h , w5100s.h , w5200.h , w5300.h
  • getSn_PORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_PORTR : w5300.h
  • getSn_PROTO : w5100.h , w5200.h , w5300.h , w5100s.h
  • getSn_PROTOR : w5300.h
  • getSn_RCR : w5100s.h
  • getSn_RTR : w5100s.h
  • getSn_RX_FIFOR : w5300.h
  • getSn_RX_RD : w5100.h , w5200.h , w5500.h , w5100s.h
  • getSn_RX_RSR() : w5500.h , w5100.h , w5100s.c , w5100s.h , w5200.h , w5300.h
  • getSn_RX_WR : w5100.h , w5100s.h , w5200.h , w5500.h
  • getSn_RxBASE() : w5100s.c , w5100.h , w5100s.h , w5200.h
  • getSn_RXBUF_SIZE : w5200.h , w5100.h , w5100s.h , w5500.h , w5300.h
  • getSn_RxMASK : w5200.h , w5100.h , w5100s.h
  • getSn_RxMAX : w5300.h , w5100s.h , w5100.h , w5200.h , w5500.h
  • getSn_RXMEM_SIZE : w5200.h , w5100s.h , w5100.h
  • getSn_SR : w5300.h , w5200.h , w5100.h , w5100s.h , w5500.h
  • getSn_SSR : w5300.h
  • getSn_TOS : w5100s.h , w5300.h , w5100.h , w5200.h , w5500.h
  • getSn_TOSR : w5300.h
  • getSn_TSR : w5100s.h
  • getSn_TTL : w5300.h , w5500.h , w5100.h , w5100s.h , w5200.h
  • getSn_TTLR : w5300.h
  • getSn_TX_FSR() : w5100s.h , w5500.h , w5300.h , w5200.h , w5100.h , w5100s.c
  • getSn_TX_RD : w5100s.h , w5500.h , w5200.h , w5100.h
  • getSn_TX_WR : w5500.h , w5100s.h , w5100.h , w5200.h
  • getSn_TX_WRSR : w5300.h
  • getSn_TxBASE() : w5100s.c , w5100s.h , w5200.h , w5100.h
  • getSn_TXBUF_SIZE : w5300.h , w5100.h , w5100s.h , w5500.h , w5200.h
  • getSn_TxMASK : w5100.h , w5200.h , w5100s.h
  • getSn_TxMAX : w5300.h , w5200.h , w5100.h , w5500.h , w5100s.h
  • getSn_TXMEM_SIZE : w5100s.h , w5100.h , w5200.h
  • getSNfromDHCP() : dhcp.c , dhcp.h
  • getSNMPTimeTick() : snmp.c , snmp.h
  • getsockopt() : socket.h , socket.c
  • getSUBR : w5300.h , w5200.h , w5100.h , w5100s.h , w5500.h
  • getTCNTR : w5100s.h
  • getTMS01R : w5300.h
  • getTMS23R : w5300.h
  • getTMS45R : w5300.h
  • getTMS67R : w5300.h
  • getTMSR : w5100s.h , w5300.h
  • getUIPR : w5100s.h , w5300.h , w5500.h
  • getUPORTR : w5300.h , w5500.h , w5100s.h
  • getValue() : snmp.c
  • getVER : w5100s.h
  • getVERSIONR : w5200.h , w5500.h
  • gMenuStart : ftpc.c
  • gModeActivePassiveflag : ftpc.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- h -

  • HOST_NAME : dhcp.c
  • hostName : dhcp.c
  • HOSTNAME : ftpd.h
  • HTML_HEADER : httpParser.h
  • htonl() : netutil.c , netutil.h
  • HTONL : snmp.h
  • htons() : netutil.c , netutil.h
  • HTTP_FAILED : httpServer.h
  • http_get_cgi_handler() : httpUtil.c , httpUtil.h
  • HTTP_MAX_TIMEOUT_SEC : httpServer.h
  • HTTP_OK : httpServer.h
  • http_post_cgi_handler() : httpUtil.h , httpUtil.c
  • HTTP_RESET : httpServer.h
  • HTTP_SERVER_PORT : httpParser.h
  • httpServer_init() : httpServer.h , httpServer.c
  • HTTPServer_ReStart : httpServer.c
  • httpServer_run() : httpServer.h , httpServer.c
  • httpServer_Sockinit() : httpServer.c
  • httpServer_tick_1s : httpServer.c
  • httpServer_time_handler() : httpServer.h , httpServer.c
  • httpServer_webContent : httpServer.h
  • HTTPSock_Status : httpServer.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- i -

  • IDR : w5300.h
  • ifMTU : dhcp.c
  • IINCHIP_READ : w5100s.h , w5200.h , w5100.h , w5300.h , w5500.h
  • IINCHIP_READ_BUF : w5100.h , w5100s.h , w5200.h , w5500.h
  • IINCHIP_WRITE : w5500.h , w5100.h , w5100s.h , w5200.h , w5300.h
  • IINCHIP_WRITE_BUF : w5100.h , w5100s.h , w5200.h , w5500.h
  • 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
  • ILLEGAL_LENGTH : snmp.h
  • IM_IR4 : w5500.h
  • IM_IR5 : w5500.h
  • IM_IR6 : w5500.h
  • IM_IR7 : w5500.h
  • IMAGE_TYPE : ftpc.h , ftpd.h
  • IMPLIED : license.txt
  • impressServer : dhcp.c
  • IMR2 : w5100s.h , w5200.h
  • IMR2_MGC : w5100s.h
  • IMR_CONFLICT : w5100s.h
  • IMR_PPPoE : w5100s.h
  • IMR_SOCK : w5100s.h
  • IMR_UNREACH : w5100s.h
  • inet_addr() : netutil.c , netutil.h
  • inet_addr_() : httpParser.c , httpParser.h
  • inet_ntoa() : netutil.c , netutil.h
  • inet_ntoa_pad() : netutil.c , netutil.h
  • INFINITE_LEASETIME : dhcp.c
  • INFO_DBG : tftp.h
  • initial_Trap() : snmp_custom.c , snmp_custom.h
  • INITIAL_WEBPAGE : httpServer.h
  • INITRTT : dns.c
  • initTable() : snmp_custom.c , snmp_custom.h
  • insertRespLen() : snmp.c
  • INTLEVEL : w5200.h , w5500.h
  • intr_kind : wizchip_conf.h
  • INVALID_DATA_TYPE : snmp.h
  • INVALID_ENTRY_ID : snmp.h
  • iodata_t : wizchip_conf.h
  • IPC_DBG : tftp.h
  • IPforwarding : dhcp.c
  • IPPORT_DOMAIN : dns.h
  • IPPORT_FTP : ftpd.h
  • IPPORT_FTPD : ftpd.h
  • IPPROTO_GGP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_ICMP : w5500.h , w5100.h , w5100s.h , w5200.h , w5300.h
  • IPPROTO_IDP : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • IPPROTO_IGMP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_IP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_ND : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • IPPROTO_PUP : w5300.h , w5100s.h , w5100.h , w5500.h , w5200.h
  • IPPROTO_RAW : w5200.h , w5500.h , w5300.h , w5100s.h , w5100.h
  • IPPROTO_TCP : w5300.h , w5100s.h , w5100.h , w5200.h , w5500.h
  • IPPROTO_UDP : w5200.h , w5300.h , w5100.h , w5500.h , w5100s.h
  • ipToByteArray() : snmp.c
  • IQUERY : dns.c
  • IR : w5200.h , w5100s.h , w5100.h , w5300.h , w5500.h
  • IR2 : w5100s.h , w5200.h
  • IR2_MGC : w5100s.h
  • IR_CONFLICT : w5100.h , w5200.h , w5100s.h , w5500.h
  • IR_DPUR : w5300.h
  • IR_FMTU : w5300.h
  • IR_IPCF : w5300.h
  • IR_MP : w5500.h
  • IR_PPPoE : w5200.h , w5100s.h , w5100.h , w5500.h
  • IR_PPPT : w5300.h
  • IR_SnINT : w5300.h
  • IR_SOCK : w5100s.h , w5100.h
  • IR_UNREACH : w5500.h , w5100s.h , w5100.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- k -

  • keepalive() : MQTTClient.c
  • KIND : license.txt


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- l -

  • LAGAIN : dns.c
  • LDGAIN : dns.c
  • LIABILITY : license.txt
  • LINELEN : ftpc.h , ftpd.h
  • LIST_CMD : ftpd.h
  • listen() : socket.h , socket.c
  • local_ip : ftpc.c , ftpd.c
  • local_port : ftpc.c , ftpd.c
  • LOGICAL_TYPE : ftpd.h
  • logServer : dhcp.c
  • LOOPBACK_MAIN_NOBLOCK : loopback.h
  • LOOPBACK_MODE : loopback.h
  • loopback_tcpc() : loopback.h , loopback.c
  • loopback_tcps() : loopback.h , loopback.c
  • loopback_udps() : loopback.h , loopback.c
  • lprServer : dhcp.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- m -

  • M_INITIAL_WEBPAGE : httpServer.h
  • MAGIC_COOKIE : dhcp.h
  • make_http_response_head() : httpParser.h , httpParser.c
  • makeDHCPMSG() : dhcp.c
  • makeTrapVariableBindings() : snmp.c
  • maskSupplier : dhcp.c
  • MAX_CONTENT_CALLBACK : httpServer.h
  • MAX_CONTENT_NAME_LEN : httpServer.h
  • MAX_DHCP_RETRY : dhcp.h
  • MAX_DNS_BUF_SIZE : dns.h
  • MAX_DNS_RETRY : dns.h
  • MAX_DOMAIN_NAME : dns.h
  • MAX_MESSAGE_HANDLERS : MQTTClient.h
  • MAX_MTU_SIZE : tftp.h
  • MAX_NO_OF_REMAINING_LENGTH_BYTES : MQTTPacket.c
  • MAX_OID : snmp.h
  • MAX_PACKET_ID : MQTTClient.h
  • MAX_SNMPMSG_LEN : snmp.h
  • MAX_SNTP_BUF_SIZE : sntp.h
  • MAX_STRING : snmp.h
  • MAX_TRAPMSG_LEN : snmp.h
  • MAX_URI_SIZE : httpParser.h
  • MAXCNAME : dns.c
  • maxData : snmp_custom.c , snmp_custom.h
  • maxDgramReasmSize : dhcp.c
  • MERCHANTABILITY : license.txt
  • merge : license.txt
  • meritDumpFile : dhcp.c
  • MessageData : MQTTClient.h
  • messageHandler : MQTTClient.h
  • METHOD_ERR : httpParser.h
  • METHOD_GET : httpParser.h
  • METHOD_HEAD : httpParser.h
  • METHOD_POST : httpParser.h
  • mid() : httpParser.c , httpParser.h
  • MilliTimer : mqtt_interface.c
  • MilliTimer_Handler() : mqtt_interface.c , mqtt_interface.h
  • min : MQTTConnectServer.c , MQTTDeserializePublish.c
  • MKD_CMD : ftpd.h
  • MLSD_CMD : ftpd.h
  • MOBILE_INITIAL_WEBPAGE : httpServer.h
  • MODE_CMD : ftpd.h
  • modify : license.txt
  • MQTTClient : MQTTClient.h
  • MQTTClientInit() : MQTTClient.c , MQTTClient.h
  • MQTTConnect() : MQTTClient.c , MQTTClient.h
  • MQTTDeserialize_ack() : MQTTDeserializePublish.c , MQTTPacket.h
  • MQTTDeserialize_connack() : MQTTConnect.h , MQTTConnectClient.c
  • MQTTDeserialize_connect() : MQTTConnect.h , MQTTConnectServer.c
  • MQTTDeserialize_publish() : MQTTDeserializePublish.c , MQTTPublish.h
  • MQTTDeserialize_suback() : MQTTSubscribe.h , MQTTSubscribeClient.c
  • MQTTDeserialize_subscribe() : MQTTSubscribe.h , MQTTSubscribeServer.c
  • MQTTDeserialize_unsuback() : MQTTUnsubscribe.h , MQTTUnsubscribeClient.c
  • MQTTDeserialize_unsubscribe() : MQTTUnsubscribe.h , MQTTUnsubscribeServer.c
  • MQTTDisconnect() : MQTTClient.c , MQTTClient.h
  • MQTTFormat_toClientString() : MQTTFormat.c , MQTTFormat.h
  • MQTTFormat_toServerString() : MQTTFormat.c , MQTTFormat.h
  • MQTTMessage : MQTTClient.h
  • MQTTPACKET_BUFFER_TOO_SHORT : MQTTPacket.h
  • MQTTPacket_checkVersion() : MQTTConnectServer.c
  • MQTTPacket_connectData_initializer : MQTTConnect.h
  • MQTTPacket_decode() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_decodeBuf() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_encode() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_equals() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_getName() : MQTTFormat.c , MQTTFormat.h
  • MQTTPacket_len() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_names : MQTTFormat.c
  • MQTTPacket_read() : MQTTPacket.c , MQTTPacket.h
  • MQTTPACKET_READ_COMPLETE : MQTTPacket.h
  • MQTTPACKET_READ_ERROR : MQTTPacket.h
  • MQTTPacket_readnb() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_willOptions_initializer : MQTTConnect.h
  • MQTTPublish() : MQTTClient.c , MQTTClient.h
  • MQTTRun() : MQTTClient.c
  • MQTTSerialize_ack() : MQTTPacket.h , MQTTSerializePublish.c
  • MQTTSerialize_connack() : MQTTConnect.h , MQTTConnectServer.c
  • MQTTSerialize_connect() : MQTTConnect.h , MQTTConnectClient.c
  • MQTTSerialize_connectLength() : MQTTConnectClient.c
  • MQTTSerialize_disconnect() : MQTTConnectClient.c , MQTTConnect.h
  • MQTTSerialize_pingreq() : MQTTConnect.h , MQTTConnectClient.c
  • MQTTSerialize_puback() : MQTTPublish.h , MQTTSerializePublish.c
  • MQTTSerialize_pubcomp() : MQTTPublish.h , MQTTSerializePublish.c
  • MQTTSerialize_publish() : MQTTSerializePublish.c , MQTTPublish.h
  • MQTTSerialize_publishLength() : MQTTSerializePublish.c
  • MQTTSerialize_pubrel() : MQTTPublish.h , MQTTSerializePublish.c
  • MQTTSerialize_suback() : MQTTSubscribe.h , MQTTSubscribeServer.c
  • MQTTSerialize_subscribe() : MQTTSubscribe.h , MQTTSubscribeClient.c
  • MQTTSerialize_subscribeLength() : MQTTSubscribeClient.c
  • MQTTSerialize_unsuback() : MQTTUnsubscribe.h , MQTTUnsubscribeServer.c
  • MQTTSerialize_unsubscribe() : MQTTUnsubscribe.h , MQTTUnsubscribeClient.c
  • MQTTSerialize_unsubscribeLength() : MQTTUnsubscribeClient.c
  • MQTTSerialize_zero() : MQTTConnectClient.c
  • MQTTString_initializer : MQTTPacket.h
  • MQTTStringFormat_ack() : MQTTFormat.h , MQTTFormat.c
  • MQTTStringFormat_connack() : MQTTFormat.c , MQTTFormat.h
  • MQTTStringFormat_connect() : MQTTFormat.c , MQTTFormat.h
  • MQTTStringFormat_publish() : MQTTFormat.h , MQTTFormat.c
  • MQTTStringFormat_suback() : MQTTFormat.h , MQTTFormat.c
  • MQTTStringFormat_subscribe() : MQTTFormat.h , MQTTFormat.c
  • MQTTStringFormat_unsubscribe() : MQTTFormat.h , MQTTFormat.c
  • MQTTstrlen() : MQTTPacket.h , MQTTPacket.c
  • MQTTSubscribe() : MQTTClient.h , MQTTClient.c
  • MQTTUnsubscribe() : MQTTClient.h , MQTTClient.c
  • MQTTYield() : MQTTClient.h , MQTTClient.c
  • MR : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.h
  • MR2 : w5100s.h
  • MR2_CLKSEL : w5100s.h
  • MR2_G_IEN : w5100s.h
  • MR2_MNOSCHK : w5100s.h
  • MR2_NOTCPRST : w5100s.h
  • MR2_SSRCHA : w5100s.h
  • MR2_UDPFARP : w5100s.h
  • MR2_UDPURB : w5100s.h
  • MR2_WOL : w5100s.h
  • MR_AI : w5200.h , w5100.h , w5100s.h
  • MR_DBS : w5300.h
  • MR_DBW : w5300.h
  • MR_FARP : w5500.h
  • MR_FS : w5300.h
  • MR_IND : w5200.h , w5100s.h , w5300.h , w5100.h
  • MR_MPF : w5300.h
  • MR_MT : w5300.h
  • MR_PB : w5500.h , w5300.h , w5100s.h , w5200.h , w5100.h
  • MR_PPPOE : w5100.h , w5100s.h , w5500.h
  • MR_PPPoE : w5300.h
  • MR_PPPOE : w5200.h
  • MR_RDH : w5300.h
  • MR_RST : w5300.h , w5500.h , w5200.h , w5100.h , w5100s.h
  • MR_WDF : w5300.h
  • MR_WOL : w5500.h , w5200.h
  • msgTypes : MQTTPacket.h
  • MTYPER : w5300.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- n -

  • NAME_CMD : ftpd.h
  • NAME_ERROR : dns.c
  • nameServer : dhcp.c
  • Need_UARTGetCharBlocking_func : ftpc.h
  • netBIOSdgramDistServer : dhcp.c
  • netBIOSnameServer : dhcp.c
  • netBIOSnodeType : dhcp.c
  • netBIOSscope : dhcp.c
  • NETINFO_DHCP : wizchip_conf.h
  • NETINFO_STATIC : wizchip_conf.h
  • NETLCKR : w5100s.h
  • NETLOCK : w5100s.h
  • netmode_type : wizchip_conf.h
  • NETUNLOCK : w5100s.h
  • Network : mqtt_interface.h
  • NewNetwork() : mqtt_interface.c , mqtt_interface.h
  • NICMAXCOLR : w5100s.h
  • nisDomainName : dhcp.c
  • nisServers : dhcp.c
  • NLST_CMD : ftpd.h
  • NM_FORCEARP : wizchip_conf.h
  • NM_PINGBLOCK : wizchip_conf.h
  • NM_PPPOE : wizchip_conf.h
  • NM_WAKEONLAN : wizchip_conf.h
  • NO_CMD : ftpd.h
  • NO_ERROR : dns.c
  • NO_SUCH_NAME : snmp.h
  • NONE : httpServer.h
  • nonLocalSourceRouting : dhcp.c
  • NORMAL_MODE : tftp.h
  • NOSTACKTRACE : StackTrace.h
  • NOT_IMPL : dns.c
  • Nowdatetime : sntp.c
  • ntohl() : netutil.h , netutil.c
  • ntohs() : netutil.c , netutil.h
  • ntp_port : sntp.h
  • ntp_retry_cnt : sntp.c
  • NTP_SOCKET : sntp.c
  • NTPformat : sntp.c
  • ntpformat : sntp.h
  • ntpmessage : sntp.c
  • ntpServers : dhcp.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- o -

  • OID_NOT_FOUND : snmp.h
  • OLD_allocated_ip : dhcp.c
  • OPT_SIZE : dhcp.c
  • OTHERWISE : license.txt


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- p -

  • PACK_COMPLETED : socket.h
  • PACK_FIFOBYTE : socket.h
  • PACK_FIRST : socket.h
  • PACK_REMAINED : socket.h
  • packet_trap : snmp.c
  • padOption : dhcp.c
  • parse_http_request() : httpParser.h , httpParser.c
  • parse_name() : dns.c
  • parseCommunity() : snmp.c
  • parseDHCPMSG() : dhcp.c
  • parseDNSMSG() : dns.c
  • parseLength() : snmp.c
  • parseRequest() : snmp.c
  • parseSequence() : snmp.c
  • parseSequenceOf() : snmp.c
  • parseSNMPMessage() : snmp.c
  • parseTLV() : snmp.c
  • parseVarBind() : snmp.c
  • parseVersion() : snmp.c
  • PASS_CMD : ftpd.h
  • PASSIVE_MODE : ftpc.h , ftpd.h
  • PASV_CMD : ftpd.h
  • pathMTUagingTimeout : dhcp.c
  • pathMTUplateauTable : dhcp.c
  • PATR : w5100.h , w5200.h , w5300.h
  • PDHAR : w5300.h
  • pDHCPMSG : dhcp.c
  • pDNSMSG : dns.c
  • performMaskDiscovery : dhcp.c
  • performRouterDiscovery : dhcp.c
  • PHAR : w5100s.h , w5500.h
  • pHTTP_RX : httpServer.c
  • pHTTP_TX : httpServer.c
  • 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
  • PHYACR : w5100s.h
  • PHYACR_READ : w5100s.h
  • PHYACR_WRITE : w5100s.h
  • PHYAR : w5100s.h
  • PHYCFGR : w5500.h
  • PHYCFGR_DPX_FULL : w5500.h
  • PHYCFGR_DPX_HALF : w5500.h
  • PHYCFGR_LNK_OFF : w5500.h
  • PHYCFGR_LNK_ON : w5500.h
  • PHYCFGR_OPMD : w5500.h
  • PHYCFGR_OPMDC_100F : w5500.h
  • PHYCFGR_OPMDC_100FA : w5500.h
  • PHYCFGR_OPMDC_100H : w5500.h
  • PHYCFGR_OPMDC_10F : w5500.h
  • PHYCFGR_OPMDC_10H : w5500.h
  • PHYCFGR_OPMDC_ALLA : w5500.h
  • PHYCFGR_OPMDC_NA : w5500.h
  • PHYCFGR_OPMDC_PDOWN : w5500.h
  • PHYCFGR_RST : w5500.h
  • PHYCFGR_SPD_10 : w5500.h
  • PHYCFGR_SPD_100 : w5500.h
  • PHYCR0 : w5100s.h
  • PHYCR1 : w5100s.h
  • PHYCR1_PWDN_DISABLE : w5100s.h
  • PHYCR1_PWDN_ENABLE : w5100s.h
  • PHYCR1_RST : w5100s.h
  • PHYCR_AUTONEGO_DISABLE : w5100s.h
  • PHYCR_AUTONEGO_ENABLE : w5100s.h
  • PHYCR_FULL_DUP : w5100s.h
  • PHYCR_HALF_DUP : w5100s.h
  • PHYCR_SPD_10 : w5100s.h
  • PHYCR_SPD_100 : w5100s.h
  • PHYDIR : w5100s.h
  • PHYDIVR : w5100s.h
  • PHYDOR : w5100s.h
  • PHYLCKR : w5100s.h
  • PHYLOCK : w5100s.h
  • PHYMDIO_BMCR : w5100s.h
  • PHYMDIO_BMSR : w5100s.h
  • PHYRAR : w5100s.h
  • PHYSR : w5100s.h
  • PHYSR1 : w5100s.h
  • PHYSR1_CLDN : w5100s.h
  • PHYSR1_LPI : w5100s.h
  • PHYSR1_RXPG : w5100s.h
  • PHYSR_CABOFF : w5100s.h
  • PHYSR_DUP : w5100s.h
  • PHYSR_LNK : w5100s.h
  • PHYSR_MD0 : w5100s.h
  • PHYSR_MD1 : w5100s.h
  • PHYSR_MD2 : w5100s.h
  • PHYSR_SPD : w5100s.h
  • PHYSTATUS : w5200.h
  • PHYSTATUS_LINK : w5200.h
  • PHYSTATUS_POWERDOWN : w5200.h
  • PHYSTATUS_POWERSAVE : w5200.h
  • PHYUNLOCK : w5100s.h
  • PINGIDR : w5100s.h
  • PINGREQ : MQTTPacket.h
  • PINGRESP : MQTTPacket.h
  • PINGSEQR : w5100s.h
  • PMAGIC : w5100.h , w5100s.h , w5200.h , w5500.h
  • PMAGICR : w5300.h
  • PMRU : w5500.h
  • PMRUR : w5100s.h
  • Pn_BDPTHR : w5300.h
  • Pn_BRDYR : w5300.h
  • Pn_MT : w5300.h
  • Pn_PEN : w5300.h
  • Pn_PPL : w5300.h
  • Pn_SN : w5300.h
  • policyFilter : dhcp.c
  • PORT_CMD : ftpd.h
  • PORT_SNMP_AGENT : snmp.h
  • PORT_SNMP_TRAP : snmp.h
  • pport() : ftpd.c , ftpd.h
  • pportc() : ftpc.h , ftpc.c
  • PPPALGO : w5200.h
  • predefined_get_cgi_processor() : httpUtil.h
  • predefined_set_cgi_processor() : httpUtil.h
  • PRINTF_FLT : stdio_private.h
  • PRINTF_MIN : stdio_private.h
  • PRINTF_STD : stdio_private.h
  • proc_ftpc() : ftpc.c , ftpc.h
  • proc_ftpd() : ftpd.c , ftpd.h
  • PSID : w5500.h
  • PSIDR : w5300.h , w5100s.h
  • PTIMER : w5300.h , w5200.h , w5100.h , w5100s.h , w5500.h
  • PTYPE_CGI : httpParser.h
  • PTYPE_CSS : httpParser.h
  • PTYPE_EOT : httpParser.h
  • PTYPE_ERR : httpParser.h
  • PTYPE_FLASH : httpParser.h
  • PTYPE_GIF : httpParser.h
  • PTYPE_HTML : httpParser.h
  • PTYPE_ICO : httpParser.h
  • PTYPE_JPEG : httpParser.h
  • PTYPE_JS : httpParser.h
  • PTYPE_JSON : httpParser.h
  • PTYPE_MPEG : httpParser.h
  • PTYPE_OTF : httpParser.h
  • PTYPE_PDF : httpParser.h
  • PTYPE_PNG : httpParser.h
  • PTYPE_SVG : httpParser.h
  • PTYPE_TEXT : httpParser.h
  • PTYPE_TTF : httpParser.h
  • PTYPE_WOFF : httpParser.h
  • PTYPE_XML : httpParser.h
  • PUBACK : MQTTPacket.h
  • PUBCOMP : MQTTPacket.h
  • publish : license.txt
  • PUBLISH : MQTTPacket.h
  • PUBREC : MQTTPacket.h
  • PUBREL : MQTTPacket.h
  • put16() : dns.c
  • PWD_CMD : ftpd.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- q -

  • QoS : MQTTClient.h
  • QOS0 : MQTTClient.h
  • QOS1 : MQTTClient.h
  • QOS2 : MQTTClient.h
  • QUERY : dns.c
  • QUIT_CMD : ftpd.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- r -

  • R_150 : ftpc.h
  • R_200 : ftpc.h
  • R_220 : ftpc.h
  • R_226 : ftpc.h
  • R_227 : ftpc.h
  • R_230 : ftpc.h
  • R_331 : ftpc.h
  • read_userReg_webContent() : httpServer.c , httpServer.h
  • readChar() : MQTTPacket.c , MQTTPacket.h
  • readInt() : MQTTPacket.c , MQTTPacket.h
  • readMQTTLenString() : MQTTPacket.c , MQTTPacket.h
  • recv() : socket.c , socket.h
  • recvfile() : ftpd.h
  • recvfrom() : socket.c , socket.h
  • recvit() : ftpd.h
  • REFUSED : dns.c
  • reg_dhcp_cbfunc() : dhcp.c , dhcp.h
  • reg_httpServer_cbfunc() : httpServer.c , httpServer.h
  • reg_httpServer_webContent() : httpServer.c , httpServer.h
  • 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.c , wizchip_conf.h
  • remote_ip : ftpc.c , ftpd.c
  • remote_port : ftpc.c , ftpd.c
  • request_msg : snmp.c
  • RES_CGIHEAD_OK : httpParser.h
  • RES_CSSHEAD_OK : httpParser.h
  • RES_EOTHEAD_OK : httpParser.h
  • RES_FLASHHEAD_OK : httpParser.h
  • RES_GIFHEAD_OK : httpParser.h
  • RES_HTMLHEAD_OK : httpParser.h
  • RES_ICOHEAD_OK : httpParser.h
  • RES_JPEGHEAD_OK : httpParser.h
  • RES_JSHEAD_OK : httpParser.h
  • RES_JSONHEAD_OK : httpParser.h
  • RES_OTFHEAD_OK : httpParser.h
  • RES_PNGHEAD_OK : httpParser.h
  • RES_SVGHEAD_OK : httpParser.h
  • RES_TEXTHEAD_OK : httpParser.h
  • RES_TTFHEAD_OK : httpParser.h
  • RES_WOFFHEAD_OK : httpParser.h
  • RES_XMLHEAD_OK : httpParser.h
  • reset_DHCP_timeout() : dhcp.c
  • resourceLocationServer : dhcp.c
  • RESPONSE : dns.c
  • response_msg : snmp.c
  • restriction : license.txt
  • RETR_CMD : ftpd.h
  • returnCode : MQTTClient.h
  • RIP_MSG_SIZE : dhcp.c
  • RMD_CMD : ftpd.h
  • RMS01R : w5300.h
  • RMS23R : w5300.h
  • RMS45R : w5300.h
  • RMS67R : w5300.h
  • RMSR : w5100.h , w5100s.h
  • RMSR0 : w5300.h
  • RMSR1 : w5300.h
  • RMSR2 : w5300.h
  • RMSR3 : w5300.h
  • RMSR4 : w5300.h
  • RMSR5 : w5300.h
  • RMSR6 : w5300.h
  • RMSR7 : w5300.h
  • rootPath : dhcp.c
  • routerSolicitationAddr : dhcp.c
  • routersOnSubnet : dhcp.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- s -

  • s_char : sntp.h
  • s_dir : ftpc.h
  • s_get : ftpc.h
  • s_nocmd : ftpc.h
  • s_put : ftpc.h
  • save_data() : tftp.c
  • SCANF_FLT : stdio_private.h
  • SCANF_MIN : stdio_private.h
  • SCANF_STD : stdio_private.h
  • SDCARD : httpServer.h
  • SECS_PERDAY : sntp.h
  • send() : socket.h , socket.c
  • send_DHCP_DECLINE() : dhcp.c
  • send_DHCP_DISCOVER() : dhcp.c
  • send_DHCP_REQUEST() : dhcp.c
  • sendfile() : ftpd.h
  • sendit() : ftpd.h
  • sendto() : socket.c , socket.h
  • SERVER_FAIL : dns.c
  • SET_REQUEST : snmp.h
  • setDBGOUT : w5100s.h
  • setEntry() : snmp.c
  • setGAR : w5500.h , w5100.h , w5100s.h , w5200.h , w5300.h
  • setIMR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setIMR2 : w5100s.h , w5200.h
  • setINTLEVEL : w5200.h , w5500.h
  • setIR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setIR2 : w5100s.h , w5200.h
  • setMR : w5100.h , w5100s.h , w5200.h , w5500.h
  • setMR2 : w5100s.h
  • setMTYPER : w5300.h
  • setNICMAXCOLR : w5100s.h
  • setPHAR : w5100s.h , w5500.h
  • setPHYACR : w5100s.h
  • setPHYCFGR : w5500.h
  • setPHYCR0 : w5100s.h
  • setPHYCR1 : w5100s.h
  • setPHYDIR : w5100s.h
  • setPHYDIVR : w5100s.h
  • setPHYDOR : w5100s.h
  • setPHYRR : w5100s.h
  • setPINGIDR : w5100s.h
  • setPINGSEQR : w5100s.h
  • setPMAGIC : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setPMRU : w5500.h
  • setPMRUR : w5100s.h
  • setPn_BDPTHR : w5300.h
  • setPn_BRDYR : w5300.h
  • setPSID : w5500.h
  • setPSIDR : w5100s.h
  • setPTIMER : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setRCR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setRMS01R : w5300.h
  • setRMS23R : w5300.h
  • setRMS45R : w5300.h
  • setRMS67R : w5300.h
  • setRMSR : w5100.h , w5100s.h , w5300.h
  • setRTR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSIMR : w5200.h , w5500.h
  • setSIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSIR : w5200.h , w5500.h
  • setSLCR : w5100s.h
  • setSLIMR : w5100s.h
  • setSLIR : w5100s.h
  • setSLPHAR : w5100s.h
  • setSLPIPR : w5100s.h
  • setSLRCR : w5100s.h
  • setSLRTR : w5100s.h
  • setSn_CR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_DHAR : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • setSn_DIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_DPORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_DPORTR : w5300.h
  • setSn_FRAG : w5100.h , w5200.h , w5300.h , w5500.h
  • setSn_FRAGR : w5100s.h , w5300.h
  • setSn_IMR : w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_IR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_KPALVTR : w5100s.h , w5300.h , w5500.h
  • setSn_MR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_MR2 : w5100s.h
  • setSn_MSSR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_PORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_PORTR : w5300.h
  • setSn_PROTO : w5100.h , w5100s.h , w5200.h , w5300.h
  • setSn_PROTOR : w5300.h
  • setSn_RCR : w5100s.h
  • setSn_RTR : w5100s.h
  • setSn_RX_RD : w5100.h , w5100s.h , w5200.h , w5500.h
  • setSn_RX_WR : w5100.h , w5100s.h , w5200.h
  • setSn_RXBUF_SIZE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_RXMEM_SIZE : w5100.h , w5100s.h , w5200.h
  • setSn_TOS : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_TOSR : w5300.h
  • setSn_TTL : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_TTLR : w5300.h
  • setSn_TX_FIFOR : w5300.h
  • setSn_TX_WR : w5100.h , w5100s.h , w5200.h , w5500.h
  • setSn_TX_WRSR : w5300.h
  • setSn_TXBUF_SIZE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_TXMEM_SIZE : w5100.h , w5100s.h , w5200.h
  • setsockopt() : socket.c , socket.h
  • setSUBR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setTCNTCLKR : w5100s.h
  • setTMS01R : w5300.h
  • setTMS23R : w5300.h
  • setTMS45R : w5300.h
  • setTMS67R : w5300.h
  • setTMSR : w5100.h , w5100s.h , w5300.h
  • setUIPR : w5100s.h
  • setUPORTR : w5100s.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
  • SHAR : w5300.h , w5500.h , w5100.h , w5100s.h , w5200.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
  • SIMR : w5500.h
  • SIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • SIR : w5500.h
  • SIZE_CMD : ftpd.h
  • SLCMD_ARP : w5100s.h
  • SLCMD_PING : w5100s.h
  • SLCR : w5100s.h
  • SLIMR : w5100s.h
  • SLIR : w5100s.h
  • SLIR_ARP : w5100s.h
  • SLIR_PING : w5100s.h
  • SLIR_TIMEOUT : w5100s.h
  • SLPHAR : w5100s.h
  • SLPIPR : w5100s.h
  • SLRCR : w5100s.h
  • SLRTR : w5100s.h
  • Sn_CR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_CLOSE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_CONNECT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_DISCON : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_IGMP_JOIN : w5100s.h
  • Sn_CR_IGMP_LEAVE : w5100s.h
  • Sn_CR_LISTEN : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_OPEN : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_PCJ : w5100.h , w5200.h , w5300.h
  • Sn_CR_PCN : w5100.h , w5200.h , w5300.h
  • Sn_CR_PCON : w5100.h , w5200.h , w5300.h
  • Sn_CR_PCR : w5100.h , w5200.h , w5300.h
  • Sn_CR_PDISCON : w5100.h , w5200.h , w5300.h
  • Sn_CR_RECV : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_SEND : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_SEND_KEEP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_SEND_MAC : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DPORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DPORTR : w5300.h
  • Sn_FRAG : w5200.h , w5300.h , w5500.h
  • Sn_FRAGR : w5100s.h , w5300.h
  • Sn_IMR : w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_IR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_IR_CON : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_IR_DISCON : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_IR_PFAIL : w5100.h , w5200.h , w5300.h
  • Sn_IR_PNEXT : w5200.h , w5100.h , w5300.h
  • Sn_IR_PRECV : w5300.h , w5100.h , w5200.h
  • Sn_IR_RECV : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_IR_SENDOK : w5200.h , w5100.h , w5100s.h , w5300.h , w5500.h
  • Sn_IR_TIMEOUT : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • Sn_KPALVTR : w5100s.h , w5300.h , w5500.h
  • Sn_MR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_MR2 : w5100s.h
  • Sn_MR2_FPSH : w5100s.h
  • Sn_MR2_IPV6BLK : w5100s.h
  • Sn_MR2_MBBLK : w5100s.h
  • Sn_MR2_MMBLK : w5100s.h
  • Sn_MR2_UBBLK : w5100s.h
  • Sn_MR2_UUBLK : w5100s.h
  • Sn_MR_ALIGN : w5300.h
  • Sn_MR_BCASTB : w5500.h
  • Sn_MR_CLOSE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_IGMPv : w5300.h
  • Sn_MR_IPRAW : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_MACRAW : w5500.h , w5100.h , w5100s.h , w5200.h , w5300.h
  • Sn_MR_MC : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_MF : w5200.h , w5100.h , w5100s.h , w5300.h
  • Sn_MR_MFEN : w5200.h , w5100.h , w5100s.h , w5500.h
  • Sn_MR_MIP6B : w5500.h
  • Sn_MR_MMB : w5500.h
  • Sn_MR_MULTI : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_ND : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_MR_PPPoE : w5300.h , w5100.h , w5100s.h
  • Sn_MR_PPPOE : w5200.h
  • Sn_MR_TCP : w5200.h , w5100.h , w5100s.h , w5300.h , w5500.h
  • Sn_MR_UCASTB : w5500.h
  • Sn_MR_UDP : w5500.h , w5100.h , w5100s.h , w5200.h , w5300.h
  • Sn_MSSR : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_PORT : w5200.h , w5100.h , w5100s.h , w5300.h , w5500.h
  • Sn_PORTR : w5300.h
  • Sn_PROTO : w5100.h , w5100s.h , w5200.h
  • Sn_PROTOR : w5300.h
  • Sn_RCR : w5100s.h
  • Sn_RTR : w5100s.h
  • Sn_RX_FIFOR : w5300.h
  • Sn_RX_RD : w5100s.h , w5100.h , w5200.h , w5500.h
  • Sn_RX_RSR : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • Sn_RX_WR : w5100s.h , w5200.h , w5500.h , w5100.h
  • Sn_RXBUF_SIZE : w5500.h , w5100s.h
  • Sn_RXMEM_SIZE : w5200.h
  • Sn_SR : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.h
  • Sn_SSR : w5300.h
  • Sn_TOS : w5100.h , w5100s.h , w5500.h , w5300.h , w5200.h
  • Sn_TOSR : w5300.h
  • Sn_TTL : w5200.h , w5500.h , w5300.h , w5100.h , w5100s.h
  • Sn_TTLR : w5300.h
  • Sn_TX_FIFOR : w5300.h
  • Sn_TX_FSR : w5300.h , w5500.h , w5100.h , w5100s.h , w5200.h
  • Sn_TX_RD : w5100.h , w5200.h , w5500.h , w5100s.h
  • Sn_TX_WR : w5200.h , w5500.h , w5100s.h , w5100.h
  • Sn_TX_WRSR : w5300.h
  • Sn_TXBUF_SIZE : w5500.h , w5100s.h
  • Sn_TXMEM_SIZE : w5200.h
  • snmp_sendTrap() : snmp.c , snmp.h
  • SNMP_SUCCESS : snmp.h
  • snmp_tick_10ms : snmp.c
  • SNMP_time_handler() : snmp.c , snmp.h
  • SNMP_V1 : snmp.h
  • snmpd_init() : snmp.h , snmp.c
  • snmpd_run() : snmp.h , snmp.c
  • snmpData : snmp_custom.h , snmp_custom.c
  • SNMPDTYPE_COUNTER : snmp.h
  • SNMPDTYPE_GAUGE : snmp.h
  • SNMPDTYPE_INTEGER : snmp.h
  • SNMPDTYPE_NULL_ITEM : snmp.h
  • SNMPDTYPE_OBJ_ID : snmp.h
  • SNMPDTYPE_OCTET_STRING : snmp.h
  • SNMPDTYPE_OPAQUE : snmp.h
  • SNMPDTYPE_SEQUENCE : snmp.h
  • SNMPDTYPE_SEQUENCE_OF : snmp.h
  • SNMPDTYPE_TIME_TICKS : snmp.h
  • SNMPTRAP_AUTHENTICATION : snmp.h
  • SNMPTRAP_COLDSTART : snmp.h
  • SNMPTRAP_EGPNEIGHBORLOSS : snmp.h
  • SNMPTRAP_LINKDOWN : snmp.h
  • SNMPTRAP_LINKUP : snmp.h
  • SNMPTRAP_WARMSTART : snmp.h
  • SNTP_init() : sntp.h , sntp.c
  • SNTP_run() : sntp.h , sntp.c
  • so : license.txt
  • 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_ARP : w5300.h
  • SOCK_BUSY : socket.h
  • SOCK_CLOSE_WAIT : w5100.h , w5100s.h , w5200.h , w5500.h , w5300.h
  • SOCK_CLOSED : w5300.h , w5200.h , w5500.h , w5100.h , w5100s.h
  • SOCK_CLOSING : w5200.h , w5300.h , w5100.h , w5100s.h , w5500.h
  • SOCK_DGRAM : w5500.h , w5300.h
  • SOCK_ERROR : socket.h
  • SOCK_ESTABLISHED : w5200.h , w5100.h , w5100s.h , w5500.h , w5300.h
  • SOCK_FATAL : socket.h
  • SOCK_FIN_WAIT : w5100.h , w5500.h , w5200.h , w5100s.h , w5300.h
  • SOCK_INIT : w5300.h , w5100.h , w5200.h , w5500.h , w5100s.h
  • SOCK_IO_BLOCK : socket.h
  • SOCK_IO_NONBLOCK : socket.h
  • SOCK_IPRAW : w5200.h , w5300.h , w5100.h , w5500.h , w5100s.h
  • SOCK_LAST_ACK : w5300.h , w5100s.h , w5500.h , w5100.h , w5200.h
  • SOCK_LISTEN : w5200.h , w5300.h , w5100.h , w5500.h , w5100s.h
  • SOCK_MACRAW : w5100s.h , w5300.h , w5200.h , w5500.h , w5100.h
  • SOCK_OK : socket.h
  • sock_pack_info : socket.c
  • SOCK_PPPOE : w5200.h , w5100.h
  • SOCK_PPPoE : w5300.h
  • SOCK_PPPOE : w5100s.h
  • SOCK_STREAM : w5300.h , w5500.h
  • SOCK_SYNRECV : w5300.h , w5500.h , w5100.h , w5100s.h , w5200.h
  • SOCK_SYNSENT : w5100s.h , w5100.h , w5200.h , w5500.h , w5300.h
  • SOCK_TFTP : tftp.h
  • SOCK_TIME_WAIT : w5100.h , w5100s.h , w5300.h , w5500.h , w5200.h
  • SOCK_UDP : w5200.h , w5300.h , w5100.h , w5100s.h , w5500.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
  • SOCKET : socket.h
  • socket() : socket.c
  • SOCKFATAL_PACKLEN : socket.h
  • sockint_kind : socket.h
  • sockopt_type : socket.h
  • Software : license.txt
  • st_http_request : httpParser.h
  • st_http_socket : httpServer.h
  • STATE_ACK : tftp.h
  • STATE_DATA : tftp.h
  • STATE_DHCP_DISCOVER : dhcp.c
  • STATE_DHCP_INIT : dhcp.c
  • STATE_DHCP_LEASED : dhcp.c
  • STATE_DHCP_RELEASE : dhcp.c
  • STATE_DHCP_REQUEST : dhcp.c
  • STATE_DHCP_REREQUEST : dhcp.c
  • STATE_DHCP_STOP : dhcp.c
  • STATE_HTTP_IDLE : httpServer.h
  • STATE_HTTP_REQ_DONE : httpServer.h
  • STATE_HTTP_REQ_INPROC : httpServer.h
  • STATE_HTTP_RES_DONE : httpServer.h
  • STATE_HTTP_RES_INPROC : httpServer.h
  • STATE_NONE : tftp.h
  • STATE_OACK : tftp.h
  • STATE_RRQ : tftp.h
  • STATE_WRQ : tftp.h
  • staticRoute : dhcp.c
  • STATUS_ACCEPTED : httpParser.h
  • STATUS_BAD_GATEWAY : httpParser.h
  • STATUS_BAD_REQ : httpParser.h
  • STATUS_CREATED : httpParser.h
  • STATUS_FORBIDDEN : httpParser.h
  • STATUS_INT_SERR : httpParser.h
  • STATUS_MV_PERM : httpParser.h
  • STATUS_MV_TEMP : httpParser.h
  • STATUS_NO_CONTENT : httpParser.h
  • STATUS_NOT_FOUND : httpParser.h
  • STATUS_NOT_IMPL : httpParser.h
  • STATUS_NOT_MODIF : httpParser.h
  • STATUS_OK : httpParser.h
  • STATUS_SERV_UNAVAIL : httpParser.h
  • STATUS_UNAUTH : httpParser.h
  • STOR_CMD : ftpd.h
  • StorageType : httpServer.h
  • STRU_CMD : ftpd.h
  • SUBACK : MQTTPacket.h
  • sublicense : license.txt
  • subnetMask : dhcp.c
  • SUBR : w5300.h , w5100s.h , w5500.h , w5100.h , w5200.h
  • SUBSCRIBE : MQTTPacket.h
  • SUCCESSS : MQTTClient.h
  • swapl() : netutil.c , netutil.h
  • swaps() : netutil.h , netutil.c
  • swapServer : dhcp.c
  • SYST_CMD : ftpd.h
  • SYSTEM_LITTLE_ENDIAN : netutil.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- t -

  • TABLE_FULL : snmp.h
  • TCNTCLKR : w5100s.h
  • TCNTR : w5100s.h
  • tcpDefaultTTL : dhcp.c
  • tcpKeepaliveGarbage : dhcp.c
  • tcpKeepaliveInterval : dhcp.c
  • tdist : sntp.h
  • TFTP_ACK : tftp.h
  • TFTP_BLK_SIZE : tftp.h
  • TFTP_DATA : tftp.h
  • TFTP_DATA_T : tftp.h
  • TFTP_ERROR : tftp.h
  • TFTP_ERROR_T : tftp.h
  • TFTP_exit() : tftp.c , tftp.h
  • TFTP_FAIL : tftp.h
  • TFTP_init() : tftp.c , tftp.h
  • TFTP_MODE : tftp.h
  • TFTP_OACK : tftp.h
  • TFTP_OPTION : tftp.h
  • TFTP_PROGRESS : tftp.h
  • TFTP_read_request() : tftp.c , tftp.h
  • TFTP_RRQ : tftp.h
  • TFTP_run() : tftp.c , tftp.h
  • TFTP_SERVER_PORT : tftp.h
  • TFTP_SUCCESS : tftp.h
  • TFTP_TEMP_PORT : tftp.h
  • tftp_timeout_handler() : tftp.h , tftp.c
  • TFTP_WRQ : tftp.h
  • time_zone : sntp.c
  • Timer : mqtt_interface.h
  • TimerCountdown() : mqtt_interface.c , mqtt_interface.h , MQTTClient.h
  • TimerCountdownMS() : mqtt_interface.c , mqtt_interface.h , MQTTClient.h
  • TimerInit() : mqtt_interface.c , mqtt_interface.h , MQTTClient.h
  • TimerIsExpired() : mqtt_interface.c , mqtt_interface.h , MQTTClient.h
  • TimerLeftMS() : mqtt_interface.c , mqtt_interface.h , MQTTClient.h
  • timerOffset : dhcp.c
  • timeServer : dhcp.c
  • TMS01R : w5300.h
  • TMS23R : w5300.h
  • TMS45R : w5300.h
  • TMS67R : w5300.h
  • TMSR : w5100.h , w5100s.h
  • TMSR0 : w5300.h
  • TMSR1 : w5300.h
  • TMSR2 : w5300.h
  • TMSR3 : w5300.h
  • TMSR4 : w5300.h
  • TMSR5 : w5300.h
  • TMSR6 : w5300.h
  • TMSR7 : w5300.h
  • trailerEncapsulation : dhcp.c
  • TRANS_ASCII : tftp.h
  • TRANS_BINARY : tftp.h
  • TransferAscii : ftpc.h
  • TransferBinary : ftpc.h
  • tstamp : sntp.h
  • TYPE_A : dns.c
  • TYPE_ANY : dns.c
  • TYPE_CMD : ftpd.h
  • TYPE_CNAME : dns.c
  • TYPE_HINFO : dns.c
  • TYPE_MB : dns.c
  • TYPE_MD : dns.c
  • TYPE_MF : dns.c
  • TYPE_MG : dns.c
  • TYPE_MINFO : dns.c
  • TYPE_MR : dns.c
  • TYPE_MX : dns.c
  • TYPE_NS : dns.c
  • TYPE_NULL : dns.c
  • TYPE_PTR : dns.c
  • TYPE_SOA : dns.c
  • TYPE_TXT : dns.c
  • TYPE_WKS : dns.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- u -

  • UIPR : w5100s.h , w5300.h , w5500.h
  • UIPR0 : w5100.h
  • un_l2cval : ftpc.h , ftpd.h
  • unescape_http_url() : httpParser.h , httpParser.c
  • UNSUBACK : MQTTPacket.h
  • UNSUBSCRIBE : MQTTPacket.h
  • UPORT0 : w5100.h
  • UPORTR : w5300.h , w5100s.h , w5500.h
  • use : license.txt
  • USER_CMD : ftpd.h
  • User_Keyboard_MSG() : ftpc.h , ftpc.c
  • UTC_ADJ_HRS : sntp.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- v -

  • VALID_REQUEST : snmp.h
  • vendorSpecificInfo : dhcp.c
  • VERR : w5100s.h
  • VERSION : ftpd.h
  • VERSIONR : w5500.h , w5300.h , w5200.h


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- w -

  • W5100 : wizchip_conf.h
  • W5100S : wizchip_conf.h
  • W5200 : wizchip_conf.h
  • W5300 : wizchip_conf.h
  • W5500 : wizchip_conf.h
  • w5x00_disconnect() : mqtt_interface.c , mqtt_interface.h
  • w5x00_read() : mqtt_interface.c , mqtt_interface.h
  • w5x00_write() : mqtt_interface.c , mqtt_interface.h
  • waitfor() : MQTTClient.c
  • web_content : httpServer.c
  • wiz_delay_ms() : w5100s.c , w5100s.h
  • wiz_mdio_read() : w5100s.c , w5100s.h
  • wiz_mdio_write() : w5100s.c , w5100s.h
  • wiz_NetInfo : wizchip_conf.h
  • wiz_NetTimeout : wizchip_conf.h
  • wiz_PhyConf : wizchip_conf.h
  • wiz_recv_data() : w5100.h , w5100s.c , w5100s.h , w5200.h , w5300.h , w5500.h
  • wiz_recv_ignore() : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.c , w5100s.h
  • wiz_send_data() : w5100.h , w5100s.c , w5100s.h , w5200.h , w5300.h , w5500.h
  • WIZCHIP : wizchip_conf.c , wizchip_conf.h
  • wizchip_bus_readdata() : wizchip_conf.c
  • wizchip_bus_writedata() : wizchip_conf.c
  • wizchip_clrinterrupt() : wizchip_conf.c , wizchip_conf.h
  • WIZCHIP_CREG_BLOCK : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • wizchip_cris_enter() : wizchip_conf.c
  • wizchip_cris_exit() : wizchip_conf.c
  • WIZCHIP_CRITICAL_ENTER : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • WIZCHIP_CRITICAL_EXIT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • 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_OFFSET_INC : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • WIZCHIP_READ() : w5100.h , w5100s.c , w5100s.h , w5200.h , w5500.h , w5300.h
  • WIZCHIP_READ_BUF() : w5100.h , w5100s.c , w5200.h , w5500.h , w5100s.h
  • WIZCHIP_RXBUF_BLOCK : w5500.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_SREG_BLOCK : w5200.h , w5500.h , w5100.h , w5100s.h , w5300.h
  • wizchip_sw_reset() : wizchip_conf.c , wizchip_conf.h
  • WIZCHIP_TXBUF_BLOCK : w5500.h
  • WIZCHIP_WRITE() : w5300.h , w5100.h , w5200.h , w5100s.h , w5100s.c , w5500.h
  • WIZCHIP_WRITE_BUF() : w5100s.c , w5500.h , w5200.h , w5100s.h , w5100.h
  • wizphy_getphyconf() : wizchip_conf.c , wizchip_conf.h
  • wizphy_getphylink() : wizchip_conf.h , wizchip_conf.c
  • wizphy_getphypmode() : wizchip_conf.h , wizchip_conf.c
  • wizphy_getphystat() : wizchip_conf.h , wizchip_conf.c
  • wizphy_reset() : wizchip_conf.c , wizchip_conf.h
  • wizphy_setphyconf() : wizchip_conf.c , wizchip_conf.h
  • wizphy_setphypmode() : wizchip_conf.h , wizchip_conf.c
  • writeChar() : MQTTPacket.h , MQTTPacket.c
  • writeCString() : MQTTPacket.h , MQTTPacket.c
  • writeInt() : MQTTPacket.h , MQTTPacket.c
  • writeMQTTString() : MQTTPacket.h , MQTTPacket.c


ioLibrary: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- x -

  • XCWD_CMD : ftpd.h
  • xDisplayManager : dhcp.c
  • xFontServer : dhcp.c
  • XMD5_CMD : ftpd.h
  • XMKD_CMD : ftpd.h
  • XPWD_CMD : ftpd.h
  • XRMD_CMD : ftpd.h


ioLibrary: Globals

- a -

  • ATOI() : httpParser.c , httpParser.h


ioLibrary: Globals

- b -

  • bufchar() : MQTTPacket.c


ioLibrary: Globals

- c -

  • calcdatetime() : sntp.c , sntp.h
  • changedatetime_to_seconds() : sntp.h , sntp.c
  • check_DHCP_leasedIP() : dhcp.c
  • check_DHCP_timeout() : dhcp.c
  • check_DNS_timeout() : dns.c
  • close() : socket.c , socket.h
  • connect() : socket.c , socket.h
  • ConnectNetwork() : mqtt_interface.c , mqtt_interface.h
  • Copyright() : license.txt
  • ctlnetwork() : wizchip_conf.h , wizchip_conf.c
  • ctlsocket() : socket.h , socket.c
  • ctlwizchip() : wizchip_conf.c , wizchip_conf.h
  • currentUptime() : snmp.c , snmp.h
  • cycle() : MQTTClient.c


ioLibrary: Globals

- d -

  • default_ip_assign() : dhcp.c
  • default_ip_conflict() : dhcp.c
  • default_ip_update() : dhcp.c
  • default_mcu_reset() : httpServer.c
  • default_wdt_reset() : httpServer.c
  • deliverMessage() : MQTTClient.c
  • DHCP_init() : dhcp.h , dhcp.c
  • DHCP_run() : dhcp.c , dhcp.h
  • DHCP_stop() : dhcp.c , dhcp.h
  • DHCP_time_handler() : dhcp.c , dhcp.h
  • disconnect() : socket.h , socket.c
  • display_reg_webContent_list() : httpServer.c , httpServer.h
  • dns_answer() : dns.c
  • DNS_init() : dns.h , dns.c
  • dns_makequery() : dns.c
  • dns_question() : dns.c
  • DNS_run() : dns.h , dns.c
  • DNS_time_handler() : dns.h , dns.c
  • dumpCode() : snmp.c


ioLibrary: Globals

- f -

  • files() : license.txt
  • find_http_uri_type() : httpParser.c , httpParser.h
  • find_userReg_webContent() : httpServer.c , httpServer.h
  • findEntry() : snmp.c
  • fsprintf() : ftpd.c
  • ftpc_init() : ftpc.c , ftpc.h
  • ftpc_run() : ftpc.h , ftpc.c
  • ftpd_init() : ftpd.h , ftpd.c
  • ftpd_run() : ftpd.c , ftpd.h
  • ftplogin() : ftpd.c , ftpd.h


ioLibrary: Globals

- g -

  • get16() : dns.c
  • get_http_param_value() : httpParser.c , httpParser.h
  • get_http_uri_name() : httpParser.c , httpParser.h
  • get_httpServer_timecount() : httpServer.c , httpServer.h
  • get_seconds_from_ntp_server() : sntp.c , sntp.h
  • getDHCPLeasetime() : dhcp.c , dhcp.h
  • getDNSfromDHCP() : dhcp.c , dhcp.h
  • getEntry() : snmp.c
  • getGWfromDHCP() : dhcp.h , dhcp.c
  • getIPfromDHCP() : dhcp.c , dhcp.h
  • getLenStringLen() : MQTTPacket.c
  • getOID() : snmp.c
  • getRMSR() : w5300.h
  • getSn_RX_RSR() : w5100.h , w5100s.c , w5500.h , w5100s.h , w5200.h , w5300.h
  • getSn_RxBASE() : w5200.h , w5100.h , w5100s.c , w5100s.h
  • getSn_TX_FSR() : w5100.h , w5100s.c , w5100s.h , w5300.h , w5500.h , w5200.h
  • getSn_TxBASE() : w5100s.h , w5100.h , w5100s.c , w5200.h
  • getSNfromDHCP() : dhcp.h , dhcp.c
  • getSNMPTimeTick() : snmp.h , snmp.c
  • getsockopt() : socket.c , socket.h
  • getTMSR() : w5300.h
  • getValue() : snmp.c


ioLibrary: Globals

- h -

  • htonl() : netutil.c , netutil.h
  • htons() : netutil.h , netutil.c
  • http_get_cgi_handler() : httpUtil.c , httpUtil.h
  • http_post_cgi_handler() : httpUtil.h , httpUtil.c
  • httpServer_init() : httpServer.c , httpServer.h
  • httpServer_run() : httpServer.c , httpServer.h
  • httpServer_Sockinit() : httpServer.c
  • httpServer_time_handler() : httpServer.h , httpServer.c


ioLibrary: Globals

- i -

  • inet_addr() : netutil.c , netutil.h
  • inet_addr_() : httpParser.h , httpParser.c
  • inet_ntoa() : netutil.c , netutil.h
  • inet_ntoa_pad() : netutil.h , netutil.c
  • initial_Trap() : snmp_custom.c , snmp_custom.h
  • initTable() : snmp_custom.c , snmp_custom.h
  • insertRespLen() : snmp.c
  • ipToByteArray() : snmp.c


ioLibrary: Globals

- k -

  • keepalive() : MQTTClient.c


ioLibrary: Globals

- l -

  • listen() : socket.c , socket.h
  • loopback_tcpc() : loopback.h , loopback.c
  • loopback_tcps() : loopback.c , loopback.h
  • loopback_udps() : loopback.h , loopback.c


ioLibrary: Globals

- m -

  • make_http_response_head() : httpParser.c , httpParser.h
  • makeDHCPMSG() : dhcp.c
  • makeTrapVariableBindings() : snmp.c
  • mid() : httpParser.c , httpParser.h
  • MilliTimer_Handler() : mqtt_interface.h , mqtt_interface.c
  • MQTTClientInit() : MQTTClient.c , MQTTClient.h
  • MQTTConnect() : MQTTClient.c , MQTTClient.h
  • MQTTDeserialize_ack() : MQTTDeserializePublish.c , MQTTPacket.h
  • MQTTDeserialize_connack() : MQTTConnectClient.c , MQTTConnect.h
  • MQTTDeserialize_connect() : MQTTConnect.h , MQTTConnectServer.c
  • MQTTDeserialize_publish() : MQTTDeserializePublish.c , MQTTPublish.h
  • MQTTDeserialize_suback() : MQTTSubscribe.h , MQTTSubscribeClient.c
  • MQTTDeserialize_subscribe() : MQTTSubscribe.h , MQTTSubscribeServer.c
  • MQTTDeserialize_unsuback() : MQTTUnsubscribe.h , MQTTUnsubscribeClient.c
  • MQTTDeserialize_unsubscribe() : MQTTUnsubscribe.h , MQTTUnsubscribeServer.c
  • MQTTDisconnect() : MQTTClient.c , MQTTClient.h
  • MQTTFormat_toClientString() : MQTTFormat.h , MQTTFormat.c
  • MQTTFormat_toServerString() : MQTTFormat.c , MQTTFormat.h
  • MQTTPacket_checkVersion() : MQTTConnectServer.c
  • MQTTPacket_decode() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_decodeBuf() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_encode() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_equals() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_getName() : MQTTFormat.c , MQTTFormat.h
  • MQTTPacket_len() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_read() : MQTTPacket.c , MQTTPacket.h
  • MQTTPacket_readnb() : MQTTPacket.c , MQTTPacket.h
  • MQTTPublish() : MQTTClient.c , MQTTClient.h
  • MQTTRun() : MQTTClient.c
  • MQTTSerialize_ack() : MQTTPacket.h , MQTTSerializePublish.c
  • MQTTSerialize_connack() : MQTTConnect.h , MQTTConnectServer.c
  • MQTTSerialize_connect() : MQTTConnect.h , MQTTConnectClient.c
  • MQTTSerialize_connectLength() : MQTTConnectClient.c
  • MQTTSerialize_disconnect() : MQTTConnectClient.c , MQTTConnect.h
  • MQTTSerialize_pingreq() : MQTTConnect.h , MQTTConnectClient.c
  • MQTTSerialize_puback() : MQTTPublish.h , MQTTSerializePublish.c
  • MQTTSerialize_pubcomp() : MQTTPublish.h , MQTTSerializePublish.c
  • MQTTSerialize_publish() : MQTTPublish.h , MQTTSerializePublish.c
  • MQTTSerialize_publishLength() : MQTTSerializePublish.c
  • MQTTSerialize_pubrel() : MQTTPublish.h , MQTTSerializePublish.c
  • MQTTSerialize_suback() : MQTTSubscribeServer.c , MQTTSubscribe.h
  • MQTTSerialize_subscribe() : MQTTSubscribeClient.c , MQTTSubscribe.h
  • MQTTSerialize_subscribeLength() : MQTTSubscribeClient.c
  • MQTTSerialize_unsuback() : MQTTUnsubscribeServer.c , MQTTUnsubscribe.h
  • MQTTSerialize_unsubscribe() : MQTTUnsubscribe.h , MQTTUnsubscribeClient.c
  • MQTTSerialize_unsubscribeLength() : MQTTUnsubscribeClient.c
  • MQTTSerialize_zero() : MQTTConnectClient.c
  • MQTTStringFormat_ack() : MQTTFormat.c , MQTTFormat.h
  • MQTTStringFormat_connack() : MQTTFormat.h , MQTTFormat.c
  • MQTTStringFormat_connect() : MQTTFormat.h , MQTTFormat.c
  • MQTTStringFormat_publish() : MQTTFormat.c , MQTTFormat.h
  • MQTTStringFormat_suback() : MQTTFormat.c , MQTTFormat.h
  • MQTTStringFormat_subscribe() : MQTTFormat.h , MQTTFormat.c
  • MQTTStringFormat_unsubscribe() : MQTTFormat.c , MQTTFormat.h
  • MQTTstrlen() : MQTTPacket.c , MQTTPacket.h
  • MQTTSubscribe() : MQTTClient.c , MQTTClient.h
  • MQTTUnsubscribe() : MQTTClient.c , MQTTClient.h
  • MQTTYield() : MQTTClient.c , MQTTClient.h


ioLibrary: Globals

- n -

  • NewNetwork() : mqtt_interface.c , mqtt_interface.h
  • ntohl() : netutil.h , netutil.c
  • ntohs() : netutil.h , netutil.c


ioLibrary: Globals

- p -

  • parse_http_request() : httpParser.c , httpParser.h
  • parse_name() : dns.c
  • parseCommunity() : snmp.c
  • parseDHCPMSG() : dhcp.c
  • parseDNSMSG() : dns.c
  • parseLength() : snmp.c
  • parseRequest() : snmp.c
  • parseSequence() : snmp.c
  • parseSequenceOf() : snmp.c
  • parseSNMPMessage() : snmp.c
  • parseTLV() : snmp.c
  • parseVarBind() : snmp.c
  • parseVersion() : snmp.c
  • pport() : ftpd.h , ftpd.c
  • pportc() : ftpc.c , ftpc.h
  • predefined_get_cgi_processor() : httpUtil.h
  • predefined_set_cgi_processor() : httpUtil.h
  • proc_ftpc() : ftpc.c , ftpc.h
  • proc_ftpd() : ftpd.c , ftpd.h
  • put16() : dns.c


ioLibrary: Globals

- r -

  • read_userReg_webContent() : httpServer.c , httpServer.h
  • readChar() : MQTTPacket.h , MQTTPacket.c
  • readInt() : MQTTPacket.c , MQTTPacket.h
  • readMQTTLenString() : MQTTPacket.h , MQTTPacket.c
  • recv() : socket.c , socket.h
  • recvfile() : ftpd.h
  • recvfrom() : socket.c , socket.h
  • recvit() : ftpd.h
  • reg_dhcp_cbfunc() : dhcp.h , dhcp.c
  • reg_httpServer_cbfunc() : httpServer.c , httpServer.h
  • reg_httpServer_webContent() : httpServer.h , httpServer.c
  • reg_wizchip_bus_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_cris_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reg_wizchip_cs_cbfunc() : wizchip_conf.h , wizchip_conf.c
  • reg_wizchip_spi_cbfunc() : wizchip_conf.h , wizchip_conf.c
  • reg_wizchip_spiburst_cbfunc() : wizchip_conf.c , wizchip_conf.h
  • reset_DHCP_timeout() : dhcp.c


ioLibrary: Globals

- s -

  • save_data() : tftp.c
  • send() : socket.c , socket.h
  • send_DHCP_DECLINE() : dhcp.c
  • send_DHCP_DISCOVER() : dhcp.c
  • send_DHCP_REQUEST() : dhcp.c
  • sendfile() : ftpd.h
  • sendit() : ftpd.h
  • sendto() : socket.c , socket.h
  • setEntry() : snmp.c
  • setRMSR() : w5300.h
  • setsockopt() : socket.c , socket.h
  • setTMSR() : w5300.h
  • snmp_sendTrap() : snmp.c , snmp.h
  • SNMP_time_handler() : snmp.h , snmp.c
  • snmpd_init() : snmp.c , snmp.h
  • snmpd_run() : snmp.c , snmp.h
  • SNTP_init() : sntp.c , sntp.h
  • SNTP_run() : sntp.c , sntp.h
  • socket() : socket.h , socket.c
  • swapl() : netutil.c , netutil.h
  • swaps() : netutil.h , netutil.c


ioLibrary: Globals

- t -

  • TFTP_exit() : tftp.c , tftp.h
  • TFTP_init() : tftp.h , tftp.c
  • TFTP_read_request() : tftp.c , tftp.h
  • TFTP_run() : tftp.h , tftp.c
  • tftp_timeout_handler() : tftp.c , tftp.h
  • TimerCountdown() : mqtt_interface.c , mqtt_interface.h , MQTTClient.h
  • TimerCountdownMS() : MQTTClient.h , mqtt_interface.h , mqtt_interface.c
  • TimerInit() : mqtt_interface.c , mqtt_interface.h , MQTTClient.h
  • TimerIsExpired() : mqtt_interface.h , mqtt_interface.c , MQTTClient.h
  • TimerLeftMS() : mqtt_interface.h , mqtt_interface.c , MQTTClient.h


ioLibrary: Globals

- u -

  • unescape_http_url() : httpParser.c , httpParser.h
  • User_Keyboard_MSG() : ftpc.c , ftpc.h


ioLibrary: Globals

- w -

  • w5x00_disconnect() : mqtt_interface.c , mqtt_interface.h
  • w5x00_read() : mqtt_interface.h , mqtt_interface.c
  • w5x00_write() : mqtt_interface.c , mqtt_interface.h
  • waitfor() : MQTTClient.c
  • wiz_delay_ms() : w5100s.c , w5100s.h
  • wiz_mdio_read() : w5100s.c , w5100s.h
  • wiz_mdio_write() : w5100s.c , w5100s.h
  • wiz_recv_data() : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h , w5100s.c
  • wiz_recv_ignore() : w5100.h , w5100s.c , w5100s.h , w5200.h , w5300.h , w5500.h
  • wiz_send_data() : w5100.h , w5100s.c , w5100s.h , w5200.h , w5300.h , w5500.h
  • wizchip_bus_readdata() : wizchip_conf.c
  • wizchip_bus_writedata() : 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_READ() : w5100.h , w5100s.c , w5100s.h , w5200.h , w5300.h , w5500.h
  • WIZCHIP_READ_BUF() : w5100s.c , w5100.h , w5100s.h , w5200.h , w5500.h
  • wizchip_setinterruptmask() : wizchip_conf.h , wizchip_conf.c
  • 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
  • WIZCHIP_WRITE() : w5100s.c , w5100.h , w5500.h , w5200.h , w5300.h , w5100s.h
  • WIZCHIP_WRITE_BUF() : w5100s.c , w5500.h , w5100s.h , w5100.h , w5200.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.c , wizchip_conf.h
  • wizphy_setphypmode() : wizchip_conf.c , wizchip_conf.h
  • writeChar() : MQTTPacket.h , MQTTPacket.c
  • writeCString() : MQTTPacket.h , MQTTPacket.c
  • writeInt() : MQTTPacket.c , MQTTPacket.h
  • writeMQTTString() : MQTTPacket.c , MQTTPacket.h


ioLibrary: Globals

- b -

  • BUFPUB : httpParser.c

- c -

  • charge : license.txt
  • CLAIM : license.txt
  • Command : ftpc.c
  • conditions : license.txt
  • connect_state_control : ftpd.c
  • connect_state_control_ftpc : ftpc.c
  • connect_state_data : ftpd.c
  • connect_state_data_ftpc : ftpc.c
  • CONTRACT : license.txt
  • copy : license.txt
  • current_day : ftpd.c
  • current_hour : ftpd.c
  • current_min : ftpd.c
  • current_month : ftpd.c
  • current_sec : ftpd.c
  • current_year : ftpd.c

- d -

  • data_buf : sntp.c
  • dbg_level : tftp.c , tftp.h
  • DHCP_allocated_dns : dhcp.c
  • DHCP_allocated_gw : dhcp.c
  • DHCP_allocated_ip : dhcp.c
  • DHCP_allocated_sn : dhcp.c
  • DHCP_CHADDR : dhcp.c
  • dhcp_ip_assign : dhcp.c
  • dhcp_lease_time : dhcp.c
  • dhcp_retry_count : dhcp.c
  • DHCP_SIP : dhcp.c
  • DHCP_SOCKET : dhcp.c
  • dhcp_state : dhcp.c
  • dhcp_tick_1s : dhcp.c
  • dhcp_tick_next : dhcp.c
  • DHCP_XID : dhcp.c
  • distribute : license.txt
  • dns_1s_tick : dns.c
  • DNS_MSGID : dns.c
  • DNS_SOCKET : dns.c

- e -

  • errorIndex : snmp.c
  • errorStatus : snmp.c

- f -

  • FROM : license.txt
  • ftp : ftpd.c
  • FTP_destip : ftpc.c
  • FTP_destport : ftpc.c
  • ftpc : ftpc.c

- g -

  • g_progress_state : tftp.c
  • gDataPutGetStart : ftpc.c
  • gDataSockReady : ftpc.c
  • gMenuStart : ftpc.c
  • gModeActivePassiveflag : ftpc.c

- h -

  • HOST_NAME : dhcp.c
  • HTTPServer_ReStart : httpServer.c
  • httpServer_tick_1s : httpServer.c
  • HTTPSock_Status : httpServer.c

- i -

  • IMPLIED : license.txt

- k -

  • KIND : license.txt

- l -

  • LIABILITY : license.txt
  • local_ip : ftpc.c , ftpd.c
  • local_port : ftpc.c , ftpd.c

- m -

  • maxData : snmp_custom.c , snmp_custom.h
  • MERCHANTABILITY : license.txt
  • merge : license.txt
  • MilliTimer : mqtt_interface.c
  • modify : license.txt
  • MQTTPacket_names : MQTTFormat.c

- n -

  • Nowdatetime : sntp.c
  • ntp_retry_cnt : sntp.c
  • NTP_SOCKET : sntp.c
  • NTPformat : sntp.c
  • ntpmessage : sntp.c

- o -

  • OLD_allocated_ip : dhcp.c
  • OTHERWISE : license.txt

- p -

  • packet_trap : snmp.c
  • pDHCPMSG : dhcp.c
  • pDNSMSG : dns.c
  • pHTTP_RX : httpServer.c
  • pHTTP_TX : httpServer.c
  • publish : license.txt

- r -

  • remote_ip : ftpc.c , ftpd.c
  • remote_port : ftpd.c , ftpc.c
  • request_msg : snmp.c
  • response_msg : snmp.c
  • restriction : license.txt

- s -

  • snmp_tick_10ms : snmp.c
  • snmpData : snmp_custom.c , snmp_custom.h
  • so : license.txt
  • sock_pack_info : socket.c
  • Software : license.txt
  • sublicense : license.txt

- t -

  • time_zone : sntp.c

- u -

  • use : license.txt

- w -

  • web_content : httpServer.c
  • WIZCHIP : wizchip_conf.h , wizchip_conf.c


ioLibrary: Globals

  • _WIZCHIP : wizchip_conf.h
  • datetime : sntp.h
  • httpServer_webContent : httpServer.h
  • iodata_t : wizchip_conf.h
  • MessageData : MQTTClient.h
  • messageHandler : MQTTClient.h
  • MQTTClient : MQTTClient.h
  • MQTTMessage : MQTTClient.h
  • Network : mqtt_interface.h
  • ntpformat : sntp.h
  • s_char : sntp.h
  • st_http_request : httpParser.h
  • st_http_socket : httpServer.h
  • tdist : sntp.h
  • TFTP_DATA_T : tftp.h
  • TFTP_ERROR_T : tftp.h
  • TFTP_OPTION : tftp.h
  • Timer : mqtt_interface.h
  • tstamp : sntp.h
  • un_l2cval : ftpc.h , ftpd.h
  • wiz_NetInfo : wizchip_conf.h
  • wiz_NetTimeout : wizchip_conf.h
  • wiz_PhyConf : wizchip_conf.h


ioLibrary: Globals

  • CommandFirst : ftpc.h
  • CommandSecond : ftpc.h
  • ctlnetwork_type : wizchip_conf.h
  • ctlsock_type : socket.h
  • ctlwizchip_type : wizchip_conf.h
  • datasock_mode : ftpd.h
  • datasock_state : ftpd.h
  • dhcp_mode : wizchip_conf.h
  • errors : MQTTPacket.h
  • ftp_cmd : ftpd.h
  • ftp_state : ftpd.h
  • ftp_type : ftpd.h
  • ftpc_datasock_mode : ftpc.h
  • ftpc_datasock_state : ftpc.h
  • ftpc_type : ftpc.h
  • intr_kind : wizchip_conf.h
  • msgTypes : MQTTPacket.h
  • netmode_type : wizchip_conf.h
  • QoS : MQTTClient.h
  • returnCode : MQTTClient.h
  • sockint_kind : socket.h
  • sockopt_type : socket.h
  • StorageType : httpServer.h


ioLibrary: Globals

- a -

  • ACCT_CMD : ftpd.h
  • ACTIVE_MODE : ftpc.h , ftpd.h
  • allSubnetsLocal : dhcp.c
  • APPE_CMD : ftpd.h
  • arpCacheTimeout : dhcp.c
  • ASCII_TYPE : ftpd.h , ftpc.h


ioLibrary: Globals

- b -

  • bootFileSize : dhcp.c
  • broadcastAddr : dhcp.c
  • BUFFER_OVERFLOW : MQTTClient.h


ioLibrary: Globals

- 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
  • CODEFLASH : httpServer.h
  • CONNACK : MQTTPacket.h
  • CONNECT : MQTTPacket.h
  • cookieServer : dhcp.c
  • 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
  • CWD_CMD : ftpd.h


ioLibrary: Globals

- d -

  • DATAFLASH : httpServer.h
  • DATASOCK_IDLE : ftpc.h , ftpd.h
  • DATASOCK_READY : ftpc.h , ftpd.h
  • DATASOCK_START : ftpc.h , ftpd.h
  • defaultIPTTL : dhcp.c
  • DELE_CMD : ftpd.h
  • DHCP_FAILED : dhcp.h
  • DHCP_IP_ASSIGN : dhcp.h
  • DHCP_IP_CHANGED : dhcp.h
  • DHCP_IP_LEASED : dhcp.h
  • DHCP_RUNNING : dhcp.h
  • DHCP_STOPPED : dhcp.h
  • dhcpClassIdentifier : dhcp.c
  • dhcpClientIdentifier : dhcp.c
  • dhcpIPaddrLeaseTime : dhcp.c
  • dhcpMaxMsgSize : dhcp.c
  • dhcpMessageType : dhcp.c
  • dhcpMsg : dhcp.c
  • dhcpOptionOverload : dhcp.c
  • dhcpParamRequest : dhcp.c
  • dhcpRequestedIPaddr : dhcp.c
  • dhcpServerIdentifier : dhcp.c
  • dhcpT1value : dhcp.c
  • dhcpT2value : dhcp.c
  • DISCONNECT : MQTTPacket.h
  • dns : dhcp.c
  • domainName : dhcp.c


ioLibrary: Globals

- e -

  • endOption : dhcp.c
  • ethernetEncapsulation : dhcp.c
  • extentionsPath : dhcp.c


ioLibrary: Globals

- f -

  • f_dir : ftpc.h
  • f_get : ftpc.h
  • f_nocmd : ftpc.h
  • f_put : ftpc.h
  • FAILURE : MQTTClient.h
  • FEAT_CMD : ftpd.h
  • FTPS_LOGIN : ftpd.h
  • FTPS_NOT_LOGIN : ftpd.h


ioLibrary: Globals

- h -

  • hostName : dhcp.c


ioLibrary: Globals

- i -

  • ifMTU : dhcp.c
  • 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
  • IMAGE_TYPE : ftpc.h , ftpd.h
  • impressServer : dhcp.c
  • IPforwarding : dhcp.c


ioLibrary: Globals

- l -

  • LIST_CMD : ftpd.h
  • LOGICAL_TYPE : ftpd.h
  • logServer : dhcp.c
  • lprServer : dhcp.c


ioLibrary: Globals

- m -

  • maskSupplier : dhcp.c
  • maxDgramReasmSize : dhcp.c
  • meritDumpFile : dhcp.c
  • MKD_CMD : ftpd.h
  • MLSD_CMD : ftpd.h
  • MODE_CMD : ftpd.h
  • MQTTPACKET_BUFFER_TOO_SHORT : MQTTPacket.h
  • MQTTPACKET_READ_COMPLETE : MQTTPacket.h
  • MQTTPACKET_READ_ERROR : MQTTPacket.h


ioLibrary: Globals

- n -

  • NAME_CMD : ftpd.h
  • nameServer : dhcp.c
  • netBIOSdgramDistServer : dhcp.c
  • netBIOSnameServer : dhcp.c
  • netBIOSnodeType : dhcp.c
  • netBIOSscope : dhcp.c
  • NETINFO_DHCP : wizchip_conf.h
  • NETINFO_STATIC : wizchip_conf.h
  • nisDomainName : dhcp.c
  • nisServers : dhcp.c
  • NLST_CMD : ftpd.h
  • NM_FORCEARP : wizchip_conf.h
  • NM_PINGBLOCK : wizchip_conf.h
  • NM_PPPOE : wizchip_conf.h
  • NM_WAKEONLAN : wizchip_conf.h
  • NO_CMD : ftpd.h
  • NONE : httpServer.h
  • nonLocalSourceRouting : dhcp.c
  • ntpServers : dhcp.c


ioLibrary: Globals

- p -

  • padOption : dhcp.c
  • PASS_CMD : ftpd.h
  • PASSIVE_MODE : ftpd.h , ftpc.h
  • PASV_CMD : ftpd.h
  • pathMTUagingTimeout : dhcp.c
  • pathMTUplateauTable : dhcp.c
  • performMaskDiscovery : dhcp.c
  • performRouterDiscovery : dhcp.c
  • PINGREQ : MQTTPacket.h
  • PINGRESP : MQTTPacket.h
  • policyFilter : dhcp.c
  • PORT_CMD : ftpd.h
  • PUBACK : MQTTPacket.h
  • PUBCOMP : MQTTPacket.h
  • PUBLISH : MQTTPacket.h
  • PUBREC : MQTTPacket.h
  • PUBREL : MQTTPacket.h
  • PWD_CMD : ftpd.h


ioLibrary: Globals

- q -

  • QOS0 : MQTTClient.h
  • QOS1 : MQTTClient.h
  • QOS2 : MQTTClient.h
  • QUIT_CMD : ftpd.h


ioLibrary: Globals

- r -

  • resourceLocationServer : dhcp.c
  • RETR_CMD : ftpd.h
  • RMD_CMD : ftpd.h
  • rootPath : dhcp.c
  • routerSolicitationAddr : dhcp.c
  • routersOnSubnet : dhcp.c


ioLibrary: Globals

- s -

  • s_dir : ftpc.h
  • s_get : ftpc.h
  • s_nocmd : ftpc.h
  • s_put : ftpc.h
  • SDCARD : httpServer.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
  • SIZE_CMD : ftpd.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
  • staticRoute : dhcp.c
  • STOR_CMD : ftpd.h
  • STRU_CMD : ftpd.h
  • SUBACK : MQTTPacket.h
  • subnetMask : dhcp.c
  • SUBSCRIBE : MQTTPacket.h
  • SUCCESSS : MQTTClient.h
  • swapServer : dhcp.c
  • SYST_CMD : ftpd.h


ioLibrary: Globals

- t -

  • tcpDefaultTTL : dhcp.c
  • tcpKeepaliveGarbage : dhcp.c
  • tcpKeepaliveInterval : dhcp.c
  • timerOffset : dhcp.c
  • timeServer : dhcp.c
  • trailerEncapsulation : dhcp.c
  • TYPE_CMD : ftpd.h


ioLibrary: Globals

- u -

  • UNSUBACK : MQTTPacket.h
  • UNSUBSCRIBE : MQTTPacket.h
  • USER_CMD : ftpd.h


ioLibrary: Globals

- v -

  • vendorSpecificInfo : dhcp.c


ioLibrary: Globals

- x -

  • XCWD_CMD : ftpd.h
  • xDisplayManager : dhcp.c
  • xFontServer : dhcp.c
  • XMD5_CMD : ftpd.h
  • XMKD_CMD : ftpd.h
  • XPWD_CMD : ftpd.h
  • XRMD_CMD : ftpd.h


ioLibrary: Globals

- _ -

  • __SEOF : stdio_private.h
  • __SERR : stdio_private.h
  • __SPGM : stdio_private.h
  • __SRD : stdio_private.h
  • __SSTR : stdio_private.h
  • __SUNGET : stdio_private.h
  • __SWR : stdio_private.h
  • __TFTP_DEBUG__ : tftp.h
  • _FTP_DEBUG_ : ftpd.h
  • _HTTPSERVER_DEBUG_ : httpServer.h
  • _IMR_ : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • _LOOPBACK_DEBUG_ : loopback.h
  • _MAX_SS : ftpc.h , ftpd.h
  • _NOTUSED_STORAGE_ : httpServer.h
  • _RCR_ : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • _RTR_ : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • _SNMP_DEBUG_ : snmp.h
  • _W5100_IO_BASE_ : w5100.h
  • _W5100S_IO_BASE_ : w5100s.h
  • _W5200_SPI_READ_ : w5200.h
  • _W5200_SPI_WRITE_ : w5200.h
  • _W5300_IO_BASE_ : w5300.h
  • _W5500_IO_BASE_ : w5500.h
  • _W5500_SPI_FDM_OP_LEN1_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN2_ : w5500.c
  • _W5500_SPI_FDM_OP_LEN4_ : w5500.c
  • _W5500_SPI_READ_ : w5500.h
  • _W5500_SPI_VDM_OP_ : w5500.c
  • _W5500_SPI_WRITE_ : w5500.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_5500_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_FDM_ : wizchip_conf.h
  • _WIZCHIP_IO_MODE_SPI_VDM_ : wizchip_conf.h
  • _WIZCHIP_IO_RXBUF_ : w5200.h , w5100.h , w5100s.h
  • _WIZCHIP_IO_TXBUF_ : w5100.h , w5200.h , w5100s.h
  • _WIZCHIP_SN_BASE_ : w5300.h , w5100.h , w5100s.h , w5200.h
  • _WIZCHIP_SN_SIZE_ : w5100.h , w5200.h , w5300.h , w5100s.h
  • _WIZCHIP_SOCK_NUM_ : wizchip_conf.h


ioLibrary: Globals

- a -

  • AGAIN : dns.c


ioLibrary: Globals

- b -

  • BAD_VALUE : snmp.h
  • BMCR_AUTONEGO : w5100s.h
  • BMCR_COLTEST : w5100s.h
  • BMCR_DUP : w5100s.h
  • BMCR_ISOLATE : w5100s.h
  • BMCR_MLOOPBACK : w5100s.h
  • BMCR_PWDN : w5100s.h
  • BMCR_RESET : w5100s.h
  • BMCR_RSTNEGO : w5100s.h
  • BMCR_SPEED : w5100s.h
  • BMSR_AUTONEGO_COMPL : w5100s.h
  • BMSR_JAB_DETECT : w5100s.h
  • BMSR_LINK_STATUS : w5100s.h
  • BMSR_REMOTE_FAULT : w5100s.h


ioLibrary: Globals

- c -

  • CHECK_SOCKDATA : socket.c
  • CHECK_SOCKINIT : socket.c
  • CHECK_SOCKMODE : socket.c
  • CHECK_SOCKNUM : socket.c
  • CHIPLCKR : w5100s.h
  • CHIPLOCK : w5100s.h
  • CHIPUNLOCK : w5100s.h
  • CLASS_IN : dns.c
  • COMMUNITY : snmp_custom.h
  • COMMUNITY_SIZE : snmp_custom.h
  • COPY_SEGMENT : snmp.h
  • CTRL_SOCK : ftpd.h , ftpc.h


ioLibrary: Globals

- d -

  • DATA_BUF_SIZE : loopback.h , httpServer.c
  • DATA_SOCK : ftpd.h , ftpc.h
  • DBG_PRINT : tftp.h
  • DBGOUT : w5100s.h
  • DCHP_HOST_NAME : dhcp.h
  • DEBUG_DBG : tftp.h
  • DefaultClient : MQTTClient.h
  • DGAIN : dns.c
  • DHCP_ACK : dhcp.c
  • DHCP_BOOTREPLY : dhcp.c
  • DHCP_BOOTREQUEST : dhcp.c
  • DHCP_CLIENT_PORT : dhcp.h
  • DHCP_DECLINE : dhcp.c
  • DHCP_DISCOVER : dhcp.c
  • DHCP_FLAGSBROADCAST : dhcp.c
  • DHCP_FLAGSUNICAST : dhcp.c
  • DHCP_HLENETHERNET : dhcp.c
  • DHCP_HOPS : dhcp.c
  • DHCP_HTYPE100MB : dhcp.c
  • DHCP_HTYPE10MB : dhcp.c
  • DHCP_INFORM : dhcp.c
  • DHCP_NAK : dhcp.c
  • DHCP_OFFER : dhcp.c
  • DHCP_RELEASE : dhcp.c
  • DHCP_REQUEST : dhcp.c
  • DHCP_SECS : dhcp.c
  • DHCP_SERVER_PORT : dhcp.h
  • DHCP_WAIT_TIME : dhcp.h
  • DLLExport : MQTTPacket.h , MQTTSubscribe.h , MQTTConnect.h , MQTTUnsubscribe.h , MQTTClient.h , MQTTPublish.h
  • DLLImport : MQTTClient.h , MQTTPublish.h , MQTTConnect.h , MQTTSubscribe.h , MQTTPacket.h , MQTTUnsubscribe.h
  • DNS_MSG_ID : dns.h
  • DNS_WAIT_TIME : dns.h


ioLibrary: Globals

- e -

  • EPOCH : sntp.h
  • ERROR_DBG : tftp.h
  • EXTENDED_CAPA : w5100s.h


ioLibrary: Globals

- f -

  • F_APP_FTP : ftpd.h
  • F_APP_FTPC : ftpc.h
  • F_APP_TFTP : tftp.h
  • F_STORAGE : tftp.h
  • FILE_NAME_SIZE : tftp.h
  • FILENAME : ftpd.h
  • FMTUR : w5300.h
  • FORMAT_ERROR : dns.c
  • FUNC_ENTRY : StackTrace.h
  • FUNC_ENTRY_MAX : StackTrace.h
  • FUNC_ENTRY_MED : StackTrace.h
  • FUNC_ENTRY_NOLOG : StackTrace.h
  • FUNC_EXIT : StackTrace.h
  • FUNC_EXIT_MAX : StackTrace.h
  • FUNC_EXIT_MAX_RC : StackTrace.h
  • FUNC_EXIT_MED : StackTrace.h
  • FUNC_EXIT_MED_RC : StackTrace.h
  • FUNC_EXIT_NOLOG : StackTrace.h
  • FUNC_EXIT_RC : StackTrace.h


ioLibrary: Globals

- g -

  • GAR : w5100.h , w5100s.h , w5300.h , w5500.h , w5200.h
  • GET_NEXT_REQUEST : snmp.h
  • GET_REQUEST : snmp.h
  • GET_RESPONSE : snmp.h
  • getFMTUR : w5300.h
  • getGAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getIDR : w5300.h
  • getIMR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getIMR2 : w5100s.h , w5200.h
  • getINTLEVEL : w5200.h , w5500.h
  • getIR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getIR2 : w5100s.h , w5200.h
  • getMR : w5100.h , w5100s.h , w5200.h , w5500.h
  • getMR2 : w5100s.h
  • getMTYPER : w5300.h
  • getNICMAXCOLR : w5100s.h
  • getPATR : w5100.h , w5100s.h , w5200.h , w5300.h
  • getPDHAR : w5300.h
  • getPHAR : w5100s.h , w5500.h
  • getPHYACR : w5100s.h
  • getPHYAR : w5100s.h
  • getPHYCFGR : w5500.h
  • getPHYCR0 : w5100s.h
  • getPHYCR1 : w5100s.h
  • getPHYDIR : w5100s.h
  • getPHYDIVR : w5100s.h
  • getPHYDOR : w5100s.h
  • getPHYRAR : w5100s.h
  • getPHYSR : w5100s.h
  • getPHYSR1 : w5100s.h
  • getPHYSTATUS : w5200.h
  • getPINGIDR : w5100s.h
  • getPINGSEQR : w5100s.h
  • getPMAGIC : w5500.h , w5100.h , w5100s.h , w5200.h , w5300.h
  • getPMRU : w5500.h
  • getPMRUR : w5100s.h
  • getPn_BDPTHR : w5300.h
  • getPn_BRDYR : w5300.h
  • getPPPALGO : w5100.h , w5100s.h , w5200.h
  • getPSID : w5500.h
  • getPSIDR : w5100s.h , w5300.h
  • getPTIMER : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getRCR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getRMS01R : w5300.h
  • getRMS23R : w5300.h
  • getRMS45R : w5300.h
  • getRMS67R : w5300.h
  • getRMSR : w5100.h , w5100s.h
  • getRTR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSIMR : w5200.h , w5500.h
  • getSIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSIR : w5200.h , w5500.h
  • getSLCR : w5100s.h
  • getSLIMR : w5100s.h
  • getSLIR : w5100s.h
  • getSLPHAR : w5100s.h
  • getSLPIPR : w5100s.h
  • getSLRCR : w5100s.h
  • getSLRTR : w5100s.h
  • getSn_CR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_DHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_DIPR : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • getSn_DPORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_DPORTR : w5300.h
  • getSn_FRAG : w5200.h , w5100.h , w5300.h , w5500.h
  • getSn_FRAGR : w5300.h , w5100s.h
  • getSn_IMR : w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_IR : w5100.h , w5100s.h , w5300.h , w5500.h , w5200.h
  • getSn_KPALVTR : w5100s.h , w5500.h , w5300.h
  • getSn_MR : w5100.h , w5100s.h , w5300.h , w5500.h , w5200.h
  • getSn_MR2 : w5100s.h
  • getSn_MSSR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • getSn_PORT : w5100.h , w5100s.h , w5200.h , w5500.h , w5300.h
  • getSn_PORTR : w5300.h
  • getSn_PROTO : w5100.h , w5200.h , w5300.h , w5100s.h
  • getSn_PROTOR : w5300.h
  • getSn_RCR : w5100s.h
  • getSn_RTR : w5100s.h
  • getSn_RX_FIFOR : w5300.h
  • getSn_RX_RD : w5100s.h , w5500.h , w5100.h , w5200.h
  • getSn_RX_WR : w5100s.h , w5100.h , w5200.h , w5500.h
  • getSn_RXBUF_SIZE : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • getSn_RxMASK : w5100.h , w5200.h , w5100s.h
  • getSn_RxMAX : w5100s.h , w5100.h , w5200.h , w5500.h , w5300.h
  • getSn_RXMEM_SIZE : w5200.h , w5100.h , w5100s.h
  • getSn_SR : w5100.h , w5500.h , w5200.h , w5300.h , w5100s.h
  • getSn_SSR : w5300.h
  • getSn_TOS : w5100.h , w5500.h , w5200.h , w5300.h , w5100s.h
  • getSn_TOSR : w5300.h
  • getSn_TSR : w5100s.h
  • getSn_TTL : w5100.h , w5300.h , w5500.h , w5100s.h , w5200.h
  • getSn_TTLR : w5300.h
  • getSn_TX_RD : w5200.h , w5100.h , w5100s.h , w5500.h
  • getSn_TX_WR : w5100s.h , w5200.h , w5100.h , w5500.h
  • getSn_TX_WRSR : w5300.h
  • getSn_TXBUF_SIZE : w5500.h , w5100s.h , w5300.h , w5200.h , w5100.h
  • getSn_TxMASK : w5100.h , w5200.h , w5100s.h
  • getSn_TxMAX : w5300.h , w5100s.h , w5100.h , w5200.h , w5500.h
  • getSn_TXMEM_SIZE : w5200.h , w5100.h , w5100s.h
  • getSUBR : w5500.h , w5300.h , w5100s.h , w5100.h , w5200.h
  • getTCNTR : w5100s.h
  • getTMS01R : w5300.h
  • getTMS23R : w5300.h
  • getTMS45R : w5300.h
  • getTMS67R : w5300.h
  • getTMSR : w5100s.h
  • getUIPR : w5300.h , w5500.h , w5100s.h
  • getUPORTR : w5100s.h , w5300.h , w5500.h
  • getVER : w5100s.h
  • getVERSIONR : w5200.h , w5500.h


ioLibrary: Globals

- h -

  • HOSTNAME : ftpd.h
  • HTML_HEADER : httpParser.h
  • HTONL : snmp.h
  • HTTP_FAILED : httpServer.h
  • HTTP_MAX_TIMEOUT_SEC : httpServer.h
  • HTTP_OK : httpServer.h
  • HTTP_RESET : httpServer.h
  • HTTP_SERVER_PORT : httpParser.h


ioLibrary: Globals

- i -

  • IDR : w5300.h
  • IINCHIP_READ : w5100.h , w5200.h , w5300.h , w5100s.h , w5500.h
  • IINCHIP_READ_BUF : w5100s.h , w5200.h , w5500.h , w5100.h
  • IINCHIP_WRITE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IINCHIP_WRITE_BUF : w5100.h , w5100s.h , w5200.h , w5500.h
  • ILLEGAL_LENGTH : snmp.h
  • IM_IR4 : w5500.h
  • IM_IR5 : w5500.h
  • IM_IR6 : w5500.h
  • IM_IR7 : w5500.h
  • IMR2 : w5100s.h , w5200.h
  • IMR2_MGC : w5100s.h
  • IMR_CONFLICT : w5100s.h
  • IMR_PPPoE : w5100s.h
  • IMR_SOCK : w5100s.h
  • IMR_UNREACH : w5100s.h
  • INFINITE_LEASETIME : dhcp.c
  • INFO_DBG : tftp.h
  • INITIAL_WEBPAGE : httpServer.h
  • INITRTT : dns.c
  • INTLEVEL : w5200.h , w5500.h
  • INVALID_DATA_TYPE : snmp.h
  • INVALID_ENTRY_ID : snmp.h
  • IPC_DBG : tftp.h
  • IPPORT_DOMAIN : dns.h
  • IPPORT_FTP : ftpd.h
  • IPPORT_FTPD : ftpd.h
  • IPPROTO_GGP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_ICMP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_IDP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_IGMP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_IP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • IPPROTO_ND : w5100.h , w5100s.h , w5300.h , w5500.h , w5200.h
  • IPPROTO_PUP : w5100.h , w5200.h , w5300.h , w5500.h , w5100s.h
  • IPPROTO_RAW : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • IPPROTO_TCP : w5100s.h , w5200.h , w5300.h , w5100.h , w5500.h
  • IPPROTO_UDP : w5300.h , w5100s.h , w5200.h , w5100.h , w5500.h
  • IQUERY : dns.c
  • IR : w5300.h , w5200.h , w5100s.h , w5500.h , w5100.h
  • IR2 : w5200.h , w5100s.h
  • IR2_MGC : w5100s.h
  • IR_CONFLICT : w5100.h , w5100s.h , w5500.h , w5200.h
  • IR_DPUR : w5300.h
  • IR_FMTU : w5300.h
  • IR_IPCF : w5300.h
  • IR_MP : w5500.h
  • IR_PPPoE : w5100.h , w5500.h , w5100s.h , w5200.h
  • IR_PPPT : w5300.h
  • IR_SnINT : w5300.h
  • IR_SOCK : w5100.h , w5100s.h
  • IR_UNREACH : w5100s.h , w5500.h , w5100.h


ioLibrary: Globals

- l -

  • LAGAIN : dns.c
  • LDGAIN : dns.c
  • LINELEN : ftpd.h , ftpc.h
  • LOOPBACK_MAIN_NOBLOCK : loopback.h
  • LOOPBACK_MODE : loopback.h


ioLibrary: Globals

- m -

  • M_INITIAL_WEBPAGE : httpServer.h
  • MAGIC_COOKIE : dhcp.h
  • MAX_CONTENT_CALLBACK : httpServer.h
  • MAX_CONTENT_NAME_LEN : httpServer.h
  • MAX_DHCP_RETRY : dhcp.h
  • MAX_DNS_BUF_SIZE : dns.h
  • MAX_DNS_RETRY : dns.h
  • MAX_DOMAIN_NAME : dns.h
  • MAX_MESSAGE_HANDLERS : MQTTClient.h
  • MAX_MTU_SIZE : tftp.h
  • MAX_NO_OF_REMAINING_LENGTH_BYTES : MQTTPacket.c
  • MAX_OID : snmp.h
  • MAX_PACKET_ID : MQTTClient.h
  • MAX_SNMPMSG_LEN : snmp.h
  • MAX_SNTP_BUF_SIZE : sntp.h
  • MAX_STRING : snmp.h
  • MAX_TRAPMSG_LEN : snmp.h
  • MAX_URI_SIZE : httpParser.h
  • MAXCNAME : dns.c
  • METHOD_ERR : httpParser.h
  • METHOD_GET : httpParser.h
  • METHOD_HEAD : httpParser.h
  • METHOD_POST : httpParser.h
  • min : MQTTConnectServer.c , MQTTDeserializePublish.c
  • MOBILE_INITIAL_WEBPAGE : httpServer.h
  • MQTTPacket_connectData_initializer : MQTTConnect.h
  • MQTTPacket_willOptions_initializer : MQTTConnect.h
  • MQTTString_initializer : MQTTPacket.h
  • MR : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.h
  • MR2 : w5100s.h
  • MR2_CLKSEL : w5100s.h
  • MR2_G_IEN : w5100s.h
  • MR2_MNOSCHK : w5100s.h
  • MR2_NOTCPRST : w5100s.h
  • MR2_SSRCHA : w5100s.h
  • MR2_UDPFARP : w5100s.h
  • MR2_UDPURB : w5100s.h
  • MR2_WOL : w5100s.h
  • MR_AI : w5100.h , w5100s.h , w5200.h
  • MR_DBS : w5300.h
  • MR_DBW : w5300.h
  • MR_FARP : w5500.h
  • MR_FS : w5300.h
  • MR_IND : w5200.h , w5100s.h , w5300.h , w5100.h
  • MR_MPF : w5300.h
  • MR_MT : w5300.h
  • MR_PB : w5500.h , w5200.h , w5100s.h , w5100.h , w5300.h
  • MR_PPPOE : w5200.h , w5500.h , w5100.h
  • MR_PPPoE : w5300.h
  • MR_PPPOE : w5100s.h
  • MR_RDH : w5300.h
  • MR_RST : w5100.h , w5300.h , w5200.h , w5100s.h , w5500.h
  • MR_WDF : w5300.h
  • MR_WOL : w5500.h , w5200.h
  • MTYPER : w5300.h


ioLibrary: Globals

- n -

  • NAME_ERROR : dns.c
  • Need_UARTGetCharBlocking_func : ftpc.h
  • NETLCKR : w5100s.h
  • NETLOCK : w5100s.h
  • NETUNLOCK : w5100s.h
  • NICMAXCOLR : w5100s.h
  • NO_ERROR : dns.c
  • NO_SUCH_NAME : snmp.h
  • NORMAL_MODE : tftp.h
  • NOSTACKTRACE : StackTrace.h
  • NOT_IMPL : dns.c
  • ntp_port : sntp.h


ioLibrary: Globals

- o -

  • OID_NOT_FOUND : snmp.h
  • OPT_SIZE : dhcp.c


ioLibrary: Globals

- p -

  • PACK_COMPLETED : socket.h
  • PACK_FIFOBYTE : socket.h
  • PACK_FIRST : socket.h
  • PACK_REMAINED : socket.h
  • PATR : w5100.h , w5200.h , w5300.h
  • PDHAR : w5300.h
  • PHAR : w5100s.h , w5500.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
  • PHYACR : w5100s.h
  • PHYACR_READ : w5100s.h
  • PHYACR_WRITE : w5100s.h
  • PHYAR : w5100s.h
  • PHYCFGR : w5500.h
  • PHYCFGR_DPX_FULL : w5500.h
  • PHYCFGR_DPX_HALF : w5500.h
  • PHYCFGR_LNK_OFF : w5500.h
  • PHYCFGR_LNK_ON : w5500.h
  • PHYCFGR_OPMD : w5500.h
  • PHYCFGR_OPMDC_100F : w5500.h
  • PHYCFGR_OPMDC_100FA : w5500.h
  • PHYCFGR_OPMDC_100H : w5500.h
  • PHYCFGR_OPMDC_10F : w5500.h
  • PHYCFGR_OPMDC_10H : w5500.h
  • PHYCFGR_OPMDC_ALLA : w5500.h
  • PHYCFGR_OPMDC_NA : w5500.h
  • PHYCFGR_OPMDC_PDOWN : w5500.h
  • PHYCFGR_RST : w5500.h
  • PHYCFGR_SPD_10 : w5500.h
  • PHYCFGR_SPD_100 : w5500.h
  • PHYCR0 : w5100s.h
  • PHYCR1 : w5100s.h
  • PHYCR1_PWDN_DISABLE : w5100s.h
  • PHYCR1_PWDN_ENABLE : w5100s.h
  • PHYCR1_RST : w5100s.h
  • PHYCR_AUTONEGO_DISABLE : w5100s.h
  • PHYCR_AUTONEGO_ENABLE : w5100s.h
  • PHYCR_FULL_DUP : w5100s.h
  • PHYCR_HALF_DUP : w5100s.h
  • PHYCR_SPD_10 : w5100s.h
  • PHYCR_SPD_100 : w5100s.h
  • PHYDIR : w5100s.h
  • PHYDIVR : w5100s.h
  • PHYDOR : w5100s.h
  • PHYLCKR : w5100s.h
  • PHYLOCK : w5100s.h
  • PHYMDIO_BMCR : w5100s.h
  • PHYMDIO_BMSR : w5100s.h
  • PHYRAR : w5100s.h
  • PHYSR : w5100s.h
  • PHYSR1 : w5100s.h
  • PHYSR1_CLDN : w5100s.h
  • PHYSR1_LPI : w5100s.h
  • PHYSR1_RXPG : w5100s.h
  • PHYSR_CABOFF : w5100s.h
  • PHYSR_DUP : w5100s.h
  • PHYSR_LNK : w5100s.h
  • PHYSR_MD0 : w5100s.h
  • PHYSR_MD1 : w5100s.h
  • PHYSR_MD2 : w5100s.h
  • PHYSR_SPD : w5100s.h
  • PHYSTATUS : w5200.h
  • PHYSTATUS_LINK : w5200.h
  • PHYSTATUS_POWERDOWN : w5200.h
  • PHYSTATUS_POWERSAVE : w5200.h
  • PHYUNLOCK : w5100s.h
  • PINGIDR : w5100s.h
  • PINGSEQR : w5100s.h
  • PMAGIC : w5100.h , w5100s.h , w5200.h , w5500.h
  • PMAGICR : w5300.h
  • PMRU : w5500.h
  • PMRUR : w5100s.h
  • Pn_BDPTHR : w5300.h
  • Pn_BRDYR : w5300.h
  • Pn_MT : w5300.h
  • Pn_PEN : w5300.h
  • Pn_PPL : w5300.h
  • Pn_SN : w5300.h
  • PORT_SNMP_AGENT : snmp.h
  • PORT_SNMP_TRAP : snmp.h
  • PPPALGO : w5200.h
  • PRINTF_FLT : stdio_private.h
  • PRINTF_MIN : stdio_private.h
  • PRINTF_STD : stdio_private.h
  • PSID : w5500.h
  • PSIDR : w5300.h , w5100s.h
  • PTIMER : w5500.h , w5100.h , w5200.h , w5100s.h , w5300.h
  • PTYPE_CGI : httpParser.h
  • PTYPE_CSS : httpParser.h
  • PTYPE_EOT : httpParser.h
  • PTYPE_ERR : httpParser.h
  • PTYPE_FLASH : httpParser.h
  • PTYPE_GIF : httpParser.h
  • PTYPE_HTML : httpParser.h
  • PTYPE_ICO : httpParser.h
  • PTYPE_JPEG : httpParser.h
  • PTYPE_JS : httpParser.h
  • PTYPE_JSON : httpParser.h
  • PTYPE_MPEG : httpParser.h
  • PTYPE_OTF : httpParser.h
  • PTYPE_PDF : httpParser.h
  • PTYPE_PNG : httpParser.h
  • PTYPE_SVG : httpParser.h
  • PTYPE_TEXT : httpParser.h
  • PTYPE_TTF : httpParser.h
  • PTYPE_WOFF : httpParser.h
  • PTYPE_XML : httpParser.h


ioLibrary: Globals

- q -

  • QUERY : dns.c


ioLibrary: Globals

- r -

  • R_150 : ftpc.h
  • R_200 : ftpc.h
  • R_220 : ftpc.h
  • R_226 : ftpc.h
  • R_227 : ftpc.h
  • R_230 : ftpc.h
  • R_331 : ftpc.h
  • REFUSED : dns.c
  • RES_CGIHEAD_OK : httpParser.h
  • RES_CSSHEAD_OK : httpParser.h
  • RES_EOTHEAD_OK : httpParser.h
  • RES_FLASHHEAD_OK : httpParser.h
  • RES_GIFHEAD_OK : httpParser.h
  • RES_HTMLHEAD_OK : httpParser.h
  • RES_ICOHEAD_OK : httpParser.h
  • RES_JPEGHEAD_OK : httpParser.h
  • RES_JSHEAD_OK : httpParser.h
  • RES_JSONHEAD_OK : httpParser.h
  • RES_OTFHEAD_OK : httpParser.h
  • RES_PNGHEAD_OK : httpParser.h
  • RES_SVGHEAD_OK : httpParser.h
  • RES_TEXTHEAD_OK : httpParser.h
  • RES_TTFHEAD_OK : httpParser.h
  • RES_WOFFHEAD_OK : httpParser.h
  • RES_XMLHEAD_OK : httpParser.h
  • RESPONSE : dns.c
  • RIP_MSG_SIZE : dhcp.c
  • RMS01R : w5300.h
  • RMS23R : w5300.h
  • RMS45R : w5300.h
  • RMS67R : w5300.h
  • RMSR : w5100.h , w5100s.h
  • RMSR0 : w5300.h
  • RMSR1 : w5300.h
  • RMSR2 : w5300.h
  • RMSR3 : w5300.h
  • RMSR4 : w5300.h
  • RMSR5 : w5300.h
  • RMSR6 : w5300.h
  • RMSR7 : w5300.h


ioLibrary: Globals

- s -

  • SCANF_FLT : stdio_private.h
  • SCANF_MIN : stdio_private.h
  • SCANF_STD : stdio_private.h
  • SECS_PERDAY : sntp.h
  • SERVER_FAIL : dns.c
  • SET_REQUEST : snmp.h
  • setDBGOUT : w5100s.h
  • setGAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setIMR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setIMR2 : w5100s.h , w5200.h
  • setINTLEVEL : w5200.h , w5500.h
  • setIR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setIR2 : w5100s.h , w5200.h
  • setMR : w5100.h , w5100s.h , w5200.h , w5500.h
  • setMR2 : w5100s.h
  • setMTYPER : w5300.h
  • setNICMAXCOLR : w5100s.h
  • setPHAR : w5100s.h , w5500.h
  • setPHYACR : w5100s.h
  • setPHYCFGR : w5500.h
  • setPHYCR0 : w5100s.h
  • setPHYCR1 : w5100s.h
  • setPHYDIR : w5100s.h
  • setPHYDIVR : w5100s.h
  • setPHYDOR : w5100s.h
  • setPHYRR : w5100s.h
  • setPINGIDR : w5100s.h
  • setPINGSEQR : w5100s.h
  • setPMAGIC : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setPMRU : w5500.h
  • setPMRUR : w5100s.h
  • setPn_BDPTHR : w5300.h
  • setPn_BRDYR : w5300.h
  • setPSID : w5500.h
  • setPSIDR : w5100s.h
  • setPTIMER : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.h
  • setRCR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setRMS01R : w5300.h
  • setRMS23R : w5300.h
  • setRMS45R : w5300.h
  • setRMS67R : w5300.h
  • setRMSR : w5100.h , w5100s.h
  • setRTR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSIMR : w5200.h , w5500.h
  • setSIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSIR : w5200.h , w5500.h
  • setSLCR : w5100s.h
  • setSLIMR : w5100s.h
  • setSLIR : w5100s.h
  • setSLPHAR : w5100s.h
  • setSLPIPR : w5100s.h
  • setSLRCR : w5100s.h
  • setSLRTR : w5100s.h
  • setSn_CR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_DHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_DIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_DPORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_DPORTR : w5300.h
  • setSn_FRAG : w5500.h , w5100.h , w5200.h , w5300.h
  • setSn_FRAGR : w5100s.h , w5300.h
  • setSn_IMR : w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_IR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_KPALVTR : w5100s.h , w5300.h , w5500.h
  • setSn_MR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_MR2 : w5100s.h
  • setSn_MSSR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_PORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_PORTR : w5300.h
  • setSn_PROTO : w5100.h , w5100s.h , w5200.h , w5300.h
  • setSn_PROTOR : w5300.h
  • setSn_RCR : w5100s.h
  • setSn_RTR : w5100s.h
  • setSn_RX_RD : w5100.h , w5100s.h , w5200.h , w5500.h
  • setSn_RX_WR : w5100.h , w5100s.h , w5200.h
  • setSn_RXBUF_SIZE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_RXMEM_SIZE : w5100.h , w5100s.h , w5200.h
  • setSn_TOS : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_TOSR : w5300.h
  • setSn_TTL : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_TTLR : w5300.h
  • setSn_TX_FIFOR : w5300.h
  • setSn_TX_WR : w5100.h , w5100s.h , w5200.h , w5500.h
  • setSn_TX_WRSR : w5300.h
  • setSn_TXBUF_SIZE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setSn_TXMEM_SIZE : w5100.h , w5100s.h , w5200.h
  • setSUBR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • setTCNTCLKR : w5100s.h
  • setTMS01R : w5300.h
  • setTMS23R : w5300.h
  • setTMS45R : w5300.h
  • setTMS67R : w5300.h
  • setTMSR : w5100.h , w5100s.h
  • setUIPR : w5100s.h
  • setUPORTR : w5100s.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
  • SHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • SIMR : w5500.h
  • SIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • SIR : w5500.h
  • SLCMD_ARP : w5100s.h
  • SLCMD_PING : w5100s.h
  • SLCR : w5100s.h
  • SLIMR : w5100s.h
  • SLIR : w5100s.h
  • SLIR_ARP : w5100s.h
  • SLIR_PING : w5100s.h
  • SLIR_TIMEOUT : w5100s.h
  • SLPHAR : w5100s.h
  • SLPIPR : w5100s.h
  • SLRCR : w5100s.h
  • SLRTR : w5100s.h
  • Sn_CR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_CLOSE : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_CONNECT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_DISCON : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_IGMP_JOIN : w5100s.h
  • Sn_CR_IGMP_LEAVE : w5100s.h
  • Sn_CR_LISTEN : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_OPEN : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_PCJ : w5100.h , w5200.h , w5300.h
  • Sn_CR_PCN : w5100.h , w5200.h , w5300.h
  • Sn_CR_PCON : w5100.h , w5200.h , w5300.h
  • Sn_CR_PCR : w5100.h , w5200.h , w5300.h
  • Sn_CR_PDISCON : w5100.h , w5200.h , w5300.h
  • Sn_CR_RECV : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_SEND : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_SEND_KEEP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_CR_SEND_MAC : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DHAR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DIPR : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DPORT : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_DPORTR : w5300.h
  • Sn_FRAG : w5200.h , w5300.h , w5500.h
  • Sn_FRAGR : w5100s.h , w5300.h
  • Sn_IMR : w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_IR : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_IR_CON : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_IR_DISCON : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • Sn_IR_PFAIL : w5100.h , w5200.h , w5300.h
  • Sn_IR_PNEXT : w5200.h , w5100.h , w5300.h
  • Sn_IR_PRECV : w5100.h , w5200.h , w5300.h
  • Sn_IR_RECV : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_IR_SENDOK : w5200.h , w5100.h , w5100s.h , w5300.h , w5500.h
  • Sn_IR_TIMEOUT : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • Sn_KPALVTR : w5100s.h , w5300.h , w5500.h
  • Sn_MR : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • Sn_MR2 : w5100s.h
  • Sn_MR2_FPSH : w5100s.h
  • Sn_MR2_IPV6BLK : w5100s.h
  • Sn_MR2_MBBLK : w5100s.h
  • Sn_MR2_MMBLK : w5100s.h
  • Sn_MR2_UBBLK : w5100s.h
  • Sn_MR2_UUBLK : w5100s.h
  • Sn_MR_ALIGN : w5300.h
  • Sn_MR_BCASTB : w5500.h
  • Sn_MR_CLOSE : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_MR_IGMPv : w5300.h
  • Sn_MR_IPRAW : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_MACRAW : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_MC : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_MR_MF : w5200.h , w5100.h , w5100s.h , w5300.h
  • Sn_MR_MFEN : w5200.h , w5100.h , w5100s.h , w5500.h
  • Sn_MR_MIP6B : w5500.h
  • Sn_MR_MMB : w5500.h
  • Sn_MR_MULTI : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_ND : w5100.h , w5100s.h , w5200.h , w5500.h , w5300.h
  • Sn_MR_PPPoE : w5100.h , w5100s.h
  • Sn_MR_PPPOE : w5200.h
  • Sn_MR_PPPoE : w5300.h
  • Sn_MR_TCP : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • Sn_MR_UCASTB : w5500.h
  • Sn_MR_UDP : w5100s.h , w5200.h , w5300.h , w5500.h , w5100.h
  • Sn_MSSR : w5300.h , w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_PORT : w5500.h , w5200.h , w5100.h , w5100s.h , w5300.h
  • Sn_PORTR : w5300.h
  • Sn_PROTO : w5100.h , w5100s.h , w5200.h
  • Sn_PROTOR : w5300.h
  • Sn_RCR : w5100s.h
  • Sn_RTR : w5100s.h
  • Sn_RX_FIFOR : w5300.h
  • Sn_RX_RD : w5100.h , w5100s.h , w5200.h , w5500.h
  • Sn_RX_RSR : w5300.h , w5100s.h , w5500.h , w5100.h , w5200.h
  • Sn_RX_WR : w5200.h , w5100.h , w5100s.h , w5500.h
  • Sn_RXBUF_SIZE : w5100s.h , w5500.h
  • Sn_RXMEM_SIZE : w5200.h
  • Sn_SR : w5100.h , w5100s.h , w5500.h , w5200.h , w5300.h
  • Sn_SSR : w5300.h
  • Sn_TOS : w5200.h , w5100s.h , w5300.h , w5100.h , w5500.h
  • Sn_TOSR : w5300.h
  • Sn_TTL : w5300.h , w5500.h , w5100s.h , w5100.h , w5200.h
  • Sn_TTLR : w5300.h
  • Sn_TX_FIFOR : w5300.h
  • Sn_TX_FSR : w5100.h , w5100s.h , w5300.h , w5200.h , w5500.h
  • Sn_TX_RD : w5200.h , w5100s.h , w5500.h , w5100.h
  • Sn_TX_WR : w5100.h , w5200.h , w5100s.h , w5500.h
  • Sn_TX_WRSR : w5300.h
  • Sn_TXBUF_SIZE : w5500.h , w5100s.h
  • Sn_TXMEM_SIZE : w5200.h
  • SNMP_SUCCESS : snmp.h
  • SNMP_V1 : snmp.h
  • SNMPDTYPE_COUNTER : snmp.h
  • SNMPDTYPE_GAUGE : snmp.h
  • SNMPDTYPE_INTEGER : snmp.h
  • SNMPDTYPE_NULL_ITEM : snmp.h
  • SNMPDTYPE_OBJ_ID : snmp.h
  • SNMPDTYPE_OCTET_STRING : snmp.h
  • SNMPDTYPE_OPAQUE : snmp.h
  • SNMPDTYPE_SEQUENCE : snmp.h
  • SNMPDTYPE_SEQUENCE_OF : snmp.h
  • SNMPDTYPE_TIME_TICKS : snmp.h
  • SNMPTRAP_AUTHENTICATION : snmp.h
  • SNMPTRAP_COLDSTART : snmp.h
  • SNMPTRAP_EGPNEIGHBORLOSS : snmp.h
  • SNMPTRAP_LINKDOWN : snmp.h
  • SNMPTRAP_LINKUP : snmp.h
  • SNMPTRAP_WARMSTART : snmp.h
  • SOCK_ANY_PORT_NUM : socket.c
  • SOCK_ARP : w5300.h
  • SOCK_BUSY : socket.h
  • SOCK_CLOSE_WAIT : w5100s.h , w5300.h , w5100.h , w5200.h , w5500.h
  • SOCK_CLOSED : w5100s.h , w5500.h , w5300.h , w5200.h , w5100.h
  • SOCK_CLOSING : w5300.h , w5100.h , w5500.h , w5100s.h , w5200.h
  • SOCK_DGRAM : w5300.h , w5500.h
  • SOCK_ERROR : socket.h
  • SOCK_ESTABLISHED : w5300.h , w5100.h , w5200.h , w5100s.h , w5500.h
  • SOCK_FATAL : socket.h
  • SOCK_FIN_WAIT : w5100s.h , w5300.h , w5100.h , w5500.h , w5200.h
  • SOCK_INIT : w5100.h , w5500.h , w5100s.h , w5200.h , w5300.h
  • SOCK_IO_BLOCK : socket.h
  • SOCK_IO_NONBLOCK : socket.h
  • SOCK_IPRAW : w5300.h , w5200.h , w5100s.h , w5500.h , w5100.h
  • SOCK_LAST_ACK : w5100.h , w5500.h , w5200.h , w5100s.h , w5300.h
  • SOCK_LISTEN : w5300.h , w5100s.h , w5500.h , w5100.h , w5200.h
  • SOCK_MACRAW : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.h
  • SOCK_OK : socket.h
  • SOCK_PPPOE : w5100.h
  • SOCK_PPPoE : w5300.h
  • SOCK_PPPOE : w5100s.h , w5200.h
  • SOCK_STREAM : w5500.h , w5300.h
  • SOCK_SYNRECV : w5100s.h , w5100.h , w5200.h , w5300.h , w5500.h
  • SOCK_SYNSENT : w5200.h , w5100.h , w5500.h , w5300.h , w5100s.h
  • SOCK_TFTP : tftp.h
  • SOCK_TIME_WAIT : w5500.h , w5300.h , w5100s.h , w5200.h , w5100.h
  • SOCK_UDP : w5100.h , w5100s.h , w5500.h , w5200.h , w5300.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
  • STATE_ACK : tftp.h
  • STATE_DATA : tftp.h
  • STATE_DHCP_DISCOVER : dhcp.c
  • STATE_DHCP_INIT : dhcp.c
  • STATE_DHCP_LEASED : dhcp.c
  • STATE_DHCP_RELEASE : dhcp.c
  • STATE_DHCP_REQUEST : dhcp.c
  • STATE_DHCP_REREQUEST : dhcp.c
  • STATE_DHCP_STOP : dhcp.c
  • STATE_HTTP_IDLE : httpServer.h
  • STATE_HTTP_REQ_DONE : httpServer.h
  • STATE_HTTP_REQ_INPROC : httpServer.h
  • STATE_HTTP_RES_DONE : httpServer.h
  • STATE_HTTP_RES_INPROC : httpServer.h
  • STATE_NONE : tftp.h
  • STATE_OACK : tftp.h
  • STATE_RRQ : tftp.h
  • STATE_WRQ : tftp.h
  • STATUS_ACCEPTED : httpParser.h
  • STATUS_BAD_GATEWAY : httpParser.h
  • STATUS_BAD_REQ : httpParser.h
  • STATUS_CREATED : httpParser.h
  • STATUS_FORBIDDEN : httpParser.h
  • STATUS_INT_SERR : httpParser.h
  • STATUS_MV_PERM : httpParser.h
  • STATUS_MV_TEMP : httpParser.h
  • STATUS_NO_CONTENT : httpParser.h
  • STATUS_NOT_FOUND : httpParser.h
  • STATUS_NOT_IMPL : httpParser.h
  • STATUS_NOT_MODIF : httpParser.h
  • STATUS_OK : httpParser.h
  • STATUS_SERV_UNAVAIL : httpParser.h
  • STATUS_UNAUTH : httpParser.h
  • SUBR : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.h
  • SYSTEM_LITTLE_ENDIAN : netutil.h


ioLibrary: Globals

- t -

  • TABLE_FULL : snmp.h
  • TCNTCLKR : w5100s.h
  • TCNTR : w5100s.h
  • TFTP_ACK : tftp.h
  • TFTP_BLK_SIZE : tftp.h
  • TFTP_DATA : tftp.h
  • TFTP_ERROR : tftp.h
  • TFTP_FAIL : tftp.h
  • TFTP_MODE : tftp.h
  • TFTP_OACK : tftp.h
  • TFTP_PROGRESS : tftp.h
  • TFTP_RRQ : tftp.h
  • TFTP_SERVER_PORT : tftp.h
  • TFTP_SUCCESS : tftp.h
  • TFTP_TEMP_PORT : tftp.h
  • TFTP_WRQ : tftp.h
  • TMS01R : w5300.h
  • TMS23R : w5300.h
  • TMS45R : w5300.h
  • TMS67R : w5300.h
  • TMSR : w5100.h , w5100s.h
  • TMSR0 : w5300.h
  • TMSR1 : w5300.h
  • TMSR2 : w5300.h
  • TMSR3 : w5300.h
  • TMSR4 : w5300.h
  • TMSR5 : w5300.h
  • TMSR6 : w5300.h
  • TMSR7 : w5300.h
  • TRANS_ASCII : tftp.h
  • TRANS_BINARY : tftp.h
  • TransferAscii : ftpc.h
  • TransferBinary : ftpc.h
  • TYPE_A : dns.c
  • TYPE_ANY : dns.c
  • TYPE_CNAME : dns.c
  • TYPE_HINFO : dns.c
  • TYPE_MB : dns.c
  • TYPE_MD : dns.c
  • TYPE_MF : dns.c
  • TYPE_MG : dns.c
  • TYPE_MINFO : dns.c
  • TYPE_MR : dns.c
  • TYPE_MX : dns.c
  • TYPE_NS : dns.c
  • TYPE_NULL : dns.c
  • TYPE_PTR : dns.c
  • TYPE_SOA : dns.c
  • TYPE_TXT : dns.c
  • TYPE_WKS : dns.c


ioLibrary: Globals

- u -

  • UIPR : w5100s.h , w5300.h , w5500.h
  • UIPR0 : w5100.h
  • UPORT0 : w5100.h
  • UPORTR : w5300.h , w5500.h , w5100s.h
  • UTC_ADJ_HRS : sntp.h


ioLibrary: Globals

- v -

  • VALID_REQUEST : snmp.h
  • VERR : w5100s.h
  • VERSION : ftpd.h
  • VERSIONR : w5200.h , w5300.h , w5500.h


ioLibrary: Globals

- w -

  • W5100 : wizchip_conf.h
  • W5100S : wizchip_conf.h
  • W5200 : wizchip_conf.h
  • W5300 : wizchip_conf.h
  • W5500 : wizchip_conf.h
  • WIZCHIP_CREG_BLOCK : w5200.h , w5300.h , w5500.h , w5100.h , w5100s.h
  • WIZCHIP_CRITICAL_ENTER : w5100.h , w5100s.h , w5200.h , w5300.h , w5500.h
  • WIZCHIP_CRITICAL_EXIT : w5100.h , w5100s.h , w5200.h , w5500.h , w5300.h
  • WIZCHIP_OFFSET_INC : w5200.h , w5100.h , w5100s.h , w5300.h , w5500.h
  • WIZCHIP_RXBUF_BLOCK : w5500.h
  • WIZCHIP_SREG_BLOCK : w5100s.h , w5300.h , w5100.h , w5500.h , w5200.h
  • WIZCHIP_TXBUF_BLOCK : w5500.h


ioLibrary: image/Berkeley_SOCKET.jpg Source File

  • image
Berkeley_SOCKET.jpg
Go to the documentation of this file.
1


ioLibrary: Internet/FTPClient/stdio_private.h Source File

  • Internet
  • FTPClient
stdio_private.h
Go to the documentation of this file.
1 /* Copyright (c) 2002, Joerg Wunsch
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of the copyright holders nor the names of
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */
31
32 #include <stdint.h>
33 #include <stdio.h>
34
35 struct __file {
36 char *buf; /* buffer pointer */
37 unsigned char unget; /* ungetc() buffer */
38 uint8_t flags; /* flags, see below */
39 #define __SRD 0x0001 /* OK to read */
40 #define __SWR 0x0002 /* OK to write */
41 #define __SSTR 0x0004 /* this is an sprintf/snprintf string */
42 #define __SPGM 0x0008 /* fmt string is in progmem */
43 #define __SERR 0x0010 /* found error */
44 #define __SEOF 0x0020 /* found EOF */
45 #define __SUNGET 0x040 /* ungetc() happened */
46 #if 0
47 /* possible future extensions, will require uint16_t flags */
48 #define __SRW 0x0080 /* open for reading & writing */
49 #define __SLBF 0x0100 /* line buffered */
50 #define __SNBF 0x0200 /* unbuffered */
51 #define __SMBF 0x0400 /* buf is from malloc */
52 #endif
53 int size; /* size of buffer */
54 int len; /* characters read or written so far */
55 int (*put)(char); /* function to write one char to device */
56 int (*get)(void); /* function to read one char from device */
57 };
58
59 /* values for PRINTF_LEVEL */
60 #define PRINTF_MIN 1
61 #define PRINTF_STD 2
62 #define PRINTF_FLT 3
63
64 /* values for SCANF_LEVEL */
65 #define SCANF_MIN 1
66 #define SCANF_STD 2
67 #define SCANF_FLT 3
__file::flags
uint8_t flags
Definition: stdio_private.h:38
__file::len
int len
Definition: stdio_private.h:54
__file
Definition: stdio_private.h:35
__file::buf
char * buf
Definition: stdio_private.h:36
__file::put
int(* put)(char)
Definition: stdio_private.h:55
__file::unget
unsigned char unget
Definition: stdio_private.h:37
__file::size
int size
Definition: stdio_private.h:53


ioLibrary: Internet/FTPServer/stdio_private.h Source File

  • Internet
  • FTPServer
stdio_private.h
Go to the documentation of this file.
1 /* Copyright (c) 2002, Joerg Wunsch
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of the copyright holders nor the names of
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */
31
32 #include <stdint.h>
33 #include <stdio.h>
34
35 struct __file {
36 char *buf; /* buffer pointer */
37 unsigned char unget; /* ungetc() buffer */
38 uint8_t flags; /* flags, see below */
39 #define __SRD 0x0001 /* OK to read */
40 #define __SWR 0x0002 /* OK to write */
41 #define __SSTR 0x0004 /* this is an sprintf/snprintf string */
42 #define __SPGM 0x0008 /* fmt string is in progmem */
43 #define __SERR 0x0010 /* found error */
44 #define __SEOF 0x0020 /* found EOF */
45 #define __SUNGET 0x040 /* ungetc() happened */
46 #if 0
47 /* possible future extensions, will require uint16_t flags */
48 #define __SRW 0x0080 /* open for reading & writing */
49 #define __SLBF 0x0100 /* line buffered */
50 #define __SNBF 0x0200 /* unbuffered */
51 #define __SMBF 0x0400 /* buf is from malloc */
52 #endif
53 int size; /* size of buffer */
54 int len; /* characters read or written so far */
55 int (*put)(char); /* function to write one char to device */
56 int (*get)(void); /* function to read one char from device */
57 };
58
59 /* values for PRINTF_LEVEL */
60 #define PRINTF_MIN 1
61 #define PRINTF_STD 2
62 #define PRINTF_FLT 3
63
64 /* values for SCANF_LEVEL */
65 #define SCANF_MIN 1
66 #define SCANF_STD 2
67 #define SCANF_FLT 3
__file::flags
uint8_t flags
Definition: stdio_private.h:38
__file::len
int len
Definition: stdio_private.h:54
__file
Definition: stdio_private.h:35
__file::buf
char * buf
Definition: stdio_private.h:36
__file::put
int(* put)(char)
Definition: stdio_private.h:55
__file::unget
unsigned char unget
Definition: stdio_private.h:37
__file::size
int size
Definition: stdio_private.h:53


ioLibrary: Internet/MQTT/MQTTClient.c Source File

  • Internet
  • MQTT
MQTTClient.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Allan Stockdill-Mander/Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16 #include "MQTTClient.h"
17
18 static void NewMessageData(MessageData* md, MQTTString* aTopicName, MQTTMessage* aMessage) {
19 md->topicName = aTopicName;
20 md->message = aMessage;
21 }
22
23
24 static int getNextPacketId(MQTTClient *c) {
25 return c->next_packetid = (c->next_packetid == MAX_PACKET_ID) ? 1 : c->next_packetid + 1;
26 }
27
28
29 static int sendPacket(MQTTClient* c, int length, Timer* timer)
30 {
31 int rc = FAILURE,
32 sent = 0;
33
34 while (sent < length && !TimerIsExpired(timer))
35 {
36 rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length, TimerLeftMS(timer));
37 if (rc < 0) // there was an error writing the data
38 break;
39 sent += rc;
40 }
41 if (sent == length)
42 {
43 TimerCountdown(&c->ping_timer, c->keepAliveInterval); // record the fact that we have successfully sent the packet
44 rc = SUCCESSS;
45 }
46 else
47 rc = FAILURE;
48 return rc;
49 }
50
51
52 void MQTTClientInit(MQTTClient* c, Network* network, unsigned int command_timeout_ms,
53 unsigned char* sendbuf, size_t sendbuf_size, unsigned char* readbuf, size_t readbuf_size)
54 {
55 int i;
56 c->ipstack = network;
57
58 for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i)
59 c->messageHandlers[i].topicFilter = 0;
60 c->command_timeout_ms = command_timeout_ms;
61 c->buf = sendbuf;
62 c->buf_size = sendbuf_size;
63 c->readbuf = readbuf;
64 c->readbuf_size = readbuf_size;
65 c->isconnected = 0;
66 c->ping_outstanding = 0;
67 c->defaultMessageHandler = NULL;
68 c->next_packetid = 1;
69 TimerInit(&c->ping_timer);
70 #if defined(MQTT_TASK)
71 MutexInit(&c->mutex);
72 #endif
73 }
74
75
76 static int decodePacket(MQTTClient* c, int* value, int timeout)
77 {
78 unsigned char i;
79 int multiplier = 1;
80 int len = 0;
81 const int MAX_NO_OF_REMAINING_LENGTH_BYTES = 4;
82
83 *value = 0;
84 do
85 {
86 int rc = MQTTPACKET_READ_ERROR;
87
88 if (++len > MAX_NO_OF_REMAINING_LENGTH_BYTES)
89 {
90 rc = MQTTPACKET_READ_ERROR; /* bad data */
91 goto exit;
92 }
93 rc = c->ipstack->mqttread(c->ipstack, &i, 1, timeout);
94 if (rc != 1)
95 goto exit;
96 *value += (i & 127) * multiplier;
97 multiplier *= 128;
98 } while ((i & 128) != 0);
99 exit:
100 return len;
101 }
102
103
104 static int readPacket(MQTTClient* c, Timer* timer)
105 {
106 int rc = FAILURE;
107 MQTTHeader header = {0};
108 int len = 0;
109 int rem_len = 0;
110
111 /* 1. read the header byte. This has the packet type in it */
112 if (c->ipstack->mqttread(c->ipstack, c->readbuf, 1, TimerLeftMS(timer)) != 1)
113 goto exit;
114
115 len = 1;
116 /* 2. read the remaining length. This is variable in itself */
117 decodePacket(c, &rem_len, TimerLeftMS(timer));
118 len += MQTTPacket_encode(c->readbuf + 1, rem_len); /* put the original remaining length back into the buffer */
119
120 /* 3. read the rest of the buffer using a callback to supply the rest of the data */
121 if (rem_len > 0 && (c->ipstack->mqttread(c->ipstack, c->readbuf + len, rem_len, TimerLeftMS(timer)) != rem_len))
122 goto exit;
123
124 header.byte = c->readbuf[0];
125 rc = header.bits.type;
126 exit:
127 return rc;
128 }
129
130
131 // assume topic filter and name is in correct format
132 // # can only be at end
133 // + and # can only be next to separator
134 static char isTopicMatched(char* topicFilter, MQTTString* topicName)
135 {
136 char* curf = topicFilter;
137 char* curn = topicName->lenstring.data;
138 char* curn_end = curn + topicName->lenstring.len;
139
140 while (*curf && curn < curn_end)
141 {
142 if (*curn == '/' && *curf != '/')
143 break;
144 if (*curf != '+' && *curf != '#' && *curf != *curn)
145 break;
146 if (*curf == '+')
147 { // skip until we meet the next separator, or end of string
148 char* nextpos = curn + 1;
149 while (nextpos < curn_end && *nextpos != '/')
150 nextpos = ++curn + 1;
151 }
152 else if (*curf == '#')
153 curn = curn_end - 1; // skip until end of string
154 curf++;
155 curn++;
156 };
157
158 return (curn == curn_end) && (*curf == '\0');
159 }
160
161
162 int deliverMessage(MQTTClient* c, MQTTString* topicName, MQTTMessage* message)
163 {
164 int i;
165 int rc = FAILURE;
166
167 // we have to find the right message handler - indexed by topic
168 for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i)
169 {
170 if (c->messageHandlers[i].topicFilter != 0 && (MQTTPacket_equals(topicName, (char*)c->messageHandlers[i].topicFilter) ||
171 isTopicMatched((char*)c->messageHandlers[i].topicFilter, topicName)))
172 {
173 if (c->messageHandlers[i].fp != NULL)
174 {
175 MessageData md;
176 NewMessageData(&md, topicName, message);
177 c->messageHandlers[i].fp(&md);
178 rc = SUCCESSS;
179 }
180 }
181 }
182
183 if (rc == FAILURE && c->defaultMessageHandler != NULL)
184 {
185 MessageData md;
186 NewMessageData(&md, topicName, message);
187 c->defaultMessageHandler(&md);
188 rc = SUCCESSS;
189 }
190
191 return rc;
192 }
193
194
195 int keepalive(MQTTClient* c)
196 {
197 int rc = FAILURE;
198
199 if (c->keepAliveInterval == 0)
200 {
201 rc = SUCCESSS;
202 goto exit;
203 }
204
205 if (TimerIsExpired(&c->ping_timer))
206 {
207 if (!c->ping_outstanding)
208 {
209 Timer timer;
210 TimerInit(&timer);
211 TimerCountdownMS(&timer, 1000);
212 int len = MQTTSerialize_pingreq(c->buf, c->buf_size);
213 if (len > 0 && (rc = sendPacket(c, len, &timer)) == SUCCESSS) // send the ping packet
214 c->ping_outstanding = 1;
215 }
216 }
217
218 exit:
219 return rc;
220 }
221
222
223 int cycle(MQTTClient* c, Timer* timer)
224 {
225 // read the socket, see what work is due
226 unsigned short packet_type = readPacket(c, timer);
227
228 int len = 0,
229 rc = SUCCESSS;
230
231 switch (packet_type)
232 {
233 case CONNACK:
234 case PUBACK:
235 case SUBACK:
236 break;
237 case PUBLISH:
238 {
239 MQTTString topicName;
240 MQTTMessage msg;
241 int intQoS;
242 if (MQTTDeserialize_publish(&msg.dup, &intQoS, &msg.retained, &msg.id, &topicName,
243 (unsigned char**)&msg.payload, (int*)&msg.payloadlen, c->readbuf, c->readbuf_size) != 1)
244 goto exit;
245 msg.qos = (enum QoS)intQoS;
246 deliverMessage(c, &topicName, &msg);
247 if (msg.qos != QOS0)
248 {
249 if (msg.qos == QOS1)
250 len = MQTTSerialize_ack(c->buf, c->buf_size, PUBACK, 0, msg.id);
251 else if (msg.qos == QOS2)
252 len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREC, 0, msg.id);
253 if (len <= 0)
254 rc = FAILURE;
255 else
256 rc = sendPacket(c, len, timer);
257 if (rc == FAILURE)
258 goto exit; // there was a problem
259 }
260 break;
261 }
262 case PUBREC:
263 {
264 unsigned short mypacketid;
265 unsigned char dup, type;
266 if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1)
267 rc = FAILURE;
268 else if ((len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREL, 0, mypacketid)) <= 0)
269 rc = FAILURE;
270 else if ((rc = sendPacket(c, len, timer)) != SUCCESSS) // send the PUBREL packet
271 rc = FAILURE; // there was a problem
272 if (rc == FAILURE)
273 goto exit; // there was a problem
274 break;
275 }
276 case PUBCOMP:
277 break;
278 case PINGRESP:
279 c->ping_outstanding = 0;
280 break;
281 }
282 keepalive(c);
283 exit:
284 if (rc == SUCCESSS)
285 rc = packet_type;
286 return rc;
287 }
288
289
290 int MQTTYield(MQTTClient* c, int timeout_ms)
291 {
292 int rc = SUCCESSS;
293 Timer timer;
294
295 TimerInit(&timer);
296 TimerCountdownMS(&timer, timeout_ms);
297
298 do
299 {
300 if (cycle(c, &timer) == FAILURE)
301 {
302 rc = FAILURE;
303 break;
304 }
305 } while (!TimerIsExpired(&timer));
306
307 return rc;
308 }
309
310
311 void MQTTRun(void* parm)
312 {
313 Timer timer;
314 MQTTClient* c = (MQTTClient*)parm;
315
316 TimerInit(&timer);
317
318 while (1)
319 {
320 #if defined(MQTT_TASK)
321 MutexLock(&c->mutex);
322 #endif
323 TimerCountdownMS(&timer, 500); /* Don't wait too long if no traffic is incoming */
324 cycle(c, &timer);
325 #if defined(MQTT_TASK)
326 MutexUnlock(&c->mutex);
327 #endif
328 }
329 }
330
331
332 #if defined(MQTT_TASK)
333 int MQTTStartTask(MQTTClient* client)
334 {
335 return ThreadStart(&client->thread, &MQTTRun, client);
336 }
337 #endif
338
339
340 int waitfor(MQTTClient* c, int packet_type, Timer* timer)
341 {
342 int rc = FAILURE;
343
344 do
345 {
346 if (TimerIsExpired(timer))
347 break; // we timed out
348 }
349 while ((rc = cycle(c, timer)) != packet_type);
350
351 return rc;
352 }
353
354
355 int MQTTConnect(MQTTClient* c, MQTTPacket_connectData* options)
356 {
357 Timer connect_timer;
358 int rc = FAILURE;
359 MQTTPacket_connectData default_options = MQTTPacket_connectData_initializer;
360 int len = 0;
361
362 #if defined(MQTT_TASK)
363 MutexLock(&c->mutex);
364 #endif
365 if (c->isconnected) /* don't send connect packet again if we are already connected */
366 goto exit;
367
368 TimerInit(&connect_timer);
369 TimerCountdownMS(&connect_timer, c->command_timeout_ms);
370
371 if (options == 0)
372 options = &default_options; /* set default options if none were supplied */
373
374 c->keepAliveInterval = options->keepAliveInterval;
375 TimerCountdown(&c->ping_timer, c->keepAliveInterval);
376 if ((len = MQTTSerialize_connect(c->buf, c->buf_size, options)) <= 0)
377 goto exit;
378 if ((rc = sendPacket(c, len, &connect_timer)) != SUCCESSS) // send the connect packet
379 goto exit; // there was a problem
380
381 // this will be a blocking call, wait for the connack
382 if (waitfor(c, CONNACK, &connect_timer) == CONNACK)
383 {
384 unsigned char connack_rc = 255;
385 unsigned char sessionPresent = 0;
386 if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, c->readbuf, c->readbuf_size) == 1)
387 rc = connack_rc;
388 else
389 rc = FAILURE;
390 }
391 else
392 rc = FAILURE;
393
394 exit:
395 if (rc == SUCCESSS)
396 c->isconnected = 1;
397
398 #if defined(MQTT_TASK)
399 MutexUnlock(&c->mutex);
400 #endif
401
402 return rc;
403 }
404
405
406 int MQTTSubscribe(MQTTClient* c, const char* topicFilter, enum QoS qos, messageHandler messageHandler)
407 {
408 int rc = FAILURE;
409 Timer timer;
410 int len = 0;
411 MQTTString topic = MQTTString_initializer;
412 topic.cstring = (char *)topicFilter;
413
414 #if defined(MQTT_TASK)
415 MutexLock(&c->mutex);
416 #endif
417 if (!c->isconnected)
418 goto exit;
419
420 TimerInit(&timer);
421 TimerCountdownMS(&timer, c->command_timeout_ms);
422
423 len = MQTTSerialize_subscribe(c->buf, c->buf_size, 0, getNextPacketId(c), 1, &topic, (int*)&qos);
424 if (len <= 0)
425 goto exit;
426 if ((rc = sendPacket(c, len, &timer)) != SUCCESSS) // send the subscribe packet
427 goto exit; // there was a problem
428
429 if (waitfor(c, SUBACK, &timer) == SUBACK) // wait for suback
430 {
431 int count = 0, grantedQoS = -1;
432 unsigned short mypacketid;
433 if (MQTTDeserialize_suback(&mypacketid, 1, &count, &grantedQoS, c->readbuf, c->readbuf_size) == 1)
434 rc = grantedQoS; // 0, 1, 2 or 0x80
435 if (rc != 0x80)
436 {
437 int i;
438 for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i)
439 {
440 if (c->messageHandlers[i].topicFilter == 0)
441 {
442 c->messageHandlers[i].topicFilter = topicFilter;
443 c->messageHandlers[i].fp = messageHandler;
444 rc = 0;
445 break;
446 }
447 }
448 }
449 }
450 else
451 rc = FAILURE;
452
453 exit:
454 #if defined(MQTT_TASK)
455 MutexUnlock(&c->mutex);
456 #endif
457 return rc;
458 }
459
460
461 int MQTTUnsubscribe(MQTTClient* c, const char* topicFilter)
462 {
463 int rc = FAILURE;
464 Timer timer;
465 MQTTString topic = MQTTString_initializer;
466 topic.cstring = (char *)topicFilter;
467 int len = 0;
468
469 #if defined(MQTT_TASK)
470 MutexLock(&c->mutex);
471 #endif
472 if (!c->isconnected)
473 goto exit;
474
475 TimerInit(&timer);
476 TimerCountdownMS(&timer, c->command_timeout_ms);
477
478 if ((len = MQTTSerialize_unsubscribe(c->buf, c->buf_size, 0, getNextPacketId(c), 1, &topic)) <= 0)
479 goto exit;
480 if ((rc = sendPacket(c, len, &timer)) != SUCCESSS) // send the subscribe packet
481 goto exit; // there was a problem
482
483 if (waitfor(c, UNSUBACK, &timer) == UNSUBACK)
484 {
485 unsigned short mypacketid; // should be the same as the packetid above
486 if (MQTTDeserialize_unsuback(&mypacketid, c->readbuf, c->readbuf_size) == 1)
487 rc = 0;
488 }
489 else
490 rc = FAILURE;
491
492 exit:
493 #if defined(MQTT_TASK)
494 MutexUnlock(&c->mutex);
495 #endif
496 return rc;
497 }
498
499
500 int MQTTPublish(MQTTClient* c, const char* topicName, MQTTMessage* message)
501 {
502 int rc = FAILURE;
503 Timer timer;
504 MQTTString topic = MQTTString_initializer;
505 topic.cstring = (char *)topicName;
506 int len = 0;
507
508 #if defined(MQTT_TASK)
509 MutexLock(&c->mutex);
510 #endif
511 if (!c->isconnected)
512 goto exit;
513
514 TimerInit(&timer);
515 TimerCountdownMS(&timer, c->command_timeout_ms);
516
517 if (message->qos == QOS1 || message->qos == QOS2)
518 message->id = getNextPacketId(c);
519
520 len = MQTTSerialize_publish(c->buf, c->buf_size, 0, message->qos, message->retained, message->id,
521 topic, (unsigned char*)message->payload, message->payloadlen);
522 if (len <= 0)
523 goto exit;
524 if ((rc = sendPacket(c, len, &timer)) != SUCCESSS) // send the subscribe packet
525 goto exit; // there was a problem
526
527 if (message->qos == QOS1)
528 {
529 if (waitfor(c, PUBACK, &timer) == PUBACK)
530 {
531 unsigned short mypacketid;
532 unsigned char dup, type;
533 if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1)
534 rc = FAILURE;
535 }
536 else
537 rc = FAILURE;
538 }
539 else if (message->qos == QOS2)
540 {
541 if (waitfor(c, PUBCOMP, &timer) == PUBCOMP)
542 {
543 unsigned short mypacketid;
544 unsigned char dup, type;
545 if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1)
546 rc = FAILURE;
547 }
548 else
549 rc = FAILURE;
550 }
551
552 exit:
553 #if defined(MQTT_TASK)
554 MutexUnlock(&c->mutex);
555 #endif
556 return rc;
557 }
558
559
560 int MQTTDisconnect(MQTTClient* c)
561 {
562 int rc = FAILURE;
563 Timer timer; // we might wait for incomplete incoming publishes to complete
564 int len = 0;
565
566 #if defined(MQTT_TASK)
567 MutexLock(&c->mutex);
568 #endif
569 TimerInit(&timer);
570 TimerCountdownMS(&timer, c->command_timeout_ms);
571
572 len = MQTTSerialize_disconnect(c->buf, c->buf_size);
573 if (len > 0)
574 rc = sendPacket(c, len, &timer); // send the disconnect packet
575
576 c->isconnected = 0;
577
578 #if defined(MQTT_TASK)
579 MutexUnlock(&c->mutex);
580 #endif
581 return rc;
582 }
583
MQTTClientInit
void MQTTClientInit(MQTTClient *c, Network *network, unsigned int command_timeout_ms, unsigned char *sendbuf, size_t sendbuf_size, unsigned char *readbuf, size_t readbuf_size)
Definition: MQTTClient.c:52
MQTTMessage::payloadlen
size_t payloadlen
Definition: MQTTClient.h:75
MQTTClient::command_timeout_ms
unsigned int command_timeout_ms
Definition: MQTTClient.h:88
MessageData::topicName
MQTTString * topicName
Definition: MQTTClient.h:81
MessageData
Definition: MQTTClient.h:78
QoS
QoS
Definition: MQTTClient.h:46
MQTTMessage::retained
unsigned char retained
Definition: MQTTClient.h:71
MQTTMessage
Definition: MQTTClient.h:68
PUBLISH
Definition: MQTTPacket.h:45
MQTTMessage::payload
void * payload
Definition: MQTTClient.h:74
waitfor
int waitfor(MQTTClient *c, int packet_type, Timer *timer)
Definition: MQTTClient.c:340
MQTTHeader::bits
struct MQTTHeader::@6 bits
Network::mqttwrite
int(* mqttwrite)(Network *, unsigned char *, int, int)
Definition: mqtt_interface.h:238
QOS2
Definition: MQTTClient.h:46
QOS1
Definition: MQTTClient.h:46
MQTTClient::buf
unsigned char * buf
Definition: MQTTClient.h:92
MQTTSerialize_pingreq
DLLExport int MQTTSerialize_pingreq(unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:211
MessageData::message
MQTTMessage * message
Definition: MQTTClient.h:80
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
MQTTSerialize_connect
DLLExport int MQTTSerialize_connect(unsigned char *buf, int buflen, MQTTPacket_connectData *options)
Definition: MQTTConnectClient.c:58
keepalive
int keepalive(MQTTClient *c)
Definition: MQTTClient.c:195
TimerLeftMS
int TimerLeftMS(Timer *timer)
Definition: mqtt_interface.c:100
PUBREL
Definition: MQTTPacket.h:45
Network::mqttread
int(* mqttread)(Network *, unsigned char *, int, int)
Definition: mqtt_interface.h:237
MQTTDisconnect
int MQTTDisconnect(MQTTClient *c)
Definition: MQTTClient.c:560
MQTTSerialize_publish
DLLExport int MQTTSerialize_publish(unsigned char *buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
Definition: MQTTSerializePublish.c:55
MQTTClient::ping_outstanding
char ping_outstanding
Definition: MQTTClient.h:95
MQTTDeserialize_unsuback
DLLExport int MQTTDeserialize_unsuback(unsigned short *packetid, unsigned char *buf, int len)
Definition: MQTTUnsubscribeClient.c:92
MQTTDeserialize_publish
int MQTTDeserialize_publish(unsigned char *dup, int *qos, unsigned char *retained, unsigned short *packetid, MQTTString *topicName, unsigned char **payload, int *payloadlen, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:36
PUBREC
Definition: MQTTPacket.h:45
MAX_PACKET_ID
#define MAX_PACKET_ID
Definition: MQTTClient.h:40
MQTTClient::ipstack
Network * ipstack
Definition: MQTTClient.h:106
TimerCountdownMS
void TimerCountdownMS(Timer *timer, unsigned int timeout)
Definition: mqtt_interface.c:81
FAILURE
Definition: MQTTClient.h:49
MQTTClient
Definition: MQTTClient.h:86
MQTTDeserialize_connack
DLLExport int MQTTDeserialize_connack(unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:132
MQTTClient::readbuf_size
size_t readbuf_size
Definition: MQTTClient.h:90
CONNACK
Definition: MQTTPacket.h:45
MQTTClient::defaultMessageHandler
void(* defaultMessageHandler)(MessageData *)
Definition: MQTTClient.h:104
MQTTClient::messageHandlers
struct MQTTClient::MessageHandlers messageHandlers[MAX_MESSAGE_HANDLERS]
MQTTSerialize_disconnect
DLLExport int MQTTSerialize_disconnect(unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:199
MQTTLenString::data
char * data
Definition: MQTTPacket.h:78
TimerInit
void TimerInit(Timer *timer)
Definition: mqtt_interface.c:61
MQTTRun
void MQTTRun(void *parm)
Definition: MQTTClient.c:311
MQTTClient::buf_size
size_t buf_size
Definition: MQTTClient.h:90
MQTTSerialize_ack
int MQTTSerialize_ack(unsigned char *buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid)
Definition: MQTTSerializePublish.c:104
MQTTPacket_equals
int MQTTPacket_equals(MQTTString *a, char *bptr)
Definition: MQTTPacket.c:260
MQTTLenString::len
int len
Definition: MQTTPacket.h:77
MAX_MESSAGE_HANDLERS
#define MAX_MESSAGE_HANDLERS
Definition: MQTTClient.h:43
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTUnsubscribe
int MQTTUnsubscribe(MQTTClient *c, const char *topicFilter)
Definition: MQTTClient.c:461
Timer
Definition: mqtt_interface.h:225
MQTTString::lenstring
MQTTLenString lenstring
Definition: MQTTPacket.h:84
PINGRESP
Definition: MQTTPacket.h:47
MQTTConnect
int MQTTConnect(MQTTClient *c, MQTTPacket_connectData *options)
Definition: MQTTClient.c:355
MQTTPacket_connectData::keepAliveInterval
unsigned short keepAliveInterval
Definition: MQTTConnect.h:98
MAX_NO_OF_REMAINING_LENGTH_BYTES
#define MAX_NO_OF_REMAINING_LENGTH_BYTES
SUBACK
Definition: MQTTPacket.h:46
MQTTClient::keepAliveInterval
unsigned int keepAliveInterval
Definition: MQTTClient.h:94
MQTTPACKET_READ_ERROR
Definition: MQTTPacket.h:39
MQTTSerialize_subscribe
DLLExport int MQTTSerialize_subscribe(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
Definition: MQTTSubscribeClient.c:50
TimerCountdown
void TimerCountdown(Timer *timer, unsigned int timeout)
Definition: mqtt_interface.c:91
deliverMessage
int deliverMessage(MQTTClient *c, MQTTString *topicName, MQTTMessage *message)
Definition: MQTTClient.c:162
MQTTMessage::qos
enum QoS qos
Definition: MQTTClient.h:70
TimerIsExpired
char TimerIsExpired(Timer *timer)
Definition: mqtt_interface.c:70
MQTTSubscribe
int MQTTSubscribe(MQTTClient *c, const char *topicFilter, enum QoS qos, messageHandler messageHandler)
Definition: MQTTClient.c:406
MQTTClient::MessageHandlers::topicFilter
const char * topicFilter
Definition: MQTTClient.h:100
PUBACK
Definition: MQTTPacket.h:45
MQTTClient::isconnected
int isconnected
Definition: MQTTClient.h:96
MQTTClient::readbuf
unsigned char * readbuf
Definition: MQTTClient.h:92
MQTTDeserialize_ack
int MQTTDeserialize_ack(unsigned char *packettype, unsigned char *dup, unsigned short *packetid, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:82
MQTTMessage::id
unsigned short id
Definition: MQTTClient.h:73
MQTTSerialize_unsubscribe
DLLExport int MQTTSerialize_unsubscribe(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
Definition: MQTTUnsubscribeClient.c:49
MQTTClient::MessageHandlers::fp
void(* fp)(MessageData *)
Definition: MQTTClient.h:101
MQTTString::cstring
char * cstring
Definition: MQTTPacket.h:83
MQTTClient.h
SUCCESSS
Definition: MQTTClient.h:49
MQTTMessage::dup
unsigned char dup
Definition: MQTTClient.h:72
MQTTYield
int MQTTYield(MQTTClient *c, int timeout_ms)
Definition: MQTTClient.c:290
MQTTDeserialize_suback
DLLExport int MQTTDeserialize_suback(unsigned short *packetid, int maxcount, int *count, int grantedQoSs[], unsigned char *buf, int len)
Definition: MQTTSubscribeClient.c:100
MQTTPacket_connectData
Definition: MQTTConnect.h:88
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
QOS0
Definition: MQTTClient.h:46
MQTTPublish
int MQTTPublish(MQTTClient *c, const char *topicName, MQTTMessage *message)
Definition: MQTTClient.c:500
messageHandler
void(* messageHandler)(MessageData *)
Definition: MQTTClient.h:84
MQTTString_initializer
#define MQTTString_initializer
Definition: MQTTPacket.h:87
MQTTClient::next_packetid
unsigned int next_packetid
Definition: MQTTClient.h:88
MQTTHeader
Definition: MQTTPacket.h:53
cycle
int cycle(MQTTClient *c, Timer *timer)
Definition: MQTTClient.c:223
UNSUBACK
Definition: MQTTPacket.h:46
MQTTPacket_connectData_initializer
#define MQTTPacket_connectData_initializer
Definition: MQTTConnect.h:124
Network
Definition: mqtt_interface.h:234
PUBCOMP
Definition: MQTTPacket.h:46
MQTTClient::ping_timer
Timer ping_timer
Definition: MQTTClient.h:107


ioLibrary: Internet/MQTT/MQTTClient.h Source File

  • Internet
  • MQTT
MQTTClient.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Allan Stockdill-Mander/Ian Craggs - initial API and implementation and/or initial documentation
15 * Ian Craggs - documentation and platform specific header
16 *******************************************************************************/
17
18 #if !defined(__MQTT_CLIENT_C_)
19 #define __MQTT_CLIENT_C_
20
21 #if defined(__cplusplus)
22 extern "C" {
23 #endif
24
25 #if defined(WIN32_DLL) || defined(WIN64_DLL)
26 #define DLLImport __declspec(dllimport)
27 #define DLLExport __declspec(dllexport)
28 #elif defined(LINUX_SO)
29 #define DLLImport extern
30 #define DLLExport __attribute__ ((visibility ("default")))
31 #else
32 #define DLLImport
33 #define DLLExport
34 #endif
35
36 #include "./MQTTPacket/src/MQTTPacket.h"
37 #include "stdio.h"
38 #include "mqtt_interface.h"
39
40 #define MAX_PACKET_ID 65535 /* according to the MQTT specification - do not change! */
41
42 #if !defined(MAX_MESSAGE_HANDLERS)
43 #define MAX_MESSAGE_HANDLERS 5 /* redefinable - how many subscriptions do you want? */
44 #endif
45
46 enum QoS { QOS0, QOS1, QOS2 };
47
48 /* all failure return codes must be negative */
49 enum returnCode { BUFFER_OVERFLOW = -2, FAILURE = -1, SUCCESSS = 0 };
50
51 /* The Platform specific header must define the Network and Timer structures and functions
52 * which operate on them.
53 *
54 typedef struct Network
55 {
56 int (*mqttread)(Network*, unsigned char* read_buffer, int, int);
57 int (*mqttwrite)(Network*, unsigned char* send_buffer, int, int);
58 } Network;*/
59
60 /* The Timer structure must be defined in the platform specific header,
61 * and have the following functions to operate on it. */
62 extern void TimerInit(Timer*);
63 extern char TimerIsExpired(Timer*);
64 extern void TimerCountdownMS(Timer*, unsigned int);
65 extern void TimerCountdown(Timer*, unsigned int);
66 extern int TimerLeftMS(Timer*);
67
68 typedef struct MQTTMessage
69 {
70 enum QoS qos;
71 unsigned char retained;
72 unsigned char dup;
73 unsigned short id;
74 void *payload;
75 size_t payloadlen;
76 } MQTTMessage;
77
78 typedef struct MessageData
79 {
80 MQTTMessage* message;
81 MQTTString* topicName;
82 } MessageData;
83
84 typedef void (*messageHandler)(MessageData*);
85
86 typedef struct MQTTClient
87 {
88 unsigned int next_packetid,
89 command_timeout_ms;
90 size_t buf_size,
91 readbuf_size;
92 unsigned char *buf,
93 *readbuf;
94 unsigned int keepAliveInterval;
95 char ping_outstanding;
96 int isconnected;
97
98 struct MessageHandlers
99 {
100 const char* topicFilter;
101 void (*fp) (MessageData*);
102 } messageHandlers[MAX_MESSAGE_HANDLERS]; /* Message handlers are indexed by subscription topic */
103
104 void (*defaultMessageHandler) (MessageData*);
105
106 Network* ipstack;
107 Timer ping_timer;
108 #if defined(MQTT_TASK)
109 Mutex mutex;
110 Thread thread;
111 #endif
112 } MQTTClient;
113
114 #define DefaultClient {0, 0, 0, 0, NULL, NULL, 0, 0, 0}
115
116
124 DLLExport void MQTTClientInit(MQTTClient* client, Network* network, unsigned int command_timeout_ms,
125 unsigned char* sendbuf, size_t sendbuf_size, unsigned char* readbuf, size_t readbuf_size);
126
132 DLLExport int MQTTConnect(MQTTClient* client, MQTTPacket_connectData* options);
133
140 DLLExport int MQTTPublish(MQTTClient* client, const char*, MQTTMessage*);
141
148 DLLExport int MQTTSubscribe(MQTTClient* client, const char* topicFilter, enum QoS, messageHandler);
149
155 DLLExport int MQTTUnsubscribe(MQTTClient* client, const char* topicFilter);
156
161 DLLExport int MQTTDisconnect(MQTTClient* client);
162
168 DLLExport int MQTTYield(MQTTClient* client, int time);
169
170 #if defined(MQTT_TASK)
171
175 DLLExport int MQTTStartTask(MQTTClient* client);
176 #endif
177
178 #if defined(__cplusplus)
179 }
180 #endif
181
182 #endif
MQTTMessage::payloadlen
size_t payloadlen
Definition: MQTTClient.h:75
MQTTClient::command_timeout_ms
unsigned int command_timeout_ms
Definition: MQTTClient.h:88
MessageData::topicName
MQTTString * topicName
Definition: MQTTClient.h:81
MessageData
Definition: MQTTClient.h:78
QoS
QoS
Definition: MQTTClient.h:46
MQTTMessage::retained
unsigned char retained
Definition: MQTTClient.h:71
MQTTMessage
Definition: MQTTClient.h:68
MQTTMessage::payload
void * payload
Definition: MQTTClient.h:74
QOS2
Definition: MQTTClient.h:46
QOS1
Definition: MQTTClient.h:46
MQTTClient::buf
unsigned char * buf
Definition: MQTTClient.h:92
MQTTUnsubscribe
DLLExport int MQTTUnsubscribe(MQTTClient *client, const char *topicFilter)
Definition: MQTTClient.c:461
MessageData::message
MQTTMessage * message
Definition: MQTTClient.h:80
MessageData
struct MessageData MessageData
MQTTDisconnect
DLLExport int MQTTDisconnect(MQTTClient *client)
Definition: MQTTClient.c:560
MQTTConnect
DLLExport int MQTTConnect(MQTTClient *client, MQTTPacket_connectData *options)
Definition: MQTTClient.c:355
mqtt_interface.h
Paho MQTT to WIZnet Chip interface Header file.
TimerCountdown
void TimerCountdown(Timer *, unsigned int)
Definition: mqtt_interface.c:91
MQTTString
Definition: MQTTPacket.h:81
MQTTClient::ping_outstanding
char ping_outstanding
Definition: MQTTClient.h:95
MQTTClient::ipstack
Network * ipstack
Definition: MQTTClient.h:106
FAILURE
Definition: MQTTClient.h:49
MQTTClient
Definition: MQTTClient.h:86
MQTTClient::readbuf_size
size_t readbuf_size
Definition: MQTTClient.h:90
MQTTClient::defaultMessageHandler
void(* defaultMessageHandler)(MessageData *)
Definition: MQTTClient.h:104
MQTTClient::messageHandlers
struct MQTTClient::MessageHandlers messageHandlers[MAX_MESSAGE_HANDLERS]
TimerInit
void TimerInit(Timer *)
Definition: mqtt_interface.c:61
TimerIsExpired
char TimerIsExpired(Timer *)
Definition: mqtt_interface.c:70
MQTTClient::buf_size
size_t buf_size
Definition: MQTTClient.h:90
MQTTSubscribe
DLLExport int MQTTSubscribe(MQTTClient *client, const char *topicFilter, enum QoS, messageHandler)
Definition: MQTTClient.c:406
MAX_MESSAGE_HANDLERS
#define MAX_MESSAGE_HANDLERS
Definition: MQTTClient.h:43
Timer
Definition: mqtt_interface.h:225
TimerLeftMS
int TimerLeftMS(Timer *)
Definition: mqtt_interface.c:100
MQTTPacket.h
MQTTClient
struct MQTTClient MQTTClient
MQTTClient::keepAliveInterval
unsigned int keepAliveInterval
Definition: MQTTClient.h:94
MQTTClient::MessageHandlers
Definition: MQTTClient.h:98
MQTTMessage::qos
enum QoS qos
Definition: MQTTClient.h:70
MQTTClient::MessageHandlers::topicFilter
const char * topicFilter
Definition: MQTTClient.h:100
MQTTClient::isconnected
int isconnected
Definition: MQTTClient.h:96
BUFFER_OVERFLOW
Definition: MQTTClient.h:49
MQTTClient::readbuf
unsigned char * readbuf
Definition: MQTTClient.h:92
MQTTMessage
struct MQTTMessage MQTTMessage
MQTTMessage::id
unsigned short id
Definition: MQTTClient.h:73
TimerCountdownMS
void TimerCountdownMS(Timer *, unsigned int)
Definition: mqtt_interface.c:81
returnCode
returnCode
Definition: MQTTClient.h:49
MQTTClient::MessageHandlers::fp
void(* fp)(MessageData *)
Definition: MQTTClient.h:101
DLLExport
#define DLLExport
Definition: MQTTClient.h:33
SUCCESSS
Definition: MQTTClient.h:49
MQTTMessage::dup
unsigned char dup
Definition: MQTTClient.h:72
MQTTPacket_connectData
Definition: MQTTConnect.h:88
QOS0
Definition: MQTTClient.h:46
MQTTClientInit
DLLExport void MQTTClientInit(MQTTClient *client, Network *network, unsigned int command_timeout_ms, unsigned char *sendbuf, size_t sendbuf_size, unsigned char *readbuf, size_t readbuf_size)
Definition: MQTTClient.c:52
messageHandler
void(* messageHandler)(MessageData *)
Definition: MQTTClient.h:84
MQTTYield
DLLExport int MQTTYield(MQTTClient *client, int time)
Definition: MQTTClient.c:290
MQTTClient::next_packetid
unsigned int next_packetid
Definition: MQTTClient.h:88
MQTTPublish
DLLExport int MQTTPublish(MQTTClient *client, const char *, MQTTMessage *)
Definition: MQTTClient.c:500
Network
Definition: mqtt_interface.h:234
MQTTClient::ping_timer
Timer ping_timer
Definition: MQTTClient.h:107


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTConnect.h Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTConnect.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Xiang Rong - 442039 Add makefile to Embedded C client
16 *******************************************************************************/
17
18 #ifndef MQTTCONNECT_H_
19 #define MQTTCONNECT_H_
20
21 #if !defined(DLLImport)
22 #define DLLImport
23 #endif
24 #if !defined(DLLExport)
25 #define DLLExport
26 #endif
27
28
29 typedef union
30 {
31 unsigned char all;
32 #if defined(REVERSED)
33 struct
34 {
35 unsigned int username : 1;
36 unsigned int password : 1;
37 unsigned int willRetain : 1;
38 unsigned int willQoS : 2;
39 unsigned int will : 1;
40 unsigned int cleansession : 1;
41 unsigned int : 1;
42 } bits;
43 #else
44 struct
45 {
46 unsigned int : 1;
47 unsigned int cleansession : 1;
48 unsigned int will : 1;
49 unsigned int willQoS : 2;
50 unsigned int willRetain : 1;
51 unsigned int password : 1;
52 unsigned int username : 1;
53 } bits;
54 #endif
55 } MQTTConnectFlags;
63 typedef struct
64 {
66 char struct_id[4];
68 int struct_version;
70 MQTTString topicName;
72 MQTTString message;
76 unsigned char retained;
81 char qos;
82 } MQTTPacket_willOptions;
83
84
85 #define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 }
86
87
88 typedef struct
89 {
91 char struct_id[4];
93 int struct_version;
96 unsigned char MQTTVersion;
97 MQTTString clientID;
98 unsigned short keepAliveInterval;
99 unsigned char cleansession;
100 unsigned char willFlag;
101 MQTTPacket_willOptions will;
102 MQTTString username;
103 MQTTString password;
104 } MQTTPacket_connectData;
105
106 typedef union
107 {
108 unsigned char all;
109 #if defined(REVERSED)
110 struct
111 {
112 unsigned int sessionpresent : 1;
113 unsigned int : 7;
114 } bits;
115 #else
116 struct
117 {
118 unsigned int : 7;
119 unsigned int sessionpresent : 1;
120 } bits;
121 #endif
122 } MQTTConnackFlags;
124 #define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \
125 MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }
126
127 DLLExport int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options);
128 DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len);
129
130 DLLExport int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent);
131 DLLExport int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen);
132
133 DLLExport int MQTTSerialize_disconnect(unsigned char* buf, int buflen);
134 DLLExport int MQTTSerialize_pingreq(unsigned char* buf, int buflen);
135
136 #endif /* MQTTCONNECT_H_ */
MQTTConnackFlags::sessionpresent
unsigned int sessionpresent
Definition: MQTTConnect.h:119
MQTTPacket_connectData::username
MQTTString username
Definition: MQTTConnect.h:102
MQTTConnectFlags
Definition: MQTTConnect.h:29
MQTTConnectFlags::username
unsigned int username
Definition: MQTTConnect.h:52
MQTTPacket_connectData::clientID
MQTTString clientID
Definition: MQTTConnect.h:97
MQTTSerialize_connack
DLLExport int MQTTSerialize_connack(unsigned char *buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
Definition: MQTTConnectServer.c:119
MQTTSerialize_pingreq
DLLExport int MQTTSerialize_pingreq(unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:211
MQTTConnectFlags::cleansession
unsigned int cleansession
Definition: MQTTConnect.h:47
MQTTString
Definition: MQTTPacket.h:81
MQTTSerialize_connect
DLLExport int MQTTSerialize_connect(unsigned char *buf, int buflen, MQTTPacket_connectData *options)
Definition: MQTTConnectClient.c:58
MQTTPacket_connectData::cleansession
unsigned char cleansession
Definition: MQTTConnect.h:99
MQTTPacket_willOptions::message
MQTTString message
Definition: MQTTConnect.h:72
MQTTDeserialize_connack
DLLExport int MQTTDeserialize_connack(unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:132
MQTTSerialize_disconnect
DLLExport int MQTTSerialize_disconnect(unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:199
MQTTConnectFlags::int
unsigned int
Definition: MQTTConnect.h:46
MQTTConnectFlags::password
unsigned int password
Definition: MQTTConnect.h:51
MQTTPacket_willOptions
Definition: MQTTConnect.h:63
MQTTPacket_willOptions::topicName
MQTTString topicName
Definition: MQTTConnect.h:70
MQTTPacket_connectData::struct_version
int struct_version
Definition: MQTTConnect.h:93
MQTTPacket_willOptions::struct_version
int struct_version
Definition: MQTTConnect.h:68
MQTTPacket_connectData::willFlag
unsigned char willFlag
Definition: MQTTConnect.h:100
MQTTConnectFlags::will
unsigned int will
Definition: MQTTConnect.h:48
MQTTPacket_connectData::will
MQTTPacket_willOptions will
Definition: MQTTConnect.h:101
MQTTConnectFlags::willRetain
unsigned int willRetain
Definition: MQTTConnect.h:50
MQTTPacket_willOptions::qos
char qos
Definition: MQTTConnect.h:81
MQTTPacket_connectData::keepAliveInterval
unsigned short keepAliveInterval
Definition: MQTTConnect.h:98
MQTTPacket_willOptions::retained
unsigned char retained
Definition: MQTTConnect.h:76
MQTTPacket_connectData::MQTTVersion
unsigned char MQTTVersion
Definition: MQTTConnect.h:96
MQTTConnackFlags::int
unsigned int
Definition: MQTTConnect.h:118
MQTTPacket_connectData::password
MQTTString password
Definition: MQTTConnect.h:103
MQTTConnackFlags
Definition: MQTTConnect.h:106
MQTTDeserialize_connect
DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData *data, unsigned char *buf, int len)
Definition: MQTTConnectServer.c:51
MQTTConnectFlags::all
unsigned char all
Definition: MQTTConnect.h:31
MQTTConnackFlags::all
unsigned char all
Definition: MQTTConnect.h:108
MQTTConnectFlags::willQoS
unsigned int willQoS
Definition: MQTTConnect.h:49
DLLExport
#define DLLExport
Definition: MQTTConnect.h:25
MQTTPacket_connectData
Definition: MQTTConnect.h:88


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTConnectClient.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTConnectClient.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "MQTTPacket.h"
18 #include "StackTrace.h"
19
20 #include <string.h>
21
27 int MQTTSerialize_connectLength(MQTTPacket_connectData* options)
28 {
29 int len = 0;
30
31 FUNC_ENTRY;
32
33 if (options->MQTTVersion == 3)
34 len = 12; /* variable depending on MQTT or MQIsdp */
35 else if (options->MQTTVersion == 4)
36 len = 10;
37
38 len += MQTTstrlen(options->clientID)+2;
39 if (options->willFlag)
40 len += MQTTstrlen(options->will.topicName)+2 + MQTTstrlen(options->will.message)+2;
41 if (options->username.cstring || options->username.lenstring.data)
42 len += MQTTstrlen(options->username)+2;
43 if (options->password.cstring || options->password.lenstring.data)
44 len += MQTTstrlen(options->password)+2;
45
46 FUNC_EXIT_RC(len);
47 return len;
48 }
49
50
58 int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options)
59 {
60 unsigned char *ptr = buf;
61 MQTTHeader header = {0};
62 MQTTConnectFlags flags = {0};
63 int len = 0;
64 int rc = -1;
65
66 FUNC_ENTRY;
67 if (MQTTPacket_len(len = MQTTSerialize_connectLength(options)) > buflen)
68 {
69 rc = MQTTPACKET_BUFFER_TOO_SHORT;
70 goto exit;
71 }
72
73 header.byte = 0;
74 header.bits.type = CONNECT;
75 writeChar(&ptr, header.byte); /* write header */
76
77 ptr += MQTTPacket_encode(ptr, len); /* write remaining length */
78
79 if (options->MQTTVersion == 4)
80 {
81 writeCString(&ptr, "MQTT");
82 writeChar(&ptr, (char) 4);
83 }
84 else
85 {
86 writeCString(&ptr, "MQIsdp");
87 writeChar(&ptr, (char) 3);
88 }
89
90 flags.all = 0;
91 flags.bits.cleansession = options->cleansession;
92 flags.bits.will = (options->willFlag) ? 1 : 0;
93 if (flags.bits.will)
94 {
95 flags.bits.willQoS = options->will.qos;
96 flags.bits.willRetain = options->will.retained;
97 }
98
99 if (options->username.cstring || options->username.lenstring.data)
100 flags.bits.username = 1;
101 if (options->password.cstring || options->password.lenstring.data)
102 flags.bits.password = 1;
103
104 writeChar(&ptr, flags.all);
105 writeInt(&ptr, options->keepAliveInterval);
106 writeMQTTString(&ptr, options->clientID);
107 if (options->willFlag)
108 {
109 writeMQTTString(&ptr, options->will.topicName);
110 writeMQTTString(&ptr, options->will.message);
111 }
112 if (flags.bits.username)
113 writeMQTTString(&ptr, options->username);
114 if (flags.bits.password)
115 writeMQTTString(&ptr, options->password);
116
117 rc = ptr - buf;
118
119 exit: FUNC_EXIT_RC(rc);
120 return rc;
121 }
122
123
132 int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen)
133 {
134 MQTTHeader header = {0};
135 unsigned char* curdata = buf;
136 unsigned char* enddata = NULL;
137 int rc = 0;
138 int mylen;
139 MQTTConnackFlags flags = {0};
140
141 FUNC_ENTRY;
142 header.byte = readChar(&curdata);
143 if (header.bits.type != CONNACK)
144 goto exit;
145
146 curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
147 enddata = curdata + mylen;
148 if (enddata - curdata < 2)
149 goto exit;
150
151 flags.all = readChar(&curdata);
152 *sessionPresent = flags.bits.sessionpresent;
153 *connack_rc = readChar(&curdata);
154
155 rc = 1;
156 exit:
157 FUNC_EXIT_RC(rc);
158 return rc;
159 }
160
161
169 int MQTTSerialize_zero(unsigned char* buf, int buflen, unsigned char packettype)
170 {
171 MQTTHeader header = {0};
172 int rc = -1;
173 unsigned char *ptr = buf;
174
175 FUNC_ENTRY;
176 if (buflen < 2)
177 {
178 rc = MQTTPACKET_BUFFER_TOO_SHORT;
179 goto exit;
180 }
181 header.byte = 0;
182 header.bits.type = packettype;
183 writeChar(&ptr, header.byte); /* write header */
184
185 ptr += MQTTPacket_encode(ptr, 0); /* write remaining length */
186 rc = ptr - buf;
187 exit:
188 FUNC_EXIT_RC(rc);
189 return rc;
190 }
191
192
199 int MQTTSerialize_disconnect(unsigned char* buf, int buflen)
200 {
201 return MQTTSerialize_zero(buf, buflen, DISCONNECT);
202 }
203
204
211 int MQTTSerialize_pingreq(unsigned char* buf, int buflen)
212 {
213 return MQTTSerialize_zero(buf, buflen, PINGREQ);
214 }
MQTTConnackFlags::sessionpresent
unsigned int sessionpresent
Definition: MQTTConnect.h:119
MQTTPacket_connectData::username
MQTTString username
Definition: MQTTConnect.h:102
MQTTSerialize_connect
int MQTTSerialize_connect(unsigned char *buf, int buflen, MQTTPacket_connectData *options)
Definition: MQTTConnectClient.c:58
MQTTConnectFlags
Definition: MQTTConnect.h:29
MQTTConnectFlags::username
unsigned int username
Definition: MQTTConnect.h:52
MQTTHeader::bits
struct MQTTHeader::@6 bits
MQTTPacket_connectData::clientID
MQTTString clientID
Definition: MQTTConnect.h:97
writeCString
void writeCString(unsigned char **pptr, const char *string)
Definition: MQTTPacket.c:178
MQTTConnectFlags::cleansession
unsigned int cleansession
Definition: MQTTConnect.h:47
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTPacket_connectData::cleansession
unsigned char cleansession
Definition: MQTTConnect.h:99
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTSerialize_zero
int MQTTSerialize_zero(unsigned char *buf, int buflen, unsigned char packettype)
Definition: MQTTConnectClient.c:169
MQTTPacket_willOptions::message
MQTTString message
Definition: MQTTConnect.h:72
MQTTSerialize_connectLength
int MQTTSerialize_connectLength(MQTTPacket_connectData *options)
Definition: MQTTConnectClient.c:27
CONNACK
Definition: MQTTPacket.h:45
MQTTLenString::data
char * data
Definition: MQTTPacket.h:78
MQTTConnectFlags::password
unsigned int password
Definition: MQTTConnect.h:51
MQTTSerialize_disconnect
int MQTTSerialize_disconnect(unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:199
MQTTPacket_willOptions::topicName
MQTTString topicName
Definition: MQTTConnect.h:70
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTPacket_connectData::willFlag
unsigned char willFlag
Definition: MQTTConnect.h:100
MQTTConnectFlags::will
unsigned int will
Definition: MQTTConnect.h:48
MQTTPacket_connectData::will
MQTTPacket_willOptions will
Definition: MQTTConnect.h:101
MQTTPacket.h
MQTTString::lenstring
MQTTLenString lenstring
Definition: MQTTPacket.h:84
CONNECT
Definition: MQTTPacket.h:45
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
MQTTConnectFlags::willRetain
unsigned int willRetain
Definition: MQTTConnect.h:50
MQTTConnectFlags::bits
struct MQTTConnectFlags::@4 bits
writeMQTTString
void writeMQTTString(unsigned char **pptr, MQTTString mqttstring)
Definition: MQTTPacket.c:194
MQTTPacket_willOptions::qos
char qos
Definition: MQTTConnect.h:81
MQTTPacket_connectData::keepAliveInterval
unsigned short keepAliveInterval
Definition: MQTTConnect.h:98
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTPacket_willOptions::retained
unsigned char retained
Definition: MQTTConnect.h:76
MQTTPacket_connectData::MQTTVersion
unsigned char MQTTVersion
Definition: MQTTConnect.h:96
MQTTDeserialize_connack
int MQTTDeserialize_connack(unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:132
MQTTPacket_connectData::password
MQTTString password
Definition: MQTTConnect.h:103
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
MQTTConnackFlags
Definition: MQTTConnect.h:106
MQTTstrlen
int MQTTstrlen(MQTTString mqttstring)
Definition: MQTTPacket.c:242
DISCONNECT
Definition: MQTTPacket.h:47
MQTTPacket_len
int MQTTPacket_len(int rem_len)
Definition: MQTTPacket.c:84
StackTrace.h
MQTTString::cstring
char * cstring
Definition: MQTTPacket.h:83
MQTTConnectFlags::all
unsigned char all
Definition: MQTTConnect.h:31
MQTTConnackFlags::all
unsigned char all
Definition: MQTTConnect.h:108
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
MQTTConnectFlags::willQoS
unsigned int willQoS
Definition: MQTTConnect.h:49
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTConnackFlags::bits
struct MQTTConnackFlags::@5 bits
PINGREQ
Definition: MQTTPacket.h:47
MQTTSerialize_pingreq
int MQTTSerialize_pingreq(unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:211
MQTTPacket_connectData
Definition: MQTTConnect.h:88
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTConnectServer.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTConnectServer.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "StackTrace.h"
18 #include "MQTTPacket.h"
19 #include <string.h>
20
21 #define min(a, b) ((a < b) ? a : b)
22
23
30 int MQTTPacket_checkVersion(MQTTString* protocol, int version)
31 {
32 int rc = 0;
33
34 if (version == 3 && memcmp(protocol->lenstring.data, "MQIsdp",
35 min(6, protocol->lenstring.len)) == 0)
36 rc = 1;
37 else if (version == 4 && memcmp(protocol->lenstring.data, "MQTT",
38 min(4, protocol->lenstring.len)) == 0)
39 rc = 1;
40 return rc;
41 }
42
43
51 int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len)
52 {
53 MQTTHeader header = {0};
54 MQTTConnectFlags flags = {0};
55 unsigned char* curdata = buf;
56 unsigned char* enddata = &buf[len];
57 int rc = 0;
58 MQTTString Protocol;
59 int version;
60 int mylen = 0;
61
62 FUNC_ENTRY;
63 header.byte = readChar(&curdata);
64 if (header.bits.type != CONNECT)
65 goto exit;
66
67 curdata += MQTTPacket_decodeBuf(curdata, &mylen); /* read remaining length */
68
69 if (!readMQTTLenString(&Protocol, &curdata, enddata) ||
70 enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */
71 goto exit;
72
73 version = (int)readChar(&curdata); /* Protocol version */
74 /* If we don't recognize the protocol version, we don't parse the connect packet on the
75 * basis that we don't know what the format will be.
76 */
77 if (MQTTPacket_checkVersion(&Protocol, version))
78 {
79 flags.all = readChar(&curdata);
80 data->cleansession = flags.bits.cleansession;
81 data->keepAliveInterval = readInt(&curdata);
82 if (!readMQTTLenString(&data->clientID, &curdata, enddata))
83 goto exit;
84 data->willFlag = flags.bits.will;
85 if (flags.bits.will)
86 {
87 data->will.qos = flags.bits.willQoS;
88 data->will.retained = flags.bits.willRetain;
89 if (!readMQTTLenString(&data->will.topicName, &curdata, enddata) ||
90 !readMQTTLenString(&data->will.message, &curdata, enddata))
91 goto exit;
92 }
93 if (flags.bits.username)
94 {
95 if (enddata - curdata < 3 || !readMQTTLenString(&data->username, &curdata, enddata))
96 goto exit; /* username flag set, but no username supplied - invalid */
97 if (flags.bits.password &&
98 (enddata - curdata < 3 || !readMQTTLenString(&data->password, &curdata, enddata)))
99 goto exit; /* password flag set, but no password supplied - invalid */
100 }
101 else if (flags.bits.password)
102 goto exit; /* password flag set without username - invalid */
103 rc = 1;
104 }
105 exit:
106 FUNC_EXIT_RC(rc);
107 return rc;
108 }
109
110
119 int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
120 {
121 MQTTHeader header = {0};
122 int rc = 0;
123 unsigned char *ptr = buf;
124 MQTTConnackFlags flags = {0};
125
126 FUNC_ENTRY;
127 if (buflen < 2)
128 {
129 rc = MQTTPACKET_BUFFER_TOO_SHORT;
130 goto exit;
131 }
132 header.byte = 0;
133 header.bits.type = CONNACK;
134 writeChar(&ptr, header.byte); /* write header */
135
136 ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
137
138 flags.all = 0;
139 flags.bits.sessionpresent = sessionPresent;
140 writeChar(&ptr, flags.all);
141 writeChar(&ptr, connack_rc);
142
143 rc = ptr - buf;
144 exit:
145 FUNC_EXIT_RC(rc);
146 return rc;
147 }
148
MQTTConnackFlags::sessionpresent
unsigned int sessionpresent
Definition: MQTTConnect.h:119
MQTTPacket_connectData::username
MQTTString username
Definition: MQTTConnect.h:102
MQTTConnectFlags
Definition: MQTTConnect.h:29
MQTTConnectFlags::username
unsigned int username
Definition: MQTTConnect.h:52
MQTTHeader::bits
struct MQTTHeader::@6 bits
MQTTPacket_connectData::clientID
MQTTString clientID
Definition: MQTTConnect.h:97
MQTTConnectFlags::cleansession
unsigned int cleansession
Definition: MQTTConnect.h:47
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
MQTTPacket_connectData::cleansession
unsigned char cleansession
Definition: MQTTConnect.h:99
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTPacket_willOptions::message
MQTTString message
Definition: MQTTConnect.h:72
MQTTDeserialize_connect
int MQTTDeserialize_connect(MQTTPacket_connectData *data, unsigned char *buf, int len)
Definition: MQTTConnectServer.c:51
CONNACK
Definition: MQTTPacket.h:45
MQTTLenString::data
char * data
Definition: MQTTPacket.h:78
MQTTConnectFlags::password
unsigned int password
Definition: MQTTConnect.h:51
readInt
int readInt(unsigned char **pptr)
Definition: MQTTPacket.c:125
MQTTPacket_willOptions::topicName
MQTTString topicName
Definition: MQTTConnect.h:70
MQTTLenString::len
int len
Definition: MQTTPacket.h:77
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTPacket_connectData::willFlag
unsigned char willFlag
Definition: MQTTConnect.h:100
MQTTConnectFlags::will
unsigned int will
Definition: MQTTConnect.h:48
MQTTPacket_connectData::will
MQTTPacket_willOptions will
Definition: MQTTConnect.h:101
MQTTPacket.h
MQTTString::lenstring
MQTTLenString lenstring
Definition: MQTTPacket.h:84
CONNECT
Definition: MQTTPacket.h:45
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
MQTTConnectFlags::willRetain
unsigned int willRetain
Definition: MQTTConnect.h:50
MQTTPacket_checkVersion
int MQTTPacket_checkVersion(MQTTString *protocol, int version)
Definition: MQTTConnectServer.c:30
MQTTConnectFlags::bits
struct MQTTConnectFlags::@4 bits
MQTTPacket_willOptions::qos
char qos
Definition: MQTTConnect.h:81
MQTTPacket_connectData::keepAliveInterval
unsigned short keepAliveInterval
Definition: MQTTConnect.h:98
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTPacket_willOptions::retained
unsigned char retained
Definition: MQTTConnect.h:76
MQTTPacket_connectData::password
MQTTString password
Definition: MQTTConnect.h:103
readMQTTLenString
int readMQTTLenString(MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
Definition: MQTTPacket.c:215
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
MQTTConnackFlags
Definition: MQTTConnect.h:106
StackTrace.h
MQTTConnectFlags::all
unsigned char all
Definition: MQTTConnect.h:31
MQTTConnackFlags::all
unsigned char all
Definition: MQTTConnect.h:108
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
MQTTConnectFlags::willQoS
unsigned int willQoS
Definition: MQTTConnect.h:49
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTConnackFlags::bits
struct MQTTConnackFlags::@5 bits
MQTTPacket_connectData
Definition: MQTTConnect.h:88
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
MQTTSerialize_connack
int MQTTSerialize_connack(unsigned char *buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
Definition: MQTTConnectServer.c:119
min
#define min(a, b)
Definition: MQTTConnectServer.c:21


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTDeserializePublish.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTDeserializePublish.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "StackTrace.h"
18 #include "MQTTPacket.h"
19 #include <string.h>
20
21 #define min(a, b) ((a < b) ? 1 : 0)
22
36 int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
37 unsigned char** payload, int* payloadlen, unsigned char* buf, int buflen)
38 {
39 MQTTHeader header = {0};
40 unsigned char* curdata = buf;
41 unsigned char* enddata = NULL;
42 int rc = 0;
43 int mylen = 0;
44
45 FUNC_ENTRY;
46 header.byte = readChar(&curdata);
47 if (header.bits.type != PUBLISH)
48 goto exit;
49 *dup = header.bits.dup;
50 *qos = header.bits.qos;
51 *retained = header.bits.retain;
52
53 curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
54 enddata = curdata + mylen;
55
56 if (!readMQTTLenString(topicName, &curdata, enddata) ||
57 enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */
58 goto exit;
59
60 if (*qos > 0)
61 *packetid = readInt(&curdata);
62
63 *payloadlen = enddata - curdata;
64 *payload = curdata;
65 rc = 1;
66 exit:
67 FUNC_EXIT_RC(rc);
68 return rc;
69 }
70
71
72
82 int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen)
83 {
84 MQTTHeader header = {0};
85 unsigned char* curdata = buf;
86 unsigned char* enddata = NULL;
87 int rc = 0;
88 int mylen;
89
90 FUNC_ENTRY;
91 header.byte = readChar(&curdata);
92 *dup = header.bits.dup;
93 *packettype = header.bits.type;
94
95 curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
96 enddata = curdata + mylen;
97
98 if (enddata - curdata < 2)
99 goto exit;
100 *packetid = readInt(&curdata);
101
102 rc = 1;
103 exit:
104 FUNC_EXIT_RC(rc);
105 return rc;
106 }
107
MQTTHeader::qos
unsigned int qos
Definition: MQTTPacket.h:68
PUBLISH
Definition: MQTTPacket.h:45
MQTTHeader::bits
struct MQTTHeader::@6 bits
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTDeserialize_publish
int MQTTDeserialize_publish(unsigned char *dup, int *qos, unsigned char *retained, unsigned short *packetid, MQTTString *topicName, unsigned char **payload, int *payloadlen, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:36
readInt
int readInt(unsigned char **pptr)
Definition: MQTTPacket.c:125
MQTTPacket.h
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
MQTTHeader::dup
unsigned int dup
Definition: MQTTPacket.h:69
readMQTTLenString
int readMQTTLenString(MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
Definition: MQTTPacket.c:215
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
MQTTDeserialize_ack
int MQTTDeserialize_ack(unsigned char *packettype, unsigned char *dup, unsigned short *packetid, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:82
MQTTHeader::retain
unsigned int retain
Definition: MQTTPacket.h:67
StackTrace.h
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTFormat.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTFormat.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "StackTrace.h"
18 #include "MQTTPacket.h"
19
20 #include <string.h>
21
22
23 const char* MQTTPacket_names[] =
24 {
25 "RESERVED", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC", "PUBREL",
26 "PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK",
27 "PINGREQ", "PINGRESP", "DISCONNECT"
28 };
29
30
31 const char* MQTTPacket_getName(unsigned short packetid)
32 {
33 return MQTTPacket_names[packetid];
34 }
35
36
37 int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data)
38 {
39 int strindex = 0;
40
41 strindex = snprintf(strbuf, strbuflen,
42 "CONNECT MQTT version %d, client id %.*s, clean session %d, keep alive %d",
43 (int)data->MQTTVersion, data->clientID.lenstring.len, data->clientID.lenstring.data,
44 (int)data->cleansession, data->keepAliveInterval);
45 if (data->willFlag)
46 strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
47 ", will QoS %d, will retain %d, will topic %.*s, will message %.*s",
48 data->will.qos, data->will.retained,
49 data->will.topicName.lenstring.len, data->will.topicName.lenstring.data,
50 data->will.message.lenstring.len, data->will.message.lenstring.data);
51 if (data->username.lenstring.data && data->username.lenstring.len > 0)
52 strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
53 ", user name %.*s", data->username.lenstring.len, data->username.lenstring.data);
54 if (data->password.lenstring.data && data->password.lenstring.len > 0)
55 strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
56 ", password %.*s", data->password.lenstring.len, data->password.lenstring.data);
57 return strindex;
58 }
59
60
61 int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent)
62 {
63 int strindex = snprintf(strbuf, strbuflen, "CONNACK session present %d, rc %d", sessionPresent, connack_rc);
64 return strindex;
65 }
66
67
68 int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,
69 unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen)
70 {
71 int strindex = snprintf(strbuf, strbuflen,
72 "PUBLISH dup %d, QoS %d, retained %d, packet id %d, topic %.*s, payload length %d, payload %.*s",
73 dup, qos, retained, packetid,
74 (topicName.lenstring.len < 20) ? topicName.lenstring.len : 20, topicName.lenstring.data,
75 payloadlen, (payloadlen < 20) ? payloadlen : 20, payload);
76 return strindex;
77 }
78
79
80 int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
81 {
82 int strindex = snprintf(strbuf, strbuflen, "%s, packet id %d", MQTTPacket_names[packettype], packetid);
83 if (dup)
84 strindex += snprintf(strbuf + strindex, strbuflen - strindex, ", dup %d", dup);
85 return strindex;
86 }
87
88
89 int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,
90 MQTTString topicFilters[], int requestedQoSs[])
91 {
92 return snprintf(strbuf, strbuflen,
93 "SUBSCRIBE dup %d, packet id %d count %d topic %.*s qos %d",
94 dup, packetid, count,
95 topicFilters[0].lenstring.len, topicFilters[0].lenstring.data,
96 requestedQoSs[0]);
97 }
98
99
100 int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs)
101 {
102 return snprintf(strbuf, strbuflen,
103 "SUBACK packet id %d count %d granted qos %d", packetid, count, grantedQoSs[0]);
104 }
105
106
107 int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,
108 int count, MQTTString topicFilters[])
109 {
110 return snprintf(strbuf, strbuflen,
111 "UNSUBSCRIBE dup %d, packet id %d count %d topic %.*s",
112 dup, packetid, count,
113 topicFilters[0].lenstring.len, topicFilters[0].lenstring.data);
114 }
115
116
117 char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen)
118 {
119 int index = 0;
120 int rem_length = 0;
121 MQTTHeader header = {0};
122 int strindex = 0;
123
124 header.byte = buf[index++];
125 index += MQTTPacket_decodeBuf(&buf[index], &rem_length);
126
127 switch (header.bits.type)
128 {
129 case CONNACK:
130 {
131 unsigned char sessionPresent, connack_rc;
132 if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) == 1)
133 strindex = MQTTStringFormat_connack(strbuf, strbuflen, connack_rc, sessionPresent);
134 }
135 break;
136 case PUBLISH:
137 {
138 unsigned char dup, retained, *payload;
139 unsigned short packetid;
140 int qos, payloadlen;
141 MQTTString topicName = MQTTString_initializer;
142 if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName,
143 &payload, &payloadlen, buf, buflen) == 1)
144 strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid,
145 topicName, payload, payloadlen);
146 }
147 break;
148 case PUBACK:
149 case PUBREC:
150 case PUBREL:
151 case PUBCOMP:
152 {
153 unsigned char packettype, dup;
154 unsigned short packetid;
155 if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1)
156 strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid);
157 }
158 break;
159 case SUBACK:
160 {
161 unsigned short packetid;
162 int maxcount = 1, count = 0;
163 int grantedQoSs[1];
164 if (MQTTDeserialize_suback(&packetid, maxcount, &count, grantedQoSs, buf, buflen) == 1)
165 strindex = MQTTStringFormat_suback(strbuf, strbuflen, packetid, count, grantedQoSs);
166 }
167 break;
168 case UNSUBACK:
169 {
170 unsigned short packetid;
171 if (MQTTDeserialize_unsuback(&packetid, buf, buflen) == 1)
172 strindex = MQTTStringFormat_ack(strbuf, strbuflen, UNSUBACK, 0, packetid);
173 }
174 break;
175 case PINGREQ:
176 case PINGRESP:
177 case DISCONNECT:
178 strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]);
179 break;
180 }
181 return strbuf;
182 }
183
184
185 char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen)
186 {
187 int index = 0;
188 int rem_length = 0;
189 MQTTHeader header = {0};
190 int strindex = 0;
191
192 header.byte = buf[index++];
193 index += MQTTPacket_decodeBuf(&buf[index], &rem_length);
194
195 switch (header.bits.type)
196 {
197 case CONNECT:
198 {
199 MQTTPacket_connectData data;
200 int rc;
201 if ((rc = MQTTDeserialize_connect(&data, buf, buflen)) == 1)
202 strindex = MQTTStringFormat_connect(strbuf, strbuflen, &data);
203 }
204 break;
205 case PUBLISH:
206 {
207 unsigned char dup, retained, *payload;
208 unsigned short packetid;
209 int qos, payloadlen;
210 MQTTString topicName = MQTTString_initializer;
211 if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName,
212 &payload, &payloadlen, buf, buflen) == 1)
213 strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid,
214 topicName, payload, payloadlen);
215 }
216 break;
217 case PUBACK:
218 case PUBREC:
219 case PUBREL:
220 case PUBCOMP:
221 {
222 unsigned char packettype, dup;
223 unsigned short packetid;
224 if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1)
225 strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid);
226 }
227 break;
228 case SUBSCRIBE:
229 {
230 unsigned char dup;
231 unsigned short packetid;
232 int maxcount = 1, count = 0;
233 MQTTString topicFilters[1];
234 int requestedQoSs[1];
235 if (MQTTDeserialize_subscribe(&dup, &packetid, maxcount, &count,
236 topicFilters, requestedQoSs, buf, buflen) == 1)
237 strindex = MQTTStringFormat_subscribe(strbuf, strbuflen, dup, packetid, count, topicFilters, requestedQoSs);;
238 }
239 break;
240 case UNSUBSCRIBE:
241 {
242 unsigned char dup;
243 unsigned short packetid;
244 int maxcount = 1, count = 0;
245 MQTTString topicFilters[1];
246 if (MQTTDeserialize_unsubscribe(&dup, &packetid, maxcount, &count, topicFilters, buf, buflen) == 1)
247 strindex = MQTTStringFormat_unsubscribe(strbuf, strbuflen, dup, packetid, count, topicFilters);
248 }
249 break;
250 case PINGREQ:
251 case PINGRESP:
252 case DISCONNECT:
253 strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]);
254 break;
255 }
256 strbuf[strbuflen] = '\0';
257 return strbuf;
258 }
MQTTPacket_connectData::username
MQTTString username
Definition: MQTTConnect.h:102
MQTTDeserialize_subscribe
DLLExport int MQTTDeserialize_subscribe(unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], unsigned char *buf, int len)
Definition: MQTTSubscribeServer.c:35
PUBLISH
Definition: MQTTPacket.h:45
MQTTHeader::bits
struct MQTTHeader::@6 bits
MQTTPacket_connectData::clientID
MQTTString clientID
Definition: MQTTConnect.h:97
SUBSCRIBE
Definition: MQTTPacket.h:46
MQTTPacket_names
const char * MQTTPacket_names[]
Definition: MQTTFormat.c:23
MQTTPacket_getName
const char * MQTTPacket_getName(unsigned short packetid)
Definition: MQTTFormat.c:31
MQTTFormat_toClientString
char * MQTTFormat_toClientString(char *strbuf, int strbuflen, unsigned char *buf, int buflen)
Definition: MQTTFormat.c:117
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTStringFormat_ack
int MQTTStringFormat_ack(char *strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
Definition: MQTTFormat.c:80
MQTTString
Definition: MQTTPacket.h:81
MQTTPacket_connectData::cleansession
unsigned char cleansession
Definition: MQTTConnect.h:99
PUBREL
Definition: MQTTPacket.h:45
MQTTDeserialize_unsuback
DLLExport int MQTTDeserialize_unsuback(unsigned short *packetid, unsigned char *buf, int len)
Definition: MQTTUnsubscribeClient.c:92
MQTTDeserialize_publish
int MQTTDeserialize_publish(unsigned char *dup, int *qos, unsigned char *retained, unsigned short *packetid, MQTTString *topicName, unsigned char **payload, int *payloadlen, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:36
MQTTStringFormat_suback
int MQTTStringFormat_suback(char *strbuf, int strbuflen, unsigned short packetid, int count, int *grantedQoSs)
Definition: MQTTFormat.c:100
PUBREC
Definition: MQTTPacket.h:45
MQTTPacket_willOptions::message
MQTTString message
Definition: MQTTConnect.h:72
MQTTDeserialize_connack
DLLExport int MQTTDeserialize_connack(unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
Definition: MQTTConnectClient.c:132
CONNACK
Definition: MQTTPacket.h:45
MQTTLenString::data
char * data
Definition: MQTTPacket.h:78
MQTTDeserialize_unsubscribe
DLLExport int MQTTDeserialize_unsubscribe(unsigned char *dup, unsigned short *packetid, int max_count, int *count, MQTTString topicFilters[], unsigned char *buf, int len)
Definition: MQTTUnsubscribeServer.c:34
MQTTPacket_willOptions::topicName
MQTTString topicName
Definition: MQTTConnect.h:70
MQTTLenString::len
int len
Definition: MQTTPacket.h:77
MQTTPacket_connectData::willFlag
unsigned char willFlag
Definition: MQTTConnect.h:100
MQTTStringFormat_unsubscribe
int MQTTStringFormat_unsubscribe(char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
Definition: MQTTFormat.c:107
MQTTPacket_connectData::will
MQTTPacket_willOptions will
Definition: MQTTConnect.h:101
MQTTPacket.h
MQTTString::lenstring
MQTTLenString lenstring
Definition: MQTTPacket.h:84
PINGRESP
Definition: MQTTPacket.h:47
CONNECT
Definition: MQTTPacket.h:45
MQTTPacket_willOptions::qos
char qos
Definition: MQTTConnect.h:81
MQTTPacket_connectData::keepAliveInterval
unsigned short keepAliveInterval
Definition: MQTTConnect.h:98
SUBACK
Definition: MQTTPacket.h:46
MQTTPacket_willOptions::retained
unsigned char retained
Definition: MQTTConnect.h:76
MQTTPacket_connectData::MQTTVersion
unsigned char MQTTVersion
Definition: MQTTConnect.h:96
MQTTStringFormat_connect
int MQTTStringFormat_connect(char *strbuf, int strbuflen, MQTTPacket_connectData *data)
Definition: MQTTFormat.c:37
MQTTStringFormat_publish
int MQTTStringFormat_publish(char *strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
Definition: MQTTFormat.c:68
PUBACK
Definition: MQTTPacket.h:45
MQTTPacket_connectData::password
MQTTString password
Definition: MQTTConnect.h:103
UNSUBSCRIBE
Definition: MQTTPacket.h:46
MQTTDeserialize_ack
int MQTTDeserialize_ack(unsigned char *packettype, unsigned char *dup, unsigned short *packetid, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:82
MQTTStringFormat_subscribe
int MQTTStringFormat_subscribe(char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
Definition: MQTTFormat.c:89
DISCONNECT
Definition: MQTTPacket.h:47
StackTrace.h
MQTTDeserialize_connect
DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData *data, unsigned char *buf, int len)
Definition: MQTTConnectServer.c:51
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
PINGREQ
Definition: MQTTPacket.h:47
MQTTDeserialize_suback
DLLExport int MQTTDeserialize_suback(unsigned short *packetid, int maxcount, int *count, int grantedQoSs[], unsigned char *buf, int len)
Definition: MQTTSubscribeClient.c:100
MQTTPacket_connectData
Definition: MQTTConnect.h:88
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTString_initializer
#define MQTTString_initializer
Definition: MQTTPacket.h:87
MQTTStringFormat_connack
int MQTTStringFormat_connack(char *strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent)
Definition: MQTTFormat.c:61
MQTTHeader
Definition: MQTTPacket.h:53
UNSUBACK
Definition: MQTTPacket.h:46
MQTTFormat_toServerString
char * MQTTFormat_toServerString(char *strbuf, int strbuflen, unsigned char *buf, int buflen)
Definition: MQTTFormat.c:185
PUBCOMP
Definition: MQTTPacket.h:46


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTFormat.h Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTFormat.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #if !defined(MQTTFORMAT_H)
18 #define MQTTFORMAT_H
19
20 #include "StackTrace.h"
21 #include "MQTTPacket.h"
22
23 const char* MQTTPacket_getName(unsigned short packetid);
24 int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data);
25 int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent);
26 int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,
27 unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen);
28 int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid);
29 int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,
30 MQTTString topicFilters[], int requestedQoSs[]);
31 int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs);
32 int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,
33 int count, MQTTString topicFilters[]);
34 char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
35 char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
36
37 #endif
MQTTFormat_toServerString
char * MQTTFormat_toServerString(char *strbuf, int strbuflen, unsigned char *buf, int buflen)
Definition: MQTTFormat.c:185
MQTTString
Definition: MQTTPacket.h:81
MQTTPacket_getName
const char * MQTTPacket_getName(unsigned short packetid)
Definition: MQTTFormat.c:31
MQTTStringFormat_publish
int MQTTStringFormat_publish(char *strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
Definition: MQTTFormat.c:68
MQTTStringFormat_suback
int MQTTStringFormat_suback(char *strbuf, int strbuflen, unsigned short packetid, int count, int *grantedQoSs)
Definition: MQTTFormat.c:100
MQTTPacket.h
MQTTStringFormat_connack
int MQTTStringFormat_connack(char *strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent)
Definition: MQTTFormat.c:61
MQTTFormat_toClientString
char * MQTTFormat_toClientString(char *strbuf, int strbuflen, unsigned char *buf, int buflen)
Definition: MQTTFormat.c:117
MQTTStringFormat_subscribe
int MQTTStringFormat_subscribe(char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
Definition: MQTTFormat.c:89
StackTrace.h
MQTTPacket_connectData
Definition: MQTTConnect.h:88
MQTTStringFormat_ack
int MQTTStringFormat_ack(char *strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
Definition: MQTTFormat.c:80
MQTTStringFormat_connect
int MQTTStringFormat_connect(char *strbuf, int strbuflen, MQTTPacket_connectData *data)
Definition: MQTTFormat.c:37
MQTTStringFormat_unsubscribe
int MQTTStringFormat_unsubscribe(char *strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
Definition: MQTTFormat.c:107


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTPacket.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTPacket.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Sergio R. Caprile - non-blocking packet read functions for stream transport
16 *******************************************************************************/
17
18 #include "StackTrace.h"
19 #include "MQTTPacket.h"
20
21 #include <string.h>
22
29 int MQTTPacket_encode(unsigned char* buf, int length)
30 {
31 int rc = 0;
32
33 FUNC_ENTRY;
34 do
35 {
36 char d = length % 128;
37 length /= 128;
38 /* if there are more digits to encode, set the top bit of this digit */
39 if (length > 0)
40 d |= 0x80;
41 buf[rc++] = d;
42 } while (length > 0);
43 FUNC_EXIT_RC(rc);
44 return rc;
45 }
46
47
54 int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value)
55 {
56 unsigned char c;
57 int multiplier = 1;
58 int len = 0;
59 #define MAX_NO_OF_REMAINING_LENGTH_BYTES 4
60
61 FUNC_ENTRY;
62 *value = 0;
63 do
64 {
65 int rc = MQTTPACKET_READ_ERROR;
66
67 if (++len > MAX_NO_OF_REMAINING_LENGTH_BYTES)
68 {
69 rc = MQTTPACKET_READ_ERROR; /* bad data */
70 goto exit;
71 }
72 rc = (*getcharfn)(&c, 1);
73 if (rc != 1)
74 goto exit;
75 *value += (c & 127) * multiplier;
76 multiplier *= 128;
77 } while ((c & 128) != 0);
78 exit:
79 FUNC_EXIT_RC(len);
80 return len;
81 }
82
83
84 int MQTTPacket_len(int rem_len)
85 {
86 rem_len += 1; /* header byte */
87
88 /* now remaining_length field */
89 if (rem_len < 128)
90 rem_len += 1;
91 else if (rem_len < 16384)
92 rem_len += 2;
93 else if (rem_len < 2097151)
94 rem_len += 3;
95 else
96 rem_len += 4;
97 return rem_len;
98 }
99
100
101 static unsigned char* bufptr;
102
103 int bufchar(unsigned char* c, int count)
104 {
105 int i;
106
107 for (i = 0; i < count; ++i)
108 *c = *bufptr++;
109 return count;
110 }
111
112
113 int MQTTPacket_decodeBuf(unsigned char* buf, int* value)
114 {
115 bufptr = buf;
116 return MQTTPacket_decode(bufchar, value);
117 }
118
119
125 int readInt(unsigned char** pptr)
126 {
127 unsigned char* ptr = *pptr;
128 int len = 256*(*ptr) + (*(ptr+1));
129 *pptr += 2;
130 return len;
131 }
132
133
139 char readChar(unsigned char** pptr)
140 {
141 char c = **pptr;
142 (*pptr)++;
143 return c;
144 }
145
146
152 void writeChar(unsigned char** pptr, char c)
153 {
154 **pptr = c;
155 (*pptr)++;
156 }
157
158
164 void writeInt(unsigned char** pptr, int anInt)
165 {
166 **pptr = (unsigned char)(anInt / 256);
167 (*pptr)++;
168 **pptr = (unsigned char)(anInt % 256);
169 (*pptr)++;
170 }
171
172
178 void writeCString(unsigned char** pptr, const char* string)
179 {
180 int len = strlen(string);
181 writeInt(pptr, len);
182 memcpy(*pptr, string, len);
183 *pptr += len;
184 }
185
186
187 int getLenStringLen(char* ptr)
188 {
189 int len = 256*((unsigned char)(*ptr)) + (unsigned char)(*(ptr+1));
190 return len;
191 }
192
193
194 void writeMQTTString(unsigned char** pptr, MQTTString mqttstring)
195 {
196 if (mqttstring.lenstring.len > 0)
197 {
198 writeInt(pptr, mqttstring.lenstring.len);
199 memcpy(*pptr, mqttstring.lenstring.data, mqttstring.lenstring.len);
200 *pptr += mqttstring.lenstring.len;
201 }
202 else if (mqttstring.cstring)
203 writeCString(pptr, mqttstring.cstring);
204 else
205 writeInt(pptr, 0);
206 }
207
208
215 int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata)
216 {
217 int rc = 0;
218
219 FUNC_ENTRY;
220 /* the first two bytes are the length of the string */
221 if (enddata - (*pptr) > 1) /* enough length to read the integer? */
222 {
223 mqttstring->lenstring.len = readInt(pptr); /* increments pptr to point past length */
224 if (&(*pptr)[mqttstring->lenstring.len] <= enddata)
225 {
226 mqttstring->lenstring.data = (char*)*pptr;
227 *pptr += mqttstring->lenstring.len;
228 rc = 1;
229 }
230 }
231 mqttstring->cstring = NULL;
232 FUNC_EXIT_RC(rc);
233 return rc;
234 }
235
236
242 int MQTTstrlen(MQTTString mqttstring)
243 {
244 int rc = 0;
245
246 if (mqttstring.cstring)
247 rc = strlen(mqttstring.cstring);
248 else
249 rc = mqttstring.lenstring.len;
250 return rc;
251 }
252
253
260 int MQTTPacket_equals(MQTTString* a, char* bptr)
261 {
262 int alen = 0,
263 blen = 0;
264 char *aptr;
265
266 if (a->cstring)
267 {
268 aptr = a->cstring;
269 alen = strlen(a->cstring);
270 }
271 else
272 {
273 aptr = a->lenstring.data;
274 alen = a->lenstring.len;
275 }
276 blen = strlen(bptr);
277
278 return (alen == blen) && (strncmp(aptr, bptr, alen) == 0);
279 }
280
281
290 int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int))
291 {
292 int rc = -1;
293 MQTTHeader header = {0};
294 int len = 0;
295 int rem_len = 0;
296
297 /* 1. read the header byte. This has the packet type in it */
298 if ((*getfn)(buf, 1) != 1)
299 goto exit;
300
301 len = 1;
302 /* 2. read the remaining length. This is variable in itself */
303 MQTTPacket_decode(getfn, &rem_len);
304 len += MQTTPacket_encode(buf + 1, rem_len); /* put the original remaining length back into the buffer */
305
306 /* 3. read the rest of the buffer using a callback to supply the rest of the data */
307 if((rem_len + len) > buflen)
308 goto exit;
309 if ((*getfn)(buf + len, rem_len) != rem_len)
310 goto exit;
311
312 header.byte = buf[0];
313 rc = header.bits.type;
314 exit:
315 return rc;
316 }
317
324 static int MQTTPacket_decodenb(MQTTTransport *trp)
325 {
326 unsigned char c;
327 int rc = MQTTPACKET_READ_ERROR;
328
329 FUNC_ENTRY;
330 if(trp->len == 0){ /* initialize on first call */
331 trp->multiplier = 1;
332 trp->rem_len = 0;
333 }
334 do {
335 int frc;
336 if (++(trp->len) > MAX_NO_OF_REMAINING_LENGTH_BYTES)
337 goto exit;
338 if ((frc=(*trp->getfn)(trp->sck, &c, 1)) == -1)
339 goto exit;
340 if (frc == 0){
341 rc = 0;
342 goto exit;
343 }
344 trp->rem_len += (c & 127) * trp->multiplier;
345 trp->multiplier *= 128;
346 } while ((c & 128) != 0);
347 rc = trp->len;
348 exit:
349 FUNC_EXIT_RC(rc);
350 return rc;
351 }
352
361 int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp)
362 {
363 int rc = -1, frc;
364 MQTTHeader header = {0};
365
366 switch(trp->state){
367 default:
368 trp->state = 0;
369 /*FALLTHROUGH*/
370 case 0:
371 /* read the header byte. This has the packet type in it */
372 if ((frc=(*trp->getfn)(trp->sck, buf, 1)) == -1)
373 goto exit;
374 if (frc == 0)
375 return 0;
376 trp->len = 0;
377 ++trp->state;
378 /*FALLTHROUGH*/
379 /* read the remaining length. This is variable in itself */
380 case 1:
381 if((frc=MQTTPacket_decodenb(trp)) == MQTTPACKET_READ_ERROR)
382 goto exit;
383 if(frc == 0)
384 return 0;
385 trp->len = 1 + MQTTPacket_encode(buf + 1, trp->rem_len); /* put the original remaining length back into the buffer */
386 if((trp->rem_len + trp->len) > buflen)
387 goto exit;
388 ++trp->state;
389 /*FALLTHROUGH*/
390 case 2:
391 /* read the rest of the buffer using a callback to supply the rest of the data */
392 if ((frc=(*trp->getfn)(trp->sck, buf + trp->len, trp->rem_len)) == -1)
393 goto exit;
394 if (frc == 0)
395 return 0;
396 trp->rem_len -= frc;
397 trp->len += frc;
398 if(trp->rem_len)
399 return 0;
400
401 header.byte = buf[0];
402 rc = header.bits.type;
403 break;
404 }
405
406 exit:
407 trp->state = 0;
408 return rc;
409 }
410
MQTTHeader::bits
struct MQTTHeader::@6 bits
writeCString
void writeCString(unsigned char **pptr, const char *string)
Definition: MQTTPacket.c:178
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTTransport::state
char state
Definition: MQTTPacket.h:123
MQTTTransport::multiplier
int multiplier
Definition: MQTTPacket.h:120
MQTTLenString::data
char * data
Definition: MQTTPacket.h:78
readInt
int readInt(unsigned char **pptr)
Definition: MQTTPacket.c:125
MQTTTransport::getfn
int(* getfn)(void *, unsigned char *, int)
Definition: MQTTPacket.h:118
MQTTPacket_read
int MQTTPacket_read(unsigned char *buf, int buflen, int(*getfn)(unsigned char *, int))
Definition: MQTTPacket.c:290
MQTTPacket_equals
int MQTTPacket_equals(MQTTString *a, char *bptr)
Definition: MQTTPacket.c:260
MQTTLenString::len
int len
Definition: MQTTPacket.h:77
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTTransport
Definition: MQTTPacket.h:117
MQTTPacket.h
MQTTString::lenstring
MQTTLenString lenstring
Definition: MQTTPacket.h:84
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
getLenStringLen
int getLenStringLen(char *ptr)
Definition: MQTTPacket.c:187
writeMQTTString
void writeMQTTString(unsigned char **pptr, MQTTString mqttstring)
Definition: MQTTPacket.c:194
MQTTPacket_decode
int MQTTPacket_decode(int(*getcharfn)(unsigned char *, int), int *value)
Definition: MQTTPacket.c:54
MQTTTransport::rem_len
int rem_len
Definition: MQTTPacket.h:121
MAX_NO_OF_REMAINING_LENGTH_BYTES
#define MAX_NO_OF_REMAINING_LENGTH_BYTES
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTPACKET_READ_ERROR
Definition: MQTTPacket.h:39
readMQTTLenString
int readMQTTLenString(MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
Definition: MQTTPacket.c:215
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
bufchar
int bufchar(unsigned char *c, int count)
Definition: MQTTPacket.c:103
MQTTstrlen
int MQTTstrlen(MQTTString mqttstring)
Definition: MQTTPacket.c:242
MQTTPacket_len
int MQTTPacket_len(int rem_len)
Definition: MQTTPacket.c:84
StackTrace.h
MQTTString::cstring
char * cstring
Definition: MQTTPacket.h:83
MQTTPacket_readnb
int MQTTPacket_readnb(unsigned char *buf, int buflen, MQTTTransport *trp)
Definition: MQTTPacket.c:361
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
MQTTTransport::len
int len
Definition: MQTTPacket.h:122
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
MQTTTransport::sck
void * sck
Definition: MQTTPacket.h:119
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTPacket.h Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTPacket.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Xiang Rong - 442039 Add makefile to Embedded C client
16 *******************************************************************************/
17
18 #ifndef MQTTPACKET_H_
19 #define MQTTPACKET_H_
20
21 #if defined(__cplusplus) /* If this is a C++ compiler, use C linkage */
22 extern "C" {
23 #endif
24
25 #if defined(WIN32_DLL) || defined(WIN64_DLL)
26 #define DLLImport __declspec(dllimport)
27 #define DLLExport __declspec(dllexport)
28 #elif defined(LINUX_SO)
29 #define DLLImport extern
30 #define DLLExport __attribute__ ((visibility ("default")))
31 #else
32 #define DLLImport
33 #define DLLExport
34 #endif
35
36 enum errors
37 {
38 MQTTPACKET_BUFFER_TOO_SHORT = -2,
39 MQTTPACKET_READ_ERROR = -1,
40 MQTTPACKET_READ_COMPLETE
41 };
42
43 enum msgTypes
44 {
45 CONNECT = 1, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL,
46 PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK,
47 PINGREQ, PINGRESP, DISCONNECT
48 };
49
53 typedef union
54 {
55 unsigned char byte;
56 #if defined(REVERSED)
57 struct
58 {
59 unsigned int type : 4;
60 unsigned int dup : 1;
61 unsigned int qos : 2;
62 unsigned int retain : 1;
63 } bits;
64 #else
65 struct
66 {
67 unsigned int retain : 1;
68 unsigned int qos : 2;
69 unsigned int dup : 1;
70 unsigned int type : 4;
71 } bits;
72 #endif
73 } MQTTHeader;
74
75 typedef struct
76 {
77 int len;
78 char* data;
79 } MQTTLenString;
80
81 typedef struct
82 {
83 char* cstring;
84 MQTTLenString lenstring;
85 } MQTTString;
86
87 #define MQTTString_initializer {NULL, {0, NULL}}
88
89 int MQTTstrlen(MQTTString mqttstring);
90
91 #include "MQTTConnect.h"
92 #include "MQTTPublish.h"
93 #include "MQTTSubscribe.h"
94 #include "MQTTUnsubscribe.h"
95 #include "MQTTFormat.h"
96
97 int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid);
98 int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen);
99
100 int MQTTPacket_len(int rem_len);
101 int MQTTPacket_equals(MQTTString* a, char* b);
102
103 int MQTTPacket_encode(unsigned char* buf, int length);
104 int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value);
105 int MQTTPacket_decodeBuf(unsigned char* buf, int* value);
106
107 int readInt(unsigned char** pptr);
108 char readChar(unsigned char** pptr);
109 void writeChar(unsigned char** pptr, char c);
110 void writeInt(unsigned char** pptr, int anInt);
111 int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata);
112 void writeCString(unsigned char** pptr, const char* string);
113 void writeMQTTString(unsigned char** pptr, MQTTString mqttstring);
114
115 DLLExport int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int));
116
117 typedef struct {
118 int (*getfn)(void *, unsigned char*, int); /* must return -1 for error, 0 for call again, or the number of bytes read */
119 void *sck; /* pointer to whatever the system may use to identify the transport */
120 int multiplier;
121 int rem_len;
122 int len;
123 char state;
124 }MQTTTransport;
125
126 int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp);
127
128 #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
129 }
130 #endif
131
132
133 #endif /* MQTTPACKET_H_ */
MQTTHeader::qos
unsigned int qos
Definition: MQTTPacket.h:68
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164
PUBLISH
Definition: MQTTPacket.h:45
MQTTPacket_len
int MQTTPacket_len(int rem_len)
Definition: MQTTPacket.c:84
msgTypes
msgTypes
Definition: MQTTPacket.h:43
SUBSCRIBE
Definition: MQTTPacket.h:46
writeCString
void writeCString(unsigned char **pptr, const char *string)
Definition: MQTTPacket.c:178
MQTTPacket_readnb
int MQTTPacket_readnb(unsigned char *buf, int buflen, MQTTTransport *trp)
Definition: MQTTPacket.c:361
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
readInt
int readInt(unsigned char **pptr)
Definition: MQTTPacket.c:125
PUBREL
Definition: MQTTPacket.h:45
MQTTPacket_read
DLLExport int MQTTPacket_read(unsigned char *buf, int buflen, int(*getfn)(unsigned char *, int))
Definition: MQTTPacket.c:290
MQTTTransport::state
char state
Definition: MQTTPacket.h:123
MQTTUnsubscribe.h
PUBREC
Definition: MQTTPacket.h:45
MQTTTransport::multiplier
int multiplier
Definition: MQTTPacket.h:120
CONNACK
Definition: MQTTPacket.h:45
MQTTLenString::data
char * data
Definition: MQTTPacket.h:78
MQTTPacket_equals
int MQTTPacket_equals(MQTTString *a, char *b)
Definition: MQTTPacket.c:260
MQTTSerialize_ack
int MQTTSerialize_ack(unsigned char *buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid)
Definition: MQTTSerializePublish.c:104
MQTTLenString::len
int len
Definition: MQTTPacket.h:77
MQTTPACKET_READ_COMPLETE
Definition: MQTTPacket.h:40
MQTTFormat.h
MQTTTransport
Definition: MQTTPacket.h:117
MQTTConnect.h
MQTTLenString
Definition: MQTTPacket.h:75
MQTTString::lenstring
MQTTLenString lenstring
Definition: MQTTPacket.h:84
PINGRESP
Definition: MQTTPacket.h:47
CONNECT
Definition: MQTTPacket.h:45
MQTTTransport::rem_len
int rem_len
Definition: MQTTPacket.h:121
SUBACK
Definition: MQTTPacket.h:46
MQTTPACKET_READ_ERROR
Definition: MQTTPacket.h:39
writeMQTTString
void writeMQTTString(unsigned char **pptr, MQTTString mqttstring)
Definition: MQTTPacket.c:194
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTHeader::dup
unsigned int dup
Definition: MQTTPacket.h:69
readMQTTLenString
int readMQTTLenString(MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
Definition: MQTTPacket.c:215
errors
errors
Definition: MQTTPacket.h:36
PUBACK
Definition: MQTTPacket.h:45
MQTTSubscribe.h
UNSUBSCRIBE
Definition: MQTTPacket.h:46
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
DISCONNECT
Definition: MQTTPacket.h:47
MQTTHeader::retain
unsigned int retain
Definition: MQTTPacket.h:67
MQTTDeserialize_ack
int MQTTDeserialize_ack(unsigned char *packettype, unsigned char *dup, unsigned short *packetid, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:82
MQTTString::cstring
char * cstring
Definition: MQTTPacket.h:83
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTTransport::len
int len
Definition: MQTTPacket.h:122
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
PINGREQ
Definition: MQTTPacket.h:47
MQTTstrlen
int MQTTstrlen(MQTTString mqttstring)
Definition: MQTTPacket.c:242
MQTTPublish.h
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
DLLExport
#define DLLExport
Definition: MQTTPacket.h:33
UNSUBACK
Definition: MQTTPacket.h:46
MQTTTransport::sck
void * sck
Definition: MQTTPacket.h:119
MQTTPacket_decode
int MQTTPacket_decode(int(*getcharfn)(unsigned char *, int), int *value)
Definition: MQTTPacket.c:54
PUBCOMP
Definition: MQTTPacket.h:46


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTPublish.h Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTPublish.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Xiang Rong - 442039 Add makefile to Embedded C client
16 *******************************************************************************/
17
18 #ifndef MQTTPUBLISH_H_
19 #define MQTTPUBLISH_H_
20
21 #if !defined(DLLImport)
22 #define DLLImport
23 #endif
24 #if !defined(DLLExport)
25 #define DLLExport
26 #endif
27
28 DLLExport int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
29 MQTTString topicName, unsigned char* payload, int payloadlen);
30
31 DLLExport int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
32 unsigned char** payload, int* payloadlen, unsigned char* buf, int len);
33
34 DLLExport int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid);
35 DLLExport int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid);
36 DLLExport int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid);
37
38 #endif /* MQTTPUBLISH_H_ */
MQTTString
Definition: MQTTPacket.h:81
MQTTSerialize_publish
DLLExport int MQTTSerialize_publish(unsigned char *buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
Definition: MQTTSerializePublish.c:55
MQTTSerialize_pubcomp
DLLExport int MQTTSerialize_pubcomp(unsigned char *buf, int buflen, unsigned short packetid)
Definition: MQTTSerializePublish.c:164
DLLExport
#define DLLExport
Definition: MQTTPublish.h:25
MQTTSerialize_pubrel
DLLExport int MQTTSerialize_pubrel(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid)
Definition: MQTTSerializePublish.c:151
MQTTDeserialize_publish
DLLExport int MQTTDeserialize_publish(unsigned char *dup, int *qos, unsigned char *retained, unsigned short *packetid, MQTTString *topicName, unsigned char **payload, int *payloadlen, unsigned char *buf, int len)
Definition: MQTTDeserializePublish.c:36
MQTTSerialize_puback
DLLExport int MQTTSerialize_puback(unsigned char *buf, int buflen, unsigned short packetid)
Definition: MQTTSerializePublish.c:137


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSerializePublish.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTSerializePublish.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Ian Craggs - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144
16 *******************************************************************************/
17
18 #include "MQTTPacket.h"
19 #include "StackTrace.h"
20
21 #include <string.h>
22
23
31 int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen)
32 {
33 int len = 0;
34
35 len += 2 + MQTTstrlen(topicName) + payloadlen;
36 if (qos > 0)
37 len += 2; /* packetid */
38 return len;
39 }
40
41
55 int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
56 MQTTString topicName, unsigned char* payload, int payloadlen)
57 {
58 unsigned char *ptr = buf;
59 MQTTHeader header = {0};
60 int rem_len = 0;
61 int rc = 0;
62
63 FUNC_ENTRY;
64 if (MQTTPacket_len(rem_len = MQTTSerialize_publishLength(qos, topicName, payloadlen)) > buflen)
65 {
66 rc = MQTTPACKET_BUFFER_TOO_SHORT;
67 goto exit;
68 }
69
70 header.bits.type = PUBLISH;
71 header.bits.dup = dup;
72 header.bits.qos = qos;
73 header.bits.retain = retained;
74 writeChar(&ptr, header.byte); /* write header */
75
76 ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
77
78 writeMQTTString(&ptr, topicName);
79
80 if (qos > 0)
81 writeInt(&ptr, packetid);
82
83 memcpy(ptr, payload, payloadlen);
84 ptr += payloadlen;
85
86 rc = ptr - buf;
87
88 exit:
89 FUNC_EXIT_RC(rc);
90 return rc;
91 }
92
93
94
104 int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
105 {
106 MQTTHeader header = {0};
107 int rc = 0;
108 unsigned char *ptr = buf;
109
110 FUNC_ENTRY;
111 if (buflen < 4)
112 {
113 rc = MQTTPACKET_BUFFER_TOO_SHORT;
114 goto exit;
115 }
116 header.bits.type = packettype;
117 header.bits.dup = dup;
118 header.bits.qos = (packettype == PUBREL) ? 1 : 0;
119 writeChar(&ptr, header.byte); /* write header */
120
121 ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
122 writeInt(&ptr, packetid);
123 rc = ptr - buf;
124 exit:
125 FUNC_EXIT_RC(rc);
126 return rc;
127 }
128
129
137 int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid)
138 {
139 return MQTTSerialize_ack(buf, buflen, PUBACK, 0, packetid);
140 }
141
142
151 int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid)
152 {
153 return MQTTSerialize_ack(buf, buflen, PUBREL, dup, packetid);
154 }
155
156
164 int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid)
165 {
166 return MQTTSerialize_ack(buf, buflen, PUBCOMP, 0, packetid);
167 }
168
169
MQTTHeader::qos
unsigned int qos
Definition: MQTTPacket.h:68
MQTTSerialize_ack
int MQTTSerialize_ack(unsigned char *buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
Definition: MQTTSerializePublish.c:104
PUBLISH
Definition: MQTTPacket.h:45
MQTTSerialize_puback
int MQTTSerialize_puback(unsigned char *buf, int buflen, unsigned short packetid)
Definition: MQTTSerializePublish.c:137
MQTTSerialize_pubrel
int MQTTSerialize_pubrel(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid)
Definition: MQTTSerializePublish.c:151
MQTTHeader::bits
struct MQTTHeader::@6 bits
MQTTSerialize_publishLength
int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen)
Definition: MQTTSerializePublish.c:31
MQTTSerialize_publish
int MQTTSerialize_publish(unsigned char *buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, MQTTString topicName, unsigned char *payload, int payloadlen)
Definition: MQTTSerializePublish.c:55
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
PUBREL
Definition: MQTTPacket.h:45
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTPacket.h
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
writeMQTTString
void writeMQTTString(unsigned char **pptr, MQTTString mqttstring)
Definition: MQTTPacket.c:194
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTHeader::dup
unsigned int dup
Definition: MQTTPacket.h:69
PUBACK
Definition: MQTTPacket.h:45
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
MQTTstrlen
int MQTTstrlen(MQTTString mqttstring)
Definition: MQTTPacket.c:242
MQTTPacket_len
int MQTTPacket_len(int rem_len)
Definition: MQTTPacket.c:84
MQTTHeader::retain
unsigned int retain
Definition: MQTTPacket.h:67
StackTrace.h
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTSerialize_pubcomp
int MQTTSerialize_pubcomp(unsigned char *buf, int buflen, unsigned short packetid)
Definition: MQTTSerializePublish.c:164
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
PUBCOMP
Definition: MQTTPacket.h:46
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSubscribe.h Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTSubscribe.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Xiang Rong - 442039 Add makefile to Embedded C client
16 *******************************************************************************/
17
18 #ifndef MQTTSUBSCRIBE_H_
19 #define MQTTSUBSCRIBE_H_
20
21 #if !defined(DLLImport)
22 #define DLLImport
23 #endif
24 #if !defined(DLLExport)
25 #define DLLExport
26 #endif
27
28 DLLExport int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
29 int count, MQTTString topicFilters[], int requestedQoSs[]);
30
31 DLLExport int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid,
32 int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len);
33
34 DLLExport int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs);
35
36 DLLExport int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len);
37
38
39 #endif /* MQTTSUBSCRIBE_H_ */
MQTTDeserialize_subscribe
DLLExport int MQTTDeserialize_subscribe(unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], unsigned char *buf, int len)
Definition: MQTTSubscribeServer.c:35
MQTTString
Definition: MQTTPacket.h:81
MQTTSerialize_suback
DLLExport int MQTTSerialize_suback(unsigned char *buf, int buflen, unsigned short packetid, int count, int *grantedQoSs)
Definition: MQTTSubscribeServer.c:82
MQTTSerialize_subscribe
DLLExport int MQTTSerialize_subscribe(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
Definition: MQTTSubscribeClient.c:50
DLLExport
#define DLLExport
Definition: MQTTSubscribe.h:25
MQTTDeserialize_suback
DLLExport int MQTTDeserialize_suback(unsigned short *packetid, int maxcount, int *count, int grantedQoSs[], unsigned char *buf, int len)
Definition: MQTTSubscribeClient.c:100


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSubscribeClient.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTSubscribeClient.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "MQTTPacket.h"
18 #include "StackTrace.h"
19
20 #include <string.h>
21
28 int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[])
29 {
30 int i;
31 int len = 2; /* packetid */
32
33 for (i = 0; i < count; ++i)
34 len += 2 + MQTTstrlen(topicFilters[i]) + 1; /* length + topic + req_qos */
35 return len;
36 }
37
38
50 int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, int count,
51 MQTTString topicFilters[], int requestedQoSs[])
52 {
53 unsigned char *ptr = buf;
54 MQTTHeader header = {0};
55 int rem_len = 0;
56 int rc = 0;
57 int i = 0;
58
59 FUNC_ENTRY;
60 if (MQTTPacket_len(rem_len = MQTTSerialize_subscribeLength(count, topicFilters)) > buflen)
61 {
62 rc = MQTTPACKET_BUFFER_TOO_SHORT;
63 goto exit;
64 }
65
66 header.byte = 0;
67 header.bits.type = SUBSCRIBE;
68 header.bits.dup = dup;
69 header.bits.qos = 1;
70 writeChar(&ptr, header.byte); /* write header */
71
72 ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
73
74 writeInt(&ptr, packetid);
75
76 for (i = 0; i < count; ++i)
77 {
78 writeMQTTString(&ptr, topicFilters[i]);
79 writeChar(&ptr, requestedQoSs[i]);
80 }
81
82 rc = ptr - buf;
83 exit:
84 FUNC_EXIT_RC(rc);
85 return rc;
86 }
87
88
89
100 int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int buflen)
101 {
102 MQTTHeader header = {0};
103 unsigned char* curdata = buf;
104 unsigned char* enddata = NULL;
105 int rc = 0;
106 int mylen;
107
108 FUNC_ENTRY;
109 header.byte = readChar(&curdata);
110 if (header.bits.type != SUBACK)
111 goto exit;
112
113 curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
114 enddata = curdata + mylen;
115 if (enddata - curdata < 2)
116 goto exit;
117
118 *packetid = readInt(&curdata);
119
120 *count = 0;
121 while (curdata < enddata)
122 {
123 if (*count > maxcount)
124 {
125 rc = -1;
126 goto exit;
127 }
128 grantedQoSs[(*count)++] = readChar(&curdata);
129 }
130
131 rc = 1;
132 exit:
133 FUNC_EXIT_RC(rc);
134 return rc;
135 }
136
137
MQTTHeader::qos
unsigned int qos
Definition: MQTTPacket.h:68
MQTTHeader::bits
struct MQTTHeader::@6 bits
SUBSCRIBE
Definition: MQTTPacket.h:46
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
MQTTDeserialize_suback
int MQTTDeserialize_suback(unsigned short *packetid, int maxcount, int *count, int grantedQoSs[], unsigned char *buf, int buflen)
Definition: MQTTSubscribeClient.c:100
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTSerialize_subscribeLength
int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[])
Definition: MQTTSubscribeClient.c:28
readInt
int readInt(unsigned char **pptr)
Definition: MQTTPacket.c:125
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTSerialize_subscribe
int MQTTSerialize_subscribe(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
Definition: MQTTSubscribeClient.c:50
MQTTPacket.h
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
writeMQTTString
void writeMQTTString(unsigned char **pptr, MQTTString mqttstring)
Definition: MQTTPacket.c:194
SUBACK
Definition: MQTTPacket.h:46
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTHeader::dup
unsigned int dup
Definition: MQTTPacket.h:69
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
MQTTstrlen
int MQTTstrlen(MQTTString mqttstring)
Definition: MQTTPacket.c:242
MQTTPacket_len
int MQTTPacket_len(int rem_len)
Definition: MQTTPacket.c:84
StackTrace.h
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTSubscribeServer.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTSubscribeServer.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "MQTTPacket.h"
18 #include "StackTrace.h"
19
20 #include <string.h>
21
22
35 int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
36 int requestedQoSs[], unsigned char* buf, int buflen)
37 {
38 MQTTHeader header = {0};
39 unsigned char* curdata = buf;
40 unsigned char* enddata = NULL;
41 int rc = -1;
42 int mylen = 0;
43
44 FUNC_ENTRY;
45 header.byte = readChar(&curdata);
46 if (header.bits.type != SUBSCRIBE)
47 goto exit;
48 *dup = header.bits.dup;
49
50 curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
51 enddata = curdata + mylen;
52
53 *packetid = readInt(&curdata);
54
55 *count = 0;
56 while (curdata < enddata)
57 {
58 if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
59 goto exit;
60 if (curdata >= enddata) /* do we have enough data to read the req_qos version byte? */
61 goto exit;
62 requestedQoSs[*count] = readChar(&curdata);
63 (*count)++;
64 }
65
66 rc = 1;
67 exit:
68 FUNC_EXIT_RC(rc);
69 return rc;
70 }
71
72
82 int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs)
83 {
84 MQTTHeader header = {0};
85 int rc = -1;
86 unsigned char *ptr = buf;
87 int i;
88
89 FUNC_ENTRY;
90 if (buflen < 2 + count)
91 {
92 rc = MQTTPACKET_BUFFER_TOO_SHORT;
93 goto exit;
94 }
95 header.byte = 0;
96 header.bits.type = SUBACK;
97 writeChar(&ptr, header.byte); /* write header */
98
99 ptr += MQTTPacket_encode(ptr, 2 + count); /* write remaining length */
100
101 writeInt(&ptr, packetid);
102
103 for (i = 0; i < count; ++i)
104 writeChar(&ptr, grantedQoSs[i]);
105
106 rc = ptr - buf;
107 exit:
108 FUNC_EXIT_RC(rc);
109 return rc;
110 }
111
112
MQTTSerialize_suback
int MQTTSerialize_suback(unsigned char *buf, int buflen, unsigned short packetid, int count, int *grantedQoSs)
Definition: MQTTSubscribeServer.c:82
MQTTHeader::bits
struct MQTTHeader::@6 bits
SUBSCRIBE
Definition: MQTTPacket.h:46
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTDeserialize_subscribe
int MQTTDeserialize_subscribe(unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], unsigned char *buf, int buflen)
Definition: MQTTSubscribeServer.c:35
readInt
int readInt(unsigned char **pptr)
Definition: MQTTPacket.c:125
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTPacket.h
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
SUBACK
Definition: MQTTPacket.h:46
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTHeader::dup
unsigned int dup
Definition: MQTTPacket.h:69
readMQTTLenString
int readMQTTLenString(MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
Definition: MQTTPacket.c:215
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
StackTrace.h
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTUnsubscribe.h Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTUnsubscribe.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Xiang Rong - 442039 Add makefile to Embedded C client
16 *******************************************************************************/
17
18 #ifndef MQTTUNSUBSCRIBE_H_
19 #define MQTTUNSUBSCRIBE_H_
20
21 #if !defined(DLLImport)
22 #define DLLImport
23 #endif
24 #if !defined(DLLExport)
25 #define DLLExport
26 #endif
27
28 DLLExport int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
29 int count, MQTTString topicFilters[]);
30
31 DLLExport int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[],
32 unsigned char* buf, int len);
33
34 DLLExport int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid);
35
36 DLLExport int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len);
37
38 #endif /* MQTTUNSUBSCRIBE_H_ */
MQTTString
Definition: MQTTPacket.h:81
MQTTDeserialize_unsuback
DLLExport int MQTTDeserialize_unsuback(unsigned short *packetid, unsigned char *buf, int len)
Definition: MQTTUnsubscribeClient.c:92
MQTTDeserialize_unsubscribe
DLLExport int MQTTDeserialize_unsubscribe(unsigned char *dup, unsigned short *packetid, int max_count, int *count, MQTTString topicFilters[], unsigned char *buf, int len)
Definition: MQTTUnsubscribeServer.c:34
DLLExport
#define DLLExport
Definition: MQTTUnsubscribe.h:25
MQTTSerialize_unsuback
DLLExport int MQTTSerialize_unsuback(unsigned char *buf, int buflen, unsigned short packetid)
Definition: MQTTUnsubscribeServer.c:76
MQTTSerialize_unsubscribe
DLLExport int MQTTSerialize_unsubscribe(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
Definition: MQTTUnsubscribeClient.c:49


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeClient.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTUnsubscribeClient.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "MQTTPacket.h"
18 #include "StackTrace.h"
19
20 #include <string.h>
21
28 int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[])
29 {
30 int i;
31 int len = 2; /* packetid */
32
33 for (i = 0; i < count; ++i)
34 len += 2 + MQTTstrlen(topicFilters[i]); /* length + topic*/
35 return len;
36 }
37
38
49 int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
50 int count, MQTTString topicFilters[])
51 {
52 unsigned char *ptr = buf;
53 MQTTHeader header = {0};
54 int rem_len = 0;
55 int rc = -1;
56 int i = 0;
57
58 FUNC_ENTRY;
59 if (MQTTPacket_len(rem_len = MQTTSerialize_unsubscribeLength(count, topicFilters)) > buflen)
60 {
61 rc = MQTTPACKET_BUFFER_TOO_SHORT;
62 goto exit;
63 }
64
65 header.byte = 0;
66 header.bits.type = UNSUBSCRIBE;
67 header.bits.dup = dup;
68 header.bits.qos = 1;
69 writeChar(&ptr, header.byte); /* write header */
70
71 ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
72
73 writeInt(&ptr, packetid);
74
75 for (i = 0; i < count; ++i)
76 writeMQTTString(&ptr, topicFilters[i]);
77
78 rc = ptr - buf;
79 exit:
80 FUNC_EXIT_RC(rc);
81 return rc;
82 }
83
84
92 int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int buflen)
93 {
94 unsigned char type = 0;
95 unsigned char dup = 0;
96 int rc = 0;
97
98 FUNC_ENTRY;
99 rc = MQTTDeserialize_ack(&type, &dup, packetid, buf, buflen);
100 if (type == UNSUBACK)
101 rc = 1;
102 FUNC_EXIT_RC(rc);
103 return rc;
104 }
105
106
MQTTHeader::qos
unsigned int qos
Definition: MQTTPacket.h:68
MQTTHeader::bits
struct MQTTHeader::@6 bits
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTDeserialize_unsuback
int MQTTDeserialize_unsuback(unsigned short *packetid, unsigned char *buf, int buflen)
Definition: MQTTUnsubscribeClient.c:92
MQTTPacket.h
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
writeMQTTString
void writeMQTTString(unsigned char **pptr, MQTTString mqttstring)
Definition: MQTTPacket.c:194
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTHeader::dup
unsigned int dup
Definition: MQTTPacket.h:69
UNSUBSCRIBE
Definition: MQTTPacket.h:46
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
MQTTDeserialize_ack
int MQTTDeserialize_ack(unsigned char *packettype, unsigned char *dup, unsigned short *packetid, unsigned char *buf, int buflen)
Definition: MQTTDeserializePublish.c:82
MQTTstrlen
int MQTTstrlen(MQTTString mqttstring)
Definition: MQTTPacket.c:242
MQTTPacket_len
int MQTTPacket_len(int rem_len)
Definition: MQTTPacket.c:84
StackTrace.h
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTSerialize_unsubscribeLength
int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[])
Definition: MQTTUnsubscribeClient.c:28
MQTTSerialize_unsubscribe
int MQTTSerialize_unsubscribe(unsigned char *buf, int buflen, unsigned char dup, unsigned short packetid, int count, MQTTString topicFilters[])
Definition: MQTTUnsubscribeClient.c:49
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
UNSUBACK
Definition: MQTTPacket.h:46
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164


ioLibrary: Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeServer.c Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
MQTTUnsubscribeServer.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #include "MQTTPacket.h"
18 #include "StackTrace.h"
19
20 #include <string.h>
21
22
34 int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
35 unsigned char* buf, int len)
36 {
37 MQTTHeader header = {0};
38 unsigned char* curdata = buf;
39 unsigned char* enddata = NULL;
40 int rc = 0;
41 int mylen = 0;
42
43 FUNC_ENTRY;
44 header.byte = readChar(&curdata);
45 if (header.bits.type != UNSUBSCRIBE)
46 goto exit;
47 *dup = header.bits.dup;
48
49 curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
50 enddata = curdata + mylen;
51
52 *packetid = readInt(&curdata);
53
54 *count = 0;
55 while (curdata < enddata)
56 {
57 if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
58 goto exit;
59 (*count)++;
60 }
61
62 rc = 1;
63 exit:
64 FUNC_EXIT_RC(rc);
65 return rc;
66 }
67
68
76 int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid)
77 {
78 MQTTHeader header = {0};
79 int rc = 0;
80 unsigned char *ptr = buf;
81
82 FUNC_ENTRY;
83 if (buflen < 2)
84 {
85 rc = MQTTPACKET_BUFFER_TOO_SHORT;
86 goto exit;
87 }
88 header.byte = 0;
89 header.bits.type = UNSUBACK;
90 writeChar(&ptr, header.byte); /* write header */
91
92 ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
93
94 writeInt(&ptr, packetid);
95
96 rc = ptr - buf;
97 exit:
98 FUNC_EXIT_RC(rc);
99 return rc;
100 }
101
102
MQTTHeader::bits
struct MQTTHeader::@6 bits
MQTTHeader::byte
unsigned char byte
Definition: MQTTPacket.h:55
MQTTString
Definition: MQTTPacket.h:81
readChar
char readChar(unsigned char **pptr)
Definition: MQTTPacket.c:139
MQTTDeserialize_unsubscribe
int MQTTDeserialize_unsubscribe(unsigned char *dup, unsigned short *packetid, int maxcount, int *count, MQTTString topicFilters[], unsigned char *buf, int len)
Definition: MQTTUnsubscribeServer.c:34
readInt
int readInt(unsigned char **pptr)
Definition: MQTTPacket.c:125
MQTTPacket_encode
int MQTTPacket_encode(unsigned char *buf, int length)
Definition: MQTTPacket.c:29
MQTTPacket.h
FUNC_ENTRY
#define FUNC_ENTRY
Definition: StackTrace.h:25
writeChar
void writeChar(unsigned char **pptr, char c)
Definition: MQTTPacket.c:152
MQTTHeader::dup
unsigned int dup
Definition: MQTTPacket.h:69
UNSUBSCRIBE
Definition: MQTTPacket.h:46
readMQTTLenString
int readMQTTLenString(MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata)
Definition: MQTTPacket.c:215
FUNC_EXIT_RC
#define FUNC_EXIT_RC(x)
Definition: StackTrace.h:33
MQTTSerialize_unsuback
int MQTTSerialize_unsuback(unsigned char *buf, int buflen, unsigned short packetid)
Definition: MQTTUnsubscribeServer.c:76
StackTrace.h
MQTTPacket_decodeBuf
int MQTTPacket_decodeBuf(unsigned char *buf, int *value)
Definition: MQTTPacket.c:113
MQTTPACKET_BUFFER_TOO_SHORT
Definition: MQTTPacket.h:38
MQTTHeader::type
unsigned int type
Definition: MQTTPacket.h:70
MQTTHeader
Definition: MQTTPacket.h:53
UNSUBACK
Definition: MQTTPacket.h:46
writeInt
void writeInt(unsigned char **pptr, int anInt)
Definition: MQTTPacket.c:164


ioLibrary: Main_page.txt File Reference

Main_page.txt File Reference


ioLibrary: README.md File Reference

README.md File Reference

Go to the source code of this file.


ioLibrary: README.md Source File

README.md
Go to the documentation of this file.
1 # ioLibrary Driver
2 The ioLibrary means “Internet Offload Library” for WIZnet chip. It includes drivers and application protocols.
3 The driver (ioLibrary) can be used for the application design of WIZnet TCP/IP chips as [W5500](http://wizwiki.net/wiki/doku.php?id=products:w5500:start), W5300, W5200, W5100 [W5100S](http://wizwiki.net/wiki/doku.php?id=products:w5100s:start).
4
5 ## ioLibrary
6 This driver provides the Berkeley Socket type APIs.
7 - Directory Structure
8 <!-- ioLibrary pic -->
9 ![ioLibrary](http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:iolibrary_bsd.jpg "ioLibrary")
10
11 - Ethernet : SOCKET APIs like BSD & WIZCHIP([W5500](http://wizwiki.net/wiki/doku.php?id=products:w5500:start) / W5300 / W5200 / W5100 / [W5100S](http://wizwiki.net/wiki/doku.php?id=products:w5100s:start)) Driver
12 - Internet :
13 - DHCP client
14 - DNS client
15 - FTP client
16 - FTP server
17 - SNMP agent/trap
18 - SNTP client
19 - TFTP client
20 - HTTP server
21 - MQTT Client
22 - Others will be added.
23
24 ## How to add an ioLibrary in project through github site.
25 - Example, refer to https://www.youtube.com/watch?v=mt815RBGdsA
26 - [ioLibrary Doxygen doument](https://github.com/Wiznet/ioLibrary_Driver/blob/master/Ethernet/Socket_APIs_V3.0.3.chm) : Refer to **TODO** in this document
27 - Define what chip is used in **wizchip_conf.h**
28 - Define what Host I/F mode is used in **wizchip_conf.h**
29
30 ## Revision History
31 * ioLibrary V3.2.1 Released : 29, MAR, 2018
32 * New features added: Library for W5100S added.
33 * ioLibrary V3.1.1 Released : 14, Dec, 2016
34 * Bug fixed : In Socket.c Fixed MACraw & IPraw sendto function.
35 * ioLibrary V3.1.0 Released : 05, Dec, 2016
36 * Internet application protocol add to MQTT Client (using paho MQTT 3.11)
37 * ioLibrary V3.0.3 Released : 03, May, 2016
38 * In W5300, Fixed some compile errors in close(). Refer to M20160503
39 * In close(), replace socket() with some command sequences.
40 * ioLibrary V3.0.2 Released : 26, April, 2016
41 * Applied the erratum #1 in close() of socket.c (Refer to A20160426)
42 * ioLibrary V3.0.1 Released : 15, July, 2015
43 * Bug fixed : In W5100, Fixed CS control problem in read/write buffer with SPI. Refer to M20150715.
44 * ioLibrary V3.0 Released : 01, June, 2015
45 * Add to W5300
46 * Typing Error in comments
47 * Refer to 20150601 in sources.
48
49 * Type casting error Fixed : 09, April. 2015
50 In socket.c, send() : Refer to M20150409
51
52 * ioLibrary V2.0 released : April. 2015
53 * Added to W5100, W5200
54 * Correct to some typing error
55 * Fixed the warning of type casting.
56
57 * Last release : Nov. 2014
58


ioLibrary: Internet/SNMP/tools/OID_Converter/Readme.txt File Reference

Internet/SNMP/tools/OID_Converter/Readme.txt File Reference


ioLibrary: Internet/MQTT/MQTTPacket/src/StackTrace.h Source File

  • Internet
  • MQTT
  • MQTTPacket
  • src
StackTrace.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 * Ian Craggs - fix for bug #434081
16 *******************************************************************************/
17
18 #ifndef STACKTRACE_H_
19 #define STACKTRACE_H_
20
21 #include <stdio.h>
22 #define NOSTACKTRACE 1
23
24 #if defined(NOSTACKTRACE)
25 #define FUNC_ENTRY
26 #define FUNC_ENTRY_NOLOG
27 #define FUNC_ENTRY_MED
28 #define FUNC_ENTRY_MAX
29 #define FUNC_EXIT
30 #define FUNC_EXIT_NOLOG
31 #define FUNC_EXIT_MED
32 #define FUNC_EXIT_MAX
33 #define FUNC_EXIT_RC(x)
34 #define FUNC_EXIT_MED_RC(x)
35 #define FUNC_EXIT_MAX_RC(x)
36
37 #else
38
39 #if defined(WIN32)
40 #define inline __inline
41 #define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM)
42 #define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1)
43 #define FUNC_ENTRY_MED StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MEDIUM)
44 #define FUNC_ENTRY_MAX StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MAXIMUM)
45 #define FUNC_EXIT StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MINIMUM)
46 #define FUNC_EXIT_NOLOG StackTrace_exit(__FUNCTION__, __LINE__, -1)
47 #define FUNC_EXIT_MED StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MEDIUM)
48 #define FUNC_EXIT_MAX StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MAXIMUM)
49 #define FUNC_EXIT_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MINIMUM)
50 #define FUNC_EXIT_MED_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MEDIUM)
51 #define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MAXIMUM)
52 #else
53 #define FUNC_ENTRY StackTrace_entry(__func__, __LINE__, TRACE_MINIMUM)
54 #define FUNC_ENTRY_NOLOG StackTrace_entry(__func__, __LINE__, -1)
55 #define FUNC_ENTRY_MED StackTrace_entry(__func__, __LINE__, TRACE_MEDIUM)
56 #define FUNC_ENTRY_MAX StackTrace_entry(__func__, __LINE__, TRACE_MAXIMUM)
57 #define FUNC_EXIT StackTrace_exit(__func__, __LINE__, NULL, TRACE_MINIMUM)
58 #define FUNC_EXIT_NOLOG StackTrace_exit(__func__, __LINE__, NULL, -1)
59 #define FUNC_EXIT_MED StackTrace_exit(__func__, __LINE__, NULL, TRACE_MEDIUM)
60 #define FUNC_EXIT_MAX StackTrace_exit(__func__, __LINE__, NULL, TRACE_MAXIMUM)
61 #define FUNC_EXIT_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MINIMUM)
62 #define FUNC_EXIT_MED_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MEDIUM)
63 #define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MAXIMUM)
64
65 void StackTrace_entry(const char* name, int line, int trace);
66 void StackTrace_exit(const char* name, int line, void* return_value, int trace);
67
68 void StackTrace_printStack(FILE* dest);
69 char* StackTrace_get(unsigned long);
70
71 #endif
72
73 #endif
74
75
76
77
78 #endif /* STACKTRACE_H_ */


ioLibrary: image/WIZnet_SOCKET.jpg Source File

  • image
WIZnet_SOCKET.jpg
Go to the documentation of this file.
1


ioLibrary: Internet/DHCP/dhcp.c Source File

  • Internet
  • DHCP
dhcp.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
49 //
50 //*****************************************************************************
51
52 #include "socket.h"
53 #include "dhcp.h"
54
55 /* If you want to display debug & procssing message, Define _DHCP_DEBUG_ in dhcp.h */
56
57 #ifdef _DHCP_DEBUG_
58 #include <stdio.h>
59 #endif
60
61 /* DHCP state machine. */
62 #define STATE_DHCP_INIT 0
63 #define STATE_DHCP_DISCOVER 1
64 #define STATE_DHCP_REQUEST 2
65 #define STATE_DHCP_LEASED 3
66 #define STATE_DHCP_REREQUEST 4
67 #define STATE_DHCP_RELEASE 5
68 #define STATE_DHCP_STOP 6
69
70 #define DHCP_FLAGSBROADCAST 0x8000
71 #define DHCP_FLAGSUNICAST 0x0000
72
73 /* DHCP message OP code */
74 #define DHCP_BOOTREQUEST 1
75 #define DHCP_BOOTREPLY 2
76
77 /* DHCP message type */
78 #define DHCP_DISCOVER 1
79 #define DHCP_OFFER 2
80 #define DHCP_REQUEST 3
81 #define DHCP_DECLINE 4
82 #define DHCP_ACK 5
83 #define DHCP_NAK 6
84 #define DHCP_RELEASE 7
85 #define DHCP_INFORM 8
86
87 #define DHCP_HTYPE10MB 1
88 #define DHCP_HTYPE100MB 2
89
90 #define DHCP_HLENETHERNET 6
91 #define DHCP_HOPS 0
92 #define DHCP_SECS 0
93
94 #define INFINITE_LEASETIME 0xffffffff
95
96 #define OPT_SIZE 312
97 #define RIP_MSG_SIZE (236+OPT_SIZE)
98
99 /*
100 * @brief DHCP option and value (cf. RFC1533)
101 */
102 enum
103 {
104 padOption = 0,
105 subnetMask = 1,
106 timerOffset = 2,
107 routersOnSubnet = 3,
108 timeServer = 4,
109 nameServer = 5,
110 dns = 6,
111 logServer = 7,
112 cookieServer = 8,
113 lprServer = 9,
114 impressServer = 10,
115 resourceLocationServer = 11,
116 hostName = 12,
117 bootFileSize = 13,
118 meritDumpFile = 14,
119 domainName = 15,
120 swapServer = 16,
121 rootPath = 17,
122 extentionsPath = 18,
123 IPforwarding = 19,
124 nonLocalSourceRouting = 20,
125 policyFilter = 21,
126 maxDgramReasmSize = 22,
127 defaultIPTTL = 23,
128 pathMTUagingTimeout = 24,
129 pathMTUplateauTable = 25,
130 ifMTU = 26,
131 allSubnetsLocal = 27,
132 broadcastAddr = 28,
133 performMaskDiscovery = 29,
134 maskSupplier = 30,
135 performRouterDiscovery = 31,
136 routerSolicitationAddr = 32,
137 staticRoute = 33,
138 trailerEncapsulation = 34,
139 arpCacheTimeout = 35,
140 ethernetEncapsulation = 36,
141 tcpDefaultTTL = 37,
142 tcpKeepaliveInterval = 38,
143 tcpKeepaliveGarbage = 39,
144 nisDomainName = 40,
145 nisServers = 41,
146 ntpServers = 42,
147 vendorSpecificInfo = 43,
148 netBIOSnameServer = 44,
149 netBIOSdgramDistServer = 45,
150 netBIOSnodeType = 46,
151 netBIOSscope = 47,
152 xFontServer = 48,
153 xDisplayManager = 49,
154 dhcpRequestedIPaddr = 50,
155 dhcpIPaddrLeaseTime = 51,
156 dhcpOptionOverload = 52,
157 dhcpMessageType = 53,
158 dhcpServerIdentifier = 54,
159 dhcpParamRequest = 55,
160 dhcpMsg = 56,
161 dhcpMaxMsgSize = 57,
162 dhcpT1value = 58,
163 dhcpT2value = 59,
164 dhcpClassIdentifier = 60,
165 dhcpClientIdentifier = 61,
166 endOption = 255
167 };
168
169 /*
170 * @brief DHCP message format
171 */
172 typedef struct {
173 uint8_t op;
174 uint8_t htype;
175 uint8_t hlen;
176 uint8_t hops;
177 uint32_t xid;
178 uint16_t secs;
179 uint16_t flags;
180 uint8_t ciaddr[4];
181 uint8_t yiaddr[4];
182 uint8_t siaddr[4];
183 uint8_t giaddr[4];
184 uint8_t chaddr[16];
185 uint8_t sname[64];
186 uint8_t file[128];
187 uint8_t OPT[OPT_SIZE];
188 } RIP_MSG;
189
190
191
192 uint8_t DHCP_SOCKET; // Socket number for DHCP
193
194 uint8_t DHCP_SIP[4]; // DHCP Server IP address
195
196 // Network information from DHCP Server
197 uint8_t OLD_allocated_ip[4] = {0, }; // Previous IP address
198 uint8_t DHCP_allocated_ip[4] = {0, }; // IP address from DHCP
199 uint8_t DHCP_allocated_gw[4] = {0, }; // Gateway address from DHCP
200 uint8_t DHCP_allocated_sn[4] = {0, }; // Subnet mask from DHCP
201 uint8_t DHCP_allocated_dns[4] = {0, }; // DNS address from DHCP
202
203
204 int8_t dhcp_state = STATE_DHCP_INIT; // DHCP state
205 int8_t dhcp_retry_count = 0;
206
207 uint32_t dhcp_lease_time = INFINITE_LEASETIME;
208 volatile uint32_t dhcp_tick_1s = 0; // unit 1 second
209 uint32_t dhcp_tick_next = DHCP_WAIT_TIME ;
210
211 uint32_t DHCP_XID; // Any number
212
213 RIP_MSG* pDHCPMSG; // Buffer pointer for DHCP processing
214
215 uint8_t HOST_NAME[] = DCHP_HOST_NAME;
216
217 uint8_t DHCP_CHADDR[6]; // DHCP Client MAC address.
218
219 /* The default callback function */
220 void default_ip_assign(void);
221 void default_ip_update(void);
222 void default_ip_conflict(void);
223
224 /* Callback handler */
225 void (*dhcp_ip_assign)(void) = default_ip_assign; /* handler to be called when the IP address from DHCP server is first assigned */
226 void (*dhcp_ip_update)(void) = default_ip_update; /* handler to be called when the IP address from DHCP server is updated */
227 void (*dhcp_ip_conflict)(void) = default_ip_conflict; /* handler to be called when the IP address from DHCP server is conflict */
228
229 void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void));
230
231
232 /* send DISCOVER message to DHCP server */
233 void send_DHCP_DISCOVER(void);
234
235 /* send REQEUST message to DHCP server */
236 void send_DHCP_REQUEST(void);
237
238 /* send DECLINE message to DHCP server */
239 void send_DHCP_DECLINE(void);
240
241 /* IP conflict check by sending ARP-request to leased IP and wait ARP-response. */
242 int8_t check_DHCP_leasedIP(void);
243
244 /* check the timeout in DHCP process */
245 uint8_t check_DHCP_timeout(void);
246
247 /* Intialize to timeout process. */
248 void reset_DHCP_timeout(void);
249
250 /* Parse message as OFFER and ACK and NACK from DHCP server.*/
251 int8_t parseDHCPCMSG(void);
252
253 /* The default handler of ip assign first */
254 void default_ip_assign(void)
255 {
256 setSIPR(DHCP_allocated_ip);
257 setSUBR(DHCP_allocated_sn);
258 setGAR (DHCP_allocated_gw);
259 }
260
261 /* The default handler of ip chaged */
262 void default_ip_update(void)
263 {
264 /* WIZchip Software Reset */
265 setMR(MR_RST);
266 getMR(); // for delay
267 default_ip_assign();
268 setSHAR(DHCP_CHADDR);
269 }
270
271 /* The default handler of ip chaged */
272 void default_ip_conflict(void)
273 {
274 // WIZchip Software Reset
275 setMR(MR_RST);
276 getMR(); // for delay
277 setSHAR(DHCP_CHADDR);
278 }
279
280 /* register the call back func. */
281 void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void))
282 {
283 dhcp_ip_assign = default_ip_assign;
284 dhcp_ip_update = default_ip_update;
285 dhcp_ip_conflict = default_ip_conflict;
286 if(ip_assign) dhcp_ip_assign = ip_assign;
287 if(ip_update) dhcp_ip_update = ip_update;
288 if(ip_conflict) dhcp_ip_conflict = ip_conflict;
289 }
290
291 /* make the common DHCP message */
292 void makeDHCPMSG(void)
293 {
294 uint8_t bk_mac[6];
295 uint8_t* ptmp;
296 uint8_t i;
297 getSHAR(bk_mac);
298 pDHCPMSG->op = DHCP_BOOTREQUEST;
299 pDHCPMSG->htype = DHCP_HTYPE10MB;
300 pDHCPMSG->hlen = DHCP_HLENETHERNET;
301 pDHCPMSG->hops = DHCP_HOPS;
302 ptmp = (uint8_t*)(&pDHCPMSG->xid);
303 *(ptmp+0) = (uint8_t)((DHCP_XID & 0xFF000000) >> 24);
304 *(ptmp+1) = (uint8_t)((DHCP_XID & 0x00FF0000) >> 16);
305 *(ptmp+2) = (uint8_t)((DHCP_XID & 0x0000FF00) >> 8);
306 *(ptmp+3) = (uint8_t)((DHCP_XID & 0x000000FF) >> 0);
307 pDHCPMSG->secs = DHCP_SECS;
308 ptmp = (uint8_t*)(&pDHCPMSG->flags);
309 *(ptmp+0) = (uint8_t)((DHCP_FLAGSBROADCAST & 0xFF00) >> 8);
310 *(ptmp+1) = (uint8_t)((DHCP_FLAGSBROADCAST & 0x00FF) >> 0);
311
312 pDHCPMSG->ciaddr[0] = 0;
313 pDHCPMSG->ciaddr[1] = 0;
314 pDHCPMSG->ciaddr[2] = 0;
315 pDHCPMSG->ciaddr[3] = 0;
316
317 pDHCPMSG->yiaddr[0] = 0;
318 pDHCPMSG->yiaddr[1] = 0;
319 pDHCPMSG->yiaddr[2] = 0;
320 pDHCPMSG->yiaddr[3] = 0;
321
322 pDHCPMSG->siaddr[0] = 0;
323 pDHCPMSG->siaddr[1] = 0;
324 pDHCPMSG->siaddr[2] = 0;
325 pDHCPMSG->siaddr[3] = 0;
326
327 pDHCPMSG->giaddr[0] = 0;
328 pDHCPMSG->giaddr[1] = 0;
329 pDHCPMSG->giaddr[2] = 0;
330 pDHCPMSG->giaddr[3] = 0;
331
332 pDHCPMSG->chaddr[0] = DHCP_CHADDR[0];
333 pDHCPMSG->chaddr[1] = DHCP_CHADDR[1];
334 pDHCPMSG->chaddr[2] = DHCP_CHADDR[2];
335 pDHCPMSG->chaddr[3] = DHCP_CHADDR[3];
336 pDHCPMSG->chaddr[4] = DHCP_CHADDR[4];
337 pDHCPMSG->chaddr[5] = DHCP_CHADDR[5];
338
339 for (i = 6; i < 16; i++) pDHCPMSG->chaddr[i] = 0;
340 for (i = 0; i < 64; i++) pDHCPMSG->sname[i] = 0;
341 for (i = 0; i < 128; i++) pDHCPMSG->file[i] = 0;
342
343 // MAGIC_COOKIE
344 pDHCPMSG->OPT[0] = (uint8_t)((MAGIC_COOKIE & 0xFF000000) >> 24);
345 pDHCPMSG->OPT[1] = (uint8_t)((MAGIC_COOKIE & 0x00FF0000) >> 16);
346 pDHCPMSG->OPT[2] = (uint8_t)((MAGIC_COOKIE & 0x0000FF00) >> 8);
347 pDHCPMSG->OPT[3] = (uint8_t) (MAGIC_COOKIE & 0x000000FF) >> 0;
348 }
349
350 /* SEND DHCP DISCOVER */
351 void send_DHCP_DISCOVER(void)
352 {
353 uint16_t i;
354 uint8_t ip[4];
355 uint16_t k = 0;
356
357 makeDHCPMSG();
358
359 k = 4; // beacaue MAGIC_COOKIE already made by makeDHCPMSG()
360
361 // Option Request Param
362 pDHCPMSG->OPT[k++] = dhcpMessageType;
363 pDHCPMSG->OPT[k++] = 0x01;
364 pDHCPMSG->OPT[k++] = DHCP_DISCOVER;
365
366 // Client identifier
367 pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
368 pDHCPMSG->OPT[k++] = 0x07;
369 pDHCPMSG->OPT[k++] = 0x01;
370 pDHCPMSG->OPT[k++] = DHCP_CHADDR[0];
371 pDHCPMSG->OPT[k++] = DHCP_CHADDR[1];
372 pDHCPMSG->OPT[k++] = DHCP_CHADDR[2];
373 pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
374 pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
375 pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
376
377 // host name
378 pDHCPMSG->OPT[k++] = hostName;
379 pDHCPMSG->OPT[k++] = 0; // fill zero length of hostname
380 for(i = 0 ; HOST_NAME[i] != 0; i++)
381 pDHCPMSG->OPT[k++] = HOST_NAME[i];
382 pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
383 pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
384 pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
385 pDHCPMSG->OPT[k - (i+3+1)] = i+3; // length of hostname
386
387 pDHCPMSG->OPT[k++] = dhcpParamRequest;
388 pDHCPMSG->OPT[k++] = 0x06; // length of request
389 pDHCPMSG->OPT[k++] = subnetMask;
390 pDHCPMSG->OPT[k++] = routersOnSubnet;
391 pDHCPMSG->OPT[k++] = dns;
392 pDHCPMSG->OPT[k++] = domainName;
393 pDHCPMSG->OPT[k++] = dhcpT1value;
394 pDHCPMSG->OPT[k++] = dhcpT2value;
395 pDHCPMSG->OPT[k++] = endOption;
396
397 for (i = k; i < OPT_SIZE; i++) pDHCPMSG->OPT[i] = 0;
398
399 // send broadcasting packet
400 ip[0] = 255;
401 ip[1] = 255;
402 ip[2] = 255;
403 ip[3] = 255;
404
405 #ifdef _DHCP_DEBUG_
406 printf("> Send DHCP_DISCOVER\r\n");
407 #endif
408
409 sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT);
410 }
411
412 /* SEND DHCP REQUEST */
413 void send_DHCP_REQUEST(void)
414 {
415 int i;
416 uint8_t ip[4];
417 uint16_t k = 0;
418
419 makeDHCPMSG();
420
421 if(dhcp_state == STATE_DHCP_LEASED || dhcp_state == STATE_DHCP_REREQUEST)
422 {
423 *((uint8_t*)(&pDHCPMSG->flags)) = ((DHCP_FLAGSUNICAST & 0xFF00)>> 8);
424 *((uint8_t*)(&pDHCPMSG->flags)+1) = (DHCP_FLAGSUNICAST & 0x00FF);
425 pDHCPMSG->ciaddr[0] = DHCP_allocated_ip[0];
426 pDHCPMSG->ciaddr[1] = DHCP_allocated_ip[1];
427 pDHCPMSG->ciaddr[2] = DHCP_allocated_ip[2];
428 pDHCPMSG->ciaddr[3] = DHCP_allocated_ip[3];
429 ip[0] = DHCP_SIP[0];
430 ip[1] = DHCP_SIP[1];
431 ip[2] = DHCP_SIP[2];
432 ip[3] = DHCP_SIP[3];
433 }
434 else
435 {
436 ip[0] = 255;
437 ip[1] = 255;
438 ip[2] = 255;
439 ip[3] = 255;
440 }
441
442 k = 4; // beacaue MAGIC_COOKIE already made by makeDHCPMSG()
443
444 // Option Request Param.
445 pDHCPMSG->OPT[k++] = dhcpMessageType;
446 pDHCPMSG->OPT[k++] = 0x01;
447 pDHCPMSG->OPT[k++] = DHCP_REQUEST;
448
449 pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
450 pDHCPMSG->OPT[k++] = 0x07;
451 pDHCPMSG->OPT[k++] = 0x01;
452 pDHCPMSG->OPT[k++] = DHCP_CHADDR[0];
453 pDHCPMSG->OPT[k++] = DHCP_CHADDR[1];
454 pDHCPMSG->OPT[k++] = DHCP_CHADDR[2];
455 pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
456 pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
457 pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
458
459 if(ip[3] == 255) // if(dchp_state == STATE_DHCP_LEASED || dchp_state == DHCP_REREQUEST_STATE)
460 {
461 pDHCPMSG->OPT[k++] = dhcpRequestedIPaddr;
462 pDHCPMSG->OPT[k++] = 0x04;
463 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[0];
464 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[1];
465 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[2];
466 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[3];
467
468 pDHCPMSG->OPT[k++] = dhcpServerIdentifier;
469 pDHCPMSG->OPT[k++] = 0x04;
470 pDHCPMSG->OPT[k++] = DHCP_SIP[0];
471 pDHCPMSG->OPT[k++] = DHCP_SIP[1];
472 pDHCPMSG->OPT[k++] = DHCP_SIP[2];
473 pDHCPMSG->OPT[k++] = DHCP_SIP[3];
474 }
475
476 // host name
477 pDHCPMSG->OPT[k++] = hostName;
478 pDHCPMSG->OPT[k++] = 0; // length of hostname
479 for(i = 0 ; HOST_NAME[i] != 0; i++)
480 pDHCPMSG->OPT[k++] = HOST_NAME[i];
481 pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
482 pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
483 pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
484 pDHCPMSG->OPT[k - (i+3+1)] = i+3; // length of hostname
485
486 pDHCPMSG->OPT[k++] = dhcpParamRequest;
487 pDHCPMSG->OPT[k++] = 0x08;
488 pDHCPMSG->OPT[k++] = subnetMask;
489 pDHCPMSG->OPT[k++] = routersOnSubnet;
490 pDHCPMSG->OPT[k++] = dns;
491 pDHCPMSG->OPT[k++] = domainName;
492 pDHCPMSG->OPT[k++] = dhcpT1value;
493 pDHCPMSG->OPT[k++] = dhcpT2value;
494 pDHCPMSG->OPT[k++] = performRouterDiscovery;
495 pDHCPMSG->OPT[k++] = staticRoute;
496 pDHCPMSG->OPT[k++] = endOption;
497
498 for (i = k; i < OPT_SIZE; i++) pDHCPMSG->OPT[i] = 0;
499
500 #ifdef _DHCP_DEBUG_
501 printf("> Send DHCP_REQUEST\r\n");
502 #endif
503
504 sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT);
505
506 }
507
508 /* SEND DHCP DHCPDECLINE */
509 void send_DHCP_DECLINE(void)
510 {
511 int i;
512 uint8_t ip[4];
513 uint16_t k = 0;
514
515 makeDHCPMSG();
516
517 k = 4; // beacaue MAGIC_COOKIE already made by makeDHCPMSG()
518
519 *((uint8_t*)(&pDHCPMSG->flags)) = ((DHCP_FLAGSUNICAST & 0xFF00)>> 8);
520 *((uint8_t*)(&pDHCPMSG->flags)+1) = (DHCP_FLAGSUNICAST & 0x00FF);
521
522 // Option Request Param.
523 pDHCPMSG->OPT[k++] = dhcpMessageType;
524 pDHCPMSG->OPT[k++] = 0x01;
525 pDHCPMSG->OPT[k++] = DHCP_DECLINE;
526
527 pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
528 pDHCPMSG->OPT[k++] = 0x07;
529 pDHCPMSG->OPT[k++] = 0x01;
530 pDHCPMSG->OPT[k++] = DHCP_CHADDR[0];
531 pDHCPMSG->OPT[k++] = DHCP_CHADDR[1];
532 pDHCPMSG->OPT[k++] = DHCP_CHADDR[2];
533 pDHCPMSG->OPT[k++] = DHCP_CHADDR[3];
534 pDHCPMSG->OPT[k++] = DHCP_CHADDR[4];
535 pDHCPMSG->OPT[k++] = DHCP_CHADDR[5];
536
537 pDHCPMSG->OPT[k++] = dhcpRequestedIPaddr;
538 pDHCPMSG->OPT[k++] = 0x04;
539 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[0];
540 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[1];
541 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[2];
542 pDHCPMSG->OPT[k++] = DHCP_allocated_ip[3];
543
544 pDHCPMSG->OPT[k++] = dhcpServerIdentifier;
545 pDHCPMSG->OPT[k++] = 0x04;
546 pDHCPMSG->OPT[k++] = DHCP_SIP[0];
547 pDHCPMSG->OPT[k++] = DHCP_SIP[1];
548 pDHCPMSG->OPT[k++] = DHCP_SIP[2];
549 pDHCPMSG->OPT[k++] = DHCP_SIP[3];
550
551 pDHCPMSG->OPT[k++] = endOption;
552
553 for (i = k; i < OPT_SIZE; i++) pDHCPMSG->OPT[i] = 0;
554
555 //send broadcasting packet
556 ip[0] = 0xFF;
557 ip[1] = 0xFF;
558 ip[2] = 0xFF;
559 ip[3] = 0xFF;
560
561 #ifdef _DHCP_DEBUG_
562 printf("\r\n> Send DHCP_DECLINE\r\n");
563 #endif
564
565 sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT);
566 }
567
568 /* PARSE REPLY pDHCPMSG */
569 int8_t parseDHCPMSG(void)
570 {
571 uint8_t svr_addr[6];
572 uint16_t svr_port;
573 uint16_t len;
574
575 uint8_t * p;
576 uint8_t * e;
577 uint8_t type;
578 uint8_t opt_len;
579
580 if((len = getSn_RX_RSR(DHCP_SOCKET)) > 0)
581 {
582 len = recvfrom(DHCP_SOCKET, (uint8_t *)pDHCPMSG, len, svr_addr, &svr_port);
583 #ifdef _DHCP_DEBUG_
584 printf("DHCP message : %d.%d.%d.%d(%d) %d received. \r\n",svr_addr[0],svr_addr[1],svr_addr[2], svr_addr[3],svr_port, len);
585 #endif
586 }
587 else return 0;
588 if (svr_port == DHCP_SERVER_PORT) {
589 // compare mac address
590 if ( (pDHCPMSG->chaddr[0] != DHCP_CHADDR[0]) || (pDHCPMSG->chaddr[1] != DHCP_CHADDR[1]) ||
591 (pDHCPMSG->chaddr[2] != DHCP_CHADDR[2]) || (pDHCPMSG->chaddr[3] != DHCP_CHADDR[3]) ||
592 (pDHCPMSG->chaddr[4] != DHCP_CHADDR[4]) || (pDHCPMSG->chaddr[5] != DHCP_CHADDR[5]) )
593 return 0;
594 type = 0;
595 p = (uint8_t *)(&pDHCPMSG->op);
596 p = p + 240; // 240 = sizeof(RIP_MSG) + MAGIC_COOKIE size in RIP_MSG.opt - sizeof(RIP_MSG.opt)
597 e = p + (len - 240);
598
599 while ( p < e ) {
600
601 switch ( *p ) {
602
603 case endOption :
604 p = e; // for break while(p < e)
605 break;
606 case padOption :
607 p++;
608 break;
609 case dhcpMessageType :
610 p++;
611 p++;
612 type = *p++;
613 break;
614 case subnetMask :
615 p++;
616 p++;
617 DHCP_allocated_sn[0] = *p++;
618 DHCP_allocated_sn[1] = *p++;
619 DHCP_allocated_sn[2] = *p++;
620 DHCP_allocated_sn[3] = *p++;
621 break;
622 case routersOnSubnet :
623 p++;
624 opt_len = *p++;
625 DHCP_allocated_gw[0] = *p++;
626 DHCP_allocated_gw[1] = *p++;
627 DHCP_allocated_gw[2] = *p++;
628 DHCP_allocated_gw[3] = *p++;
629 p = p + (opt_len - 4);
630 break;
631 case dns :
632 p++;
633 opt_len = *p++;
634 DHCP_allocated_dns[0] = *p++;
635 DHCP_allocated_dns[1] = *p++;
636 DHCP_allocated_dns[2] = *p++;
637 DHCP_allocated_dns[3] = *p++;
638 p = p + (opt_len - 4);
639 break;
640 case dhcpIPaddrLeaseTime :
641 p++;
642 opt_len = *p++;
643 dhcp_lease_time = *p++;
644 dhcp_lease_time = (dhcp_lease_time << 8) + *p++;
645 dhcp_lease_time = (dhcp_lease_time << 8) + *p++;
646 dhcp_lease_time = (dhcp_lease_time << 8) + *p++;
647 #ifdef _DHCP_DEBUG_
648 dhcp_lease_time = 10;
649 #endif
650 break;
651 case dhcpServerIdentifier :
652 p++;
653 opt_len = *p++;
654 DHCP_SIP[0] = *p++;
655 DHCP_SIP[1] = *p++;
656 DHCP_SIP[2] = *p++;
657 DHCP_SIP[3] = *p++;
658 break;
659 default :
660 p++;
661 opt_len = *p++;
662 p += opt_len;
663 break;
664 } // switch
665 } // while
666 } // if
667 return type;
668 }
669
670 uint8_t DHCP_run(void)
671 {
672 uint8_t type;
673 uint8_t ret;
674
675 if(dhcp_state == STATE_DHCP_STOP) return DHCP_STOPPED;
676
677 if(getSn_SR(DHCP_SOCKET) != SOCK_UDP)
678 socket(DHCP_SOCKET, Sn_MR_UDP, DHCP_CLIENT_PORT, 0x00);
679
680 ret = DHCP_RUNNING;
681 type = parseDHCPMSG();
682
683 switch ( dhcp_state ) {
684 case STATE_DHCP_INIT :
685 DHCP_allocated_ip[0] = 0;
686 DHCP_allocated_ip[1] = 0;
687 DHCP_allocated_ip[2] = 0;
688 DHCP_allocated_ip[3] = 0;
689 send_DHCP_DISCOVER();
690 dhcp_state = STATE_DHCP_DISCOVER;
691 break;
692 case STATE_DHCP_DISCOVER :
693 if (type == DHCP_OFFER){
694 #ifdef _DHCP_DEBUG_
695 printf("> Receive DHCP_OFFER\r\n");
696 #endif
697 DHCP_allocated_ip[0] = pDHCPMSG->yiaddr[0];
698 DHCP_allocated_ip[1] = pDHCPMSG->yiaddr[1];
699 DHCP_allocated_ip[2] = pDHCPMSG->yiaddr[2];
700 DHCP_allocated_ip[3] = pDHCPMSG->yiaddr[3];
701
702 send_DHCP_REQUEST();
703 dhcp_state = STATE_DHCP_REQUEST;
704 } else ret = check_DHCP_timeout();
705 break;
706
707 case STATE_DHCP_REQUEST :
708 if (type == DHCP_ACK) {
709
710 #ifdef _DHCP_DEBUG_
711 printf("> Receive DHCP_ACK\r\n");
712 #endif
713 if (check_DHCP_leasedIP()) {
714 // Network info assignment from DHCP
715 dhcp_ip_assign();
716 reset_DHCP_timeout();
717
718 dhcp_state = STATE_DHCP_LEASED;
719 } else {
720 // IP address conflict occurred
721 reset_DHCP_timeout();
722 dhcp_ip_conflict();
723 dhcp_state = STATE_DHCP_INIT;
724 }
725 } else if (type == DHCP_NAK) {
726
727 #ifdef _DHCP_DEBUG_
728 printf("> Receive DHCP_NACK\r\n");
729 #endif
730
731 reset_DHCP_timeout();
732
733 dhcp_state = STATE_DHCP_DISCOVER;
734 } else ret = check_DHCP_timeout();
735 break;
736
737 case STATE_DHCP_LEASED :
738 ret = DHCP_IP_LEASED;
739 if ((dhcp_lease_time != INFINITE_LEASETIME) && ((dhcp_lease_time/2) < dhcp_tick_1s)) {
740
741 #ifdef _DHCP_DEBUG_
742 printf("> Maintains the IP address \r\n");
743 #endif
744
745 type = 0;
746 OLD_allocated_ip[0] = DHCP_allocated_ip[0];
747 OLD_allocated_ip[1] = DHCP_allocated_ip[1];
748 OLD_allocated_ip[2] = DHCP_allocated_ip[2];
749 OLD_allocated_ip[3] = DHCP_allocated_ip[3];
750
751 DHCP_XID++;
752
753 send_DHCP_REQUEST();
754
755 reset_DHCP_timeout();
756
757 dhcp_state = STATE_DHCP_REREQUEST;
758 }
759 break;
760
761 case STATE_DHCP_REREQUEST :
762 ret = DHCP_IP_LEASED;
763 if (type == DHCP_ACK) {
764 dhcp_retry_count = 0;
765 if (OLD_allocated_ip[0] != DHCP_allocated_ip[0] ||
766 OLD_allocated_ip[1] != DHCP_allocated_ip[1] ||
767 OLD_allocated_ip[2] != DHCP_allocated_ip[2] ||
768 OLD_allocated_ip[3] != DHCP_allocated_ip[3])
769 {
770 ret = DHCP_IP_CHANGED;
771 dhcp_ip_update();
772 #ifdef _DHCP_DEBUG_
773 printf(">IP changed.\r\n");
774 #endif
775
776 }
777 #ifdef _DHCP_DEBUG_
778 else printf(">IP is continued.\r\n");
779 #endif
780 reset_DHCP_timeout();
781 dhcp_state = STATE_DHCP_LEASED;
782 } else if (type == DHCP_NAK) {
783
784 #ifdef _DHCP_DEBUG_
785 printf("> Receive DHCP_NACK, Failed to maintain ip\r\n");
786 #endif
787
788 reset_DHCP_timeout();
789
790 dhcp_state = STATE_DHCP_DISCOVER;
791 } else ret = check_DHCP_timeout();
792 break;
793 default :
794 break;
795 }
796
797 return ret;
798 }
799
800 void DHCP_stop(void)
801 {
802 close(DHCP_SOCKET);
803 dhcp_state = STATE_DHCP_STOP;
804 }
805
806 uint8_t check_DHCP_timeout(void)
807 {
808 uint8_t ret = DHCP_RUNNING;
809
810 if (dhcp_retry_count < MAX_DHCP_RETRY) {
811 if (dhcp_tick_next < dhcp_tick_1s) {
812
813 switch ( dhcp_state ) {
814 case STATE_DHCP_DISCOVER :
815 // printf("<<timeout>> state : STATE_DHCP_DISCOVER\r\n");
816 send_DHCP_DISCOVER();
817 break;
818
819 case STATE_DHCP_REQUEST :
820 // printf("<<timeout>> state : STATE_DHCP_REQUEST\r\n");
821
822 send_DHCP_REQUEST();
823 break;
824
825 case STATE_DHCP_REREQUEST :
826 // printf("<<timeout>> state : STATE_DHCP_REREQUEST\r\n");
827
828 send_DHCP_REQUEST();
829 break;
830
831 default :
832 break;
833 }
834
835 dhcp_tick_1s = 0;
836 dhcp_tick_next = dhcp_tick_1s + DHCP_WAIT_TIME;
837 dhcp_retry_count++;
838 }
839 } else { // timeout occurred
840
841 switch(dhcp_state) {
842 case STATE_DHCP_DISCOVER:
843 dhcp_state = STATE_DHCP_INIT;
844 ret = DHCP_FAILED;
845 break;
846 case STATE_DHCP_REQUEST:
847 case STATE_DHCP_REREQUEST:
848 send_DHCP_DISCOVER();
849 dhcp_state = STATE_DHCP_DISCOVER;
850 break;
851 default :
852 break;
853 }
854 reset_DHCP_timeout();
855 }
856 return ret;
857 }
858
859 int8_t check_DHCP_leasedIP(void)
860 {
861 uint8_t tmp;
862 int32_t ret;
863
864 //WIZchip RCR value changed for ARP Timeout count control
865 tmp = getRCR();
866 setRCR(0x03);
867
868 // IP conflict detection : ARP request - ARP reply
869 // Broadcasting ARP Request for check the IP conflict using UDP sendto() function
870 ret = sendto(DHCP_SOCKET, (uint8_t *)"CHECK_IP_CONFLICT", 17, DHCP_allocated_ip, 5000);
871
872 // RCR value restore
873 setRCR(tmp);
874
875 if(ret == SOCKERR_TIMEOUT) {
876 // UDP send Timeout occurred : allocated IP address is unique, DHCP Success
877
878 #ifdef _DHCP_DEBUG_
879 printf("\r\n> Check leased IP - OK\r\n");
880 #endif
881
882 return 1;
883 } else {
884 // Received ARP reply or etc : IP address conflict occur, DHCP Failed
885 send_DHCP_DECLINE();
886
887 ret = dhcp_tick_1s;
888 while((dhcp_tick_1s - ret) < 2) ; // wait for 1s over; wait to complete to send DECLINE message;
889
890 return 0;
891 }
892 }
893
894 void DHCP_init(uint8_t s, uint8_t * buf)
895 {
896 uint8_t zeroip[4] = {0,0,0,0};
897 getSHAR(DHCP_CHADDR);
898 if((DHCP_CHADDR[0] | DHCP_CHADDR[1] | DHCP_CHADDR[2] | DHCP_CHADDR[3] | DHCP_CHADDR[4] | DHCP_CHADDR[5]) == 0x00)
899 {
900 // assing temporary mac address, you should be set SHAR before call this function.
901 DHCP_CHADDR[0] = 0x00;
902 DHCP_CHADDR[1] = 0x08;
903 DHCP_CHADDR[2] = 0xdc;
904 DHCP_CHADDR[3] = 0x00;
905 DHCP_CHADDR[4] = 0x00;
906 DHCP_CHADDR[5] = 0x00;
907 setSHAR(DHCP_CHADDR);
908 }
909
910 DHCP_SOCKET = s; // SOCK_DHCP
911 pDHCPMSG = (RIP_MSG*)buf;
912 DHCP_XID = 0x12345678;
913
914 // WIZchip Netinfo Clear
915 setSIPR(zeroip);
916 setSIPR(zeroip);
917 setGAR(zeroip);
918
919 reset_DHCP_timeout();
920 dhcp_state = STATE_DHCP_INIT;
921 }
922
923
924 /* Rset the DHCP timeout count and retry count. */
925 void reset_DHCP_timeout(void)
926 {
927 dhcp_tick_1s = 0;
928 dhcp_tick_next = DHCP_WAIT_TIME;
929 dhcp_retry_count = 0;
930 }
931
932 void DHCP_time_handler(void)
933 {
934 dhcp_tick_1s++;
935 }
936
937 void getIPfromDHCP(uint8_t* ip)
938 {
939 ip[0] = DHCP_allocated_ip[0];
940 ip[1] = DHCP_allocated_ip[1];
941 ip[2] = DHCP_allocated_ip[2];
942 ip[3] = DHCP_allocated_ip[3];
943 }
944
945 void getGWfromDHCP(uint8_t* ip)
946 {
947 ip[0] =DHCP_allocated_gw[0];
948 ip[1] =DHCP_allocated_gw[1];
949 ip[2] =DHCP_allocated_gw[2];
950 ip[3] =DHCP_allocated_gw[3];
951 }
952
953 void getSNfromDHCP(uint8_t* ip)
954 {
955 ip[0] = DHCP_allocated_sn[0];
956 ip[1] = DHCP_allocated_sn[1];
957 ip[2] = DHCP_allocated_sn[2];
958 ip[3] = DHCP_allocated_sn[3];
959 }
960
961 void getDNSfromDHCP(uint8_t* ip)
962 {
963 ip[0] = DHCP_allocated_dns[0];
964 ip[1] = DHCP_allocated_dns[1];
965 ip[2] = DHCP_allocated_dns[2];
966 ip[3] = DHCP_allocated_dns[3];
967 }
968
969 uint32_t getDHCPLeasetime(void)
970 {
971 return dhcp_lease_time;
972 }
973
974
975
976
DHCP_DISCOVER
#define DHCP_DISCOVER
DISCOVER message in OPT of RIP_MSG.
Definition: dhcp.c:78
DHCP_DECLINE
#define DHCP_DECLINE
DECLINE message in OPT of RIP_MSG.
Definition: dhcp.c:81
allSubnetsLocal
Definition: dhcp.c:131
staticRoute
Definition: dhcp.c:137
performMaskDiscovery
Definition: dhcp.c:133
DHCP_SOCKET
uint8_t DHCP_SOCKET
Definition: dhcp.c:192
RIP_MSG::giaddr
uint8_t giaddr[4]
No use.
Definition: dhcp.c:183
reset_DHCP_timeout
void reset_DHCP_timeout(void)
Definition: dhcp.c:925
DHCP_BOOTREQUEST
#define DHCP_BOOTREQUEST
Request Message used in op of RIP_MSG.
Definition: dhcp.c:74
check_DHCP_leasedIP
int8_t check_DHCP_leasedIP(void)
Definition: dhcp.c:859
default_ip_conflict
void default_ip_conflict(void)
Definition: dhcp.c:272
dhcpServerIdentifier
Definition: dhcp.c:158
dhcp.h
DHCP APIs Header file.
SOCK_UDP
#define SOCK_UDP
UDP socket.
Definition: w5100.h:982
nisDomainName
Definition: dhcp.c:144
impressServer
Definition: dhcp.c:114
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
RIP_MSG::siaddr
uint8_t siaddr[4]
No use.
Definition: dhcp.c:182
send_DHCP_REQUEST
void send_DHCP_REQUEST(void)
Definition: dhcp.c:413
send_DHCP_DISCOVER
void send_DHCP_DISCOVER(void)
Definition: dhcp.c:351
nonLocalSourceRouting
Definition: dhcp.c:124
OPT_SIZE
#define OPT_SIZE
Definition: dhcp.c:96
DHCP_allocated_ip
uint8_t DHCP_allocated_ip[4]
Definition: dhcp.c:198
RIP_MSG_SIZE
#define RIP_MSG_SIZE
Definition: dhcp.c:97
dhcpMsg
Definition: dhcp.c:160
RIP_MSG::xid
uint32_t xid
DHCP_XID This increase one every DHCP transaction.
Definition: dhcp.c:177
setSIPR
#define setSIPR(sipr)
Set SIPR.
Definition: w5100.h:1186
hostName
Definition: dhcp.c:116
maskSupplier
Definition: dhcp.c:134
DCHP_HOST_NAME
#define DCHP_HOST_NAME
Definition: dhcp.h:68
HOST_NAME
uint8_t HOST_NAME[]
Definition: dhcp.c:215
timerOffset
Definition: dhcp.c:106
endOption
Definition: dhcp.c:166
DHCP_NAK
#define DHCP_NAK
NACK message in OPT of RIP_MSG.
Definition: dhcp.c:83
MAX_DHCP_RETRY
#define MAX_DHCP_RETRY
Maxium retry count.
Definition: dhcp.h:57
DHCP_OFFER
#define DHCP_OFFER
OFFER message in OPT of RIP_MSG.
Definition: dhcp.c:79
DHCP_SIP
uint8_t DHCP_SIP[4]
Definition: dhcp.c:194
DHCP_FLAGSBROADCAST
#define DHCP_FLAGSBROADCAST
The broadcast value of flags in RIP_MSG.
Definition: dhcp.c:70
dhcpIPaddrLeaseTime
Definition: dhcp.c:155
padOption
Definition: dhcp.c:104
ntpServers
Definition: dhcp.c:146
resourceLocationServer
Definition: dhcp.c:115
DHCP_allocated_gw
uint8_t DHCP_allocated_gw[4]
Definition: dhcp.c:199
DHCP_WAIT_TIME
#define DHCP_WAIT_TIME
Wait Time 10s.
Definition: dhcp.h:58
SOCKERR_TIMEOUT
#define SOCKERR_TIMEOUT
Timeout occurred.
Definition: socket.h:107
DHCP_stop
void DHCP_stop(void)
Definition: dhcp.c:800
reg_dhcp_cbfunc
void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void))
Definition: dhcp.c:281
STATE_DHCP_REREQUEST
#define STATE_DHCP_REREQUEST
send REQUEST for maintaining leased IP
Definition: dhcp.c:66
performRouterDiscovery
Definition: dhcp.c:135
dhcpParamRequest
Definition: dhcp.c:159
check_DHCP_timeout
uint8_t check_DHCP_timeout(void)
Definition: dhcp.c:806
DHCP_CLIENT_PORT
#define DHCP_CLIENT_PORT
DHCP client port number.
Definition: dhcp.h:63
arpCacheTimeout
Definition: dhcp.c:139
timeServer
Definition: dhcp.c:108
DHCP_SERVER_PORT
#define DHCP_SERVER_PORT
DHCP server port number.
Definition: dhcp.h:62
dhcpT2value
Definition: dhcp.c:163
netBIOSnameServer
Definition: dhcp.c:148
setGAR
#define setGAR(gar)
Set GAR.
Definition: w5100.h:1129
maxDgramReasmSize
Definition: dhcp.c:126
DHCP_HLENETHERNET
#define DHCP_HLENETHERNET
Used in hlen of RIP_MSG.
Definition: dhcp.c:90
DHCP_ACK
#define DHCP_ACK
ACK message in OPT of RIP_MSG.
Definition: dhcp.c:82
meritDumpFile
Definition: dhcp.c:118
RIP_MSG::htype
uint8_t htype
DHCP_HTYPE10MB or DHCP_HTYPE100MB
Definition: dhcp.c:174
DHCP_allocated_sn
uint8_t DHCP_allocated_sn[4]
Definition: dhcp.c:200
DHCP_STOPPED
Stop procssing DHCP protocol.
Definition: dhcp.h:80
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
RIP_MSG::file
uint8_t file[128]
No use.
Definition: dhcp.c:186
getDNSfromDHCP
void getDNSfromDHCP(uint8_t *ip)
Definition: dhcp.c:961
DHCP_allocated_dns
uint8_t DHCP_allocated_dns[4]
Definition: dhcp.c:201
setMR
#define setMR(mr)
Set Mode Register.
Definition: w5100.h:1108
RIP_MSG::flags
uint16_t flags
DHCP_FLAGSBROADCAST or DHCP_FLAGSUNICAST
Definition: dhcp.c:179
broadcastAddr
Definition: dhcp.c:132
tcpDefaultTTL
Definition: dhcp.c:141
dhcpOptionOverload
Definition: dhcp.c:156
RIP_MSG
Definition: dhcp.c:172
bootFileSize
Definition: dhcp.c:117
RIP_MSG::hops
uint8_t hops
DHCP_HOPS
Definition: dhcp.c:176
getDHCPLeasetime
uint32_t getDHCPLeasetime(void)
Definition: dhcp.c:969
MAGIC_COOKIE
#define MAGIC_COOKIE
Any number. You can be modifyed it any number.
Definition: dhcp.h:66
Sn_MR_UDP
#define Sn_MR_UDP
UDP.
Definition: w5100.h:654
xFontServer
Definition: dhcp.c:152
logServer
Definition: dhcp.c:111
defaultIPTTL
Definition: dhcp.c:127
setSUBR
#define setSUBR(subr)
Set SUBR.
Definition: w5100.h:1150
swapServer
Definition: dhcp.c:120
getMR
#define getMR()
Get MR.
Definition: w5100.h:1120
dhcp_retry_count
int8_t dhcp_retry_count
Definition: dhcp.c:205
default_ip_update
void default_ip_update(void)
Definition: dhcp.c:262
getSNfromDHCP
void getSNfromDHCP(uint8_t *ip)
Definition: dhcp.c:953
RIP_MSG::chaddr
uint8_t chaddr[16]
DHCP client 6bytes MAC address. Others is filled to zero.
Definition: dhcp.c:184
RIP_MSG::sname
uint8_t sname[64]
No use.
Definition: dhcp.c:185
getSHAR
#define getSHAR(shar)
Get SHAR.
Definition: w5100.h:1177
dhcpT1value
Definition: dhcp.c:162
policyFilter
Definition: dhcp.c:125
subnetMask
Definition: dhcp.c:105
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
domainName
Definition: dhcp.c:119
nisServers
Definition: dhcp.c:145
OLD_allocated_ip
uint8_t OLD_allocated_ip[4]
Definition: dhcp.c:197
DHCP_HTYPE10MB
#define DHCP_HTYPE10MB
Used in type of RIP_MSG.
Definition: dhcp.c:87
setRCR
#define setRCR(rcr)
Set RCR register.
Definition: w5100.h:1259
vendorSpecificInfo
Definition: dhcp.c:147
netBIOSnodeType
Definition: dhcp.c:150
RIP_MSG::op
uint8_t op
DHCP_BOOTREQUEST or DHCP_BOOTREPLY
Definition: dhcp.c:173
dhcpClientIdentifier
Definition: dhcp.c:165
DHCP_FAILED
Procssing Fail.
Definition: dhcp.h:75
sendto
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.
Definition: socket.c:489
DHCP_FLAGSUNICAST
#define DHCP_FLAGSUNICAST
The unicast value of flags in RIP_MSG.
Definition: dhcp.c:71
STATE_DHCP_INIT
#define STATE_DHCP_INIT
Initialize.
Definition: dhcp.c:62
RIP_MSG::secs
uint16_t secs
DHCP_SECS
Definition: dhcp.c:178
trailerEncapsulation
Definition: dhcp.c:138
INFINITE_LEASETIME
#define INFINITE_LEASETIME
Infinite lease time.
Definition: dhcp.c:94
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
pathMTUplateauTable
Definition: dhcp.c:129
send_DHCP_DECLINE
void send_DHCP_DECLINE(void)
Definition: dhcp.c:509
setSHAR
#define setSHAR(shar)
Set SHAR.
Definition: w5100.h:1168
STATE_DHCP_STOP
#define STATE_DHCP_STOP
Stop procssing DHCP.
Definition: dhcp.c:68
routerSolicitationAddr
Definition: dhcp.c:136
DHCP_SECS
#define DHCP_SECS
Used in secs of RIP_MSG.
Definition: dhcp.c:92
pDHCPMSG
RIP_MSG * pDHCPMSG
Definition: dhcp.c:213
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
dhcp_state
int8_t dhcp_state
Definition: dhcp.c:204
DHCP_init
void DHCP_init(uint8_t s, uint8_t *buf)
Definition: dhcp.c:894
extentionsPath
Definition: dhcp.c:122
RIP_MSG::hlen
uint8_t hlen
DHCP_HLENETHERNET
Definition: dhcp.c:175
RIP_MSG::OPT
uint8_t OPT[OPT_SIZE]
Option.
Definition: dhcp.c:187
getRCR
#define getRCR()
Get RCR register.
Definition: w5100.h:1268
routersOnSubnet
Definition: dhcp.c:107
RIP_MSG::yiaddr
uint8_t yiaddr[4]
Offered IP from DHCP server
Definition: dhcp.c:181
ifMTU
Definition: dhcp.c:130
dhcp_ip_assign
void(* dhcp_ip_assign)(void)
Definition: dhcp.c:225
parseDHCPMSG
int8_t parseDHCPMSG(void)
Definition: dhcp.c:569
cookieServer
Definition: dhcp.c:112
dhcp_tick_next
uint32_t dhcp_tick_next
Definition: dhcp.c:209
dhcpMessageType
Definition: dhcp.c:157
dhcpMaxMsgSize
Definition: dhcp.c:161
netBIOSdgramDistServer
Definition: dhcp.c:149
RIP_MSG::ciaddr
uint8_t ciaddr[4]
Request IP to DHCP sever
Definition: dhcp.c:180
netBIOSscope
Definition: dhcp.c:151
default_ip_assign
void default_ip_assign(void)
dhcp_tick_1s
volatile uint32_t dhcp_tick_1s
Definition: dhcp.c:208
lprServer
Definition: dhcp.c:113
DHCP_IP_LEASED
Stand by.
Definition: dhcp.h:79
rootPath
Definition: dhcp.c:121
dns
Definition: dhcp.c:110
dhcpClassIdentifier
Definition: dhcp.c:164
nameServer
Definition: dhcp.c:109
DHCP_time_handler
void DHCP_time_handler(void)
Definition: dhcp.c:932
dhcp_lease_time
uint32_t dhcp_lease_time
Definition: dhcp.c:207
STATE_DHCP_LEASED
#define STATE_DHCP_LEASED
ReceiveD ACK and IP leased.
Definition: dhcp.c:65
getIPfromDHCP
void getIPfromDHCP(uint8_t *ip)
Definition: dhcp.c:937
tcpKeepaliveGarbage
Definition: dhcp.c:143
STATE_DHCP_DISCOVER
#define STATE_DHCP_DISCOVER
send DISCOVER and wait OFFER
Definition: dhcp.c:63
DHCP_CHADDR
uint8_t DHCP_CHADDR[6]
Definition: dhcp.c:217
IPforwarding
Definition: dhcp.c:123
DHCP_REQUEST
#define DHCP_REQUEST
REQUEST message in OPT of RIP_MSG.
Definition: dhcp.c:80
DHCP_run
uint8_t DHCP_run(void)
Definition: dhcp.c:670
socket.h
SOCKET APIs Header file.
STATE_DHCP_REQUEST
#define STATE_DHCP_REQUEST
send REQEUST and wait ACK or NACK
Definition: dhcp.c:64
dhcpRequestedIPaddr
Definition: dhcp.c:154
DHCP_HOPS
#define DHCP_HOPS
Used in hops of RIP_MSG.
Definition: dhcp.c:91
makeDHCPMSG
void makeDHCPMSG(void)
Definition: dhcp.c:292
DHCP_XID
uint32_t DHCP_XID
Definition: dhcp.c:211
ethernetEncapsulation
Definition: dhcp.c:140
DHCP_RUNNING
Procssing DHCP proctocol.
Definition: dhcp.h:76
pathMTUagingTimeout
Definition: dhcp.c:128
MR_RST
#define MR_RST
Reset.
Definition: w5100.h:577
tcpKeepaliveInterval
Definition: dhcp.c:142
getGWfromDHCP
void getGWfromDHCP(uint8_t *ip)
Definition: dhcp.c:945
DHCP_IP_CHANGED
Change IP address by new ip from DHCP (if cbfunc == null, act as default default_ip_update) ...
Definition: dhcp.h:78
xDisplayManager
Definition: dhcp.c:153


ioLibrary: Internet/DHCP/dhcp.h Source File

  • Internet
  • DHCP
dhcp.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
43 //
44 //*****************************************************************************
45 #ifndef _DHCP_H_
46 #define _DHCP_H_
47
48 /*
49 * @brief
50 * @details If you want to display debug & procssing message, Define _DHCP_DEBUG_
51 * @note If defined, it dependens on <stdio.h>
52 */
53 //#define _DHCP_DEBUG_
54
55
56 /* Retry to processing DHCP */
57 #define MAX_DHCP_RETRY 2
58 #define DHCP_WAIT_TIME 10
59
60
61 /* UDP port numbers for DHCP */
62 #define DHCP_SERVER_PORT 67
63 #define DHCP_CLIENT_PORT 68
64
65
66 #define MAGIC_COOKIE 0x63825363
67
68 #define DCHP_HOST_NAME "WIZnet\0"
69
70 /*
71 * @brief return value of @ref DHCP_run()
72 */
73 enum
74 {
75 DHCP_FAILED = 0,
76 DHCP_RUNNING,
77 DHCP_IP_ASSIGN,
78 DHCP_IP_CHANGED,
79 DHCP_IP_LEASED,
80 DHCP_STOPPED
81 };
82
83 /*
84 * @brief DHCP client initialization (outside of the main loop)
85 * @param s - socket number
86 * @param buf - buffer for procssing DHCP message
87 */
88 void DHCP_init(uint8_t s, uint8_t * buf);
89
90 /*
91 * @brief DHCP 1s Tick Timer handler
92 * @note SHOULD BE register to your system 1s Tick timer handler
93 */
94 void DHCP_time_handler(void);
95
96 /*
97 * @brief Register call back function
98 * @param ip_assign - callback func when IP is assigned from DHCP server first
99 * @param ip_update - callback func when IP is changed
100 * @prarm ip_conflict - callback func when the assigned IP is conflict with others.
101 */
102 void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void));
103
104 /*
105 * @brief DHCP client in the main loop
106 * @return The value is as the follow \n
107 * @ref DHCP_FAILED \n
108 * @ref DHCP_RUNNING \n
109 * @ref DHCP_IP_ASSIGN \n
110 * @ref DHCP_IP_CHANGED \n
111 * @ref DHCP_IP_LEASED \n
112 * @ref DHCP_STOPPED \n
113 *
114 * @note This function is always called by you main task.
115 */
116 uint8_t DHCP_run(void);
117
118 /*
119 * @brief Stop DHCP procssing
120 * @note If you want to restart. call DHCP_init() and DHCP_run()
121 */
122 void DHCP_stop(void);
123
124 /* Get Network information assigned from DHCP server */
125 /*
126 * @brief Get IP address
127 * @param ip - IP address to be returned
128 */
129 void getIPfromDHCP(uint8_t* ip);
130 /*
131 * @brief Get Gateway address
132 * @param ip - Gateway address to be returned
133 */
134 void getGWfromDHCP(uint8_t* ip);
135 /*
136 * @brief Get Subnet mask value
137 * @param ip - Subnet mask to be returned
138 */
139 void getSNfromDHCP(uint8_t* ip);
140 /*
141 * @brief Get DNS address
142 * @param ip - DNS address to be returned
143 */
144 void getDNSfromDHCP(uint8_t* ip);
145
146 /*
147 * @brief Get the leased time by DHCP sever
148 * @retrun unit 1s
149 */
150 uint32_t getDHCPLeasetime(void);
151
152 #endif /* _DHCP_H_ */
DHCP_run
uint8_t DHCP_run(void)
Definition: dhcp.c:670
getSNfromDHCP
void getSNfromDHCP(uint8_t *ip)
Definition: dhcp.c:953
DHCP_time_handler
void DHCP_time_handler(void)
Definition: dhcp.c:932
DHCP_IP_ASSIGN
First Occupy IP from DHPC server (if cbfunc == null, act as default default_ip_assign) ...
Definition: dhcp.h:77
DHCP_STOPPED
Stop procssing DHCP protocol.
Definition: dhcp.h:80
reg_dhcp_cbfunc
void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void))
Definition: dhcp.c:281
getDHCPLeasetime
uint32_t getDHCPLeasetime(void)
Definition: dhcp.c:969
DHCP_init
void DHCP_init(uint8_t s, uint8_t *buf)
Definition: dhcp.c:894
DHCP_FAILED
Procssing Fail.
Definition: dhcp.h:75
getGWfromDHCP
void getGWfromDHCP(uint8_t *ip)
Definition: dhcp.c:945
getDNSfromDHCP
void getDNSfromDHCP(uint8_t *ip)
Definition: dhcp.c:961
DHCP_stop
void DHCP_stop(void)
Definition: dhcp.c:800
DHCP_IP_LEASED
Stand by.
Definition: dhcp.h:79
DHCP_RUNNING
Procssing DHCP proctocol.
Definition: dhcp.h:76
DHCP_IP_CHANGED
Change IP address by new ip from DHCP (if cbfunc == null, act as default default_ip_update) ...
Definition: dhcp.h:78
getIPfromDHCP
void getIPfromDHCP(uint8_t *ip)
Definition: dhcp.c:937


ioLibrary: Application/loopback -> Ethernet Relation

  • Application
  • loopback

loopback → Ethernet Relation

File in Application/loopback | Includes file in Ethernet
loopback.c | socket.h
loopback.c | wizchip_conf.h


ioLibrary: Ethernet -> W5500 Relation

  • Ethernet

Ethernet → W5500 Relation

File in Ethernet | Includes file in Ethernet/W5500
wizchip_conf.h | w5500.h


ioLibrary: Internet/DHCP -> Ethernet Relation

  • Internet
  • DHCP

DHCP → Ethernet Relation

File in Internet/DHCP | Includes file in Ethernet
dhcp.c | socket.h


ioLibrary: Internet/DNS -> Ethernet Relation

  • Internet
  • DNS

DNS → Ethernet Relation

File in Internet/DNS | Includes file in Ethernet
dns.c | socket.h


ioLibrary: Internet/FTPClient -> Ethernet Relation

  • Internet
  • FTPClient

FTPClient → Ethernet Relation

File in Internet/FTPClient | Includes file in Ethernet
ftpc.h | socket.h


ioLibrary: Internet/FTPServer -> Ethernet Relation

  • Internet
  • FTPServer

FTPServer → Ethernet Relation

File in Internet/FTPServer | Includes file in Ethernet
ftpd.c | socket.h


ioLibrary: Internet/httpServer -> Ethernet Relation

  • Internet
  • httpServer

httpServer → Ethernet Relation

File in Internet/httpServer | Includes file in Ethernet
httpParser.c | socket.h
httpServer.c | socket.h
httpServer.c | wizchip_conf.h


ioLibrary: Internet/MQTT -> Ethernet Relation

  • Internet
  • MQTT

MQTT → Ethernet Relation

File in Internet/MQTT | Includes file in Ethernet
mqtt_interface.c | wizchip_conf.h


ioLibrary: Internet/MQTT -> MQTTPacket Relation

  • Internet
  • MQTT

MQTT → MQTTPacket Relation

File in Internet/MQTT | Includes file in Internet/MQTT/MQTTPacket
MQTTClient.h | src / MQTTPacket.h


ioLibrary: Internet/SNMP -> Ethernet Relation

  • Internet
  • SNMP

SNMP → Ethernet Relation

File in Internet/SNMP | Includes file in Ethernet
snmp.c | socket.h


ioLibrary: Internet/SNTP -> Ethernet Relation

  • Internet
  • SNTP

SNTP → Ethernet Relation

File in Internet/SNTP | Includes file in Ethernet
sntp.c | socket.h


ioLibrary: Internet/TFTP -> Ethernet Relation

  • Internet
  • TFTP

TFTP → Ethernet Relation

File in Internet/TFTP | Includes file in Ethernet
tftp.c | socket.h


ioLibrary: Internet/DNS/dns.c Source File

  • Internet
  • DNS
dns.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
49 //
50 //*****************************************************************************
51
52 #include <string.h>
53 #include <stdlib.h>
54
55 #include "socket.h"
56 #include "dns.h"
57
58 #ifdef _DNS_DEBUG_
59 #include <stdio.h>
60 #endif
61
62 #define INITRTT 2000L /* Initial smoothed response time */
63 #define MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */
64
65 #define TYPE_A 1 /* Host address */
66 #define TYPE_NS 2 /* Name server */
67 #define TYPE_MD 3 /* Mail destination (obsolete) */
68 #define TYPE_MF 4 /* Mail forwarder (obsolete) */
69 #define TYPE_CNAME 5 /* Canonical name */
70 #define TYPE_SOA 6 /* Start of Authority */
71 #define TYPE_MB 7 /* Mailbox name (experimental) */
72 #define TYPE_MG 8 /* Mail group member (experimental) */
73 #define TYPE_MR 9 /* Mail rename name (experimental) */
74 #define TYPE_NULL 10 /* Null (experimental) */
75 #define TYPE_WKS 11 /* Well-known sockets */
76 #define TYPE_PTR 12 /* Pointer record */
77 #define TYPE_HINFO 13 /* Host information */
78 #define TYPE_MINFO 14 /* Mailbox information (experimental)*/
79 #define TYPE_MX 15 /* Mail exchanger */
80 #define TYPE_TXT 16 /* Text strings */
81 #define TYPE_ANY 255 /* Matches any type */
82
83 #define CLASS_IN 1 /* The ARPA Internet */
84
85 /* Round trip timing parameters */
86 #define AGAIN 8 /* Average RTT gain = 1/8 */
87 #define LAGAIN 3 /* Log2(AGAIN) */
88 #define DGAIN 4 /* Mean deviation gain = 1/4 */
89 #define LDGAIN 2 /* log2(DGAIN) */
90
91 /* Header for all domain messages */
92 struct dhdr
93 {
94 uint16_t id; /* Identification */
95 uint8_t qr; /* Query/Response */
96 #define QUERY 0
97 #define RESPONSE 1
98 uint8_t opcode;
99 #define IQUERY 1
100 uint8_t aa; /* Authoratative answer */
101 uint8_t tc; /* Truncation */
102 uint8_t rd; /* Recursion desired */
103 uint8_t ra; /* Recursion available */
104 uint8_t rcode; /* Response code */
105 #define NO_ERROR 0
106 #define FORMAT_ERROR 1
107 #define SERVER_FAIL 2
108 #define NAME_ERROR 3
109 #define NOT_IMPL 4
110 #define REFUSED 5
111 uint16_t qdcount; /* Question count */
112 uint16_t ancount; /* Answer count */
113 uint16_t nscount; /* Authority (name server) count */
114 uint16_t arcount; /* Additional record count */
115 };
116
117
118 uint8_t* pDNSMSG; // DNS message buffer
119 uint8_t DNS_SOCKET; // SOCKET number for DNS
120 uint16_t DNS_MSGID; // DNS message ID
121
122 uint32_t dns_1s_tick; // for timout of DNS processing
123
124 /* converts uint16_t from network buffer to a host byte order integer. */
125 uint16_t get16(uint8_t * s)
126 {
127 uint16_t i;
128 i = *s++ << 8;
129 i = i + *s;
130 return i;
131 }
132
133 /* copies uint16_t to the network buffer with network byte order. */
134 uint8_t * put16(uint8_t * s, uint16_t i)
135 {
136 *s++ = i >> 8;
137 *s++ = i;
138 return s;
139 }
140
141
142 /*
143 * CONVERT A DOMAIN NAME TO THE HUMAN-READABLE FORM
144 *
145 * Description : This function converts a compressed domain name to the human-readable form
146 * Arguments : msg - is a pointer to the reply message
147 * compressed - is a pointer to the domain name in reply message.
148 * buf - is a pointer to the buffer for the human-readable form name.
149 * len - is the MAX. size of buffer.
150 * Returns : the length of compressed message
151 */
152 int parse_name(uint8_t * msg, uint8_t * compressed, char * buf, int16_t len)
153 {
154 uint16_t slen; /* Length of current segment */
155 uint8_t * cp;
156 int clen = 0; /* Total length of compressed name */
157 int indirect = 0; /* Set if indirection encountered */
158 int nseg = 0; /* Total number of segments in name */
159
160 cp = compressed;
161
162 for (;;)
163 {
164 slen = *cp++; /* Length of this segment */
165
166 if (!indirect) clen++;
167
168 if ((slen & 0xc0) == 0xc0)
169 {
170 if (!indirect)
171 clen++;
172 indirect = 1;
173 /* Follow indirection */
174 cp = &msg[((slen & 0x3f)<<8) + *cp];
175 slen = *cp++;
176 }
177
178 if (slen == 0) /* zero length == all done */
179 break;
180
181 len -= slen + 1;
182
183 if (len < 0) return -1;
184
185 if (!indirect) clen += slen;
186
187 while (slen-- != 0) *buf++ = (char)*cp++;
188 *buf++ = '.';
189 nseg++;
190 }
191
192 if (nseg == 0)
193 {
194 /* Root name; represent as single dot */
195 *buf++ = '.';
196 len--;
197 }
198
199 *buf++ = '\0';
200 len--;
201
202 return clen; /* Length of compressed message */
203 }
204
205 /*
206 * PARSE QUESTION SECTION
207 *
208 * Description : This function parses the qeustion record of the reply message.
209 * Arguments : msg - is a pointer to the reply message
210 * cp - is a pointer to the qeustion record.
211 * Returns : a pointer the to next record.
212 */
213 uint8_t * dns_question(uint8_t * msg, uint8_t * cp)
214 {
215 int len;
216 char name[MAXCNAME];
217
218 len = parse_name(msg, cp, name, MAXCNAME);
219
220
221 if (len == -1) return 0;
222
223 cp += len;
224 cp += 2; /* type */
225 cp += 2; /* class */
226
227 return cp;
228 }
229
230
231 /*
232 * PARSE ANSER SECTION
233 *
234 * Description : This function parses the answer record of the reply message.
235 * Arguments : msg - is a pointer to the reply message
236 * cp - is a pointer to the answer record.
237 * Returns : a pointer the to next record.
238 */
239 uint8_t * dns_answer(uint8_t * msg, uint8_t * cp, uint8_t * ip_from_dns)
240 {
241 int len, type;
242 char name[MAXCNAME];
243
244 len = parse_name(msg, cp, name, MAXCNAME);
245
246 if (len == -1) return 0;
247
248 cp += len;
249 type = get16(cp);
250 cp += 2; /* type */
251 cp += 2; /* class */
252 cp += 4; /* ttl */
253 cp += 2; /* len */
254
255
256 switch (type)
257 {
258 case TYPE_A:
259 /* Just read the address directly into the structure */
260 ip_from_dns[0] = *cp++;
261 ip_from_dns[1] = *cp++;
262 ip_from_dns[2] = *cp++;
263 ip_from_dns[3] = *cp++;
264 break;
265 case TYPE_CNAME:
266 case TYPE_MB:
267 case TYPE_MG:
268 case TYPE_MR:
269 case TYPE_NS:
270 case TYPE_PTR:
271 /* These types all consist of a single domain name */
272 /* convert it to ascii format */
273 len = parse_name(msg, cp, name, MAXCNAME);
274 if (len == -1) return 0;
275
276 cp += len;
277 break;
278 case TYPE_HINFO:
279 len = *cp++;
280 cp += len;
281
282 len = *cp++;
283 cp += len;
284 break;
285 case TYPE_MX:
286 cp += 2;
287 /* Get domain name of exchanger */
288 len = parse_name(msg, cp, name, MAXCNAME);
289 if (len == -1) return 0;
290
291 cp += len;
292 break;
293 case TYPE_SOA:
294 /* Get domain name of name server */
295 len = parse_name(msg, cp, name, MAXCNAME);
296 if (len == -1) return 0;
297
298 cp += len;
299
300 /* Get domain name of responsible person */
301 len = parse_name(msg, cp, name, MAXCNAME);
302 if (len == -1) return 0;
303
304 cp += len;
305
306 cp += 4;
307 cp += 4;
308 cp += 4;
309 cp += 4;
310 cp += 4;
311 break;
312 case TYPE_TXT:
313 /* Just stash */
314 break;
315 default:
316 /* Ignore */
317 break;
318 }
319
320 return cp;
321 }
322
323 /*
324 * PARSE THE DNS REPLY
325 *
326 * Description : This function parses the reply message from DNS server.
327 * Arguments : dhdr - is a pointer to the header for DNS message
328 * buf - is a pointer to the reply message.
329 * len - is the size of reply message.
330 * Returns : -1 - Domain name lenght is too big
331 * 0 - Fail (Timout or parse error)
332 * 1 - Success,
333 */
334 int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns)
335 {
336 uint16_t tmp;
337 uint16_t i;
338 uint8_t * msg;
339 uint8_t * cp;
340
341 msg = pbuf;
342 memset(pdhdr, 0, sizeof(pdhdr));
343
344 pdhdr->id = get16(&msg[0]);
345 tmp = get16(&msg[2]);
346 if (tmp & 0x8000) pdhdr->qr = 1;
347
348 pdhdr->opcode = (tmp >> 11) & 0xf;
349
350 if (tmp & 0x0400) pdhdr->aa = 1;
351 if (tmp & 0x0200) pdhdr->tc = 1;
352 if (tmp & 0x0100) pdhdr->rd = 1;
353 if (tmp & 0x0080) pdhdr->ra = 1;
354
355 pdhdr->rcode = tmp & 0xf;
356 pdhdr->qdcount = get16(&msg[4]);
357 pdhdr->ancount = get16(&msg[6]);
358 pdhdr->nscount = get16(&msg[8]);
359 pdhdr->arcount = get16(&msg[10]);
360
361
362 /* Now parse the variable length sections */
363 cp = &msg[12];
364
365 /* Question section */
366 for (i = 0; i < pdhdr->qdcount; i++)
367 {
368 cp = dns_question(msg, cp);
369 #ifdef _DNS_DEUBG_
370 printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h"
371 #endif
372 if(!cp) return -1;
373 }
374
375 /* Answer section */
376 for (i = 0; i < pdhdr->ancount; i++)
377 {
378 cp = dns_answer(msg, cp, ip_from_dns);
379 #ifdef _DNS_DEUBG_
380 printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h"
381 #endif
382 if(!cp) return -1;
383 }
384
385 /* Name server (authority) section */
386 for (i = 0; i < pdhdr->nscount; i++)
387 {
388 ;
389 }
390
391 /* Additional section */
392 for (i = 0; i < pdhdr->arcount; i++)
393 {
394 ;
395 }
396
397 if(pdhdr->rcode == 0) return 1; // No error
398 else return 0;
399 }
400
401
402 /*
403 * MAKE DNS QUERY MESSAGE
404 *
405 * Description : This function makes DNS query message.
406 * Arguments : op - Recursion desired
407 * name - is a pointer to the domain name.
408 * buf - is a pointer to the buffer for DNS message.
409 * len - is the MAX. size of buffer.
410 * Returns : the pointer to the DNS message.
411 */
412 int16_t dns_makequery(uint16_t op, char * name, uint8_t * buf, uint16_t len)
413 {
414 uint8_t *cp;
415 char *cp1;
416 char sname[MAXCNAME];
417 char *dname;
418 uint16_t p;
419 uint16_t dlen;
420
421 cp = buf;
422
423 DNS_MSGID++;
424 cp = put16(cp, DNS_MSGID);
425 p = (op << 11) | 0x0100; /* Recursion desired */
426 cp = put16(cp, p);
427 cp = put16(cp, 1);
428 cp = put16(cp, 0);
429 cp = put16(cp, 0);
430 cp = put16(cp, 0);
431
432 strcpy(sname, name);
433 dname = sname;
434 dlen = strlen(dname);
435 for (;;)
436 {
437 /* Look for next dot */
438 cp1 = strchr(dname, '.');
439
440 if (cp1 != NULL) len = cp1 - dname; /* More to come */
441 else len = dlen; /* Last component */
442
443 *cp++ = len; /* Write length of component */
444 if (len == 0) break;
445
446 /* Copy component up to (but not including) dot */
447 strncpy((char *)cp, dname, len);
448 cp += len;
449 if (cp1 == NULL)
450 {
451 *cp++ = 0; /* Last one; write null and finish */
452 break;
453 }
454 dname += len+1;
455 dlen -= len+1;
456 }
457
458 cp = put16(cp, 0x0001); /* type */
459 cp = put16(cp, 0x0001); /* class */
460
461 return ((int16_t)((uint32_t)(cp) - (uint32_t)(buf)));
462 }
463
464 /*
465 * CHECK DNS TIMEOUT
466 *
467 * Description : This function check the DNS timeout
468 * Arguments : None.
469 * Returns : -1 - timeout occurred, 0 - timer over, but no timeout, 1 - no timer over, no timeout occur
470 * Note : timeout : retry count and timer both over.
471 */
472
473 int8_t check_DNS_timeout(void)
474 {
475 static uint8_t retry_count;
476
477 if(dns_1s_tick >= DNS_WAIT_TIME)
478 {
479 dns_1s_tick = 0;
480 if(retry_count >= MAX_DNS_RETRY) {
481 retry_count = 0;
482 return -1; // timeout occurred
483 }
484 retry_count++;
485 return 0; // timer over, but no timeout
486 }
487
488 return 1; // no timer over, no timeout occur
489 }
490
491
492
493 /* DNS CLIENT INIT */
494 void DNS_init(uint8_t s, uint8_t * buf)
495 {
496 DNS_SOCKET = s; // SOCK_DNS
497 pDNSMSG = buf; // User's shared buffer
498 DNS_MSGID = DNS_MSG_ID;
499 }
500
501 /* DNS CLIENT RUN */
502 int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns)
503 {
504 int8_t ret;
505 struct dhdr dhp;
506 uint8_t ip[4];
507 uint16_t len, port;
508 int8_t ret_check_timeout;
509
510 // Socket open
511 socket(DNS_SOCKET, Sn_MR_UDP, 0, 0);
512
513 #ifdef _DNS_DEBUG_
514 printf("> DNS Query to DNS Server : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]);
515 #endif
516
517 len = dns_makequery(0, (char *)name, pDNSMSG, MAX_DNS_BUF_SIZE);
518 sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN);
519
520 while (1)
521 {
522 if ((len = getSn_RX_RSR(DNS_SOCKET)) > 0)
523 {
524 if (len > MAX_DNS_BUF_SIZE) len = MAX_DNS_BUF_SIZE;
525 len = recvfrom(DNS_SOCKET, pDNSMSG, len, ip, &port);
526 #ifdef _DNS_DEBUG_
527 printf("> Receive DNS message from %d.%d.%d.%d(%d). len = %d\r\n", ip[0], ip[1], ip[2], ip[3],port,len);
528 #endif
529 ret = parseDNSMSG(&dhp, pDNSMSG, ip_from_dns);
530 break;
531 }
532 // Check Timeout
533 ret_check_timeout = check_DNS_timeout();
534 if (ret_check_timeout < 0) {
535
536 #ifdef _DNS_DEBUG_
537 printf("> DNS Server is not responding : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]);
538 #endif
539 return 0; // timeout occurred
540 }
541 else if (ret_check_timeout == 0) {
542
543 #ifdef _DNS_DEBUG_
544 printf("> DNS Timeout\r\n");
545 #endif
546 sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN);
547 }
548 }
549 close(DNS_SOCKET);
550 // Return value
551 // 0 > : failed / 1 - success
552 return ret;
553 }
554
555
556 /* DNS TIMER HANDLER */
557 void DNS_time_handler(void)
558 {
559 dns_1s_tick++;
560 }
561
562
563
parseDNSMSG
int8_t parseDNSMSG(struct dhdr *pdhdr, uint8_t *pbuf, uint8_t *ip_from_dns)
Definition: dns.c:334
TYPE_MX
#define TYPE_MX
Definition: dns.c:79
dns_question
uint8_t * dns_question(uint8_t *msg, uint8_t *cp)
Definition: dns.c:213
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
MAX_DNS_BUF_SIZE
#define MAX_DNS_BUF_SIZE
maximum size of DNS buffer. */
Definition: dns.h:61
dns_1s_tick
uint32_t dns_1s_tick
Definition: dns.c:122
TYPE_PTR
#define TYPE_PTR
Definition: dns.c:76
dhdr::ancount
uint16_t ancount
Definition: dns.c:112
DNS_run
int8_t DNS_run(uint8_t *dns_ip, uint8_t *name, uint8_t *ip_from_dns)
Definition: dns.c:502
DNS_WAIT_TIME
#define DNS_WAIT_TIME
Wait response time. unit 1s.
Definition: dns.h:70
MAX_DNS_RETRY
#define MAX_DNS_RETRY
Requery Count.
Definition: dns.h:69
dhdr::tc
uint8_t tc
Definition: dns.c:101
pDNSMSG
uint8_t * pDNSMSG
Definition: dns.c:118
dhdr::nscount
uint16_t nscount
Definition: dns.c:113
TYPE_A
#define TYPE_A
Definition: dns.c:65
TYPE_HINFO
#define TYPE_HINFO
Definition: dns.c:77
TYPE_MG
#define TYPE_MG
Definition: dns.c:72
dhdr::opcode
uint8_t opcode
Definition: dns.c:98
dhdr::aa
uint8_t aa
Definition: dns.c:100
MAXCNAME
#define MAXCNAME
Definition: dns.c:63
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
dhdr::arcount
uint16_t arcount
Definition: dns.c:114
TYPE_SOA
#define TYPE_SOA
Definition: dns.c:70
DNS_init
void DNS_init(uint8_t s, uint8_t *buf)
Definition: dns.c:494
Sn_MR_UDP
#define Sn_MR_UDP
UDP.
Definition: w5100.h:654
TYPE_NS
#define TYPE_NS
Definition: dns.c:66
DNS_MSGID
uint16_t DNS_MSGID
Definition: dns.c:120
TYPE_TXT
#define TYPE_TXT
Definition: dns.c:80
DNS_time_handler
void DNS_time_handler(void)
Definition: dns.c:557
TYPE_CNAME
#define TYPE_CNAME
Definition: dns.c:69
dns_makequery
int16_t dns_makequery(uint16_t op, char *name, uint8_t *buf, uint16_t len)
Definition: dns.c:412
IPPORT_DOMAIN
#define IPPORT_DOMAIN
DNS server port number.
Definition: dns.h:72
dns_answer
uint8_t * dns_answer(uint8_t *msg, uint8_t *cp, uint8_t *ip_from_dns)
Definition: dns.c:239
DNS_SOCKET
uint8_t DNS_SOCKET
Definition: dns.c:119
sendto
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.
Definition: socket.c:489
dhdr
Definition: dns.c:92
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
DNS_MSG_ID
#define DNS_MSG_ID
ID for DNS message. You can be modifyed it any number.
Definition: dns.h:74
get16
uint16_t get16(uint8_t *s)
Definition: dns.c:125
TYPE_MR
#define TYPE_MR
Definition: dns.c:73
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
dhdr::rcode
uint8_t rcode
Definition: dns.c:104
dhdr::ra
uint8_t ra
Definition: dns.c:103
check_DNS_timeout
int8_t check_DNS_timeout(void)
Definition: dns.c:473
TYPE_MB
#define TYPE_MB
Definition: dns.c:71
parse_name
int parse_name(uint8_t *msg, uint8_t *compressed, char *buf, int16_t len)
Definition: dns.c:152
put16
uint8_t * put16(uint8_t *s, uint16_t i)
Definition: dns.c:134
dhdr::qr
uint8_t qr
Definition: dns.c:95
dhdr::id
uint16_t id
Definition: dns.c:94
socket.h
SOCKET APIs Header file.
dhdr::qdcount
uint16_t qdcount
Definition: dns.c:111
dns.h
DNS APIs Header file.
dhdr::rd
uint8_t rd
Definition: dns.c:102


ioLibrary: Internet/DNS/dns.h Source File

  • Internet
  • DNS
dns.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
48 //
49 //*****************************************************************************
50
51 #ifndef _DNS_H_
52 #define _DNS_H_
53
54 #include <stdint.h>
55 /*
56 * @brief Define it for Debug & Monitor DNS processing.
57 * @note If defined, it dependens on <stdio.h>
58 */
59 //#define _DNS_DEBUG_
60
61 #define MAX_DNS_BUF_SIZE 256
62 /*
63 * @brief Maxium length of your queried Domain name
64 * @todo SHOULD BE defined it equal as or greater than your Domain name lenght + null character(1)
65 * @note SHOULD BE careful to stack overflow because it is allocated 1.5 times as MAX_DOMAIN_NAME in stack.
66 */
67 #define MAX_DOMAIN_NAME 16 // for example "www.google.com"
68
69 #define MAX_DNS_RETRY 2
70 #define DNS_WAIT_TIME 3
71
72 #define IPPORT_DOMAIN 53
73
74 #define DNS_MSG_ID 0x1122
75 /*
76 * @brief DNS process initialize
77 * @param s : Socket number for DNS
78 * @param buf : Buffer for DNS message
79 */
80 void DNS_init(uint8_t s, uint8_t * buf);
81
82 /*
83 * @brief DNS process
84 * @details Send DNS query and receive DNS response
85 * @param dns_ip : DNS server ip
86 * @param name : Domain name to be queryed
87 * @param ip_from_dns : IP address from DNS server
88 * @return -1 : failed. @ref MAX_DOMIN_NAME is too small \n
89 * 0 : failed (Timeout or Parse error)\n
90 * 1 : success
91 * @note This funtion blocks until success or fail. max time = @ref MAX_DNS_RETRY * @ref DNS_WAIT_TIME
92 */
93 int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns);
94
95 /*
96 * @brief DNS 1s Tick Timer handler
97 * @note SHOULD BE register to your system 1s Tick timer handler
98 */
99 void DNS_time_handler(void);
100
101 #endif /* _DNS_H_ */
DNS_init
void DNS_init(uint8_t s, uint8_t *buf)
Definition: dns.c:494
DNS_time_handler
void DNS_time_handler(void)
Definition: dns.c:557
DNS_run
int8_t DNS_run(uint8_t *dns_ip, uint8_t *name, uint8_t *ip_from_dns)
Definition: dns.c:502


ioLibrary: Internet/FTPClient/ftpc.c Source File

  • Internet
  • FTPClient
ftpc.c
Go to the documentation of this file.
1 #include "ftpc.h"
2
3 un_l2cval remote_ip;
4 uint16_t remote_port;
5 un_l2cval local_ip;
6 uint16_t local_port;
7 uint8_t connect_state_control_ftpc = 0;
8 uint8_t connect_state_data_ftpc = 0;
9 uint8_t gModeActivePassiveflag = 0;
10 uint8_t FTP_destip[4] = {192, 168, 10, 230}; // For FTP client examples; destination network info
11 uint16_t FTP_destport = 21; // For FTP client examples; destination network info
12 uint8_t gMenuStart = 0;
13 uint8_t gDataSockReady = 0;
14 uint8_t gDataPutGetStart = 0;
15 static uint8_t gMsgBuf[20]={0,};
16
17 struct ftpc ftpc;
18 struct Command Command;
19
20 void ftpc_init(uint8_t * src_ip)
21 {
22 ftpc.dsock_mode = ACTIVE_MODE;
23
24 local_ip.cVal[0] = src_ip[0];
25 local_ip.cVal[1] = src_ip[1];
26 local_ip.cVal[2] = src_ip[2];
27 local_ip.cVal[3] = src_ip[3];
28 local_port = 35000;
29 strcpy(ftpc.workingdir, "/");
30 socket(CTRL_SOCK, Sn_MR_TCP, FTP_destport, 0x0);
31 }
32 uint8_t ftpc_run(uint8_t * dbuf)
33 {
34 #ifndef Need_UARTGetCharBlocking_func
35 uint16_t size = 0;
36 long ret = 0;
37 uint32_t send_byte, recv_byte;
38 uint32_t blocklen;
39 uint32_t remain_filesize;
40 uint32_t remain_datasize;
41 uint8_t msg_c;
42 uint8_t dat[50]={0,};
43 uint32_t totalSize = 0, availableSize = 0;
44
45 switch(getSn_SR(CTRL_SOCK))
46 {
47 case SOCK_ESTABLISHED :
48 if(!connect_state_control_ftpc){
49 printf("%d:FTP Connected\r\n", CTRL_SOCK);
50 strcpy(ftpc.workingdir, "/");
51 connect_state_control_ftpc = 1;
52 }
53 if(gMenuStart){
54 gMenuStart = 0;
55 printf("\r\n----------------------------------------\r\n");
56 printf("Press menu key\r\n");
57 printf("----------------------------------------\r\n");
58 printf("1> View FTP Server Directory\r\n");
59 printf("2> View My Directory\r\n");
60 printf("3> Sets the type of file to be transferred. Current state : %s\r\n", (ftpc.type==ASCII_TYPE)?"Ascii":"Binary");
61 printf("4> Sets Data Connection. Current state : %s\r\n", (ftpc.dsock_mode==ACTIVE_MODE)?"Active":"Passive");
62 printf("5> Put File to Server\r\n");
63 printf("6> Get File from Server\r\n");
64 #if defined(F_FILESYSTEM)
65 printf("7> Delete My File\r\n");
66 #endif
67 printf("----------------------------------------\r\n");
68 while(1){
69 msg_c=ftp_getc();
70 if(msg_c=='1'){
71 if(ftpc.dsock_mode==PASSIVE_MODE){
72 sprintf(dat,"PASV\r\n");
73 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
74 Command.First = f_dir;
75 break;
76 }
77 else{
78 wiz_NetInfo gWIZNETINFO;
79 ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO);
80 sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff));
81 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
82 Command.First = f_dir;
83
84 gModeActivePassiveflag = 1;
85 break;
86 }
87 break;
88 }
89 else if(msg_c=='5'){
90 if(ftpc.dsock_mode==PASSIVE_MODE){
91 sprintf(dat,"PASV\r\n");
92 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
93 Command.First = f_put;
94 break;
95 }
96 else{
97 wiz_NetInfo gWIZNETINFO;
98 ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO);
99 sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff));
100 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
101 Command.First = f_put;
102
103 gModeActivePassiveflag = 1;
104 break;
105 }
106 }
107 else if(msg_c=='6'){
108 if(ftpc.dsock_mode==PASSIVE_MODE){
109 sprintf(dat,"PASV\r\n");
110 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
111 Command.First = f_get;
112 break;
113 }
114 else{
115 wiz_NetInfo gWIZNETINFO;
116 ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO);
117 sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff));
118 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
119 Command.First = f_get;
120
121 gModeActivePassiveflag = 1;
122 break;
123 }
124 }
125 else if(msg_c=='2'){
126 #if defined(F_FILESYSTEM)
127 scan_files(ftpc.workingdir, dbuf, (int *)&size);
128 printf("\r\n%s\r\n", dbuf);
129 #else
130 if (strncmp(ftpc.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0)
131 size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n");
132 printf("\r\n%s\r\n", dbuf);
133 #endif
134 gMenuStart = 1;
135 break;
136 }
137 else if(msg_c=='3'){
138 printf("1> ASCII\r\n");
139 printf("2> BINARY\r\n");
140 while(1){
141 msg_c=ftp_getc();
142 if(msg_c=='1'){
143 sprintf(dat,"TYPE %c\r\n", TransferAscii);
144 ftpc.type = ASCII_TYPE;
145 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
146 break;
147 }
148 else if(msg_c=='2'){
149 sprintf(dat,"TYPE %c\r\n", TransferBinary);
150 ftpc.type = IMAGE_TYPE;
151 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
152 break;
153 }
154 else{
155 printf("\r\nRetry...\r\n");
156 }
157 }
158 break;
159 }
160 else if(msg_c=='4'){
161 printf("1> ACTIVE\r\n");
162 printf("2> PASSIVE\r\n");
163 while(1){
164 msg_c=ftp_getc();
165 if(msg_c=='1'){
166 ftpc.dsock_mode=ACTIVE_MODE;
167 break;
168 }
169 else if(msg_c=='2'){
170 ftpc.dsock_mode=PASSIVE_MODE;
171 break;
172 }
173 else{
174 printf("\r\nRetry...\r\n");
175 }
176 }
177 gMenuStart = 1;
178 break;
179 }
180 #if defined(F_FILESYSTEM)
181 else if(msg_c=='7'){
182 printf(">del filename?");
183 sprintf(ftpc.filename, "/%s\r\n", User_Keyboard_MSG());
184 if (f_unlink((const char *)ftpc.filename) != 0){
185 printf("\r\nCould not delete.\r\n");
186 }
187 else{
188 printf("\r\nDeleted.\r\n");
189 }
190 gMenuStart = 1;
191 break;
192 }
193 #endif
194 else{
195 printf("\r\nRetry...\r\n");
196 }
197 }
198 }
199 if(gDataSockReady){
200 gDataSockReady = 0;
201 switch(Command.First){
202 case f_dir:
203 sprintf(dat,"LIST\r\n");
204 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
205 break;
206 case f_put:
207 printf(">put file name?");
208 sprintf(dat,"STOR %s\r\n", User_Keyboard_MSG());
209 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
210 break;
211 case f_get:
212 printf(">get file name?");
213 sprintf(dat,"RETR %s\r\n", User_Keyboard_MSG());
214 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
215 break;
216 default:
217 printf("Command.First = default\r\n");
218 break;
219 }
220 }
221 if((size = getSn_RX_RSR(CTRL_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur.
222 memset(dbuf, 0, _MAX_SS);
223 if(size > _MAX_SS) size = _MAX_SS - 1;
224 ret = recv(CTRL_SOCK,dbuf,size);
225 dbuf[ret] = '\0';
226 if(ret != size)
227 {
228 if(ret==SOCK_BUSY) return 0;
229 if(ret < 0){
230 printf("%d:recv() error:%ld\r\n",CTRL_SOCK,ret);
231 close(CTRL_SOCK);
232 return ret;
233 }
234 }
235 printf("Rcvd Command: %s\r\n", dbuf);
236 proc_ftpc((char *)dbuf);
237 }
238 break;
239 case SOCK_CLOSE_WAIT :
240 printf("%d:CloseWait\r\n",CTRL_SOCK);
241 if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret;
242 printf("%d:Closed\r\n",CTRL_SOCK);
243 break;
244 case SOCK_CLOSED :
245 printf("%d:FTPStart\r\n",CTRL_SOCK);
246 if((ret=socket(CTRL_SOCK, Sn_MR_TCP, FTP_destport, 0x0)) != CTRL_SOCK){
247 printf("%d:socket() error:%ld\r\n", CTRL_SOCK, ret);
248 close(CTRL_SOCK);
249 return ret;
250 }
251 break;
252 case SOCK_INIT :
253 printf("%d:Opened\r\n",CTRL_SOCK);
254 if((ret = connect(CTRL_SOCK, FTP_destip, FTP_destport)) != SOCK_OK){
255 printf("%d:Connect error\r\n",CTRL_SOCK);
256 return ret;
257 }
258 connect_state_control_ftpc = 0;
259 printf("%d:Connectting...\r\n",CTRL_SOCK);
260 break;
261 default :
262 break;
263 }
264
265 switch(getSn_SR(DATA_SOCK)){
266 case SOCK_ESTABLISHED :
267 if(!connect_state_data_ftpc){
268 printf("%d:FTP Data socket Connected\r\n", DATA_SOCK);
269 connect_state_data_ftpc = 1;
270 }
271 if(gDataPutGetStart){
272 switch(Command.Second){
273 case s_dir:
274 printf("dir waiting...\r\n");
275 if((size = getSn_RX_RSR(DATA_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur.
276 printf("ok\r\n");
277 memset(dbuf, 0, _MAX_SS);
278 if(size > _MAX_SS) size = _MAX_SS - 1;
279 ret = recv(DATA_SOCK,dbuf,size);
280 dbuf[ret] = '\0';
281 if(ret != size){
282 if(ret==SOCK_BUSY) return 0;
283 if(ret < 0){
284 printf("%d:recv() error:%ld\r\n",CTRL_SOCK,ret);
285 close(DATA_SOCK);
286 return ret;
287 }
288 }
289 printf("Rcvd Data:\n\r%s\n\r", dbuf);
290 gDataPutGetStart = 0;
291 Command.Second = s_nocmd;
292 }
293 break;
294 case s_put:
295 printf("put waiting...\r\n");
296 if(strlen(ftpc.workingdir) == 1)
297 sprintf(ftpc.filename, "/%s", (uint8_t *)gMsgBuf);
298 else
299 sprintf(ftpc.filename, "%s/%s", ftpc.workingdir, (uint8_t *)gMsgBuf);
300 #if defined(F_FILESYSTEM)
301 ftpc.fr = f_open(&(ftpc.fil), (const char *)ftpc.filename, FA_READ);
302 if(ftpc.fr == FR_OK){
303 remain_filesize = ftpc.fil.fsize;
304 printf("f_open return FR_OK\r\n");
305 do{
306 memset(dbuf, 0, _MAX_SS);
307 if(remain_filesize > _MAX_SS)
308 send_byte = _MAX_SS;
309 else
310 send_byte = remain_filesize;
311 ftpc.fr = f_read(&(ftpc.fil), (void *)dbuf, send_byte , (UINT *)&blocklen);
312 if(ftpc.fr != FR_OK){
313 break;
314 }
315 printf("#");
316 send(DATA_SOCK, dbuf, blocklen);
317 remain_filesize -= blocklen;
318 }while(remain_filesize != 0);
319 printf("\r\nFile read finished\r\n");
320 ftpc.fr = f_close(&(ftpc.fil));
321 }
322 else{
323 printf("File Open Error: %d\r\n", ftpc.fr);
324 ftpc.fr = f_close(&(ftpc.fil));
325 }
326 #else
327 remain_filesize = strlen(ftpc.filename);
328 do{
329 memset(dbuf, 0, _MAX_SS);
330 blocklen = sprintf(dbuf, "%s", ftpc.filename);
331 printf("########## dbuf:%s\r\n", dbuf);
332 send(DATA_SOCK, dbuf, blocklen);
333 remain_filesize -= blocklen;
334 }while(remain_filesize != 0);
335 #endif
336 gDataPutGetStart = 0;
337 Command.Second = s_nocmd;
338 disconnect(DATA_SOCK);
339 break;
340 case s_get:
341 printf("get waiting...\r\n");
342 if(strlen(ftpc.workingdir) == 1)
343 sprintf(ftpc.filename, "/%s", (uint8_t *)gMsgBuf);
344 else
345 sprintf(ftpc.filename, "%s/%s", ftpc.workingdir, (uint8_t *)gMsgBuf);
346 #if defined(F_FILESYSTEM)
347 ftpc.fr = f_open(&(ftpc.fil), (const char *)ftpc.filename, FA_CREATE_ALWAYS | FA_WRITE);
348 if(ftpc.fr == FR_OK){
349 printf("f_open return FR_OK\r\n");
350 while(1){
351 if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){
352 while(1){
353 memset(dbuf, 0, _MAX_SS);
354 if(remain_datasize > _MAX_SS) recv_byte = _MAX_SS;
355 else recv_byte = remain_datasize;
356 ret = recv(DATA_SOCK, dbuf, recv_byte);
357 ftpc.fr = f_write(&(ftpc.fil), (const void *)dbuf, (UINT)ret, (UINT *)&blocklen);
358 remain_datasize -= blocklen;
359 if(ftpc.fr != FR_OK){
360 printf("f_write failed\r\n");
361 break;
362 }
363 if(remain_datasize <= 0) break;
364 }
365 if(ftpc.fr != FR_OK){
366 printf("f_write failed\r\n");
367 break;
368 }
369 printf("#");
370 }
371 else{
372 if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) break;
373 }
374 }
375 printf("\r\nFile write finished\r\n");
376 ftpc.fr = f_close(&(ftpc.fil));
377 gDataPutGetStart = 0;
378 }else{
379 printf("File Open Error: %d\r\n", ftpc.fr);
380 }
381 #else
382 while(1){
383 if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){
384 while(1){
385 memset(dbuf, 0, _MAX_SS);
386 if(remain_datasize > _MAX_SS)
387 recv_byte = _MAX_SS;
388 else
389 recv_byte = remain_datasize;
390 ret = recv(DATA_SOCK, dbuf, recv_byte);
391 printf("########## dbuf:%s\r\n", dbuf);
392 remain_datasize -= ret;
393 if(remain_datasize <= 0)
394 break;
395 }
396 }else{
397 if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED)
398 break;
399 }
400 }
401 gDataPutGetStart = 0;
402 Command.Second = s_nocmd;
403 #endif
404 break;
405 default:
406 printf("Command.Second = default\r\n");
407 break;
408 }
409 }
410 break;
411 case SOCK_CLOSE_WAIT :
412 printf("%d:CloseWait\r\n",DATA_SOCK);
413 if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret;
414 printf("%d:Closed\r\n",DATA_SOCK);
415 break;
416 case SOCK_CLOSED :
417 if(ftpc.dsock_state == DATASOCK_READY){
418 if(ftpc.dsock_mode == PASSIVE_MODE){
419 printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, local_port);
420 if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK){
421 printf("%d:socket() error:%ld\r\n", DATA_SOCK, ret);
422 close(DATA_SOCK);
423 return ret;
424 }
425 local_port++;
426 if(local_port > 50000)
427 local_port = 35000;
428 }else{
429 printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, local_port);
430 if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK){
431 printf("%d:socket() error:%ld\r\n", DATA_SOCK, ret);
432 close(DATA_SOCK);
433 return ret;
434 }
435 local_port++;
436 if(local_port > 50000)
437 local_port = 35000;
438 }
439 ftpc.dsock_state = DATASOCK_START;
440 }
441 break;
442
443 case SOCK_INIT :
444 printf("%d:Opened\r\n",DATA_SOCK);
445 if(ftpc.dsock_mode == ACTIVE_MODE){
446 if( (ret = listen(DATA_SOCK)) != SOCK_OK){
447 printf("%d:Listen error\r\n",DATA_SOCK);
448 return ret;
449 }
450 gDataSockReady = 1;
451 printf("%d:Listen ok\r\n",DATA_SOCK);
452 }else{
453 if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){
454 printf("%d:Connect error\r\n", DATA_SOCK);
455 return ret;
456 }
457 gDataSockReady = 1;
458 }
459 connect_state_data_ftpc = 0;
460 break;
461 default :
462 break;
463 }
464 #endif
465 return 0;
466 }
467
468 char proc_ftpc(char * buf)
469 {
470 uint16_t Responses;
471 uint8_t dat[30]={0,};
472
473 Responses =(buf[0]-'0')*100+(buf[1]-'0')*10+(buf[2]-'0');
474
475 switch(Responses){
476 case R_220: /* Service ready for new user. */
477 printf("\r\nInput your User ID > ");
478 sprintf(dat,"USER %s\r\n", User_Keyboard_MSG());
479 printf("\r\n");
480 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
481 break;
482
483 case R_331: /* User name okay, need password. */
484 printf("\r\nInput your Password > ");
485 sprintf(dat,"PASS %s\r\n", User_Keyboard_MSG());
486 printf("\r\n");
487 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
488 break;
489 case R_230: /* User logged in, proceed */
490 printf("\r\nUser logged in, proceed\r\n");
491
492 sprintf(dat,"TYPE %c\r\n", TransferAscii);
493 ftpc.type = ASCII_TYPE;
494 send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
495 break;
496 case R_200:
497 if((ftpc.dsock_mode==ACTIVE_MODE)&&gModeActivePassiveflag){
498 ftpc.dsock_state = DATASOCK_READY;
499 gModeActivePassiveflag = 0;
500 }
501 else{
502 gMenuStart = 1;
503 }
504 break;
505 case R_150:
506 switch(Command.First){
507 case f_dir:
508 Command.First = f_nocmd;
509 Command.Second = s_dir;
510 gDataPutGetStart = 1;
511 break;
512 case f_get:
513 Command.First = f_nocmd;
514 Command.Second = s_get;
515 gDataPutGetStart = 1;
516 break;
517 case f_put:
518 Command.First = f_nocmd;
519 Command.Second = s_put;
520 gDataPutGetStart = 1;
521 break;
522 default :
523 printf("Command.First = default\r\n");
524 break;
525 }
526 break;
527 case R_226:
528 gMenuStart = 1;
529 break;
530 case R_227:
531 if (pportc(buf) == -1){
532 printf("Bad port syntax\r\n");
533 }
534 else{
535 printf("Go Open Data Sock...\r\n ");
536 ftpc.dsock_mode = PASSIVE_MODE;
537 ftpc.dsock_state = DATASOCK_READY;
538 }
539 break;
540 default:
541 printf("\r\nDefault Status = %d\r\n",(uint16_t)Responses);
542 gDataSockReady = 1;
543 break;
544 }
545 return 1;
546 }
547 int pportc(char * arg)
548 {
549 int i;
550 char* tok=0;
551 strtok(arg,"(");
552 for (i = 0; i < 4; i++)
553 {
554 if(i==0) tok = strtok(NULL,",\r\n");
555 else tok = strtok(NULL,",");
556 remote_ip.cVal[i] = (uint8_t)atoi(tok, 10);
557 if (!tok){
558 printf("bad pport : %s\r\n", arg);
559 return -1;
560 }
561 }
562 remote_port = 0;
563 for (i = 0; i < 2; i++){
564 tok = strtok(NULL,",\r\n");
565 remote_port <<= 8;
566 remote_port += atoi(tok, 10);
567 if (!tok){
568 printf("bad pport : %s\r\n", arg);
569 return -1;
570 }
571 }
572 printf("ip : %d.%d.%d.%d, port : %d\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port);
573 return 0;
574 }
575 uint8_t* User_Keyboard_MSG()
576 {
577 uint8_t i=0;
578 do{
579 gMsgBuf[i] = ftp_getc();
580 i++;
581 }while(gMsgBuf[i-1]!=0x0d);
582 gMsgBuf[i-1]=0;
583 return gMsgBuf;
584 }
CN_GET_NETINFO
Get Network with wiz_NetInfo.
Definition: wizchip_conf.h:320
IMAGE_TYPE
Definition: ftpc.h:59
ftpc::workingdir
char workingdir[LINELEN]
Definition: ftpc.h:97
PASSIVE_MODE
Definition: ftpc.h:69
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
FTP_destip
uint8_t FTP_destip[4]
Definition: ftpc.c:10
s_nocmd
Definition: ftpc.h:79
gMenuStart
uint8_t gMenuStart
Definition: ftpc.c:12
SOCK_OK
#define SOCK_OK
Result is OK about socket process.
Definition: socket.h:92
proc_ftpc
char proc_ftpc(char *buf)
Definition: ftpc.c:468
SOCK_BUSY
#define SOCK_BUSY
Socket is busy on processing the operation. Valid only Non-block IO Mode.
Definition: socket.h:93
ftpc_init
void ftpc_init(uint8_t *src_ip)
Definition: ftpc.c:20
s_dir
Definition: ftpc.h:80
gModeActivePassiveflag
uint8_t gModeActivePassiveflag
Definition: ftpc.c:9
connect_state_data_ftpc
uint8_t connect_state_data_ftpc
Definition: ftpc.c:8
CTRL_SOCK
#define CTRL_SOCK
Definition: ftpc.h:42
ftpc::filename
char filename[LINELEN]
Definition: ftpc.h:98
ftpc::type
enum ftpc_type type
Definition: ftpc.h:92
User_Keyboard_MSG
uint8_t * User_Keyboard_MSG()
Definition: ftpc.c:575
R_220
#define R_220
Definition: ftpc.h:48
_un_l2cval::cVal
uint8_t cVal[4]
Definition: ftpc.h:109
gDataPutGetStart
uint8_t gDataPutGetStart
Definition: ftpc.c:14
Sn_MR_TCP
#define Sn_MR_TCP
TCP.
Definition: w5100.h:648
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
f_nocmd
Definition: ftpc.h:73
TransferAscii
#define TransferAscii
Definition: ftpc.h:54
f_put
Definition: ftpc.h:75
FTP_destport
uint16_t FTP_destport
Definition: ftpc.c:11
SOCK_CLOSED
#define SOCK_CLOSED
Closed.
Definition: w5100.h:893
f_dir
Definition: ftpc.h:74
R_226
#define R_226
Definition: ftpc.h:49
Command::Second
enum CommandSecond Second
Definition: ftpc.h:86
local_port
uint16_t local_port
Definition: ftpc.c:6
ctlnetwork
int8_t ctlnetwork(ctlnetwork_type cntype, void *arg)
Controls to network.
Definition: wizchip_conf.c:359
recv
int32_t recv(uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer.
Definition: socket.c:384
R_230
#define R_230
Definition: ftpc.h:51
ftpc::dsock_state
enum ftpc_datasock_state dsock_state
Definition: ftpc.h:94
R_227
#define R_227
Definition: ftpc.h:50
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
Command
Definition: ftpc.h:84
SOCK_CLOSE_WAIT
#define SOCK_CLOSE_WAIT
Closing state.
Definition: w5100.h:967
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
disconnect
int8_t disconnect(uint8_t sn)
Try to disconnect a connection socket.
Definition: socket.c:296
ftpc.h
_MAX_SS
#define _MAX_SS
Definition: ftpc.h:39
ACTIVE_MODE
Definition: ftpc.h:70
DATASOCK_START
Definition: ftpc.h:65
gDataSockReady
uint8_t gDataSockReady
Definition: ftpc.c:13
listen
int8_t listen(uint8_t sn)
Listen to a connection request from a client.
Definition: socket.c:240
pportc
int pportc(char *arg)
Definition: ftpc.c:547
R_150
#define R_150
Definition: ftpc.h:46
ftpc
Definition: ftpc.h:88
ftpc::dsock_mode
enum ftpc_datasock_mode dsock_mode
Definition: ftpc.h:95
s_put
Definition: ftpc.h:81
ASCII_TYPE
Definition: ftpc.h:58
Command::First
enum CommandFirst First
Definition: ftpc.h:85
connect_state_control_ftpc
uint8_t connect_state_control_ftpc
Definition: ftpc.c:7
DATA_SOCK
#define DATA_SOCK
Definition: ftpc.h:43
connect
int8_t connect(uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server.
Definition: socket.c:256
wiz_NetInfo_t
Definition: wizchip_conf.h:413
local_ip
un_l2cval local_ip
Definition: ftpc.c:5
s_get
Definition: ftpc.h:82
SOCK_INIT
#define SOCK_INIT
Initiate state.
Definition: w5100.h:901
remote_ip
un_l2cval remote_ip
Definition: ftpc.c:3
R_200
#define R_200
Definition: ftpc.h:47
R_331
#define R_331
Definition: ftpc.h:52
_un_l2cval
Definition: ftpc.h:107
remote_port
uint16_t remote_port
Definition: ftpc.c:4
ftpc_run
uint8_t ftpc_run(uint8_t *dbuf)
Definition: ftpc.c:32
DATASOCK_READY
Definition: ftpc.h:64
SOCK_ESTABLISHED
#define SOCK_ESTABLISHED
Success to connect.
Definition: w5100.h:935
f_get
Definition: ftpc.h:76
send
int32_t send(uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket.
Definition: socket.c:316
TransferBinary
#define TransferBinary
Definition: ftpc.h:55


ioLibrary: Internet/FTPClient/ftpc.h Source File

  • Internet
  • FTPClient
ftpc.h
Go to the documentation of this file.
1 #ifndef _FTPC_H_
2 #define _FTPC_H_
3
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <ctype.h>
7 #include <string.h>
8 #include <limits.h>
9 #include <stdarg.h>
10 #include "stdio_private.h"
11 #include "socket.h"
12
13 #define F_APP_FTPC
14
15 /* If your target support a file system, you have to activate this feature and implement. */
16 //#define F_FILESYSTEM
17
18 /* Change to your Chipset Uart function, you have to activate this feature and implement.
19 * Change!! -> Board_UARTGetCharBlocking()
20 * Below is an example of a function of lpc_chip library. */
21 //#define ftp_getc() Board_UARTGetCharBlocking()
22
23 #ifdef F_FILESYSTEM
24 #include "ff.h"
25 #endif
26
27 #ifndef ftp_getc()
28 #define Need_UARTGetCharBlocking_func
29 #else
30 /* Change library
31 * Change!! -> board_api.h,
32 * Below is an example of a function of lpc_chip library. */
33 #include "board_api.h"
34 #endif
35
36
37 #define LINELEN 100
38 #ifndef F_FILESYSTEM
39 #define _MAX_SS 512
40 #endif
41
42 #define CTRL_SOCK 2
43 #define DATA_SOCK 3
44
45 /* FTP Responses */
46 #define R_150 150 /* File status ok; opening data conn */
47 #define R_200 200 /* 'Generic' command ok */
48 #define R_220 220 /* Service ready for new user. */
49 #define R_226 226 /* Closing data connection. File transfer/abort successful */
50 #define R_227 227 /* Entering passive mode (h1,h2,h3,h4,p1,p2) */
51 #define R_230 230 /* User logged in, proceed */
52 #define R_331 331 /* User name okay, need password. */
53
54 #define TransferAscii 'A'
55 #define TransferBinary 'I'
56
57 enum ftpc_type {
58 ASCII_TYPE,
59 IMAGE_TYPE,
60 };
61
62 enum ftpc_datasock_state{
63 DATASOCK_IDLE,
64 DATASOCK_READY,
65 DATASOCK_START
66 };
67
68 enum ftpc_datasock_mode{
69 PASSIVE_MODE,
70 ACTIVE_MODE
71 };
72 enum CommandFirst {
73 f_nocmd,
74 f_dir,
75 f_put,
76 f_get,
77 };
78 enum CommandSecond {
79 s_nocmd,
80 s_dir,
81 s_put,
82 s_get,
83 };
84 struct Command {
85 enum CommandFirst First;
86 enum CommandSecond Second;
87 };
88 struct ftpc {
89 uint8_t control; /* Control stream */
90 uint8_t data; /* Data stream */
91
92 enum ftpc_type type; /* Transfer type */
93
94 enum ftpc_datasock_state dsock_state;
95 enum ftpc_datasock_mode dsock_mode;
96
97 char workingdir[LINELEN];
98 char filename[LINELEN];
99
100 #ifdef F_FILESYSTEM
101 FIL fil; // FatFs File objects
102 FRESULT fr; // FatFs function common result code
103 #endif
104 };
105
106 #ifndef un_I2cval
107 typedef union _un_l2cval {
108 uint32_t lVal;
109 uint8_t cVal[4];
110 }un_l2cval;
111 #endif
112
113 void ftpc_init(uint8_t * src_ip);
114 uint8_t ftpc_run(uint8_t * dbuf);
115 char proc_ftpc(char * buf);
116 int pportc(char * arg);
117 uint8_t* User_Keyboard_MSG();
118
119 #endif // _FTPC_H_
proc_ftpc
char proc_ftpc(char *buf)
Definition: ftpc.c:468
IMAGE_TYPE
Definition: ftpc.h:59
ftpc::control
uint8_t control
Definition: ftpc.h:89
ftpc::workingdir
char workingdir[LINELEN]
Definition: ftpc.h:97
PASSIVE_MODE
Definition: ftpc.h:69
s_nocmd
Definition: ftpc.h:79
ftpc_type
ftpc_type
Definition: ftpc.h:57
ftpc_datasock_state
ftpc_datasock_state
Definition: ftpc.h:62
s_dir
Definition: ftpc.h:80
ftpc_run
uint8_t ftpc_run(uint8_t *dbuf)
Definition: ftpc.c:32
ftpc_datasock_mode
ftpc_datasock_mode
Definition: ftpc.h:68
User_Keyboard_MSG
uint8_t * User_Keyboard_MSG()
Definition: ftpc.c:575
ftpc::filename
char filename[LINELEN]
Definition: ftpc.h:98
ftpc::type
enum ftpc_type type
Definition: ftpc.h:92
_un_l2cval::cVal
uint8_t cVal[4]
Definition: ftpc.h:109
LINELEN
#define LINELEN
Definition: ftpc.h:37
f_nocmd
Definition: ftpc.h:73
f_put
Definition: ftpc.h:75
f_dir
Definition: ftpc.h:74
Command::Second
enum CommandSecond Second
Definition: ftpc.h:86
un_l2cval
union _un_l2cval un_l2cval
ftpc::dsock_state
enum ftpc_datasock_state dsock_state
Definition: ftpc.h:94
CommandFirst
CommandFirst
Definition: ftpc.h:72
DATASOCK_IDLE
Definition: ftpc.h:63
Command
Definition: ftpc.h:84
ftpc::data
uint8_t data
Definition: ftpc.h:90
_un_l2cval::lVal
uint32_t lVal
Definition: ftpc.h:108
ACTIVE_MODE
Definition: ftpc.h:70
DATASOCK_START
Definition: ftpc.h:65
pportc
int pportc(char *arg)
Definition: ftpc.c:547
CommandSecond
CommandSecond
Definition: ftpc.h:78
ftpc
Definition: ftpc.h:88
ftpc::dsock_mode
enum ftpc_datasock_mode dsock_mode
Definition: ftpc.h:95
s_put
Definition: ftpc.h:81
ASCII_TYPE
Definition: ftpc.h:58
Command::First
enum CommandFirst First
Definition: ftpc.h:85
socket.h
SOCKET APIs Header file.
s_get
Definition: ftpc.h:82
stdio_private.h
_un_l2cval
Definition: ftpc.h:107
ftpc_init
void ftpc_init(uint8_t *src_ip)
Definition: ftpc.c:20
DATASOCK_READY
Definition: ftpc.h:64
f_get
Definition: ftpc.h:76


ioLibrary: Internet/FTPServer/ftpd.c Source File

  • Internet
  • FTPServer
ftpd.c
Go to the documentation of this file.
1 /*
2 * Wiznet.
3 * (c) Copyright 2002, Wiznet.
4 *
5 * Filename : ftpd.c
6 * Version : 1.0
7 * Programmer(s) :
8 * Created : 2003/01/28
9 * Description : FTP daemon. (AVR-GCC Compiler)
10 */
11
12
13 #include <stdio.h>
14 #include <ctype.h>
15 #include <string.h>
16 #include <limits.h>
17 #include <stdarg.h>
18 #include "stdio_private.h"
19 #include "socket.h"
20 #include "ftpd.h"
21
22 /* Command table */
23 static char *commands[] = {
24 "user",
25 "acct",
26 "pass",
27 "type",
28 "list",
29 "cwd",
30 "dele",
31 "name",
32 "quit",
33 "retr",
34 "stor",
35 "port",
36 "nlst",
37 "pwd",
38 "xpwd",
39 "mkd",
40 "xmkd",
41 "xrmd",
42 "rmd ",
43 "stru",
44 "mode",
45 "syst",
46 "xmd5",
47 "xcwd",
48 "feat",
49 "pasv",
50 "size",
51 "mlsd",
52 "appe",
53 NULL
54 };
55
56 #if 0
57 /* Response messages */
58 char banner[] = "220 %s FTP version %s ready.\r\n";
59 char badcmd[] = "500 Unknown command '%s'\r\n";
60 char binwarn[] = "100 Warning: type is ASCII and %s appears to be binary\r\n";
61 char unsupp[] = "500 Unsupported command or option\r\n";
62 char givepass[] = "331 Enter PASS command\r\n";
63 char logged[] = "230 Logged in\r\n";
64 char typeok[] = "200 Type %s OK\r\n";
65 char only8[] = "501 Only logical bytesize 8 supported\r\n";
66 char deleok[] = "250 File deleted\r\n";
67 char mkdok[] = "200 MKD ok\r\n";
68 char delefail[] = "550 Delete failed: %s\r\n";
69 char pwdmsg[] = "257 \"%s\" is current directory\r\n";
70 char badtype[] = "501 Unknown type \"%s\"\r\n";
71 char badport[] = "501 Bad port syntax\r\n";
72 char unimp[] = "502 Command does not implemented yet.\r\n";
73 char bye[] = "221 Goodbye!\r\n";
74 char nodir[] = "553 Can't read directory \"%s\": %s\r\n";
75 char cantopen[] = "550 Can't read file \"%s\": %s\r\n";
76 char sending[] = "150 Opening data connection for %s (%d.%d.%d.%d,%d)\r\n";
77 char cantmake[] = "553 Can't create \"%s\": %s\r\n";
78 char writerr[] = "552 Write error: %s\r\n";
79 char portok[] = "200 PORT command successful.\r\n";
80 char rxok[] = "226 Transfer complete.\r\n";
81 char txok[] = "226 Transfer complete.\r\n";
82 char noperm[] = "550 Permission denied\r\n";
83 char noconn[] = "425 Data connection reset\r\n";
84 char lowmem[] = "421 System overloaded, try again later\r\n";
85 char notlog[] = "530 Please log in with USER and PASS\r\n";
86 char userfirst[] = "503 Login with USER first.\r\n";
87 char okay[] = "200 Ok\r\n";
88 char syst[] = "215 %s Type: L%d Version: %s\r\n";
89 char sizefail[] = "550 File not found\r\n";
90 #endif
91
92 un_l2cval remote_ip;
93 uint16_t remote_port;
94 un_l2cval local_ip;
95 uint16_t local_port;
96 uint8_t connect_state_control = 0;
97 uint8_t connect_state_data = 0;
98
99 struct ftpd ftp;
100
101 int current_year = 2014;
102 int current_month = 12;
103 int current_day = 31;
104 int current_hour = 10;
105 int current_min = 10;
106 int current_sec = 30;
107
108 int fsprintf(uint8_t s, const char *format, ...)
109 {
110 int i;
111 /*
112 char buf[LINELEN];
113 FILE f;
114 va_list ap;
115
116 f.flags = __SWR | __SSTR;
117 f.buf = buf;
118 f.size = INT_MAX;
119 va_start(ap, format);
120 i = vfprintf(&f, format, ap);
121 va_end(ap);
122 buf[f.len] = 0;
123
124 send(s, (uint8_t *)buf, strlen(buf));
125 */
126 return i;
127 }
128
129 void ftpd_init(uint8_t * src_ip)
130 {
131 ftp.state = FTPS_NOT_LOGIN;
132 ftp.current_cmd = NO_CMD;
133 ftp.dsock_mode = ACTIVE_MODE;
134
135 local_ip.cVal[0] = src_ip[0];
136 local_ip.cVal[1] = src_ip[1];
137 local_ip.cVal[2] = src_ip[2];
138 local_ip.cVal[3] = src_ip[3];
139 local_port = 35000;
140
141 strcpy(ftp.workingdir, "/");
142
143 socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0);
144 }
145
146 uint8_t ftpd_run(uint8_t * dbuf)
147 {
148 uint16_t size = 0, i;
149 long ret = 0;
150 uint32_t blocklen, send_byte, recv_byte;
151 uint32_t remain_filesize;
152 uint32_t remain_datasize;
153 #if defined(F_FILESYSTEM)
154 //FILINFO fno;
155 #endif
156
157 //memset(dbuf, 0, sizeof(_MAX_SS));
158
159 switch(getSn_SR(CTRL_SOCK))
160 {
161 case SOCK_ESTABLISHED :
162 if(!connect_state_control)
163 {
164 #if defined(_FTP_DEBUG_)
165 printf("%d:FTP Connected\r\n", CTRL_SOCK);
166 #endif
167 //fsprintf(CTRL_SOCK, banner, HOSTNAME, VERSION);
168 strcpy(ftp.workingdir, "/");
169 sprintf((char *)dbuf, "220 %s FTP version %s ready.\r\n", HOSTNAME, VERSION);
170 ret = send(CTRL_SOCK, (uint8_t *)dbuf, strlen((const char *)dbuf));
171 if(ret < 0)
172 {
173 #if defined(_FTP_DEBUG_)
174 printf("%d:send() error:%ld\r\n",CTRL_SOCK,ret);
175 #endif
176 close(CTRL_SOCK);
177 return ret;
178 }
179 connect_state_control = 1;
180 }
181
182 #if defined(_FTP_DEBUG_)
183 //printf("ftp socket %d\r\n", CTRL_SOCK);
184 #endif
185
186 if((size = getSn_RX_RSR(CTRL_SOCK)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur.
187 {
188 #if defined(_FTP_DEBUG_)
189 printf("size: %d\r\n", size);
190 #endif
191
192 memset(dbuf, 0, _MAX_SS);
193
194 if(size > _MAX_SS) size = _MAX_SS - 1;
195
196 ret = recv(CTRL_SOCK,dbuf,size);
197 dbuf[ret] = '\0';
198 if(ret != size)
199 {
200 if(ret==SOCK_BUSY) return 0;
201 if(ret < 0)
202 {
203 #if defined(_FTP_DEBUG_)
204 printf("%d:recv() error:%ld\r\n",CTRL_SOCK,ret);
205 #endif
206 close(CTRL_SOCK);
207 return ret;
208 }
209 }
210 #if defined(_FTP_DEBUG_)
211 printf("Rcvd Command: %s", dbuf);
212 #endif
213 proc_ftpd((char *)dbuf);
214 }
215 break;
216
217 case SOCK_CLOSE_WAIT :
218 #if defined(_FTP_DEBUG_)
219 printf("%d:CloseWait\r\n",CTRL_SOCK);
220 #endif
221 if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret;
222 #if defined(_FTP_DEBUG_)
223 printf("%d:Closed\r\n",CTRL_SOCK);
224 #endif
225 break;
226
227 case SOCK_CLOSED :
228 #if defined(_FTP_DEBUG_)
229 printf("%d:FTPStart\r\n",CTRL_SOCK);
230 #endif
231 if((ret=socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0)) != CTRL_SOCK)
232 {
233 #if defined(_FTP_DEBUG_)
234 printf("%d:socket() error:%ld\r\n", CTRL_SOCK, ret);
235 #endif
236 close(CTRL_SOCK);
237 return ret;
238 }
239 break;
240
241 case SOCK_INIT :
242 #if defined(_FTP_DEBUG_)
243 printf("%d:Opened\r\n",CTRL_SOCK);
244 #endif
245 //strcpy(ftp.workingdir, "/");
246 if( (ret = listen(CTRL_SOCK)) != SOCK_OK)
247 {
248 #if defined(_FTP_DEBUG_)
249 printf("%d:Listen error\r\n",CTRL_SOCK);
250 #endif
251 return ret;
252 }
253 connect_state_control = 0;
254
255 #if defined(_FTP_DEBUG_)
256 printf("%d:Listen ok\r\n",CTRL_SOCK);
257 #endif
258 break;
259
260 default :
261 break;
262 }
263
264 #if 1
265 switch(getSn_SR(DATA_SOCK))
266 {
267 case SOCK_ESTABLISHED :
268 if(!connect_state_data)
269 {
270 #if defined(_FTP_DEBUG_)
271 printf("%d:FTP Data socket Connected\r\n", DATA_SOCK);
272 #endif
273 connect_state_data = 1;
274 }
275
276 switch(ftp.current_cmd)
277 {
278 case LIST_CMD:
279 case MLSD_CMD:
280 #if defined(_FTP_DEBUG_)
281 printf("previous size: %d\r\n", size);
282 #endif
283 #if defined(F_FILESYSTEM)
284 scan_files(ftp.workingdir, dbuf, (int *)&size);
285 #endif
286 #if defined(_FTP_DEBUG_)
287 printf("returned size: %d\r\n", size);
288 printf("%s\r\n", dbuf);
289 #endif
290 #if !defined(F_FILESYSTEM)
291 if (strncmp(ftp.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0)
292 size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n");
293 #endif
294 size = strlen(dbuf);
295 send(DATA_SOCK, dbuf, size);
296 ftp.current_cmd = NO_CMD;
297 disconnect(DATA_SOCK);
298 size = sprintf(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir);
299 send(CTRL_SOCK, dbuf, size);
300 break;
301
302 case RETR_CMD:
303 #if defined(_FTP_DEBUG_)
304 printf("filename to retrieve : %s %d\r\n", ftp.filename, strlen(ftp.filename));
305 #endif
306 #if defined(F_FILESYSTEM)
307 ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_READ);
308 //print_filedsc(&(ftp.fil));
309 if(ftp.fr == FR_OK){
310 remain_filesize = ftp.fil.fsize;
311 #if defined(_FTP_DEBUG_)
312 printf("f_open return FR_OK\r\n");
313 #endif
314 do{
315 #if defined(_FTP_DEBUG_)
316 //printf("remained file size: %d\r\n", ftp.fil.fsize);
317 #endif
318 memset(dbuf, 0, _MAX_SS);
319
320 if(remain_filesize > _MAX_SS)
321 send_byte = _MAX_SS;
322 else
323 send_byte = remain_filesize;
324
325 ftp.fr = f_read(&(ftp.fil), dbuf, send_byte , &blocklen);
326 if(ftp.fr != FR_OK)
327 break;
328 #if defined(_FTP_DEBUG_)
329 printf("#");
330 //printf("----->fsize:%d recv:%d len:%d \r\n", remain_filesize, send_byte, blocklen);
331 //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf);
332 #endif
333 send(DATA_SOCK, dbuf, blocklen);
334 remain_filesize -= blocklen;
335 }while(remain_filesize != 0);
336 #if defined(_FTP_DEBUG_)
337 printf("\r\nFile read finished\r\n");
338 #endif
339 ftp.fr = f_close(&(ftp.fil));
340 }else{
341 #if defined(_FTP_DEBUG_)
342 printf("File Open Error: %d\r\n", ftp.fr);
343 #endif
344 }
345 #else
346 remain_filesize = strlen(ftp.filename);
347
348 do{
349 memset(dbuf, 0, _MAX_SS);
350
351 blocklen = sprintf(dbuf, "%s", ftp.filename);
352
353 printf("########## dbuf:%s\r\n", dbuf);
354
355 send(DATA_SOCK, dbuf, blocklen);
356 remain_filesize -= blocklen;
357 }while(remain_filesize != 0);
358
359 #endif
360 ftp.current_cmd = NO_CMD;
361 disconnect(DATA_SOCK);
362 size = sprintf(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename);
363 send(CTRL_SOCK, dbuf, size);
364 break;
365
366 case STOR_CMD:
367 #if defined(_FTP_DEBUG_)
368 printf("filename to store : %s %d\r\n", ftp.filename, strlen(ftp.filename));
369 #endif
370 #if defined(F_FILESYSTEM)
371 ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_CREATE_ALWAYS | FA_WRITE);
372 //print_filedsc(&(ftp.fil));
373 if(ftp.fr == FR_OK){
374 #if defined(_FTP_DEBUG_)
375 printf("f_open return FR_OK\r\n");
376 #endif
377 while(1){
378 if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){
379 while(1){
380 memset(dbuf, 0, _MAX_SS);
381
382 if(remain_datasize > _MAX_SS)
383 recv_byte = _MAX_SS;
384 else
385 recv_byte = remain_datasize;
386
387 ret = recv(DATA_SOCK, dbuf, recv_byte);
388 #if defined(_FTP_DEBUG_)
389 //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf);
390 #endif
391
392 ftp.fr = f_write(&(ftp.fil), dbuf, (UINT)ret, &blocklen);
393 #if defined(_FTP_DEBUG_)
394 //printf("----->dsize:%d recv:%d len:%d \r\n", remain_datasize, ret, blocklen);
395 #endif
396 remain_datasize -= blocklen;
397
398 if(ftp.fr != FR_OK){
399 #if defined(_FTP_DEBUG_)
400 printf("f_write failed\r\n");
401 #endif
402 break;
403 }
404
405 if(remain_datasize <= 0)
406 break;
407 }
408
409 if(ftp.fr != FR_OK){
410 #if defined(_FTP_DEBUG_)
411 printf("f_write failed\r\n");
412 #endif
413 break;
414 }
415
416 #if defined(_FTP_DEBUG_)
417 printf("#");
418 #endif
419 }else{
420 if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED)
421 break;
422 }
423 }
424 #if defined(_FTP_DEBUG_)
425 printf("\r\nFile write finished\r\n");
426 #endif
427 ftp.fr = f_close(&(ftp.fil));
428 }else{
429 #if defined(_FTP_DEBUG_)
430 printf("File Open Error: %d\r\n", ftp.fr);
431 #endif
432 }
433
434 //fno.fdate = (WORD)(((current_year - 1980) << 9) | (current_month << 5) | current_day);
435 //fno.ftime = (WORD)((current_hour << 11) | (current_min << 5) | (current_sec >> 1));
436 //f_utime((const char *)ftp.filename, &fno);
437 #else
438 while(1){
439 if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){
440 while(1){
441 memset(dbuf, 0, _MAX_SS);
442
443 if(remain_datasize > _MAX_SS)
444 recv_byte = _MAX_SS;
445 else
446 recv_byte = remain_datasize;
447
448 ret = recv(DATA_SOCK, dbuf, recv_byte);
449
450 printf("########## dbuf:%s\r\n", dbuf);
451
452 remain_datasize -= ret;
453
454 if(remain_datasize <= 0)
455 break;
456 }
457 }else{
458 if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED)
459 break;
460 }
461 }
462 #endif
463 ftp.current_cmd = NO_CMD;
464 disconnect(DATA_SOCK);
465 size = sprintf(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename);
466 send(CTRL_SOCK, dbuf, size);
467 break;
468
469 case NO_CMD:
470 default:
471 break;
472 }
473 break;
474
475 case SOCK_CLOSE_WAIT :
476 #if defined(_FTP_DEBUG_)
477 printf("%d:CloseWait\r\n",DATA_SOCK);
478 #endif
479 if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret;
480 #if defined(_FTP_DEBUG_)
481 printf("%d:Closed\r\n",DATA_SOCK);
482 #endif
483 break;
484
485 case SOCK_CLOSED :
486 if(ftp.dsock_state == DATASOCK_READY)
487 {
488 if(ftp.dsock_mode == PASSIVE_MODE){
489 #if defined(_FTP_DEBUG_)
490 printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, local_port);
491 #endif
492 if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK)
493 {
494 #if defined(_FTP_DEBUG_)
495 printf("%d:socket() error:%ld\r\n", DATA_SOCK, ret);
496 #endif
497 close(DATA_SOCK);
498 return ret;
499 }
500
501 local_port++;
502 if(local_port > 50000)
503 local_port = 35000;
504 }else{
505 #if defined(_FTP_DEBUG_)
506 printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, IPPORT_FTPD);
507 #endif
508 if((ret=socket(DATA_SOCK, Sn_MR_TCP, IPPORT_FTPD, 0x0)) != DATA_SOCK)
509 {
510 #if defined(_FTP_DEBUG_)
511 printf("%d:socket() error:%ld\r\n", DATA_SOCK, ret);
512 #endif
513 close(DATA_SOCK);
514 return ret;
515 }
516 }
517
518 ftp.dsock_state = DATASOCK_START;
519 }
520 break;
521
522 case SOCK_INIT :
523 #if defined(_FTP_DEBUG_)
524 printf("%d:Opened\r\n",DATA_SOCK);
525 #endif
526 if(ftp.dsock_mode == PASSIVE_MODE){
527 if( (ret = listen(DATA_SOCK)) != SOCK_OK)
528 {
529 #if defined(_FTP_DEBUG_)
530 printf("%d:Listen error\r\n",DATA_SOCK);
531 #endif
532 return ret;
533 }
534
535 #if defined(_FTP_DEBUG_)
536 printf("%d:Listen ok\r\n",DATA_SOCK);
537 #endif
538 }else{
539 if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){
540 #if defined(_FTP_DEBUG_)
541 printf("%d:Connect error\r\n", DATA_SOCK);
542 #endif
543 return ret;
544 }
545 }
546 connect_state_data = 0;
547 break;
548
549 default :
550 break;
551 }
552 #endif
553
554 return 0;
555 }
556
557 char proc_ftpd(char * buf)
558 {
559 char **cmdp, *cp, *arg, *tmpstr;
560 char sendbuf[200];
561 int slen;
562 long ret;
563
564
565 /* Translate first word to lower case */
566 for (cp = buf; *cp != ' ' && *cp != '\0'; cp++)
567 *cp = tolower(*cp);
568
569 /* Find command in table; if not present, return syntax error */
570 for (cmdp = commands; *cmdp != NULL; cmdp++)
571 if (strncmp(*cmdp, buf, strlen(*cmdp)) == 0)
572 break;
573
574 if (*cmdp == NULL)
575 {
576 //fsprintf(CTRL_SOCK, badcmd, buf);
577 slen = sprintf(sendbuf, "500 Unknown command '%s'\r\n", buf);
578 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
579 return 0;
580 }
581 /* Allow only USER, PASS and QUIT before logging in */
582 if (ftp.state == FTPS_NOT_LOGIN)
583 {
584 switch(cmdp - commands)
585 {
586 case USER_CMD:
587 case PASS_CMD:
588 case QUIT_CMD:
589 break;
590 default:
591 //fsprintf(CTRL_SOCK, notlog);
592 slen = sprintf(sendbuf, "530 Please log in with USER and PASS\r\n");
593 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
594 return 0;
595 }
596 }
597
598 arg = &buf[strlen(*cmdp)];
599 while(*arg == ' ') arg++;
600
601 /* Execute specific command */
602 switch (cmdp - commands)
603 {
604 case USER_CMD :
605 #if defined(_FTP_DEBUG_)
606 printf("USER_CMD : %s", arg);
607 #endif
608 slen = strlen(arg);
609 arg[slen - 1] = 0x00;
610 arg[slen - 2] = 0x00;
611 strcpy(ftp.username, arg);
612 //fsprintf(CTRL_SOCK, givepass);
613 slen = sprintf(sendbuf, "331 Enter PASS command\r\n");
614 ret = send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
615 if(ret < 0)
616 {
617 #if defined(_FTP_DEBUG_)
618 printf("%d:send() error:%ld\r\n",CTRL_SOCK,ret);
619 #endif
620 close(CTRL_SOCK);
621 return ret;
622 }
623 break;
624
625 case PASS_CMD :
626 #if defined(_FTP_DEBUG_)
627 printf("PASS_CMD : %s", arg);
628 #endif
629 slen = strlen(arg);
630 arg[slen - 1] = 0x00;
631 arg[slen - 2] = 0x00;
632 ftplogin(arg);
633 break;
634
635 case TYPE_CMD :
636 slen = strlen(arg);
637 arg[slen - 1] = 0x00;
638 arg[slen - 2] = 0x00;
639 switch(arg[0])
640 {
641 case 'A':
642 case 'a': /* Ascii */
643 ftp.type = ASCII_TYPE;
644 //fsprintf(CTRL_SOCK, typeok, arg);
645 slen = sprintf(sendbuf, "200 Type set to %s\r\n", arg);
646 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
647 break;
648
649 case 'B':
650 case 'b': /* Binary */
651 case 'I':
652 case 'i': /* Image */
653 ftp.type = IMAGE_TYPE;
654 //fsprintf(CTRL_SOCK, typeok, arg);
655 slen = sprintf(sendbuf, "200 Type set to %s\r\n", arg);
656 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
657 break;
658
659 default: /* Invalid */
660 //fsprintf(CTRL_SOCK, badtype, arg);
661 slen = sprintf(sendbuf, "501 Unknown type \"%s\"\r\n", arg);
662 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
663 break;
664 }
665 break;
666
667 case FEAT_CMD :
668 slen = sprintf(sendbuf, "211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST size*;type*;create*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 END\r\n");
669 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
670 break;
671
672 case QUIT_CMD :
673 #if defined(_FTP_DEBUG_)
674 printf("QUIT_CMD\r\n");
675 #endif
676 //fsprintf(CTRL_SOCK, bye);
677 slen = sprintf(sendbuf, "221 Goodbye!\r\n");
678 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
679 disconnect(CTRL_SOCK);
680 break;
681
682 case RETR_CMD :
683 slen = strlen(arg);
684 arg[slen - 1] = 0x00;
685 arg[slen - 2] = 0x00;
686 #if defined(_FTP_DEBUG_)
687 printf("RETR_CMD\r\n");
688 #endif
689 if(strlen(ftp.workingdir) == 1)
690 sprintf(ftp.filename, "/%s", arg);
691 else
692 sprintf(ftp.filename, "%s/%s", ftp.workingdir, arg);
693 slen = sprintf(sendbuf, "150 Opening data channel for file downloand from server of \"%s\"\r\n", ftp.filename);
694 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
695 ftp.current_cmd = RETR_CMD;
696 break;
697
698 case APPE_CMD :
699 case STOR_CMD:
700 slen = strlen(arg);
701 arg[slen - 1] = 0x00;
702 arg[slen - 2] = 0x00;
703 #if defined(_FTP_DEBUG_)
704 printf("STOR_CMD\r\n");
705 #endif
706 if(strlen(ftp.workingdir) == 1)
707 sprintf(ftp.filename, "/%s", arg);
708 else
709 sprintf(ftp.filename, "%s/%s", ftp.workingdir, arg);
710 slen = sprintf(sendbuf, "150 Opening data channel for file upload to server of \"%s\"\r\n", ftp.filename);
711 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
712 ftp.current_cmd = STOR_CMD;
713 if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){
714 #if defined(_FTP_DEBUG_)
715 printf("%d:Connect error\r\n", DATA_SOCK);
716 #endif
717 return ret;
718 }
719 connect_state_data = 0;
720 break;
721
722 case PORT_CMD:
723 #if defined(_FTP_DEBUG_)
724 printf("PORT_CMD\r\n");
725 #endif
726 if (pport(arg) == -1){
727 //fsprintf(CTRL_SOCK, badport);
728 slen = sprintf(sendbuf, "501 Bad port syntax\r\n");
729 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
730 } else{
731 //fsprintf(CTRL_SOCK, portok);
732 ftp.dsock_mode = ACTIVE_MODE;
733 ftp.dsock_state = DATASOCK_READY;
734 slen = sprintf(sendbuf, "200 PORT command successful.\r\n");
735 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
736 }
737 break;
738
739 case MLSD_CMD:
740 #if defined(_FTP_DEBUG_)
741 printf("MLSD_CMD\r\n");
742 #endif
743 slen = sprintf(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir);
744 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
745 ftp.current_cmd = MLSD_CMD;
746 break;
747
748 case LIST_CMD:
749 #if defined(_FTP_DEBUG_)
750 printf("LIST_CMD\r\n");
751 #endif
752 slen = sprintf(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir);
753 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
754 ftp.current_cmd = LIST_CMD;
755 break;
756
757 case NLST_CMD:
758 #if defined(_FTP_DEBUG_)
759 printf("NLST_CMD\r\n");
760 #endif
761 break;
762
763 case SYST_CMD:
764 slen = sprintf(sendbuf, "215 UNIX emulated by WIZnet\r\n");
765 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
766 break;
767
768 case PWD_CMD:
769 case XPWD_CMD:
770 slen = sprintf(sendbuf, "257 \"%s\" is current directory.\r\n", ftp.workingdir);
771 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
772 break;
773
774 case PASV_CMD:
775 slen = sprintf(sendbuf, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", local_ip.cVal[0], local_ip.cVal[1], local_ip.cVal[2], local_ip.cVal[3], local_port >> 8, local_port & 0x00ff);
776 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
777 disconnect(DATA_SOCK);
778 ftp.dsock_mode = PASSIVE_MODE;
779 ftp.dsock_state = DATASOCK_READY;
780 #if defined(_FTP_DEBUG_)
781 printf("PASV port: %d\r\n", local_port);
782 #endif
783 break;
784
785 case SIZE_CMD:
786 slen = strlen(arg);
787 arg[slen - 1] = 0x00;
788 arg[slen - 2] = 0x00;
789 if(slen > 3)
790 {
791 tmpstr = strrchr(arg, '/');
792 *tmpstr = 0;
793 #if defined(F_FILESYSTEM)
794 slen = get_filesize(arg, tmpstr + 1);
795 #else
796 slen = _MAX_SS;
797 #endif
798 if(slen > 0)
799 slen = sprintf(sendbuf, "213 %d\r\n", slen);
800 else
801 slen = sprintf(sendbuf, "550 File not Found\r\n");
802 }
803 else
804 {
805 slen = sprintf(sendbuf, "550 File not Found\r\n");
806 }
807 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
808 break;
809
810 case CWD_CMD:
811 slen = strlen(arg);
812 arg[slen - 1] = 0x00;
813 arg[slen - 2] = 0x00;
814 if(slen > 3)
815 {
816 arg[slen - 3] = 0x00;
817 tmpstr = strrchr(arg, '/');
818 *tmpstr = 0;
819 #if defined(F_FILESYSTEM)
820 slen = get_filesize(arg, tmpstr + 1);
821 #else
822 slen = 0;
823 #endif
824 *tmpstr = '/';
825 if(slen == 0){
826 slen = sprintf(sendbuf, "213 %d\r\n", slen);
827 strcpy(ftp.workingdir, arg);
828 slen = sprintf(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir);
829 }
830 else
831 {
832 slen = sprintf(sendbuf, "550 CWD failed. \"%s\"\r\n", arg);
833 }
834 }
835 else
836 {
837 strcpy(ftp.workingdir, arg);
838 slen = sprintf(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir);
839 }
840 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
841 break;
842
843 case MKD_CMD:
844 case XMKD_CMD:
845 slen = strlen(arg);
846 arg[slen - 1] = 0x00;
847 arg[slen - 2] = 0x00;
848 #if defined(F_FILESYSTEM)
849 if (f_mkdir(arg) != 0)
850 {
851 slen = sprintf(sendbuf, "550 Can't create directory. \"%s\"\r\n", arg);
852 }
853 else
854 {
855 slen = sprintf(sendbuf, "257 MKD command successful. \"%s\"\r\n", arg);
856 //strcpy(ftp.workingdir, arg);
857 }
858 #else
859 slen = sprintf(sendbuf, "550 Can't create directory. Permission denied\r\n");
860 #endif
861 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
862 break;
863
864 case DELE_CMD:
865 slen = strlen(arg);
866 arg[slen - 1] = 0x00;
867 arg[slen - 2] = 0x00;
868 #if defined(F_FILESYSTEM)
869 if (f_unlink(arg) != 0)
870 {
871 slen = sprintf(sendbuf, "550 Could not delete. \"%s\"\r\n", arg);
872 }
873 else
874 {
875 slen = sprintf(sendbuf, "250 Deleted. \"%s\"\r\n", arg);
876 }
877 #else
878 slen = sprintf(sendbuf, "550 Could not delete. Permission denied\r\n");
879 #endif
880 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
881 break;
882
883 case XCWD_CMD:
884 case ACCT_CMD:
885 case XRMD_CMD:
886 case RMD_CMD:
887 case STRU_CMD:
888 case MODE_CMD:
889 case XMD5_CMD:
890 //fsprintf(CTRL_SOCK, unimp);
891 slen = sprintf(sendbuf, "502 Command does not implemented yet.\r\n");
892 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
893 break;
894
895 default: /* Invalid */
896 //fsprintf(CTRL_SOCK, badcmd, arg);
897 slen = sprintf(sendbuf, "500 Unknown command \'%s\'\r\n", arg);
898 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
899 break;
900 }
901
902 return 1;
903 }
904
905
906 char ftplogin(char * pass)
907 {
908 char sendbuf[100];
909 int slen = 0;
910
911 //memset(sendbuf, 0, DATA_BUF_SIZE);
912
913 #if defined(_FTP_DEBUG_)
914 printf("%s logged in\r\n", ftp.username);
915 #endif
916 //fsprintf(CTRL_SOCK, logged);
917 slen = sprintf(sendbuf, "230 Logged on\r\n");
918 send(CTRL_SOCK, (uint8_t *)sendbuf, slen);
919 ftp.state = FTPS_LOGIN;
920
921 return 1;
922 }
923
924 int pport(char * arg)
925 {
926 int i;
927 char* tok=0;
928
929 for (i = 0; i < 4; i++)
930 {
931 if(i==0) tok = strtok(arg,",\r\n");
932 else tok = strtok(NULL,",");
933 remote_ip.cVal[i] = (uint8_t)atoi(tok, 10);
934 if (!tok)
935 {
936 #if defined(_FTP_DEBUG_)
937 printf("bad pport : %s\r\n", arg);
938 #endif
939 return -1;
940 }
941 }
942 remote_port = 0;
943 for (i = 0; i < 2; i++)
944 {
945 tok = strtok(NULL,",\r\n");
946 remote_port <<= 8;
947 remote_port += atoi(tok, 10);
948 if (!tok)
949 {
950 #if defined(_FTP_DEBUG_)
951 printf("bad pport : %s\r\n", arg);
952 #endif
953 return -1;
954 }
955 }
956 #if defined(_FTP_DEBUG_)
957 printf("ip : %d.%d.%d.%d, port : %d\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port);
958 #endif
959
960 return 0;
961 }
962
963 #if defined(F_FILESYSTEM)
964 void print_filedsc(FIL *fil)
965 {
966 #if defined(_FTP_DEBUG_)
967 printf("File System pointer : %08X\r\n", fil->fs);
968 printf("File System mount ID : %d\r\n", fil->id);
969 printf("File status flag : %08X\r\n", fil->flag);
970 printf("File System pads : %08X\r\n", fil->err);
971 printf("File read write pointer : %08X\r\n", fil->fptr);
972 printf("File size : %08X\r\n", fil->fsize);
973 printf("File start cluster : %08X\r\n", fil->sclust);
974 printf("current cluster : %08X\r\n", fil->clust);
975 printf("current data sector : %08X\r\n", fil->dsect);
976 printf("dir entry sector : %08X\r\n", fil->dir_sect);
977 printf("dir entry pointer : %08X\r\n", fil->dir_ptr);
978 #endif
979 }
980 #endif
ftpd::username
char username[LINELEN]
Definition: ftpd.h:112
SIZE_CMD
Definition: ftpd.h:72
FEAT_CMD
Definition: ftpd.h:70
NLST_CMD
Definition: ftpd.h:58
current_hour
int current_hour
Definition: ftpd.c:104
IMAGE_TYPE
Definition: ftpc.h:59
VERSION
#define VERSION
Definition: ftpd.h:40
ftp
struct ftpd ftp
Definition: ftpd.c:99
FTPS_NOT_LOGIN
Definition: ftpd.h:85
PASSIVE_MODE
Definition: ftpc.h:69
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
ftpd::dsock_state
enum datasock_state dsock_state
Definition: ftpd.h:109
IPPORT_FTP
#define IPPORT_FTP
Definition: ftpd.h:37
ftpd_run
uint8_t ftpd_run(uint8_t *dbuf)
Definition: ftpd.c:146
RMD_CMD
Definition: ftpd.h:64
HOSTNAME
#define HOSTNAME
Definition: ftpd.h:39
PASV_CMD
Definition: ftpd.h:71
proc_ftpd
char proc_ftpd(char *buf)
Definition: ftpd.c:557
XMD5_CMD
Definition: ftpd.h:68
STRU_CMD
Definition: ftpd.h:65
SOCK_OK
#define SOCK_OK
Result is OK about socket process.
Definition: socket.h:92
APPE_CMD
Definition: ftpd.h:74
XCWD_CMD
Definition: ftpd.h:69
MKD_CMD
Definition: ftpd.h:61
SOCK_BUSY
#define SOCK_BUSY
Socket is busy on processing the operation. Valid only Non-block IO Mode.
Definition: socket.h:93
remote_port
uint16_t remote_port
Definition: ftpd.c:93
XRMD_CMD
Definition: ftpd.h:63
ftpd::filename
char filename[LINELEN]
Definition: ftpd.h:114
local_ip
un_l2cval local_ip
Definition: ftpd.c:94
CTRL_SOCK
#define CTRL_SOCK
Definition: ftpc.h:42
PORT_CMD
Definition: ftpd.h:57
IPPORT_FTPD
#define IPPORT_FTPD
Definition: ftpd.h:36
ftpd_init
void ftpd_init(uint8_t *src_ip)
Definition: ftpd.c:129
RETR_CMD
Definition: ftpd.h:55
_un_l2cval::cVal
uint8_t cVal[4]
Definition: ftpc.h:109
PASS_CMD
Definition: ftpd.h:48
current_sec
int current_sec
Definition: ftpd.c:106
Sn_MR_TCP
#define Sn_MR_TCP
TCP.
Definition: w5100.h:648
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
SYST_CMD
Definition: ftpd.h:67
PWD_CMD
Definition: ftpd.h:59
current_day
int current_day
Definition: ftpd.c:103
USER_CMD
Definition: ftpd.h:46
stdio_private.h
SOCK_CLOSED
#define SOCK_CLOSED
Closed.
Definition: w5100.h:893
XMKD_CMD
Definition: ftpd.h:62
current_year
int current_year
Definition: ftpd.c:101
connect_state_data
uint8_t connect_state_data
Definition: ftpd.c:97
fsprintf
int fsprintf(uint8_t s, const char *format,...)
Definition: ftpd.c:108
LIST_CMD
Definition: ftpd.h:50
recv
int32_t recv(uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer.
Definition: socket.c:384
ACCT_CMD
Definition: ftpd.h:47
TYPE_CMD
Definition: ftpd.h:49
MLSD_CMD
Definition: ftpd.h:73
pport
int pport(char *arg)
Definition: ftpd.c:924
ftpd::current_cmd
enum ftp_cmd current_cmd
Definition: ftpd.h:107
ftpd.h
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
ftpd::state
enum ftp_state state
Definition: ftpd.h:105
SOCK_CLOSE_WAIT
#define SOCK_CLOSE_WAIT
Closing state.
Definition: w5100.h:967
FTPS_LOGIN
Definition: ftpd.h:86
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
disconnect
int8_t disconnect(uint8_t sn)
Try to disconnect a connection socket.
Definition: socket.c:296
_MAX_SS
#define _MAX_SS
Definition: ftpc.h:39
ACTIVE_MODE
Definition: ftpc.h:70
DATASOCK_START
Definition: ftpc.h:65
remote_ip
un_l2cval remote_ip
Definition: ftpd.c:92
ftpd::workingdir
char workingdir[LINELEN]
Definition: ftpd.h:113
current_min
int current_min
Definition: ftpd.c:105
CWD_CMD
Definition: ftpd.h:51
DELE_CMD
Definition: ftpd.h:52
listen
int8_t listen(uint8_t sn)
Listen to a connection request from a client.
Definition: socket.c:240
current_month
int current_month
Definition: ftpd.c:102
ftpd::dsock_mode
enum datasock_mode dsock_mode
Definition: ftpd.h:110
connect_state_control
uint8_t connect_state_control
Definition: ftpd.c:96
STOR_CMD
Definition: ftpd.h:56
XPWD_CMD
Definition: ftpd.h:60
ftplogin
char ftplogin(char *pass)
Definition: ftpd.c:906
ASCII_TYPE
Definition: ftpc.h:58
local_port
uint16_t local_port
Definition: ftpd.c:95
DATA_SOCK
#define DATA_SOCK
Definition: ftpc.h:43
MODE_CMD
Definition: ftpd.h:66
connect
int8_t connect(uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server.
Definition: socket.c:256
socket.h
SOCKET APIs Header file.
SOCK_INIT
#define SOCK_INIT
Initiate state.
Definition: w5100.h:901
QUIT_CMD
Definition: ftpd.h:54
ftpd::type
enum ftp_type type
Definition: ftpd.h:104
_un_l2cval
Definition: ftpc.h:107
NO_CMD
Definition: ftpd.h:75
DATASOCK_READY
Definition: ftpc.h:64
SOCK_ESTABLISHED
#define SOCK_ESTABLISHED
Success to connect.
Definition: w5100.h:935
send
int32_t send(uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket.
Definition: socket.c:316
ftpd
Definition: ftpd.h:100


ioLibrary: Internet/FTPServer/ftpd.h Source File

  • Internet
  • FTPServer
ftpd.h
Go to the documentation of this file.
1 #ifndef _FTPD_H_
2 #define _FTPD_H_
3
4 /*
5 * Wiznet.
6 * (c) Copyright 2002, Wiznet.
7 *
8 * Filename : ftpd.h
9 * Version : 1.0
10 * Programmer(s) :
11 * Created : 2003/01/28
12 * Description : Header file of FTP daemon. (AVR-GCC Compiler)
13 */
14
15 #include <stdint.h>
16
17 //#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement.
18
19 #if defined(F_FILESYSTEM)
20 #include "ff.h"
21 #endif
22
23 #define F_APP_FTP
24 #define _FTP_DEBUG_
25
26
27 #define LINELEN 100
28 //#define DATA_BUF_SIZE 100
29 #if !defined(F_FILESYSTEM)
30 #define _MAX_SS 512
31 #endif
32
33 #define CTRL_SOCK 2
34 #define DATA_SOCK 3
35
36 #define IPPORT_FTPD 20 /* FTP Data port */
37 #define IPPORT_FTP 21 /* FTP Control port */
38
39 #define HOSTNAME "iinChip"
40 #define VERSION "1.0"
41
42 #define FILENAME "a.txt"
43
44 /* FTP commands */
45 enum ftp_cmd {
46 USER_CMD,
47 ACCT_CMD,
48 PASS_CMD,
49 TYPE_CMD,
50 LIST_CMD,
51 CWD_CMD,
52 DELE_CMD,
53 NAME_CMD,
54 QUIT_CMD,
55 RETR_CMD,
56 STOR_CMD,
57 PORT_CMD,
58 NLST_CMD,
59 PWD_CMD,
60 XPWD_CMD,
61 MKD_CMD,
62 XMKD_CMD,
63 XRMD_CMD,
64 RMD_CMD,
65 STRU_CMD,
66 MODE_CMD,
67 SYST_CMD,
68 XMD5_CMD,
69 XCWD_CMD,
70 FEAT_CMD,
71 PASV_CMD,
72 SIZE_CMD,
73 MLSD_CMD,
74 APPE_CMD,
75 NO_CMD,
76 };
77
78 enum ftp_type {
79 ASCII_TYPE,
80 IMAGE_TYPE,
81 LOGICAL_TYPE
82 };
83
84 enum ftp_state {
85 FTPS_NOT_LOGIN,
86 FTPS_LOGIN
87 };
88
89 enum datasock_state{
90 DATASOCK_IDLE,
91 DATASOCK_READY,
92 DATASOCK_START
93 };
94
95 enum datasock_mode{
96 PASSIVE_MODE,
97 ACTIVE_MODE
98 };
99
100 struct ftpd {
101 uint8_t control; /* Control stream */
102 uint8_t data; /* Data stream */
103
104 enum ftp_type type; /* Transfer type */
105 enum ftp_state state;
106
107 enum ftp_cmd current_cmd;
108
109 enum datasock_state dsock_state;
110 enum datasock_mode dsock_mode;
111
112 char username[LINELEN]; /* Arg to USER command */
113 char workingdir[LINELEN];
114 char filename[LINELEN];
115
116 #if defined(F_FILESYSTEM)
117 FIL fil; // FatFs File objects
118 FRESULT fr; // FatFs function common result code
119 #endif
120
121 };
122
123 #ifndef un_I2cval
124 typedef union _un_l2cval {
125 uint32_t lVal;
126 uint8_t cVal[4];
127 }un_l2cval;
128 #endif
129
130 void ftpd_init(uint8_t * src_ip);
131 uint8_t ftpd_run(uint8_t * dbuf);
132 char proc_ftpd(char * buf);
133 char ftplogin(char * pass);
134 int pport(char * arg);
135
136 int sendit(char * command);
137 int recvit(char * command);
138
139 long sendfile(uint8_t s, char * command);
140 long recvfile(uint8_t s);
141
142 #if defined(F_FILESYSTEM)
143 void print_filedsc(FIL *fil);
144 #endif
145 #endif // _FTPD_H_
ftpd::username
char username[LINELEN]
Definition: ftpd.h:112
SIZE_CMD
Definition: ftpd.h:72
FEAT_CMD
Definition: ftpd.h:70
ASCII_TYPE
Definition: ftpd.h:79
NLST_CMD
Definition: ftpd.h:58
recvfile
long recvfile(uint8_t s)
NAME_CMD
Definition: ftpd.h:53
FTPS_NOT_LOGIN
Definition: ftpd.h:85
ftpd::dsock_state
enum datasock_state dsock_state
Definition: ftpd.h:109
ftpd::control
uint8_t control
Definition: ftpd.h:101
RMD_CMD
Definition: ftpd.h:64
PASV_CMD
Definition: ftpd.h:71
XMD5_CMD
Definition: ftpd.h:68
STRU_CMD
Definition: ftpd.h:65
APPE_CMD
Definition: ftpd.h:74
XCWD_CMD
Definition: ftpd.h:69
ftp_type
ftp_type
Definition: ftpd.h:78
DATASOCK_READY
Definition: ftpd.h:91
MKD_CMD
Definition: ftpd.h:61
ftplogin
char ftplogin(char *pass)
Definition: ftpd.c:906
XRMD_CMD
Definition: ftpd.h:63
ftpd::filename
char filename[LINELEN]
Definition: ftpd.h:114
IMAGE_TYPE
Definition: ftpd.h:80
un_l2cval
union _un_l2cval un_l2cval
PASSIVE_MODE
Definition: ftpd.h:96
PORT_CMD
Definition: ftpd.h:57
datasock_mode
datasock_mode
Definition: ftpd.h:95
RETR_CMD
Definition: ftpd.h:55
ftp_state
ftp_state
Definition: ftpd.h:84
DATASOCK_IDLE
Definition: ftpd.h:90
_un_l2cval::cVal
uint8_t cVal[4]
Definition: ftpc.h:109
PASS_CMD
Definition: ftpd.h:48
DATASOCK_START
Definition: ftpd.h:92
SYST_CMD
Definition: ftpd.h:67
sendit
int sendit(char *command)
PWD_CMD
Definition: ftpd.h:59
USER_CMD
Definition: ftpd.h:46
XMKD_CMD
Definition: ftpd.h:62
datasock_state
datasock_state
Definition: ftpd.h:89
LIST_CMD
Definition: ftpd.h:50
ACCT_CMD
Definition: ftpd.h:47
TYPE_CMD
Definition: ftpd.h:49
MLSD_CMD
Definition: ftpd.h:73
proc_ftpd
char proc_ftpd(char *buf)
Definition: ftpd.c:557
ftpd::current_cmd
enum ftp_cmd current_cmd
Definition: ftpd.h:107
ftpd::data
uint8_t data
Definition: ftpd.h:102
sendfile
long sendfile(uint8_t s, char *command)
ACTIVE_MODE
Definition: ftpd.h:97
_un_l2cval::lVal
uint32_t lVal
Definition: ftpc.h:108
ftpd::state
enum ftp_state state
Definition: ftpd.h:105
FTPS_LOGIN
Definition: ftpd.h:86
ftpd::workingdir
char workingdir[LINELEN]
Definition: ftpd.h:113
CWD_CMD
Definition: ftpd.h:51
ftpd_run
uint8_t ftpd_run(uint8_t *dbuf)
Definition: ftpd.c:146
DELE_CMD
Definition: ftpd.h:52
ftp_cmd
ftp_cmd
Definition: ftpd.h:45
ftpd::dsock_mode
enum datasock_mode dsock_mode
Definition: ftpd.h:110
LINELEN
#define LINELEN
Definition: ftpd.h:27
recvit
int recvit(char *command)
STOR_CMD
Definition: ftpd.h:56
XPWD_CMD
Definition: ftpd.h:60
MODE_CMD
Definition: ftpd.h:66
ftpd_init
void ftpd_init(uint8_t *src_ip)
Definition: ftpd.c:129
QUIT_CMD
Definition: ftpd.h:54
pport
int pport(char *arg)
Definition: ftpd.c:924
ftpd::type
enum ftp_type type
Definition: ftpd.h:104
_un_l2cval
Definition: ftpc.h:107
NO_CMD
Definition: ftpd.h:75
LOGICAL_TYPE
Definition: ftpd.h:81
ftpd
Definition: ftpd.h:100


ioLibrary: 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 gray 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 labelled 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 labelled with the template parameters of the instance.


ioLibrary: Internet/httpServer/httpParser.c Source File

  • Internet
  • httpServer
httpParser.c
Go to the documentation of this file.
1
6 #include <stdio.h>
7 #include <string.h>
8 #include "socket.h"
9 #include "httpParser.h"
10
11 /*****************************************************************************
12 * Public types/enumerations/variables
13 ****************************************************************************/
14 //uint8_t BUFPUB[2048];
15 uint8_t BUFPUB[256];
16
17 /*****************************************************************************
18 * Private functions
19 ****************************************************************************/
20 static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */
21 static uint8_t C2D(uint8_t c); /* Convert a character to HEX */
22
26 void unescape_http_url(
27 char * url
28 )
29 {
30 int x, y;
31
32 for (x = 0, y = 0; url[y]; ++x, ++y) {
33 if ((url[x] = url[y]) == '%') {
34 url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]);
35 y+=2;
36 }
37 }
38 url[x] = '\0';
39 }
40
41
45 void make_http_response_head(
46 char * buf,
47 char type,
48 uint32_t len
49 )
50 {
51 char * head;
52 char tmp[10];
53
54 /* file type*/
55 if (type == PTYPE_HTML) head = RES_HTMLHEAD_OK;
56 else if (type == PTYPE_GIF) head = RES_GIFHEAD_OK;
57 else if (type == PTYPE_TEXT) head = RES_TEXTHEAD_OK;
58 else if (type == PTYPE_JPEG) head = RES_JPEGHEAD_OK;
59 else if (type == PTYPE_FLASH) head = RES_FLASHHEAD_OK;
60 else if (type == PTYPE_XML) head = RES_XMLHEAD_OK;
61 else if (type == PTYPE_CSS) head = RES_CSSHEAD_OK;
62 else if (type == PTYPE_JSON) head = RES_JSONHEAD_OK;
63 else if (type == PTYPE_JS) head = RES_JSHEAD_OK;
64 else if (type == PTYPE_CGI) head = RES_CGIHEAD_OK;
65 else if (type == PTYPE_PNG) head = RES_PNGHEAD_OK;
66 else if (type == PTYPE_ICO) head = RES_ICOHEAD_OK;
67 else if (type == PTYPE_TTF) head = RES_TTFHEAD_OK;
68 else if (type == PTYPE_OTF) head = RES_OTFHEAD_OK;
69 else if (type == PTYPE_WOFF) head = RES_WOFFHEAD_OK;
70 else if (type == PTYPE_EOT) head = RES_EOTHEAD_OK;
71 else if (type == PTYPE_SVG) head = RES_SVGHEAD_OK;
72 #ifdef _HTTPPARSER_DEBUG_
73 else
74 {
75 head = NULL;
76 printf("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n");
77 }
78 #else
79 else head = NULL;
80 #endif
81
82 sprintf(tmp, "%ld", len);
83 strcpy(buf, head);
84 strcat(buf, tmp);
85 strcat(buf, "\r\n\r\n");
86 }
87
88
92 void find_http_uri_type(
93 uint8_t * type,
94 uint8_t * buff
95 )
96 {
97 /* Decide type according to extension*/
98
99 char * buf;
100 buf = (char *)buff;
101
102 if (strstr(buf, ".htm") || strstr(buf, ".html")) *type = PTYPE_HTML;
103 else if (strstr(buf, ".gif")) *type = PTYPE_GIF;
104 else if (strstr(buf, ".text") || strstr(buf,".txt")) *type = PTYPE_TEXT;
105 else if (strstr(buf, ".jpeg") || strstr(buf,".jpg")) *type = PTYPE_JPEG;
106 else if (strstr(buf, ".swf")) *type = PTYPE_FLASH;
107 else if (strstr(buf, ".cgi") || strstr(buf,".CGI")) *type = PTYPE_CGI;
108 else if (strstr(buf, ".json") || strstr(buf,".JSON")) *type = PTYPE_JSON;
109 else if (strstr(buf, ".js") || strstr(buf,".JS")) *type = PTYPE_JS;
110 else if (strstr(buf, ".CGI") || strstr(buf,".cgi")) *type = PTYPE_CGI;
111 else if (strstr(buf, ".xml") || strstr(buf,".XML")) *type = PTYPE_XML;
112 else if (strstr(buf, ".css") || strstr(buf,".CSS")) *type = PTYPE_CSS;
113 else if (strstr(buf, ".png") || strstr(buf,".PNG")) *type = PTYPE_PNG;
114 else if (strstr(buf, ".ico") || strstr(buf,".ICO")) *type = PTYPE_ICO;
115 else if (strstr(buf, ".ttf") || strstr(buf,".TTF")) *type = PTYPE_TTF;
116 else if (strstr(buf, ".otf") || strstr(buf,".OTF")) *type = PTYPE_OTF;
117 else if (strstr(buf, ".woff") || strstr(buf,".WOFF")) *type = PTYPE_WOFF;
118 else if (strstr(buf, ".eot") || strstr(buf,".EOT")) *type = PTYPE_EOT;
119 else if (strstr(buf, ".svg") || strstr(buf,".SVG")) *type = PTYPE_SVG;
120 else *type = PTYPE_ERR;
121 }
122
123
127 void parse_http_request(
128 st_http_request * request,
129 uint8_t * buf
130 )
131 {
132 char * nexttok;
133 nexttok = strtok((char*)buf," ");
134 if(!nexttok)
135 {
136 request->METHOD = METHOD_ERR;
137 return;
138 }
139 if(!strcmp(nexttok, "GET") || !strcmp(nexttok,"get"))
140 {
141 request->METHOD = METHOD_GET;
142 nexttok = strtok(NULL," ");
143
144 }
145 else if (!strcmp(nexttok, "HEAD") || !strcmp(nexttok,"head"))
146 {
147 request->METHOD = METHOD_HEAD;
148 nexttok = strtok(NULL," ");
149
150 }
151 else if (!strcmp(nexttok, "POST") || !strcmp(nexttok,"post"))
152 {
153 nexttok = strtok(NULL,"\0");
154 request->METHOD = METHOD_POST;
155 }
156 else
157 {
158 request->METHOD = METHOD_ERR;
159 }
160
161 if(!nexttok)
162 {
163 request->METHOD = METHOD_ERR;
164 return;
165 }
166 strcpy((char *)request->URI, nexttok);
167 }
168
169 #ifdef _OLD_
170
173 uint8_t * get_http_param_value(
174 char* uri,
175 char* param_name
176 )
177 {
178 char tempURI[MAX_URI_SIZE];
179 uint8_t * name = 0;
180
181
182 if(!uri || !param_name) return 0;
183
184 strcpy((char*)tempURI,uri);
185 if((name = (uint8_t*)strstr(tempURI, param_name)))
186 {
187 name += strlen(param_name) + 1; // strlen(para_name) + strlen("=")
188 if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0")))
189 {
190 unescape_http_url((char *)name);
191 replacetochar(name, '+', ' ');
192 }
193 }
194 #ifdef _HTTPPARSER_DEBUG_
195 printf(" %s=%s",param_name,name);
196 #endif
197
198 return name;
199 }
200 #else
201
204 uint8_t * get_http_param_value(char* uri, char* param_name)
205 {
206
207 uint8_t * name = 0;
208 uint8_t * ret = BUFPUB;
209 uint8_t * pos2;
210 uint16_t len = 0, content_len = 0;
211 uint8_t tmp_buf[10]={0x00, };
212
213 if(!uri || !param_name) return 0;
214
215 /***************/
216 mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf);
217 content_len = ATOI(tmp_buf, 10);
218 uri = strstr(uri, "\r\n\r\n");
219 uri += 4;
220 uri[content_len] = 0;
221 /***************/
222
223 if((name = (uint8_t *)strstr(uri, param_name)))
224 {
225 name += strlen(param_name) + 1;
226 pos2 = (uint8_t*)strstr((char*)name, "&");
227 if(!pos2)
228 {
229 pos2 = name + strlen((char*)name);
230 }
231 len = pos2 - name;
232
233 if(len)
234 {
235 ret[len] = 0;
236 strncpy((char*)ret,(char*)name, len);
237 unescape_http_url((char *)ret);
238 replacetochar(ret, '+' ,' ');
239 //ret[len] = 0;
240 //ret[strlen((int8*)ret)] = 0;
241 //printf("len=%d\r\n",len);
242 }
243 else
244 {
245 ret[0] = 0;
246 }
247 }
248 else
249 {
250 return 0;
251 }
252 #ifdef _HTTPPARSER_DEBUG_
253 printf(" %s=%s\r\n", param_name, ret);
254 #endif
255 return ret;
256 }
257 #endif
258
259 #ifdef _OLD_
260 uint8_t * get_http_uri_name(uint8_t * uri)
261 {
262 char tempURI[MAX_URI_SIZE];
263 uint8_t * uri_name;
264
265 if(!uri) return 0;
266
267 strcpy(tempURI, (char *)uri);
268
269 uri_name = (uint8_t *)strtok(tempURI, " ?");
270
271 if(strcmp((char *)uri_name,"/")) uri_name++;
272
273 #ifdef _HTTPPARSER_DEBUG_
274 printf(" uri_name = %s\r\n", uri_name);
275 #endif
276
277 return uri_name;
278 }
279 #else
280
281 uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf)
282 {
283 uint8_t * uri_ptr;
284 if(!uri) return 0;
285
286 strcpy((char *)uri_buf, (char *)uri);
287
288 uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?");
289
290 if(strcmp((char *)uri_ptr,"/")) uri_ptr++;
291 strcpy((char *)uri_buf, (char *)uri_ptr);
292
293 #ifdef _HTTPPARSER_DEBUG_
294 printf(" uri_name = %s\r\n", uri_buf);
295 #endif
296
297 return 1;
298 }
299
300 #endif
301
302 void inet_addr_(uint8_t * addr, uint8_t *ip)
303 {
304 uint8_t i;
305 uint8_t taddr[30];
306 uint8_t * nexttok;
307 uint8_t num;
308
309 strcpy((char *)taddr, (char *)addr);
310
311 nexttok = taddr;
312 for(i = 0; i < 4 ; i++)
313 {
314 nexttok = (uint8_t *)strtok((char *)nexttok, ".");
315 if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10);
316 else num = ATOI(nexttok,10);
317 ip[i] = num;
318 nexttok = NULL;
319 }
320 }
321
322
327 uint16_t ATOI(
328 uint8_t * str,
329 uint8_t base
330 )
331 {
332 unsigned int num = 0;
333 // debug_2013_11_25
334 // while (*str !=0)
335 while ((*str !=0) && (*str != 0x20)) // not include the space(0x020)
336 num = num * base + C2D(*str++);
337 return num;
338 }
339
348 void mid(char* src, char* s1, char* s2, char* sub)
349 {
350 char* sub1;
351 char* sub2;
352 uint16_t n;
353
354 sub1=strstr((char*)src,(char*)s1);
355 sub1+=strlen((char*)s1);
356 sub2=strstr((char*)sub1,(char*)s2);
357
358 n=sub2-sub1;
359 strncpy((char*)sub,(char*)sub1,n);
360 sub[n]='\0';
361 }
362
364 // Static functions
366
370 static void replacetochar(
371 uint8_t * str,
372 uint8_t oldchar,
373 uint8_t newchar
374 )
375 {
376 int x;
377 for (x = 0; str[x]; x++)
378 if (str[x] == oldchar) str[x] = newchar;
379 }
380
387 static uint8_t C2D(
388 uint8_t c
389 )
390 {
391 if (c >= '0' && c <= '9')
392 return c - '0';
393 if (c >= 'a' && c <= 'f')
394 return 10 + c -'a';
395 if (c >= 'A' && c <= 'F')
396 return 10 + c -'A';
397
398 return (char)c;
399 }
400
401
402
PTYPE_JPEG
#define PTYPE_JPEG
Definition: httpParser.h:26
METHOD_POST
#define METHOD_POST
Definition: httpParser.h:19
RES_PNGHEAD_OK
#define RES_PNGHEAD_OK
Definition: httpParser.h:82
make_http_response_head
void make_http_response_head(char *buf, char type, uint32_t len)
make response header such as html, gif, jpeg,etc.
Definition: httpParser.c:45
RES_CGIHEAD_OK
#define RES_CGIHEAD_OK
Definition: httpParser.h:103
unescape_http_url
void unescape_http_url(char *url)
convert escape characters(XX) to ASCII character
Definition: httpParser.c:26
METHOD_HEAD
#define METHOD_HEAD
Definition: httpParser.h:18
PTYPE_CSS
#define PTYPE_CSS
Definition: httpParser.h:32
METHOD_GET
#define METHOD_GET
Definition: httpParser.h:17
PTYPE_FLASH
#define PTYPE_FLASH
Definition: httpParser.h:27
RES_XMLHEAD_OK
#define RES_XMLHEAD_OK
Definition: httpParser.h:88
METHOD_ERR
#define METHOD_ERR
Definition: httpParser.h:16
RES_JSHEAD_OK
#define RES_JSHEAD_OK
Definition: httpParser.h:94
get_http_param_value
uint8_t * get_http_param_value(char *uri, char *param_name)
get next parameter value in the request
Definition: httpParser.c:204
RES_JPEGHEAD_OK
#define RES_JPEGHEAD_OK
Definition: httpParser.h:79
RES_EOTHEAD_OK
#define RES_EOTHEAD_OK
Definition: httpParser.h:115
PTYPE_ICO
#define PTYPE_ICO
Definition: httpParser.h:36
parse_http_request
void parse_http_request(st_http_request *request, uint8_t *buf)
parse http request from a peer
Definition: httpParser.c:127
RES_WOFFHEAD_OK
#define RES_WOFFHEAD_OK
Definition: httpParser.h:112
get_http_uri_name
uint8_t get_http_uri_name(uint8_t *uri, uint8_t *uri_buf)
Definition: httpParser.c:281
MAX_URI_SIZE
#define MAX_URI_SIZE
Structure of HTTP REQUEST.
Definition: httpParser.h:125
RES_SVGHEAD_OK
#define RES_SVGHEAD_OK
Definition: httpParser.h:118
_st_http_request
Definition: httpParser.h:127
PTYPE_TEXT
#define PTYPE_TEXT
Definition: httpParser.h:25
PTYPE_XML
#define PTYPE_XML
Definition: httpParser.h:31
PTYPE_ERR
#define PTYPE_ERR
Definition: httpParser.h:22
PTYPE_SVG
#define PTYPE_SVG
Definition: httpParser.h:42
PTYPE_HTML
#define PTYPE_HTML
Definition: httpParser.h:23
BUFPUB
uint8_t BUFPUB[256]
Definition: httpParser.c:15
RES_HTMLHEAD_OK
#define RES_HTMLHEAD_OK
Definition: httpParser.h:70
PTYPE_EOT
#define PTYPE_EOT
Definition: httpParser.h:41
RES_ICOHEAD_OK
#define RES_ICOHEAD_OK
Definition: httpParser.h:100
RES_GIFHEAD_OK
#define RES_GIFHEAD_OK
Definition: httpParser.h:76
_st_http_request::URI
uint8_t URI[MAX_URI_SIZE]
Definition: httpParser.h:131
PTYPE_JSON
#define PTYPE_JSON
Definition: httpParser.h:34
_st_http_request::METHOD
uint8_t METHOD
Definition: httpParser.h:129
httpParser.h
RES_OTFHEAD_OK
#define RES_OTFHEAD_OK
Definition: httpParser.h:109
PTYPE_WOFF
#define PTYPE_WOFF
Definition: httpParser.h:40
ATOI
uint16_t ATOI(uint8_t *str, uint8_t base)
CONVERT STRING INTO INTEGER.
Definition: httpParser.c:327
inet_addr_
void inet_addr_(uint8_t *addr, uint8_t *ip)
Definition: httpParser.c:302
mid
void mid(char *src, char *s1, char *s2, char *sub)
Check strings and then execute callback function by each string.
Definition: httpParser.c:348
PTYPE_OTF
#define PTYPE_OTF
Definition: httpParser.h:39
RES_TTFHEAD_OK
#define RES_TTFHEAD_OK
Definition: httpParser.h:106
RES_JSONHEAD_OK
#define RES_JSONHEAD_OK
Definition: httpParser.h:97
PTYPE_GIF
#define PTYPE_GIF
Definition: httpParser.h:24
PTYPE_JS
#define PTYPE_JS
Definition: httpParser.h:33
RES_FLASHHEAD_OK
#define RES_FLASHHEAD_OK
Definition: httpParser.h:85
find_http_uri_type
void find_http_uri_type(uint8_t *type, uint8_t *buff)
find MIME type of a file
Definition: httpParser.c:92
socket.h
SOCKET APIs Header file.
PTYPE_PNG
#define PTYPE_PNG
Definition: httpParser.h:35
PTYPE_CGI
#define PTYPE_CGI
Definition: httpParser.h:30
PTYPE_TTF
#define PTYPE_TTF
Definition: httpParser.h:38
RES_CSSHEAD_OK
#define RES_CSSHEAD_OK
Definition: httpParser.h:91
RES_TEXTHEAD_OK
#define RES_TEXTHEAD_OK
Definition: httpParser.h:73


ioLibrary: Internet/httpServer/httpParser.h Source File

  • Internet
  • httpServer
httpParser.h
Go to the documentation of this file.
1
6 #include <stdint.h>
7
8 #ifndef __HTTPPARSER_H__
9 #define __HTTPPARSER_H__
10
11 //#define _HTTPPARSER_DEBUG_
12
13 #define HTTP_SERVER_PORT 80
15 /* HTTP Method */
16 #define METHOD_ERR 0
17 #define METHOD_GET 1
18 #define METHOD_HEAD 2
19 #define METHOD_POST 3
21 /* HTTP GET Method */
22 #define PTYPE_ERR 0
23 #define PTYPE_HTML 1
24 #define PTYPE_GIF 2
25 #define PTYPE_TEXT 3
26 #define PTYPE_JPEG 4
27 #define PTYPE_FLASH 5
28 #define PTYPE_MPEG 6
29 #define PTYPE_PDF 7
30 #define PTYPE_CGI 8
31 #define PTYPE_XML 9
32 #define PTYPE_CSS 10
33 #define PTYPE_JS 11
34 #define PTYPE_JSON 12
35 #define PTYPE_PNG 13
36 #define PTYPE_ICO 14
38 #define PTYPE_TTF 20
39 #define PTYPE_OTF 21
40 #define PTYPE_WOFF 22
41 #define PTYPE_EOT 23
42 #define PTYPE_SVG 24
45 /* HTTP response */
46 #define STATUS_OK 200
47 #define STATUS_CREATED 201
48 #define STATUS_ACCEPTED 202
49 #define STATUS_NO_CONTENT 204
50 #define STATUS_MV_PERM 301
51 #define STATUS_MV_TEMP 302
52 #define STATUS_NOT_MODIF 304
53 #define STATUS_BAD_REQ 400
54 #define STATUS_UNAUTH 401
55 #define STATUS_FORBIDDEN 403
56 #define STATUS_NOT_FOUND 404
57 #define STATUS_INT_SERR 500
58 #define STATUS_NOT_IMPL 501
59 #define STATUS_BAD_GATEWAY 502
60 #define STATUS_SERV_UNAVAIL 503
61
62 /* HTML Doc. for ERROR */
63 static const char ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n<HTML>\r\n<BODY>\r\nSorry, the page you requested was not found.\r\n</BODY>\r\n</HTML>\r\n\0";
64 static const char ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n<HTML>\r\n<BODY>\r\nInvalid request.\r\n</BODY>\r\n</HTML>\r\n\0";
65
66 /* HTML Doc. for CGI result */
67 #define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "
68
69 /* Response header for HTML*/
70 #define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: "
71
72 /* Response head for TEXT */
73 #define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: "
74
75 /* Response head for GIF */
76 #define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: "
77
78 /* Response head for JPEG */
79 #define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: "
80
81 /* Response head for PNG */
82 #define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: "
83
84 /* Response head for FLASH */
85 #define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: "
86
87 /* Response head for XML */
88 #define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: "
89
90 /* Response head for CSS */
91 #define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: "
92
93 /* Response head for JavaScript */
94 #define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: "
95
96 /* Response head for JSON */
97 #define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: "
98
99 /* Response head for ICO */
100 #define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: "
101
102 /* Response head for CGI */
103 #define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "
104
105 /* Response head for TTF, Font */
106 #define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: "
107
108 /* Response head for OTF, Font */
109 #define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: "
110
111 /* Response head for WOFF, Font */
112 #define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: "
113
114 /* Response head for EOT, Font */
115 #define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: "
116
117 /* Response head for SVG, Font */
118 #define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: "
119
124 //#define MAX_URI_SIZE 1461
125 #define MAX_URI_SIZE 512
126
127 typedef struct _st_http_request
128 {
129 uint8_t METHOD;
130 uint8_t TYPE;
131 uint8_t URI[MAX_URI_SIZE];
132 }st_http_request;
133
134 // HTTP Parsing functions
135 void unescape_http_url(char * url); /* convert escape character to ascii */
136 void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */
137 void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */
138 void make_http_response_head(char *, char, uint32_t); /* make response header */
139 uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */
140 uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */
141 #ifdef _OLD_
142 uint8_t * get_http_uri_name(uint8_t * uri);
143 #endif
144
145 // Utility functions
146 uint16_t ATOI(uint8_t * str, uint8_t base);
147 void mid(char* src, char* s1, char* s2, char* sub);
148 void inet_addr_(uint8_t * addr, uint8_t * ip);
149
150 #endif /* end of __HTTPPARSER_H__ */
ATOI
uint16_t ATOI(uint8_t *str, uint8_t base)
CONVERT STRING INTO INTEGER.
Definition: httpParser.c:327
parse_http_request
void parse_http_request(st_http_request *, uint8_t *)
parse http request from a peer
Definition: httpParser.c:127
st_http_request
struct _st_http_request st_http_request
find_http_uri_type
void find_http_uri_type(uint8_t *, uint8_t *)
find MIME type of a file
Definition: httpParser.c:92
make_http_response_head
void make_http_response_head(char *, char, uint32_t)
make response header such as html, gif, jpeg,etc.
Definition: httpParser.c:45
get_http_uri_name
uint8_t get_http_uri_name(uint8_t *uri, uint8_t *uri_buf)
Definition: httpParser.c:281
get_http_param_value
uint8_t * get_http_param_value(char *uri, char *param_name)
get next parameter value in the request
Definition: httpParser.c:204
MAX_URI_SIZE
#define MAX_URI_SIZE
Structure of HTTP REQUEST.
Definition: httpParser.h:125
mid
void mid(char *src, char *s1, char *s2, char *sub)
Check strings and then execute callback function by each string.
Definition: httpParser.c:348
_st_http_request
Definition: httpParser.h:127
_st_http_request::URI
uint8_t URI[MAX_URI_SIZE]
Definition: httpParser.h:131
_st_http_request::METHOD
uint8_t METHOD
Definition: httpParser.h:129
inet_addr_
void inet_addr_(uint8_t *addr, uint8_t *ip)
Definition: httpParser.c:302
unescape_http_url
void unescape_http_url(char *url)
convert escape characters(XX) to ASCII character
Definition: httpParser.c:26
_st_http_request::TYPE
uint8_t TYPE
Definition: httpParser.h:130


ioLibrary: Internet/httpServer/httpServer.c Source File

  • Internet
  • httpServer
httpServer.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5 #include "socket.h"
6 #include "wizchip_conf.h"
7
8 #include "httpServer.h"
9 #include "httpParser.h"
10 #include "httpUtil.h"
11
12 #ifdef _USE_SDCARD_
13 #include "ff.h" // header file for FatFs library (FAT file system)
14 #endif
15
16 #ifndef DATA_BUF_SIZE
17 #define DATA_BUF_SIZE 2048
18 #endif
19
20 /*****************************************************************************
21 * Private types/enumerations/variables
22 ****************************************************************************/
23 static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, };
24 static st_http_request * http_request;
25 static st_http_request * parsed_http_request;
26 static uint8_t * http_response;
28 // ## For Debugging
29 //static uint8_t uri_buf[128];
30
31 // Number of registered web content in code flash memory
32 static uint16_t total_content_cnt = 0;
33 /*****************************************************************************
34 * Public types/enumerations/variables
35 ****************************************************************************/
36 uint8_t * pHTTP_TX;
37 uint8_t * pHTTP_RX;
38
39 volatile uint32_t httpServer_tick_1s = 0;
40 st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, };
41 httpServer_webContent web_content[MAX_CONTENT_CALLBACK];
42
43 #ifdef _USE_SDCARD_
44 FIL fs; // FatFs: File object
45 FRESULT fr; // FatFs: File function return code
46 #endif
47
48 /*****************************************************************************
49 * Private functions
50 ****************************************************************************/
51 void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist);
52 static uint8_t getHTTPSocketNum(uint8_t seqnum);
53 static int8_t getHTTPSequenceNum(uint8_t socket);
54 static int8_t http_disconnect(uint8_t sn);
55
56 static void http_process_handler(uint8_t s, st_http_request * p_http_request);
57 static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status);
58 static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len);
59 static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len);
60
61 /*****************************************************************************
62 * Public functions
63 ****************************************************************************/
64 // Callback functions definition: MCU Reset / WDT Reset
65 void default_mcu_reset(void) {;}
66 void default_wdt_reset(void) {;}
67 void (*HTTPServer_ReStart)(void) = default_mcu_reset;
68 void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset;
69
70 void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist)
71 {
72 uint8_t i;
73
74 for(i = 0; i < cnt; i++)
75 {
76 // Mapping the H/W socket numbers to the sequential index numbers
77 HTTPSock_Num[i] = socklist[i];
78 }
79 }
80
81 static uint8_t getHTTPSocketNum(uint8_t seqnum)
82 {
83 // Return the 'H/W socket number' corresponding to the index number
84 return HTTPSock_Num[seqnum];
85 }
86
87 static int8_t getHTTPSequenceNum(uint8_t socket)
88 {
89 uint8_t i;
90
91 for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++)
92 if(HTTPSock_Num[i] == socket) return i;
93
94 return -1;
95 }
96
97 void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist)
98 {
99 // User's shared buffer
100 pHTTP_TX = tx_buf;
101 pHTTP_RX = rx_buf;
102
103 // H/W Socket number mapping
104 httpServer_Sockinit(cnt, socklist);
105 }
106
107
108 /* Register the call back functions for HTTP Server */
109 void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void))
110 {
111 // Callback: HW Reset and WDT reset function for each MCU platforms
112 if(mcu_reset) HTTPServer_ReStart = mcu_reset;
113 if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset;
114 }
115
116
117 void httpServer_run(uint8_t seqnum)
118 {
119 uint8_t s; // socket number
120 uint16_t len;
121 uint32_t gettime = 0;
122
123 #ifdef _HTTPSERVER_DEBUG_
124 uint8_t destip[4] = {0, };
125 uint16_t destport = 0;
126 #endif
127
128 http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request
129 parsed_http_request = (st_http_request *)pHTTP_TX;
130
131 // Get the H/W socket number
132 s = getHTTPSocketNum(seqnum);
133
134 /* HTTP Service Start */
135 switch(getSn_SR(s))
136 {
137 case SOCK_ESTABLISHED:
138 // Interrupt clear
139 if(getSn_IR(s) & Sn_IR_CON)
140 {
141 setSn_IR(s, Sn_IR_CON);
142 }
143
144 // HTTP Process states
145 switch(HTTPSock_Status[seqnum].sock_status)
146 {
147
148 case STATE_HTTP_IDLE :
149 if ((len = getSn_RX_RSR(s)) > 0)
150 {
151 if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE;
152 len = recv(s, (uint8_t *)http_request, len);
153
154 *(((uint8_t *)http_request) + len) = '\0';
155
156 parse_http_request(parsed_http_request, (uint8_t *)http_request);
157 #ifdef _HTTPSERVER_DEBUG_
158 getSn_DIPR(s, destip);
159 destport = getSn_DPORT(s);
160 printf("\r\n");
161 printf("> HTTPSocket[%d] : HTTP Request received ", s);
162 printf("from %d.%d.%d.%d : %d\r\n", destip[0], destip[1], destip[2], destip[3], destport);
163 #endif
164 #ifdef _HTTPSERVER_DEBUG_
165 printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s);
166 #endif
167 // HTTP 'response' handler; includes send_http_response_header / body function
168 http_process_handler(s, parsed_http_request);
169
170 gettime = get_httpServer_timecount();
171 // Check the TX socket buffer for End of HTTP response sends
172 while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024))
173 {
174 if((get_httpServer_timecount() - gettime) > 3)
175 {
176 #ifdef _HTTPSERVER_DEBUG_
177 printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s);
178 #endif
179 break;
180 }
181 }
182
183 if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC;
184 else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end
185 }
186 break;
187
188 case STATE_HTTP_RES_INPROC :
189 /* Repeat: Send the remain parts of HTTP responses */
190 #ifdef _HTTPSERVER_DEBUG_
191 printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s);
192 #endif
193 // Repeatedly send remaining data to client
194 send_http_response_body(s, 0, http_response, 0, 0);
195
196 if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE;
197 break;
198
199 case STATE_HTTP_RES_DONE :
200 #ifdef _HTTPSERVER_DEBUG_
201 printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s);
202 #endif
203 // Socket file info structure re-initialize
204 HTTPSock_Status[seqnum].file_len = 0;
205 HTTPSock_Status[seqnum].file_offset = 0;
206 HTTPSock_Status[seqnum].file_start = 0;
207 HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE;
208
209 //#ifdef _USE_SDCARD_
210 // f_close(&fs);
211 //#endif
212 #ifdef _USE_WATCHDOG_
213 HTTPServer_WDT_Reset();
214 #endif
215 http_disconnect(s);
216 break;
217
218 default :
219 break;
220 }
221 break;
222
223 case SOCK_CLOSE_WAIT:
224 #ifdef _HTTPSERVER_DEBUG_
225 printf("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection
226 #endif
227 disconnect(s);
228 break;
229
230 case SOCK_CLOSED:
231 #ifdef _HTTPSERVER_DEBUG_
232 printf("> HTTPSocket[%d] : CLOSED\r\n", s);
233 #endif
234 if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */
235 {
236 #ifdef _HTTPSERVER_DEBUG_
237 printf("> HTTPSocket[%d] : OPEN\r\n", s);
238 #endif
239 }
240 break;
241
242 case SOCK_INIT:
243 listen(s);
244 break;
245
246 case SOCK_LISTEN:
247 break;
248
249 default :
250 break;
251
252 } // end of switch
253
254 #ifdef _USE_WATCHDOG_
255 HTTPServer_WDT_Reset();
256 #endif
257 }
258
260 // Private Functions
262 static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status)
263 {
264 switch(http_status)
265 {
266 case STATUS_OK: // HTTP/1.1 200 OK
267 if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header
268 {
269 #ifdef _HTTPSERVER_DEBUG_
270 printf("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s);
271 #endif
272 make_http_response_head((char*)http_response, content_type, body_len);
273 }
274 else
275 {
276 #ifdef _HTTPSERVER_DEBUG_
277 printf("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s);
278 #endif
279 // CGI/XML type request does not respond HTTP header to client
280 http_status = 0;
281 }
282 break;
283 case STATUS_BAD_REQ: // HTTP/1.1 400 OK
284 #ifdef _HTTPSERVER_DEBUG_
285 printf("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s);
286 #endif
287 memcpy(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE));
288 break;
289 case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found
290 #ifdef _HTTPSERVER_DEBUG_
291 printf("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s);
292 #endif
293 memcpy(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE));
294 break;
295 default:
296 break;
297 }
298
299 // Send the HTTP Response 'header'
300 if(http_status)
301 {
302 #ifdef _HTTPSERVER_DEBUG_
303 printf("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response));
304 #endif
305 send(s, http_response, strlen((char *)http_response));
306 }
307 }
308
309 static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len)
310 {
311 int8_t get_seqnum;
312 uint32_t send_len;
313
314 uint8_t flag_datasend_end = 0;
315
316 #ifdef _USE_SDCARD_
317 uint16_t blocklen;
318 #endif
319 #ifdef _USE_FLASH_
320 uint32_t addr = 0;
321 #endif
322
323 if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number
324
325 // Send the HTTP Response 'body'; requested file
326 if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ###
327 {
328 if (file_len > DATA_BUF_SIZE - 1)
329 {
330 HTTPSock_Status[get_seqnum].file_start = start_addr;
331 HTTPSock_Status[get_seqnum].file_len = file_len;
332 send_len = DATA_BUF_SIZE - 1;
333
335 // ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1)
336 memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN);
337 strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name);
338 #ifdef _HTTPSERVER_DEBUG_
339 printf("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name);
340 #endif
341
343 #ifdef _HTTPSERVER_DEBUG_
344 printf("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len);
345 #endif
346 }
347 else
348 {
349 // Send process end
350 send_len = file_len;
351
352 #ifdef _HTTPSERVER_DEBUG_
353 printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, send_len);
354 #endif
355 }
356 #ifdef _USE_FLASH_
357 if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr;
358 #endif
359 }
360 else // remained parts
361 {
362 #ifdef _USE_FLASH_
363 if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH)
364 {
365 addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset;
366 }
367 #endif
368 send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset;
369
370 if(send_len > DATA_BUF_SIZE - 1)
371 {
372 send_len = DATA_BUF_SIZE - 1;
373 //HTTPSock_Status[get_seqnum]->file_offset += send_len;
374 }
375 else
376 {
377 #ifdef _HTTPSERVER_DEBUG_
378 printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len);
379 #endif
380 // Send process end
381 flag_datasend_end = 1;
382 }
383 #ifdef _HTTPSERVER_DEBUG_
384 printf("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len);
385 #endif
386 }
387
388 /*****************************************************/
389 //HTTPSock_Status[get_seqnum]->storage_type == NONE
390 //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH
391 //HTTPSock_Status[get_seqnum]->storage_type == SDCARD
392 //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH
393 /*****************************************************/
394
395 if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH)
396 {
397 if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start;
398 read_userReg_webContent(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len);
399 }
400 #ifdef _USE_SDCARD_
401 else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD)
402 {
403 // Data read from SD Card
404 fr = f_read(&fs, &buf[0], send_len, (void *)&blocklen);
405 if(fr != FR_OK)
406 {
407 send_len = 0;
408 #ifdef _HTTPSERVER_DEBUG_
409 printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name);
410 #endif
411 }
412 else
413 {
414 *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated)
415 }
416 }
417 #endif
418
419 #ifdef _USE_FLASH_
420 else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH)
421 {
422 // Data read from external data flash memory
423 read_from_flashbuf(addr, &buf[0], send_len);
424 *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated)
425 }
426 #endif
427 else
428 {
429 send_len = 0;
430 }
431 // Requested content send to HTTP client
432 #ifdef _HTTPSERVER_DEBUG_
433 printf("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len);
434 #endif
435
436 if(send_len) send(s, buf, send_len);
437 else flag_datasend_end = 1;
438
439 if(flag_datasend_end)
440 {
441 HTTPSock_Status[get_seqnum].file_start = 0;
442 HTTPSock_Status[get_seqnum].file_len = 0;
443 HTTPSock_Status[get_seqnum].file_offset = 0;
444 flag_datasend_end = 0;
445 }
446 else
447 {
448 HTTPSock_Status[get_seqnum].file_offset += send_len;
449 #ifdef _HTTPSERVER_DEBUG_
450 printf("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset);
451 #endif
452 }
453
454 // ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1)
455 #ifdef _USE_SDCARD_
456 f_close(&fs);
457 #endif
458 // ## 20141219 added end
459 }
460
461 static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len)
462 {
463 uint16_t send_len = 0;
464
465 #ifdef _HTTPSERVER_DEBUG_
466 printf("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s);
467 #endif
468 send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body);
469 #ifdef _HTTPSERVER_DEBUG_
470 printf("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len);
471 #endif
472
473 send(s, buf, send_len);
474 }
475
476
477 static int8_t http_disconnect(uint8_t sn)
478 {
479 setSn_CR(sn,Sn_CR_DISCON);
480 /* wait to process the command... */
481 while(getSn_CR(sn));
482
483 return SOCK_OK;
484 }
485
486
487 static void http_process_handler(uint8_t s, st_http_request * p_http_request)
488 {
489 uint8_t * uri_name;
490 uint32_t content_addr = 0;
491 uint16_t content_num = 0;
492 uint32_t file_len = 0;
493
494 uint8_t uri_buf[MAX_URI_SIZE]={0x00, };
495
496 uint16_t http_status;
497 int8_t get_seqnum;
498 uint8_t content_found;
499
500 if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number
501
502 http_status = 0;
503 http_response = pHTTP_RX;
504 file_len = 0;
505
506 //method Analyze
507 switch (p_http_request->METHOD)
508 {
509 case METHOD_ERR :
510 http_status = STATUS_BAD_REQ;
511 send_http_response_header(s, 0, 0, http_status);
512 break;
513
514 case METHOD_HEAD :
515 case METHOD_GET :
516 get_http_uri_name(p_http_request->URI, uri_buf);
517 uri_name = uri_buf;
518
519 if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html
520 if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE);
521 if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE);
522 find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included)
523
524 #ifdef _HTTPSERVER_DEBUG_
525 printf("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s);
526 printf("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE);
527 printf("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name);
528 #endif
529
530 if(p_http_request->TYPE == PTYPE_CGI)
531 {
532 content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len);
533 if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8))))
534 {
535 send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len);
536 }
537 else
538 {
539 send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND);
540 }
541 }
542 else
543 {
544 // Find the User registered index for web content
545 if(find_userReg_webContent(uri_buf, &content_num, &file_len))
546 {
547 content_found = 1; // Web content found in code flash memory
548 content_addr = (uint32_t)content_num;
549 HTTPSock_Status[get_seqnum].storage_type = CODEFLASH;
550 }
551 // Not CGI request, Web content in 'SD card' or 'Data flash' requested
552 #ifdef _USE_SDCARD_
553 #ifdef _HTTPSERVER_DEBUG_
554 printf("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s);
555 #endif
556 if((fr = f_open(&fs, (const char *)uri_name, FA_READ)) == 0)
557 {
558 content_found = 1; // file open succeed
559
560 file_len = fs.fsize;
561 content_addr = fs.sclust;
562 HTTPSock_Status[get_seqnum].storage_type = SDCARD;
563 }
564 #elif _USE_FLASH_
565 else if(/* Read content from Dataflash */)
566 {
567 content_found = 1;
568 HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH;
569 ; // To do
570 }
571 #endif
572 else
573 {
574 content_found = 0; // fail to find content
575 }
576
577 if(!content_found)
578 {
579 #ifdef _HTTPSERVER_DEBUG_
580 printf("> HTTPSocket[%d] : Unknown Page Request\r\n", s);
581 #endif
582 http_status = STATUS_NOT_FOUND;
583 }
584 else
585 {
586 #ifdef _HTTPSERVER_DEBUG_
587 printf("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len);
588 #endif
589 http_status = STATUS_OK;
590 }
591
592 // Send HTTP header
593 if(http_status)
594 {
595 #ifdef _HTTPSERVER_DEBUG_
596 printf("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len);
597 #endif
598 send_http_response_header(s, p_http_request->TYPE, file_len, http_status);
599 }
600
601 // Send HTTP body (content)
602 if(http_status == STATUS_OK)
603 {
604 send_http_response_body(s, uri_name, http_response, content_addr, file_len);
605 }
606 }
607 break;
608
609 case METHOD_POST :
610 mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf);
611 uri_name = uri_buf;
612 find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included)
613
614 #ifdef _HTTPSERVER_DEBUG_
615 printf("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s);
616 printf("> HTTPSocket[%d] : Request URI = %s ", s, uri_name);
617 printf("Type = %d\r\n", p_http_request->TYPE);
618 #endif
619
620 if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process
621 {
622 content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len);
623 #ifdef _HTTPSERVER_DEBUG_
624 printf("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len);
625 #endif
626 if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8))))
627 {
628 send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len);
629
630 // Reset the H/W for apply to the change configuration information
631 if(content_found == HTTP_RESET) HTTPServer_ReStart();
632 }
633 else
634 {
635 send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND);
636 }
637 }
638 else // HTTP POST Method; Content not found
639 {
640 send_http_response_header(s, 0, 0, STATUS_NOT_FOUND);
641 }
642 break;
643
644 default :
645 http_status = STATUS_BAD_REQ;
646 send_http_response_header(s, 0, 0, http_status);
647 break;
648 }
649 }
650
651 void httpServer_time_handler(void)
652 {
653 httpServer_tick_1s++;
654 }
655
656 uint32_t get_httpServer_timecount(void)
657 {
658 return httpServer_tick_1s;
659 }
660
661 void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content)
662 {
663 uint16_t name_len;
664 uint32_t content_len;
665
666 if(content_name == NULL || content == NULL)
667 {
668 return;
669 }
670 else if(total_content_cnt >= MAX_CONTENT_CALLBACK)
671 {
672 return;
673 }
674
675 name_len = strlen((char *)content_name);
676 content_len = strlen((char *)content);
677
678 web_content[total_content_cnt].content_name = malloc(name_len+1);
679 strcpy((char *)web_content[total_content_cnt].content_name, (const char *)content_name);
680 web_content[total_content_cnt].content_len = content_len;
681 web_content[total_content_cnt].content = content;
682
683 total_content_cnt++;
684 }
685
686 uint8_t display_reg_webContent_list(void)
687 {
688 uint16_t i;
689 uint8_t ret;
690
691 if(total_content_cnt == 0)
692 {
693 printf(">> Web content file not found\r\n");
694 ret = 0;
695 }
696 else
697 {
698 printf("\r\n=== List of Web content in code flash ===\r\n");
699 for(i = 0; i < total_content_cnt; i++)
700 {
701 printf(" [%d] ", i+1);
702 printf("%s, ", web_content[i].content_name);
703 printf("%ld byte, ", web_content[i].content_len);
704
705 if(web_content[i].content_len < 30) printf("[%s]\r\n", web_content[i].content);
706 else printf("[ ... ]\r\n");
707 }
708 printf("=========================================\r\n\r\n");
709 ret = 1;
710 }
711
712 return ret;
713 }
714
715 uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len)
716 {
717 uint16_t i;
718 uint8_t ret = 0; // '0' means 'File Not Found'
719
720 for(i = 0; i < total_content_cnt; i++)
721 {
722 if(!strcmp((char *)content_name, (char *)web_content[i].content_name))
723 {
724 *file_len = web_content[i].content_len;
725 *content_num = i;
726 ret = 1; // If the requested content found, ret set to '1' (Found)
727 break;
728 }
729 }
730 return ret;
731 }
732
733
734 uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size)
735 {
736 uint16_t ret = 0;
737 uint8_t * ptr;
738
739 if(content_num > total_content_cnt) return 0;
740
741 ptr = web_content[content_num].content;
742 if(offset) ptr += offset;
743
744 strncpy((char *)buf, (char *)ptr, size);
745 *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated)
746
747 ret = strlen((void *)buf);
748 return ret;
749 }
default_mcu_reset
void default_mcu_reset(void)
Definition: httpServer.c:65
getSn_IR
#define getSn_IR(sn)
Get Sn_IR register.
Definition: w5100.h:1417
METHOD_POST
#define METHOD_POST
Definition: httpParser.h:19
MOBILE_INITIAL_WEBPAGE
#define MOBILE_INITIAL_WEBPAGE
Definition: httpServer.h:16
MAX_CONTENT_CALLBACK
#define MAX_CONTENT_CALLBACK
Definition: httpServer.h:77
httpServer.h
Define constants and functions related HTTP Web server.
_st_http_socket::sock_status
uint8_t sock_status
Definition: httpServer.h:68
pHTTP_TX
uint8_t * pHTTP_TX
Definition: httpServer.c:36
MAX_CONTENT_NAME_LEN
#define MAX_CONTENT_NAME_LEN
Definition: httpServer.h:51
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
_st_http_socket
Definition: httpServer.h:66
make_http_response_head
void make_http_response_head(char *buf, char type, uint32_t len)
make response header such as html, gif, jpeg,etc.
Definition: httpParser.c:45
SOCK_LISTEN
#define SOCK_LISTEN
Listen state.
Definition: w5100.h:909
RES_CGIHEAD_OK
#define RES_CGIHEAD_OK
Definition: httpParser.h:103
getSn_DIPR
#define getSn_DIPR(sn, dipr)
Get Sn_DIPR register.
Definition: w5100.h:1488
http_post_cgi_handler
uint8_t http_post_cgi_handler(uint8_t *uri_name, st_http_request *p_http_request, uint8_t *buf, uint32_t *file_len)
Definition: httpUtil.c:41
METHOD_HEAD
#define METHOD_HEAD
Definition: httpParser.h:18
httpServer_run
void httpServer_run(uint8_t seqnum)
Definition: httpServer.c:117
METHOD_GET
#define METHOD_GET
Definition: httpParser.h:17
default_wdt_reset
void default_wdt_reset(void)
Definition: httpServer.c:66
M_INITIAL_WEBPAGE
#define M_INITIAL_WEBPAGE
Definition: httpServer.h:15
httpServer_Sockinit
void httpServer_Sockinit(uint8_t cnt, uint8_t *socklist)
SOCK_OK
#define SOCK_OK
Result is OK about socket process.
Definition: socket.h:92
STATE_HTTP_RES_DONE
#define STATE_HTTP_RES_DONE
Definition: httpServer.h:39
_httpServer_webContent::content_len
uint32_t content_len
Definition: httpServer.h:82
HTTPServer_ReStart
void(* HTTPServer_ReStart)(void)
Definition: httpServer.c:67
HTTP_RESET
#define HTTP_RESET
Definition: httpServer.h:46
setSn_IR
#define setSn_IR(sn, ir)
Set Sn_IR register.
Definition: w5100.h:1407
reg_httpServer_cbfunc
void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void))
Definition: httpServer.c:109
METHOD_ERR
#define METHOD_ERR
Definition: httpParser.h:16
_httpServer_webContent::content_name
uint8_t * content_name
Definition: httpServer.h:81
_st_http_socket::storage_type
uint8_t storage_type
Definition: httpServer.h:73
get_httpServer_timecount
uint32_t get_httpServer_timecount(void)
Definition: httpServer.c:656
getSn_CR
#define getSn_CR(sn)
Get Sn_CR register.
Definition: w5100.h:1397
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
INITIAL_WEBPAGE
#define INITIAL_WEBPAGE
Definition: httpServer.h:14
read_userReg_webContent
uint16_t read_userReg_webContent(uint16_t content_num, uint8_t *buf, uint32_t offset, uint16_t size)
Definition: httpServer.c:734
parse_http_request
void parse_http_request(st_http_request *request, uint8_t *buf)
parse http request from a peer
Definition: httpParser.c:127
get_http_uri_name
uint8_t get_http_uri_name(uint8_t *uri, uint8_t *uri_buf)
Definition: httpParser.c:281
MAX_URI_SIZE
#define MAX_URI_SIZE
Structure of HTTP REQUEST.
Definition: httpParser.h:125
Sn_MR_TCP
#define Sn_MR_TCP
TCP.
Definition: w5100.h:648
Sn_CR_DISCON
#define Sn_CR_DISCON
Send closing request in TCP mode.
Definition: w5100.h:766
httpServer_tick_1s
volatile uint32_t httpServer_tick_1s
Definition: httpServer.c:39
HTTP_SERVER_PORT
#define HTTP_SERVER_PORT
Definition: httpParser.h:13
getSn_TXBUF_SIZE
#define getSn_TXBUF_SIZE(sn)
Definition: w5100.h:1637
_st_http_request
Definition: httpParser.h:127
httpServer_init
void httpServer_init(uint8_t *tx_buf, uint8_t *rx_buf, uint8_t cnt, uint8_t *socklist)
Definition: httpServer.c:97
SOCK_CLOSED
#define SOCK_CLOSED
Closed.
Definition: w5100.h:893
web_content
httpServer_webContent web_content[MAX_CONTENT_CALLBACK]
Definition: httpServer.c:41
PTYPE_XML
#define PTYPE_XML
Definition: httpParser.h:31
recv
int32_t recv(uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer.
Definition: socket.c:384
STATE_HTTP_IDLE
#define STATE_HTTP_IDLE
Definition: httpServer.h:35
CODEFLASH
Code flash memory.
Definition: httpServer.h:61
getSn_DPORT
#define getSn_DPORT(sn)
Get Sn_DPORT register.
Definition: w5100.h:1510
_st_http_socket::file_start
uint32_t file_start
Definition: httpServer.h:70
_st_http_request::URI
uint8_t URI[MAX_URI_SIZE]
Definition: httpParser.h:131
_st_http_request::METHOD
uint8_t METHOD
Definition: httpParser.h:129
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
SDCARD
SD card.
Definition: httpServer.h:62
httpServer_time_handler
void httpServer_time_handler(void)
Definition: httpServer.c:651
httpParser.h
STATUS_OK
#define STATUS_OK
Definition: httpParser.h:46
SOCK_CLOSE_WAIT
#define SOCK_CLOSE_WAIT
Closing state.
Definition: w5100.h:967
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
disconnect
int8_t disconnect(uint8_t sn)
Try to disconnect a connection socket.
Definition: socket.c:296
STATUS_BAD_REQ
#define STATUS_BAD_REQ
Definition: httpParser.h:53
_httpServer_webContent
Definition: httpServer.h:79
_st_http_socket::file_len
uint32_t file_len
Definition: httpServer.h:71
mid
void mid(char *src, char *s1, char *s2, char *sub)
Check strings and then execute callback function by each string.
Definition: httpParser.c:348
HTTPSock_Status
st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_]
Definition: httpServer.c:40
listen
int8_t listen(uint8_t sn)
Listen to a connection request from a client.
Definition: socket.c:240
setSn_CR
#define setSn_CR(sn, cr)
Set Sn_CR register.
Definition: w5100.h:1387
pHTTP_RX
uint8_t * pHTTP_RX
Definition: httpServer.c:37
_WIZCHIP_SOCK_NUM_
#define _WIZCHIP_SOCK_NUM_
The count of independant socket of WIZCHIP.
Definition: wizchip_conf.h:212
DATA_BUF_SIZE
#define DATA_BUF_SIZE
Definition: httpServer.c:17
display_reg_webContent_list
uint8_t display_reg_webContent_list(void)
Definition: httpServer.c:686
_httpServer_webContent::content
uint8_t * content
Definition: httpServer.h:83
httpUtil.h
Header File for HTTP Server Utilities.
Sn_IR_CON
#define Sn_IR_CON
CON Interrupt.
Definition: w5100.h:885
STATE_HTTP_RES_INPROC
#define STATE_HTTP_RES_INPROC
Definition: httpServer.h:38
find_userReg_webContent
uint8_t find_userReg_webContent(uint8_t *content_name, uint16_t *content_num, uint32_t *file_len)
Definition: httpServer.c:715
reg_httpServer_webContent
void reg_httpServer_webContent(uint8_t *content_name, uint8_t *content)
Definition: httpServer.c:661
DATAFLASH
External data flash memory.
Definition: httpServer.h:63
find_http_uri_type
void find_http_uri_type(uint8_t *type, uint8_t *buff)
find MIME type of a file
Definition: httpParser.c:92
socket.h
SOCKET APIs Header file.
_st_http_socket::file_offset
uint32_t file_offset
Definition: httpServer.h:72
wizchip_conf.h
WIZCHIP Config Header File.
SOCK_INIT
#define SOCK_INIT
Initiate state.
Definition: w5100.h:901
STATUS_NOT_FOUND
#define STATUS_NOT_FOUND
Definition: httpParser.h:56
PTYPE_CGI
#define PTYPE_CGI
Definition: httpParser.h:30
_st_http_request::TYPE
uint8_t TYPE
Definition: httpParser.h:130
SOCK_ESTABLISHED
#define SOCK_ESTABLISHED
Success to connect.
Definition: w5100.h:935
send
int32_t send(uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket.
Definition: socket.c:316
http_get_cgi_handler
uint8_t http_get_cgi_handler(uint8_t *uri_name, uint8_t *buf, uint32_t *file_len)
Definition: httpUtil.c:17


ioLibrary: Internet/httpServer/httpServer.h Source File

  • Internet
  • httpServer
httpServer.h
Go to the documentation of this file.
1
6 #include <stdint.h>
7
8 #ifndef __HTTPSERVER_H__
9 #define __HTTPSERVER_H__
10
11 // HTTP Server debug message enable
12 #define _HTTPSERVER_DEBUG_
13
14 #define INITIAL_WEBPAGE "index.html"
15 #define M_INITIAL_WEBPAGE "m/index.html"
16 #define MOBILE_INITIAL_WEBPAGE "mobile/index.html"
17
18 /* Web Server Content Storage Select */
19 //#define _USE_SDCARD_
20 #ifndef _USE_SDCARD_
21 //#define _USE_FLASH_
22 #endif
23
24 #if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_)
25 #define _NOTUSED_STORAGE_
26 #endif
27
28
29 /* Watchdog timer */
30 //#define _USE_WATCHDOG_
31
32 /*********************************************
33 * HTTP Process states list
34 *********************************************/
35 #define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */
36 #define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */
37 #define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */
38 #define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */
39 #define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */
40
41 /*********************************************
42 * HTTP Simple Return Value
43 *********************************************/
44 #define HTTP_FAILED 0
45 #define HTTP_OK 1
46 #define HTTP_RESET 2
47
48 /*********************************************
49 * HTTP Content NAME length
50 *********************************************/
51 #define MAX_CONTENT_NAME_LEN 128
52
53 /*********************************************
54 * HTTP Timeout
55 *********************************************/
56 #define HTTP_MAX_TIMEOUT_SEC 3 // Sec.
57
58 typedef enum
59 {
60 NONE,
61 CODEFLASH,
62 SDCARD,
63 DATAFLASH
64 }StorageType;
65
66 typedef struct _st_http_socket
67 {
68 uint8_t sock_status;
69 uint8_t file_name[MAX_CONTENT_NAME_LEN];
70 uint32_t file_start;
71 uint32_t file_len;
72 uint32_t file_offset; // (start addr + sent size...)
73 uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ...
74 }st_http_socket;
75
76 // Web content structure for file in code flash memory
77 #define MAX_CONTENT_CALLBACK 20
78
79 typedef struct _httpServer_webContent
80 {
81 uint8_t * content_name;
82 uint32_t content_len;
83 uint8_t * content;
84 }httpServer_webContent;
85
86
87 void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist);
88 void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void));
89 void httpServer_run(uint8_t seqnum);
90
91 void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content);
92 uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len);
93 uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size);
94 uint8_t display_reg_webContent_list(void);
95
96 /*
97 * @brief HTTP Server 1sec Tick Timer handler
98 * @note SHOULD BE register to your system 1s Tick timer handler
99 */
100 void httpServer_time_handler(void);
101 uint32_t get_httpServer_timecount(void);
102
103 #endif
get_httpServer_timecount
uint32_t get_httpServer_timecount(void)
Definition: httpServer.c:656
httpServer_webContent
struct _httpServer_webContent httpServer_webContent
find_userReg_webContent
uint8_t find_userReg_webContent(uint8_t *content_name, uint16_t *content_num, uint32_t *file_len)
Definition: httpServer.c:715
_st_http_socket::sock_status
uint8_t sock_status
Definition: httpServer.h:68
MAX_CONTENT_NAME_LEN
#define MAX_CONTENT_NAME_LEN
Definition: httpServer.h:51
_st_http_socket
Definition: httpServer.h:66
_httpServer_webContent::content_len
uint32_t content_len
Definition: httpServer.h:82
read_userReg_webContent
uint16_t read_userReg_webContent(uint16_t content_num, uint8_t *buf, uint32_t offset, uint16_t size)
Definition: httpServer.c:734
httpServer_init
void httpServer_init(uint8_t *tx_buf, uint8_t *rx_buf, uint8_t cnt, uint8_t *socklist)
Definition: httpServer.c:97
StorageType
StorageType
Definition: httpServer.h:58
_httpServer_webContent::content_name
uint8_t * content_name
Definition: httpServer.h:81
_st_http_socket::storage_type
uint8_t storage_type
Definition: httpServer.h:73
httpServer_time_handler
void httpServer_time_handler(void)
Definition: httpServer.c:651
httpServer_run
void httpServer_run(uint8_t seqnum)
Definition: httpServer.c:117
NONE
Web storage none.
Definition: httpServer.h:60
CODEFLASH
Code flash memory.
Definition: httpServer.h:61
_st_http_socket::file_start
uint32_t file_start
Definition: httpServer.h:70
SDCARD
SD card.
Definition: httpServer.h:62
display_reg_webContent_list
uint8_t display_reg_webContent_list(void)
Definition: httpServer.c:686
_httpServer_webContent
Definition: httpServer.h:79
_st_http_socket::file_len
uint32_t file_len
Definition: httpServer.h:71
st_http_socket
struct _st_http_socket st_http_socket
reg_httpServer_webContent
void reg_httpServer_webContent(uint8_t *content_name, uint8_t *content)
Definition: httpServer.c:661
_httpServer_webContent::content
uint8_t * content
Definition: httpServer.h:83
DATAFLASH
External data flash memory.
Definition: httpServer.h:63
_st_http_socket::file_offset
uint32_t file_offset
Definition: httpServer.h:72
_st_http_socket::file_name
uint8_t file_name[MAX_CONTENT_NAME_LEN]
Definition: httpServer.h:69
reg_httpServer_cbfunc
void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void))
Definition: httpServer.c:109


ioLibrary: Internet/httpServer/httpUtil.c Source File

  • Internet
  • httpServer
httpUtil.c
Go to the documentation of this file.
1
12 #include <stdio.h>
13 #include <string.h>
14 #include <stdlib.h>
15 #include "httpUtil.h"
16
17 uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len)
18 {
19 uint8_t ret = HTTP_OK;
20 uint16_t len = 0;
21
22 if(predefined_get_cgi_processor(uri_name, buf, &len))
23 {
24 ;
25 }
26 else if(strcmp((const char *)uri_name, "example.cgi") == 0)
27 {
28 // To do
29 ;
30 }
31 else
32 {
33 // CGI file not found
34 ret = HTTP_FAILED;
35 }
36
37 if(ret) *file_len = len;
38 return ret;
39 }
40
41 uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len)
42 {
43 uint8_t ret = HTTP_OK;
44 uint16_t len = 0;
45 uint8_t val = 0;
46
47 if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len))
48 {
49 ;
50 }
51 else if(strcmp((const char *)uri_name, "example.cgi") == 0)
52 {
53 // To do
54 val = 1;
55 len = sprintf((char *)buf, "%d", val);
56 }
57 else
58 {
59 // CGI file not found
60 ret = HTTP_FAILED;
61 }
62
63 if(ret) *file_len = len;
64 return ret;
65 }
http_post_cgi_handler
uint8_t http_post_cgi_handler(uint8_t *uri_name, st_http_request *p_http_request, uint8_t *buf, uint32_t *file_len)
Definition: httpUtil.c:41
_st_http_request
Definition: httpParser.h:127
predefined_get_cgi_processor
uint8_t predefined_get_cgi_processor(uint8_t *uri_name, uint8_t *buf, uint16_t *len)
_st_http_request::URI
uint8_t URI[MAX_URI_SIZE]
Definition: httpParser.h:131
HTTP_OK
#define HTTP_OK
Definition: httpServer.h:45
httpUtil.h
Header File for HTTP Server Utilities.
predefined_set_cgi_processor
uint8_t predefined_set_cgi_processor(uint8_t *uri_name, uint8_t *uri, uint8_t *buf, uint16_t *len)
HTTP_FAILED
#define HTTP_FAILED
Definition: httpServer.h:44
http_get_cgi_handler
uint8_t http_get_cgi_handler(uint8_t *uri_name, uint8_t *buf, uint32_t *file_len)
Definition: httpUtil.c:17


ioLibrary: Internet/httpServer/httpUtil.h Source File

  • Internet
  • httpServer
httpUtil.h
Go to the documentation of this file.
1
12 #ifndef __HTTPUTIL_H__
13 #define __HTTPUTIL_H__
14
15 #include "httpServer.h"
16 #include "httpParser.h"
17
18 uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len);
19 uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len);
20
21 uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len);
22 uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len);
23
24 #endif
httpServer.h
Define constants and functions related HTTP Web server.
_st_http_request
Definition: httpParser.h:127
predefined_get_cgi_processor
uint8_t predefined_get_cgi_processor(uint8_t *uri_name, uint8_t *buf, uint16_t *len)
httpParser.h
predefined_set_cgi_processor
uint8_t predefined_set_cgi_processor(uint8_t *uri_name, uint8_t *uri, uint8_t *buf, uint16_t *len)
http_get_cgi_handler
uint8_t http_get_cgi_handler(uint8_t *uri_name, uint8_t *buf, uint32_t *file_len)
Definition: httpUtil.c:17
http_post_cgi_handler
uint8_t http_post_cgi_handler(uint8_t *uri_name, st_http_request *p_http_request, uint8_t *buf, uint32_t *file_len)
Definition: httpUtil.c:41


ioLibrary: ioLibrary

ioLibrary

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
  • W5100S
  • W5500
    - W5200
  • W5100
  • W5300
Version 4.0.0
Release Notes
  • 2018/03/29
    • W5100S added V4.0.0
  • 2016/05/03 : V3.0.3
    • In W5300, Fixed some compile errors in close(). Refer to M20160503
    • In close(), replace socket() with some command sequences.
  • 2016/04/26 : V3.0.2
    • W5300 Erratum #1 is applied in close() of socket.c (Refer to A20160426)
  • 2015/07/15 : V3.0.1
    • Bug fixed : In W5100, CS control problem is fixed to read/write buffer read/write. Refer to M20150715.
  • 2015/06/01
    • 3rd Released V3.0.0
    • Add W5300 to ioLibrary
  • 2015/04/01
    • Second Released V2.0.0
    • Add W5100 & W5200 to ioLibrary
  • 2013/10/01
    • First Released V1.0.0


ioLibrary: license.txt File Reference

Functions | Variables
license.txt File Reference

Functions

Copyright (c) 2014 WIZnet Co.
Ltd free of to any person obtaining a copy of this software and associated documentation files (the "Software")

Variables

Ltd free of | charge
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without | restriction
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to | use
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to | copy
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to | modify
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to | merge
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to | publish
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to | distribute
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to | sublicense
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the | Software
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do | so
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following | conditions
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY | KIND
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR | IMPLIED
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | MERCHANTABILITY
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | CLAIM
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER | LIABILITY
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF | CONTRACT
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR | OTHERWISE
Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR ARISING | FROM

Function Documentation

◆ Copyright()

Ltd Copyright ( c )

◆ files()

Ltd free of to any person obtaining a copy of this software and associated documentation files ( the "Software" )

Variable Documentation

◆ charge

Ltd free of charge

Definition at line 6 of file license.txt.

◆ CLAIM

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM

Definition at line 8 of file license.txt.

◆ conditions

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following conditions

Definition at line 8 of file license.txt.

◆ CONTRACT

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF CONTRACT

Definition at line 8 of file license.txt.

◆ copy

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy

Definition at line 8 of file license.txt.

◆ distribute

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to distribute

Definition at line 8 of file license.txt.

◆ FROM

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR ARISING FROM

Definition at line 8 of file license.txt.

◆ IMPLIED

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR IMPLIED

Definition at line 8 of file license.txt.

◆ KIND

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY KIND

Definition at line 8 of file license.txt.

◆ LIABILITY

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY

Definition at line 8 of file license.txt.

◆ MERCHANTABILITY

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY

Definition at line 8 of file license.txt.

◆ merge

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to merge

Definition at line 8 of file license.txt.

◆ modify

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to modify

Definition at line 8 of file license.txt.

◆ OTHERWISE

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR OTHERWISE

Definition at line 8 of file license.txt.

◆ publish

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to publish

Definition at line 8 of file license.txt.

◆ restriction

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without restriction

Definition at line 8 of file license.txt.

◆ so

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do so

Definition at line 8 of file license.txt.

◆ Software

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the Software

Definition at line 8 of file license.txt.

◆ sublicense

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to sublicense

Definition at line 8 of file license.txt.

◆ use

Ltd free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use

Definition at line 8 of file license.txt.


ioLibrary: Application/loopback/loopback.c Source File

  • Application
  • loopback
loopback.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "loopback.h"
3 #include "socket.h"
4 #include "wizchip_conf.h"
5
6 #if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK
7
8 int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
9 {
10 int32_t ret;
11 uint16_t size = 0, sentsize=0;
12
13 #ifdef _LOOPBACK_DEBUG_
14 uint8_t destip[4];
15 uint16_t destport;
16 #endif
17
18 switch(getSn_SR(sn))
19 {
20 case SOCK_ESTABLISHED :
21 if(getSn_IR(sn) & Sn_IR_CON)
22 {
23 #ifdef _LOOPBACK_DEBUG_
24 getSn_DIPR(sn, destip);
25 destport = getSn_DPORT(sn);
26
27 printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport);
28 #endif
29 setSn_IR(sn,Sn_IR_CON);
30 }
31 if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur.
32 {
33 if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
34 ret = recv(sn, buf, size);
35
36 if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY.
37 size = (uint16_t) ret;
38 sentsize = 0;
39
40 while(size != sentsize)
41 {
42 ret = send(sn, buf+sentsize, size-sentsize);
43 if(ret < 0)
44 {
45 close(sn);
46 return ret;
47 }
48 sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero.
49 }
50 }
51 break;
52 case SOCK_CLOSE_WAIT :
53 #ifdef _LOOPBACK_DEBUG_
54 //printf("%d:CloseWait\r\n",sn);
55 #endif
56 if((ret = disconnect(sn)) != SOCK_OK) return ret;
57 #ifdef _LOOPBACK_DEBUG_
58 printf("%d:Socket Closed\r\n", sn);
59 #endif
60 break;
61 case SOCK_INIT :
62 #ifdef _LOOPBACK_DEBUG_
63 printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port);
64 #endif
65 if( (ret = listen(sn)) != SOCK_OK) return ret;
66 break;
67 case SOCK_CLOSED:
68 #ifdef _LOOPBACK_DEBUG_
69 //printf("%d:TCP server loopback start\r\n",sn);
70 #endif
71 if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret;
72 #ifdef _LOOPBACK_DEBUG_
73 //printf("%d:Socket opened\r\n",sn);
74 #endif
75 break;
76 default:
77 break;
78 }
79 return 1;
80 }
81
82
83 int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport)
84 {
85 int32_t ret; // return value for SOCK_ERRORs
86 uint16_t size = 0, sentsize=0;
87
88 // Destination (TCP Server) IP info (will be connected)
89 // >> loopback_tcpc() function parameter
90 // >> Ex)
91 // uint8_t destip[4] = {192, 168, 0, 214};
92 // uint16_t destport = 5000;
93
94 // Port number for TCP client (will be increased)
95 static uint16_t any_port = 50000;
96
97 // Socket Status Transitions
98 // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status)
99 switch(getSn_SR(sn))
100 {
101 case SOCK_ESTABLISHED :
102 if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful
103 {
104 #ifdef _LOOPBACK_DEBUG_
105 printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport);
106 #endif
107 setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1'
108 }
109
111 // Data Transaction Parts; Handle the [data receive and send] process
113 if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length
114 {
115 if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array)
116 ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer)
117
118 if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end
119 size = (uint16_t) ret;
120 sentsize = 0;
121
122 // Data sentsize control
123 while(size != sentsize)
124 {
125 ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer)
126 if(ret < 0) // Send Error occurred (sent data length < 0)
127 {
128 close(sn); // socket close
129 return ret;
130 }
131 sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero.
132 }
133 }
135 break;
136
137 case SOCK_CLOSE_WAIT :
138 #ifdef _LOOPBACK_DEBUG_
139 //printf("%d:CloseWait\r\n",sn);
140 #endif
141 if((ret=disconnect(sn)) != SOCK_OK) return ret;
142 #ifdef _LOOPBACK_DEBUG_
143 printf("%d:Socket Closed\r\n", sn);
144 #endif
145 break;
146
147 case SOCK_INIT :
148 #ifdef _LOOPBACK_DEBUG_
149 printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport);
150 #endif
151 if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination)
152 break;
153
154 case SOCK_CLOSED:
155 close(sn);
156 if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){
157 if(any_port == 0xffff) any_port = 50000;
158 return ret; // TCP socket open with 'any_port' port number
159 }
160 #ifdef _LOOPBACK_DEBUG_
161 //printf("%d:TCP client loopback start\r\n",sn);
162 //printf("%d:Socket opened\r\n",sn);
163 #endif
164 break;
165 default:
166 break;
167 }
168 return 1;
169 }
170
171
172 int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port)
173 {
174 int32_t ret;
175 uint16_t size, sentsize;
176 uint8_t destip[4];
177 uint16_t destport;
178
179 switch(getSn_SR(sn))
180 {
181 case SOCK_UDP :
182 if((size = getSn_RX_RSR(sn)) > 0)
183 {
184 if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
185 ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport);
186 if(ret <= 0)
187 {
188 #ifdef _LOOPBACK_DEBUG_
189 printf("%d: recvfrom error. %ld\r\n",sn,ret);
190 #endif
191 return ret;
192 }
193 size = (uint16_t) ret;
194 sentsize = 0;
195 while(sentsize != size)
196 {
197 ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport);
198 if(ret < 0)
199 {
200 #ifdef _LOOPBACK_DEBUG_
201 printf("%d: sendto error. %ld\r\n",sn,ret);
202 #endif
203 return ret;
204 }
205 sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero.
206 }
207 }
208 break;
209 case SOCK_CLOSED:
210 #ifdef _LOOPBACK_DEBUG_
211 //printf("%d:UDP loopback start\r\n",sn);
212 #endif
213 if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn)
214 return ret;
215 #ifdef _LOOPBACK_DEBUG_
216 printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port);
217 #endif
218 break;
219 default :
220 break;
221 }
222 return 1;
223 }
224
225 #endif
getSn_IR
#define getSn_IR(sn)
Get Sn_IR register.
Definition: w5100.h:1417
SOCK_UDP
#define SOCK_UDP
UDP socket.
Definition: w5100.h:982
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
getSn_DIPR
#define getSn_DIPR(sn, dipr)
Get Sn_DIPR register.
Definition: w5100.h:1488
SOCK_OK
#define SOCK_OK
Result is OK about socket process.
Definition: socket.h:92
setSn_IR
#define setSn_IR(sn, ir)
Set Sn_IR register.
Definition: w5100.h:1407
DATA_BUF_SIZE
#define DATA_BUF_SIZE
Definition: loopback.h:11
Sn_MR_TCP
#define Sn_MR_TCP
TCP.
Definition: w5100.h:648
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
loopback_tcps
int32_t loopback_tcps(uint8_t sn, uint8_t *buf, uint16_t port)
Definition: loopback.c:8
SOCK_CLOSED
#define SOCK_CLOSED
Closed.
Definition: w5100.h:893
loopback_tcpc
int32_t loopback_tcpc(uint8_t sn, uint8_t *buf, uint8_t *destip, uint16_t destport)
Definition: loopback.c:83
Sn_MR_UDP
#define Sn_MR_UDP
UDP.
Definition: w5100.h:654
recv
int32_t recv(uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer.
Definition: socket.c:384
getSn_DPORT
#define getSn_DPORT(sn)
Get Sn_DPORT register.
Definition: w5100.h:1510
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
sendto
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.
Definition: socket.c:489
SOCK_CLOSE_WAIT
#define SOCK_CLOSE_WAIT
Closing state.
Definition: w5100.h:967
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
disconnect
int8_t disconnect(uint8_t sn)
Try to disconnect a connection socket.
Definition: socket.c:296
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
listen
int8_t listen(uint8_t sn)
Listen to a connection request from a client.
Definition: socket.c:240
Sn_IR_CON
#define Sn_IR_CON
CON Interrupt.
Definition: w5100.h:885
loopback.h
connect
int8_t connect(uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server.
Definition: socket.c:256
loopback_udps
int32_t loopback_udps(uint8_t sn, uint8_t *buf, uint16_t port)
Definition: loopback.c:172
socket.h
SOCKET APIs Header file.
wizchip_conf.h
WIZCHIP Config Header File.
SOCK_INIT
#define SOCK_INIT
Initiate state.
Definition: w5100.h:901
SOCK_ESTABLISHED
#define SOCK_ESTABLISHED
Success to connect.
Definition: w5100.h:935
send
int32_t send(uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket.
Definition: socket.c:316


ioLibrary: Application/loopback/loopback.h Source File

  • Application
  • loopback
loopback.h
Go to the documentation of this file.
1 #ifndef _LOOPBACK_H_
2 #define _LOOPBACK_H_
3
4 #include <stdint.h>
5
6 /* Loopback test debug message printout enable */
7 #define _LOOPBACK_DEBUG_
8
9 /* DATA_BUF_SIZE define for Loopback example */
10 #ifndef DATA_BUF_SIZE
11 #define DATA_BUF_SIZE 2048
12 #endif
13
14 /************************/
15 /* Select LOOPBACK_MODE */
16 /************************/
17 #define LOOPBACK_MAIN_NOBLOCK 0
18 #define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK
19
20
21 /* TCP server Loopback test example */
22 int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port);
23
24 /* TCP client Loopback test example */
25 int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport);
26
27 /* UDP Loopback test example */
28 int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port);
29
30 #endif
loopback_tcpc
int32_t loopback_tcpc(uint8_t sn, uint8_t *buf, uint8_t *destip, uint16_t destport)
Definition: loopback.c:83
loopback_udps
int32_t loopback_udps(uint8_t sn, uint8_t *buf, uint16_t port)
Definition: loopback.c:172
loopback_tcps
int32_t loopback_tcps(uint8_t sn, uint8_t *buf, uint16_t port)
Definition: loopback.c:8


ioLibrary: Internet/MQTT/mqtt_interface.c Source File

  • Internet
  • MQTT
mqtt_interface.c
Go to the documentation of this file.
1 //*****************************************************************************
40 //
41 //*****************************************************************************
42
43 #include "mqtt_interface.h"
44 #include "wizchip_conf.h"
45
46 unsigned long MilliTimer;
47
48 /*
49 * @brief MQTT MilliTimer handler
50 * @note MUST BE register to your system 1m Tick timer handler.
51 */
52 void MilliTimer_Handler(void) {
53 MilliTimer++;
54 }
55
56 /*
57 * @brief Timer Initialize
58 * @param timer : pointer to a Timer structure
59 * that contains the configuration information for the Timer.
60 */
61 void TimerInit(Timer* timer) {
62 timer->end_time = 0;
63 }
64
65 /*
66 * @brief expired Timer
67 * @param timer : pointer to a Timer structure
68 * that contains the configuration information for the Timer.
69 */
70 char TimerIsExpired(Timer* timer) {
71 long left = timer->end_time - MilliTimer;
72 return (left < 0);
73 }
74
75 /*
76 * @brief Countdown millisecond Timer
77 * @param timer : pointer to a Timer structure
78 * that contains the configuration information for the Timer.
79 * timeout : setting timeout millisecond.
80 */
81 void TimerCountdownMS(Timer* timer, unsigned int timeout) {
82 timer->end_time = MilliTimer + timeout;
83 }
84
85 /*
86 * @brief Countdown second Timer
87 * @param timer : pointer to a Timer structure
88 * that contains the configuration information for the Timer.
89 * timeout : setting timeout millisecond.
90 */
91 void TimerCountdown(Timer* timer, unsigned int timeout) {
92 timer->end_time = MilliTimer + (timeout * 1000);
93 }
94
95 /*
96 * @brief left millisecond Timer
97 * @param timer : pointer to a Timer structure
98 * that contains the configuration information for the Timer.
99 */
100 int TimerLeftMS(Timer* timer) {
101 long left = timer->end_time - MilliTimer;
102 return (left < 0) ? 0 : left;
103 }
104
105 /*
106 * @brief New network setting
107 * @param n : pointer to a Network structure
108 * that contains the configuration information for the Network.
109 * sn : socket number where x can be (0..7).
110 * @retval None
111 */
112 void NewNetwork(Network* n, int sn) {
113 n->my_socket = sn;
114 n->mqttread = w5x00_read;
115 n->mqttwrite = w5x00_write;
116 n->disconnect = w5x00_disconnect;
117 }
118
119 /*
120 * @brief read function
121 * @param n : pointer to a Network structure
122 * that contains the configuration information for the Network.
123 * buffer : pointer to a read buffer.
124 * len : buffer length.
125 */
126 int w5x00_read(Network* n, unsigned char* buffer, int len)
127 {
128
129 if((getSn_SR(n->my_socket) == SOCK_ESTABLISHED) && (getSn_RX_RSR(n->my_socket)>0))
130 return recv(n->my_socket, buffer, len);
131 }
132
133 /*
134 * @brief write function
135 * @param n : pointer to a Network structure
136 * that contains the configuration information for the Network.
137 * buffer : pointer to a read buffer.
138 * len : buffer length.
139 */
140 int w5x00_write(Network* n, unsigned char* buffer, int len)
141 {
142 if(getSn_SR(n->my_socket) == SOCK_ESTABLISHED)
143 return send(n->my_socket, buffer, len);
144 }
145
146 /*
147 * @brief disconnect function
148 * @param n : pointer to a Network structure
149 * that contains the configuration information for the Network.
150 */
151 void w5x00_disconnect(Network* n)
152 {
153 disconnect(n->my_socket);
154 }
155
156 /*
157 * @brief connect network function
158 * @param n : pointer to a Network structure
159 * that contains the configuration information for the Network.
160 * ip : server iP.
161 * port : server port.
162 */
163 int ConnectNetwork(Network* n, char* ip, int port)
164 {
165 uint8_t myport = 12345;
166
167 socket(n->my_socket,Sn_MR_TCP,myport,0);
168 connect(n->my_socket,ip,port);
169 }
MilliTimer
unsigned long MilliTimer
Definition: mqtt_interface.c:46
w5x00_write
int w5x00_write(Network *n, unsigned char *buffer, int len)
Definition: mqtt_interface.c:140
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
Network::mqttwrite
int(* mqttwrite)(Network *, unsigned char *, int, int)
Definition: mqtt_interface.h:238
mqtt_interface.h
Paho MQTT to WIZnet Chip interface Header file.
NewNetwork
void NewNetwork(Network *n, int sn)
Definition: mqtt_interface.c:112
TimerLeftMS
int TimerLeftMS(Timer *timer)
Definition: mqtt_interface.c:100
Network::mqttread
int(* mqttread)(Network *, unsigned char *, int, int)
Definition: mqtt_interface.h:237
MilliTimer_Handler
void MilliTimer_Handler(void)
Definition: mqtt_interface.c:52
TimerCountdownMS
void TimerCountdownMS(Timer *timer, unsigned int timeout)
Definition: mqtt_interface.c:81
TimerInit
void TimerInit(Timer *timer)
Definition: mqtt_interface.c:61
Timer::end_time
unsigned long end_time
Definition: mqtt_interface.h:227
Network::disconnect
void(* disconnect)(Network *)
Definition: mqtt_interface.h:239
Sn_MR_TCP
#define Sn_MR_TCP
TCP.
Definition: w5100.h:648
Timer
Definition: mqtt_interface.h:225
recv
int32_t recv(uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer.
Definition: socket.c:384
TimerCountdown
void TimerCountdown(Timer *timer, unsigned int timeout)
Definition: mqtt_interface.c:91
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
TimerIsExpired
char TimerIsExpired(Timer *timer)
Definition: mqtt_interface.c:70
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
disconnect
int8_t disconnect(uint8_t sn)
Try to disconnect a connection socket.
Definition: socket.c:296
Network::my_socket
int my_socket
Definition: mqtt_interface.h:236
w5x00_read
int w5x00_read(Network *n, unsigned char *buffer, int len)
Definition: mqtt_interface.c:126
connect
int8_t connect(uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server.
Definition: socket.c:256
ConnectNetwork
int ConnectNetwork(Network *n, char *ip, int port)
Definition: mqtt_interface.c:163
wizchip_conf.h
WIZCHIP Config Header File.
w5x00_disconnect
void w5x00_disconnect(Network *n)
Definition: mqtt_interface.c:151
SOCK_ESTABLISHED
#define SOCK_ESTABLISHED
Success to connect.
Definition: w5100.h:935
Network
Definition: mqtt_interface.h:234
send
int32_t send(uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket.
Definition: socket.c:316


ioLibrary: Internet/MQTT/mqtt_interface.h Source File

  • Internet
  • MQTT
mqtt_interface.h
Go to the documentation of this file.
1 //*****************************************************************************
40 //
41 //*****************************************************************************
42
43 /* MQTT subscribe Example.... W5500 + STM32F103(IoT board)
44 //Include: Board configuration
45 #include "IoTEVB.h"
46
47 //Include: MCU peripheral Library
48 #include "stm32f10x_rcc.h"
49 #include "stm32f10x.h"
50
51 //Include: W5500 iolibrary
52 #include "w5500.h"
53 #include "wizchip_conf.h"
54 #include "misc.h"
55
56 //Include: Internet iolibrary
57 #include "MQTTClient.h"
58
59 //Include: MCU Specific W5500 driver
60 #include "W5500HardwareDriver.h"
61
62 //Include: Standard IO Library
63 #include <stdio.h>
64
65 //Socket number defines
66 #define TCP_SOCKET 0
67
68 //Receive Buffer Size define
69 #define BUFFER_SIZE 2048
70
71 //Global variables
72 unsigned char targetIP[4] = {}; // mqtt server IP
73 unsigned int targetPort = 1883; // mqtt server port
74 uint8_t mac_address[6] = {};
75 wiz_NetInfo gWIZNETINFO = { .mac = {}, //user MAC
76 .ip = {}, //user IP
77 .sn = {},
78 .gw = {},
79 .dns = {},
80 .dhcp = NETINFO_STATIC};
81
82 unsigned char tempBuffer[BUFFER_SIZE] = {};
83
84 struct opts_struct
85 {
86 char* clientid;
87 int nodelimiter;
88 char* delimiter;
89 enum QoS qos;
90 char* username;
91 char* password;
92 char* host;
93 int port;
94 int showtopics;
95 } opts ={ (char*)"stdout-subscriber", 0, (char*)"\n", QOS0, NULL, NULL, targetIP, targetPort, 0 };
96
97
98 // @brief messageArrived callback function
99 void messageArrived(MessageData* md)
100 {
101 unsigned char testbuffer[100];
102 MQTTMessage* message = md->message;
103
104 if (opts.showtopics)
105 {
106 memcpy(testbuffer,(char*)message->payload,(int)message->payloadlen);
107 *(testbuffer + (int)message->payloadlen + 1) = "\n";
108 printf("%s\r\n",testbuffer);
109 }
110
111 if (opts.nodelimiter)
112 printf("%.*s", (int)message->payloadlen, (char*)message->payload);
113 else
114 printf("%.*s%s", (int)message->payloadlen, (char*)message->payload, opts.delimiter);
115 }
116
117
118 // @brief 1 millisecond Tick Timer setting
119 void NVIC_configuration(void)
120 {
121 NVIC_InitTypeDef NVIC_InitStructure;
122 SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
123 SysTick_Config(72000);
124 NVIC_InitStructure.NVIC_IRQChannel = SysTick_IRQn;
125 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; // Highest priority
126 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
127 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
128 NVIC_Init(&NVIC_InitStructure);
129 }
130
131 // @brief 1 millisecond Tick Timer Handler setting
132 void SysTick_Handler(void)
133 {
134 MilliTimer_Handler();
135 }
136
137 int main(void)
138 {
139 led_ctrl led1,led2;
140 int i;
141 int rc = 0;
142 unsigned char buf[100];
143 //Usart initialization for Debug.
144 USART1Initialze();
145 printf("USART initialized.\n\r");
146
147 I2C1Initialize();
148 printf("I2C initialized.\n\r");
149
150 MACEEP_Read(mac_address,0xfa,6);
151
152 printf("Mac address\n\r");
153 for(i = 0 ; i < 6 ; i++)
154 {
155 printf("%02x ",mac_address[i]);
156 }
157 printf("\n\r");
158
159 //LED initialization.
160 led_initialize();
161 led1 = led2 = ON;
162
163 led2Ctrl(led2);
164 led1Ctrl(led1);
165
166 //W5500 initialization.
167 W5500HardwareInitilize();
168 printf("W5500 hardware interface initialized.\n\r");
169
170 W5500Initialze();
171 printf("W5500 IC initialized.\n\r");
172
173 //Set network informations
174 wizchip_setnetinfo(&gWIZNETINFO);
175
176 setSHAR(mac_address);
177
178 print_network_information();
179
180 Network n;
181 MQTTClient c;
182
183 NewNetwork(&n, TCP_SOCKET);
184 ConnectNetwork(&n, targetIP, targetPort);
185 MQTTClientInit(&c,&n,1000,buf,100,tempBuffer,2048);
186
187 MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
188 data.willFlag = 0;
189 data.MQTTVersion = 3;
190 data.clientID.cstring = opts.clientid;
191 data.username.cstring = opts.username;
192 data.password.cstring = opts.password;
193
194 data.keepAliveInterval = 60;
195 data.cleansession = 1;
196
197 rc = MQTTConnect(&c, &data);
198 printf("Connected %d\r\n", rc);
199 opts.showtopics = 1;
200
201 printf("Subscribing to %s\r\n", "hello/wiznet");
202 rc = MQTTSubscribe(&c, "hello/wiznet", opts.qos, messageArrived);
203 printf("Subscribed %d\r\n", rc);
204
205 while(1)
206 {
207 MQTTYield(&c, data.keepAliveInterval);
208 }
209 }
210 */
211
212 #ifndef __MQTT_INTERFACE_H_
213 #define __MQTT_INTERFACE_H_
214
215 /*
216 * @brief MQTT MilliTimer handler
217 * @note MUST BE register to your system 1m Tick timer handler
218 */
219 void MilliTimer_Handler(void);
220
221 /*
222 * @brief Timer structure
223 */
224 typedef struct Timer Timer;
225 struct Timer {
226 unsigned long systick_period;
227 unsigned long end_time;
228 };
229
230 /*
231 * @brief Network structure
232 */
233 typedef struct Network Network;
234 struct Network
235 {
236 int my_socket;
237 int (*mqttread) (Network*, unsigned char*, int, int);
238 int (*mqttwrite) (Network*, unsigned char*, int, int);
239 void (*disconnect) (Network*);
240 };
241
242 /*
243 * @brief Timer function
244 */
245 void TimerInit(Timer*);
246 char TimerIsExpired(Timer*);
247 void TimerCountdownMS(Timer*, unsigned int);
248 void TimerCountdown(Timer*, unsigned int);
249 int TimerLeftMS(Timer*);
250
251 /*
252 * @brief Network interface porting
253 */
254 int w5x00_read(Network*, unsigned char*, int);
255 int w5x00_write(Network*, unsigned char*, int);
256 void w5x00_disconnect(Network*);
257 void NewNetwork(Network* n, int sn);
258 int ConnectNetwork(Network*, char*, int);
259
260 #endif //__MQTT_INTERFACE_H_
w5x00_read
int w5x00_read(Network *, unsigned char *, int)
Definition: mqtt_interface.c:126
Network::mqttwrite
int(* mqttwrite)(Network *, unsigned char *, int, int)
Definition: mqtt_interface.h:238
TimerLeftMS
int TimerLeftMS(Timer *)
Definition: mqtt_interface.c:100
Network::mqttread
int(* mqttread)(Network *, unsigned char *, int, int)
Definition: mqtt_interface.h:237
Timer::end_time
unsigned long end_time
Definition: mqtt_interface.h:227
Network::disconnect
void(* disconnect)(Network *)
Definition: mqtt_interface.h:239
TimerCountdownMS
void TimerCountdownMS(Timer *, unsigned int)
Definition: mqtt_interface.c:81
Timer::systick_period
unsigned long systick_period
Definition: mqtt_interface.h:226
TimerInit
void TimerInit(Timer *)
Definition: mqtt_interface.c:61
w5x00_disconnect
void w5x00_disconnect(Network *)
Definition: mqtt_interface.c:151
Timer
Definition: mqtt_interface.h:225
MilliTimer_Handler
void MilliTimer_Handler(void)
Definition: mqtt_interface.c:52
TimerIsExpired
char TimerIsExpired(Timer *)
Definition: mqtt_interface.c:70
ConnectNetwork
int ConnectNetwork(Network *, char *, int)
Definition: mqtt_interface.c:163
NewNetwork
void NewNetwork(Network *n, int sn)
Definition: mqtt_interface.c:112
Network::my_socket
int my_socket
Definition: mqtt_interface.h:236
w5x00_write
int w5x00_write(Network *, unsigned char *, int)
Definition: mqtt_interface.c:140
TimerCountdown
void TimerCountdown(Timer *, unsigned int)
Definition: mqtt_interface.c:91
Network
Definition: mqtt_interface.h:234


ioLibrary: Internet/TFTP/netutil.c Source File

  • Internet
  • TFTP
netutil.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "netutil.h"
5
12 int8_t* inet_ntoa(uint32_t addr)
13 {
14 static int8_t addr_str[16];
15 memset(addr_str,0,16);
16 sprintf((char*)addr_str,"%d.%d.%d.%d",(int32_t)(addr>>24 & 0xFF),(int32_t)(addr>>16 & 0xFF),(int32_t)(addr>>8 & 0xFF),(int32_t)(addr & 0xFF));
17 return addr_str;
18 }
19
27 int8_t* inet_ntoa_pad(uint32_t addr)
28 {
29 static int8_t addr_str[16];
30 memset(addr_str,0,16);
31 sprintf((char*)addr_str,"%03d.%03d.%03d.%03d",(int32_t)(addr>>24 & 0xFF),(int32_t)(addr>>16 & 0xFF),(int32_t)(addr>>8 & 0xFF),(int32_t)(addr & 0xFF));
32 return addr_str;
33 }
34
41 uint32_t inet_addr(uint8_t* addr)
42 {
43 int8_t i;
44 uint32_t inetaddr = 0;
45 int8_t taddr[30];
46 int8_t * nexttok;
47 int32_t num;
48 strcpy((char*)taddr,(char*)addr);
49
50 nexttok = taddr;
51 for(i = 0; i < 4 ; i++)
52 {
53 nexttok = (int8_t*)strtok((char*)nexttok,".");
54 if(nexttok[0] == '0' && nexttok[1] == 'x') num = strtol((char*)nexttok+2, NULL, 16);
55 else num = strtol((char*)nexttok, NULL, 10);
56 inetaddr = inetaddr << 8;
57 inetaddr |= (num & 0xFF);
58 nexttok = NULL;
59 }
60 return inetaddr;
61 }
62
69 uint16_t swaps(uint16_t i)
70 {
71 uint16_t ret=0;
72 ret = (i & 0xFF) << 8;
73 ret |= ((i >> 8)& 0xFF);
74 return ret;
75 }
76
83 uint32_t swapl(uint32_t l)
84 {
85 uint32_t ret=0;
86 ret = (l & 0xFF) << 24;
87 ret |= ((l >> 8) & 0xFF) << 16;
88 ret |= ((l >> 16) & 0xFF) << 8;
89 ret |= ((l >> 24) & 0xFF);
90 return ret;
91 }
92
99 uint16_t htons(uint16_t hostshort)
100 {
101 #ifdef SYSTEM_LITTLE_ENDIAN
102 return swaps(hostshort);
103 #else
104 return hostshort;
105 #endif
106 }
107
108
115 uint32_t htonl(uint32_t hostlong)
116 {
117 #ifdef SYSTEM_LITTLE_ENDIAN
118 return swapl(hostlong);
119 #else
120 return hostlong;
121 #endif
122 }
123
124
132 uint32_t ntohs(uint16_t netshort)
133 {
134 #ifdef SYSTEM_LITTLE_ENDIAN
135 return htons(netshort);
136 #else
137 return netshort;
138 #endif
139 }
140
148 uint32_t ntohl(uint32_t netlong)
149 {
150 #ifdef SYSTEM_LITTLE_ENDIAN
151 return swapl(netlong);
152 #else
153 return netlong;
154 #endif
155 }
htons
uint16_t htons(uint16_t hostshort)
Definition: netutil.c:99
netutil.h
inet_addr
uint32_t inet_addr(uint8_t *addr)
Definition: netutil.c:41
swaps
uint16_t swaps(uint16_t i)
Definition: netutil.c:69
ntohl
uint32_t ntohl(uint32_t netlong)
Definition: netutil.c:148
htonl
uint32_t htonl(uint32_t hostlong)
Definition: netutil.c:115
inet_ntoa
int8_t * inet_ntoa(uint32_t addr)
Definition: netutil.c:12
swapl
uint32_t swapl(uint32_t l)
Definition: netutil.c:83
ntohs
uint32_t ntohs(uint16_t netshort)
Definition: netutil.c:132
inet_ntoa_pad
int8_t * inet_ntoa_pad(uint32_t addr)
Definition: netutil.c:27


ioLibrary: Internet/TFTP/netutil.h Source File

  • Internet
  • TFTP
netutil.h
Go to the documentation of this file.
1
2 #ifndef __NETUTIL_H__
3 #define __NETUTIL_H__
4
5 #include <stdint.h>
6
7 #define SYSTEM_LITTLE_ENDIAN
8
9 int8_t* inet_ntoa(uint32_t addr);
10 int8_t* inet_ntoa_pad(uint32_t addr);
11 uint32_t inet_addr(uint8_t* addr);
12 uint16_t swaps(uint16_t i);
13 uint32_t swapl(uint32_t l);
14 uint16_t htons(uint16_t hostshort);
15 uint32_t htonl(uint32_t hostlong);
16 uint32_t ntohs(uint16_t netshort);
17 uint32_t ntohl(uint32_t netlong);
18
19 #endif
ntohl
uint32_t ntohl(uint32_t netlong)
Definition: netutil.c:148
inet_ntoa_pad
int8_t * inet_ntoa_pad(uint32_t addr)
Definition: netutil.c:27
swapl
uint32_t swapl(uint32_t l)
Definition: netutil.c:83
swaps
uint16_t swaps(uint16_t i)
Definition: netutil.c:69
inet_ntoa
int8_t * inet_ntoa(uint32_t addr)
Definition: netutil.c:12
htons
uint16_t htons(uint16_t hostshort)
Definition: netutil.c:99
htonl
uint32_t htonl(uint32_t hostlong)
Definition: netutil.c:115
inet_addr
uint32_t inet_addr(uint8_t *addr)
Definition: netutil.c:41
ntohs
uint32_t ntohs(uint16_t netshort)
Definition: netutil.c:132


ioLibrary: Related Pages

Related Pages
Here is a list of all related documentation pages:
ioLibrary Driver
Todo List


ioLibrary: Internet/SNMP/snmp.c Source File

  • Internet
  • SNMP
snmp.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <ctype.h>
4 #include <stdarg.h>
5 #include <time.h>
6
7 #include "socket.h"
8 #include "snmp.h"
9 #include "snmp_custom.h"
10
11 /********************************************************************************************/
12 /* SNMP : Functions declaration */
13 /********************************************************************************************/
14 // SNMP Parsing functions
15 int32_t findEntry(uint8_t *oid, int32_t len);
16 int32_t getOID(int32_t id, uint8_t *oid, uint8_t *len);
17 int32_t getValue( uint8_t *vptr, int32_t vlen);
18 int32_t getEntry(int32_t id, uint8_t *dataType, void *ptr, int32_t *len);
19 int32_t setEntry(int32_t id, void *val, int32_t vlen, uint8_t dataType, int32_t index);
20 int32_t makeTrapVariableBindings(dataEntryType *oid_data, void *ptr, uint32_t *len);
21
22 int32_t parseLength(const uint8_t *msg, int32_t *len);
23 int32_t parseTLV(const uint8_t *msg, int32_t index, tlvStructType *tlv);
24 void insertRespLen(int32_t reqStart, int32_t respStart, int32_t size);
25 int32_t parseVarBind(int32_t reqType, int32_t index);
26 int32_t parseSequence(int32_t reqType, int32_t index);
27 int32_t parseSequenceOf(int32_t reqType);
28 int32_t parseRequest();
29 int32_t parseCommunity();
30 int32_t parseVersion();
31 int32_t parseSNMPMessage();
32
33 // Debugging function
34 #ifdef _SNMP_DEBUG_
35 void dumpCode(uint8_t* header, uint8_t* tail, uint8_t *buff, int32_t len);
36 #endif
37
38 // Utils
39 void ipToByteArray(int8_t *ip, uint8_t *pDes);
40
41 /********************************************************************************************/
42 /* SNMP : Variable declaration */
43 /********************************************************************************************/
44 // SNMP message structures
45 struct messageStruct request_msg;
46 struct messageStruct response_msg;
47
48 // SNMP Time counter
49 static time_t startTime = 0;
50 volatile uint32_t snmp_tick_10ms = 0; //volatile uint32_t snmp_tick_1ms = 0;
51
52 // SNMP Sockets
53 static uint8_t SOCK_SNMP_AGENT;
54 static uint8_t SOCK_SNMP_TRAP;
55
56 uint8_t packet_trap[MAX_TRAPMSG_LEN] = {0,};
57 uint8_t errorStatus, errorIndex;
58
59
60 /********************************************************************************************/
61 /* SNMP : Time handler */
62 /********************************************************************************************/
63 void currentUptime(void *ptr, uint8_t *len)
64 {
65 time_t curTime = getSNMPTimeTick();
66
67 //*(uint32_t *)ptr = (uint32_t)(curTime - startTime) / 10; // calculation for 1ms tick
68 *(uint32_t *)ptr = (uint32_t)(curTime - startTime); // calculation for 10ms tick
69 *len = 4;
70 }
71
72 void SNMP_time_handler(void)
73 {
74 //snmp_tick_1ms++;
75 snmp_tick_10ms++;
76 }
77
78 uint32_t getSNMPTimeTick(void)
79 {
80 //return snmp_tick_1ms;
81 return snmp_tick_10ms;
82 }
83
84
85 /********************************************************************************************/
86 /* SNMP : Library Part */
87 /********************************************************************************************/
100 void snmpd_init(uint8_t * managerIP, uint8_t * agentIP, uint8_t sn_agent, uint8_t sn_trap)
101 {
102 #ifdef _SNMP_DEBUG_
103 printf("\r\n - SNMP : Start SNMP Agent Daemon\r\n");
104 #endif
105 SOCK_SNMP_AGENT = sn_agent;
106 SOCK_SNMP_TRAP = sn_trap;
107
108 if((SOCK_SNMP_AGENT > _WIZCHIP_SOCK_NUM_) || (SOCK_SNMP_TRAP > _WIZCHIP_SOCK_NUM_)) return;
109
110 startTime = getSNMPTimeTick(); // Start time (unit: 10ms)
111 initTable(); // Settings for OID entry values
112
113 initial_Trap(managerIP, agentIP);
114
115 /*
116 // Example Codes for SNMP Trap
117 {
118 dataEntryType enterprise_oid = {0x0a, {0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0x9b, 0x19, 0x01, 0x00},
119 SNMPDTYPE_OBJ_ID, 0x0a, {"\x2b\x06\x01\x04\x01\x81\x9b\x19\x10\x00"}, NULL, NULL};
120
121 dataEntryType trap_oid1 = {8, {0x2b, 6, 1, 4, 1, 0, 11, 0}, SNMPDTYPE_OCTET_STRING, 30, {""}, NULL, NULL};
122 dataEntryType trap_oid2 = {8, {0x2b, 6, 1, 4, 1, 0, 12, 0}, SNMPDTYPE_INTEGER, 4, {""}, NULL, NULL};
123
124 strcpy((char *)trap_oid1.u.octetstring, "Alert!!!"); // String added
125 trap_oid2.u.intval = 123456; // Integer value added
126
127 // Generic Trap: warmStart
128 snmp_sendTrap((void *)"192.168.0.214", (void *)"192.168.0.112", (void *)"public", enterprise_oid, SNMPTRAP_WARMSTART, 0, 0);
129
130 // Enterprise-Specific Trap
131 snmp_sendTrap((void *)"192.168.0.214", (void *)"192.168.0.112", (void *)"public", enterprise_oid, 6, 0, 2, &trap_oid1, &trap_oid2);
132 }
133 */
134 }
135
136
145 int32_t snmpd_run(void)
146 {
147 int32_t ret;
148 int32_t len = 0;
149
150 uint8_t svr_addr[6];
151 uint16_t svr_port;
152
153 if(SOCK_SNMP_AGENT > _WIZCHIP_SOCK_NUM_) return -99;
154
155 switch(getSn_SR(SOCK_SNMP_AGENT))
156 {
157 case SOCK_UDP :
158 if ( (len = getSn_RX_RSR(SOCK_SNMP_AGENT)) > 0)
159 {
160 request_msg.len= recvfrom(SOCK_SNMP_AGENT, request_msg.buffer, len, svr_addr, &svr_port);
161 }
162 else
163 {
164 request_msg.len = 0;
165 }
166
167 if (request_msg.len > 0)
168 {
169 #ifdef _SNMP_DEBUG_
170 dumpCode((void *)"\r\n[Request]\r\n", (void *)"\r\n", request_msg.buffer, request_msg.len);
171 #endif
172 // Initialize
173 request_msg.index = 0;
174 response_msg.index = 0;
175 errorStatus = errorIndex = 0;
176 memset(response_msg.buffer, 0x00, MAX_SNMPMSG_LEN);
177
178 // Received message parsing and send response process
179 if (parseSNMPMessage() != -1)
180 {
181 sendto(SOCK_SNMP_AGENT, response_msg.buffer, response_msg.index, svr_addr, svr_port);
182 }
183
184 #ifdef _SNMP_DEBUG_
185 dumpCode((void *)"\r\n[Response]\r\n", (void *)"\r\n", response_msg.buffer, response_msg.index);
186 #endif
187 }
188 break;
189
190 case SOCK_CLOSED :
191 if((ret = socket(SOCK_SNMP_AGENT, Sn_MR_UDP, PORT_SNMP_AGENT, 0x00)) != SOCK_SNMP_AGENT)
192 return ret;
193 #ifdef _SNMP_DEBUG_
194 printf(" - [%d] UDP Socket for SNMP Agent, port [%d]\r\n", SOCK_SNMP_AGENT, PORT_SNMP_AGENT);
195 #endif
196 break;
197
198 default :
199 break;
200 }
201
202
203 return 1;
204 }
205
206
207 int32_t findEntry(uint8_t *oid, int32_t len)
208 {
209 int32_t i;
210
211 for (i = 0 ; i < maxData ; i++)
212 {
213 if (len == snmpData[i].oidlen)
214 {
215 if (!memcmp(snmpData[i].oid, oid, len)) return(i);
216 }
217 }
218
219 return OID_NOT_FOUND;
220 }
221
222
223 int32_t getOID(int32_t id, uint8_t *oid, uint8_t *len)
224 {
225 int32_t j;
226
227 if (!((id >= 0) && (id < maxData))) return INVALID_ENTRY_ID;
228
229 *len = snmpData[id].oidlen;
230
231 for (j = 0 ; j < *len ; j++)
232 {
233 oid[j] = snmpData[id].oid[j];
234 }
235
236 return SNMP_SUCCESS;
237 }
238
239
240 int32_t getValue( uint8_t *vptr, int32_t vlen)
241 {
242 int32_t index = 0;
243 int32_t value = 0;
244
245 while (index < vlen)
246 {
247 if (index != 0) value <<= 8;
248 value |= vptr[index++];
249 }
250
251 return value;
252 }
253
254
255 int32_t getEntry(int32_t id, uint8_t *dataType, void *ptr, int32_t *len)
256 {
257 uint8_t * ptr_8;
258 int32_t value;
259
260 uint8_t * string;
261 int32_t j;
262
263 if (!((id >= 0) && (id < maxData))) return INVALID_ENTRY_ID;
264
265 *dataType = snmpData[id].dataType;
266
267 switch(*dataType)
268 {
269 case SNMPDTYPE_OCTET_STRING :
270 case SNMPDTYPE_OBJ_ID :
271 {
272 string = ptr;
273
274 if (snmpData[id].getfunction != NULL)
275 {
276 snmpData[id].getfunction( (void *)&snmpData[id].u.octetstring, &snmpData[id].dataLen );
277 }
278
279 if ( (*dataType)==SNMPDTYPE_OCTET_STRING )
280 {
281 snmpData[id].dataLen = (uint8_t)strlen((char const*)&snmpData[id].u.octetstring);
282 }
283
284 *len = snmpData[id].dataLen;
285 for (j = 0 ; j < *len ; j++)
286 {
287 string[j] = snmpData[id].u.octetstring[j];
288 }
289 }
290 break;
291
292 case SNMPDTYPE_INTEGER :
293 case SNMPDTYPE_TIME_TICKS :
294 case SNMPDTYPE_COUNTER :
295 case SNMPDTYPE_GAUGE :
296 {
297 if (snmpData[id].getfunction != NULL)
298 {
299 snmpData[id].getfunction( (void *)&snmpData[id].u.intval, &snmpData[id].dataLen );
300 }
301
302 if(snmpData[id].dataLen) *len = snmpData[id].dataLen;
303 else *len = sizeof(uint32_t);
304
305 /*
306 // Original code (IAR, STM32)
307 // This code is not working in NXP+LPCXpresso (32-bit pointer operation error)
308 value = (int32_t *)ptr;
309 *value = HTONL(snmpData[id].u.intval);
310 */
311
312 ptr_8 = ptr;
313 //value = HTONL(snmpData[id].u.intval); // Endian convert when processing 32bit pointer operation
314 value = snmpData[id].u.intval;
315
316 for (j = 0 ; j < *len ; j++)
317 {
318 ptr_8[j] = (uint8_t)((value >> ((*len-j-1)*8)));
319 }
320 }
321 break;
322
323 default :
324 return INVALID_DATA_TYPE;
325 }
326
327 return SNMP_SUCCESS;
328 }
329
330
331 int32_t setEntry(int32_t id, void *val, int32_t vlen, uint8_t dataType, int32_t index)
332 {
333
334 int32_t retStatus=OID_NOT_FOUND;
335 int32_t j;
336
337 if (snmpData[id].dataType != dataType)
338 {
339 errorStatus = BAD_VALUE;
340 errorIndex = index;
341 return INVALID_DATA_TYPE;
342 }
343
344 switch(snmpData[id].dataType)
345 {
346 case SNMPDTYPE_OCTET_STRING :
347 case SNMPDTYPE_OBJ_ID :
348 {
349 uint8_t *string = val;
350 for (j = 0 ; j < vlen ; j++)
351 {
352 snmpData[id].u.octetstring[j] = string[j];
353 }
354 snmpData[id].dataLen = vlen;
355 }
356 retStatus = SNMP_SUCCESS;
357 break;
358
359 case SNMPDTYPE_INTEGER :
360 case SNMPDTYPE_TIME_TICKS :
361 case SNMPDTYPE_COUNTER :
362 case SNMPDTYPE_GAUGE :
363 {
364 snmpData[id].u.intval = getValue( (uint8_t *)val, vlen);
365 snmpData[id].dataLen = vlen;
366
367 if (snmpData[id].setfunction != NULL)
368 {
369 snmpData[id].setfunction(snmpData[id].u.intval);
370 }
371
372 }
373 retStatus = SNMP_SUCCESS;
374 break;
375
376 default :
377 retStatus = INVALID_DATA_TYPE;
378 break;
379
380 }
381
382 return retStatus;
383 }
384
385
386 int32_t parseLength(const uint8_t *msg, int32_t *len)
387 {
388 int32_t i=1;
389
390 if (msg[0] & 0x80)
391 {
392 int32_t tlen = (msg[0] & 0x7f) - 1;
393 *len = msg[i++];
394
395 while (tlen--)
396 {
397 *len <<= 8;
398 *len |= msg[i++];
399 }
400 }
401 else
402 {
403 *len = msg[0];
404 }
405
406 return i;
407 }
408
409
410 int32_t parseTLV(const uint8_t *msg, int32_t index, tlvStructType *tlv)
411 {
412 int32_t Llen = 0;
413
414 tlv->start = index;
415
416 Llen = parseLength((const uint8_t *)&msg[index+1], &tlv->len );
417
418 tlv->vstart = index + Llen + 1;
419
420 switch (msg[index])
421 {
422 case SNMPDTYPE_SEQUENCE:
423 case GET_REQUEST:
424 case GET_NEXT_REQUEST:
425 case SET_REQUEST:
426 tlv->nstart = tlv->vstart;
427 break;
428 default:
429 tlv->nstart = tlv->vstart + tlv->len;
430 break;
431 }
432
433 return 0;
434 }
435
436
437 void insertRespLen(int32_t reqStart, int32_t respStart, int32_t size)
438 {
439 int32_t indexStart, lenLength;
440 uint32_t mask = 0xff;
441 int32_t shift = 0;
442
443 if (request_msg.buffer[reqStart+1] & 0x80)
444 {
445 lenLength = request_msg.buffer[reqStart+1] & 0x7f;
446 indexStart = respStart+2;
447
448 while (lenLength--)
449 {
450 response_msg.buffer[indexStart+lenLength] =
451 (uint8_t)((size & mask) >> shift);
452 shift+=8;
453 mask <<= shift;
454 }
455 }
456 else
457 {
458 response_msg.buffer[respStart+1] = (uint8_t)(size & 0xff);
459 }
460 }
461
462 int32_t parseVarBind(int32_t reqType, int32_t index)
463 {
464 int32_t seglen = 0, id;
465 tlvStructType name, value;
466 int32_t size = 0;
467
468 //extern const int32_t maxData;
469
470 parseTLV(request_msg.buffer, request_msg.index, &name);
471
472 if ( request_msg.buffer[name.start] != SNMPDTYPE_OBJ_ID ) return -1;
473
474 id = findEntry(&request_msg.buffer[name.vstart], name.len);
475
476 if ((reqType == GET_REQUEST) || (reqType == SET_REQUEST))
477 {
478 seglen = name.nstart - name.start;
479 COPY_SEGMENT(name);
480 size = seglen;
481 }
482 else if (reqType == GET_NEXT_REQUEST)
483 {
484 response_msg.buffer[response_msg.index] = request_msg.buffer[name.start];
485
486 if (++id >= maxData)
487 {
488 id = OID_NOT_FOUND;
489 seglen = name.nstart - name.start;
490 COPY_SEGMENT(name);
491 size = seglen;
492 }
493 else
494 {
495 request_msg.index += name.nstart - name.start;
496
497 getOID(id, &response_msg.buffer[response_msg.index+2], &response_msg.buffer[response_msg.index+1]);
498
499 seglen = response_msg.buffer[response_msg.index+1]+2;
500 response_msg.index += seglen ;
501 size = seglen;
502 }
503 }
504
505 parseTLV(request_msg.buffer, request_msg.index, &value);
506
507 if (id != OID_NOT_FOUND)
508 {
509 uint8_t dataType;
510 int32_t len;
511
512 if ((reqType == GET_REQUEST) || (reqType == GET_NEXT_REQUEST))
513 {
514 getEntry(id, &dataType, &response_msg.buffer[response_msg.index+2], &len);
515
516 response_msg.buffer[response_msg.index] = dataType;
517 response_msg.buffer[response_msg.index+1] = len;
518 seglen = (2 + len);
519 response_msg.index += seglen;
520
521 request_msg.index += (value.nstart - value.start);
522
523 }
524 else if (reqType == SET_REQUEST)
525 {
526 setEntry(id, &request_msg.buffer[value.vstart], value.len, request_msg.buffer[value.start], index);
527 seglen = value.nstart - value.start;
528 COPY_SEGMENT(value);
529 }
530 }
531 else
532 {
533 seglen = value.nstart - value.start;
534 COPY_SEGMENT(value);
535
536 errorIndex = index;
537 errorStatus = NO_SUCH_NAME;
538 }
539
540 size += seglen;
541
542 return size;
543 }
544
545
546 int32_t parseSequence(int32_t reqType, int32_t index)
547 {
548 int32_t seglen;
549 tlvStructType seq;
550 int32_t size = 0, respLoc;
551
552 parseTLV(request_msg.buffer, request_msg.index, &seq);
553
554 if ( request_msg.buffer[seq.start] != SNMPDTYPE_SEQUENCE ) return -1;
555
556 seglen = seq.vstart - seq.start;
557 respLoc = response_msg.index;
558 COPY_SEGMENT(seq);
559
560 size = parseVarBind( reqType, index );
561 insertRespLen(seq.start, respLoc, size);
562 size += seglen;
563
564 return size;
565 }
566
567
568 int32_t parseSequenceOf(int32_t reqType)
569 {
570 int32_t seglen;
571 tlvStructType seqof;
572 int32_t size = 0, respLoc;
573 int32_t index = 0;
574
575 parseTLV(request_msg.buffer, request_msg.index, &seqof);
576
577 if ( request_msg.buffer[seqof.start] != SNMPDTYPE_SEQUENCE_OF ) return -1;
578
579 seglen = seqof.vstart - seqof.start;
580 respLoc = response_msg.index;
581 COPY_SEGMENT(seqof);
582
583 while (request_msg.index < request_msg.len)
584 {
585 size += parseSequence( reqType, index++ );
586 }
587
588 insertRespLen(seqof.start, respLoc, size);
589
590 return size;
591 }
592
593
594 int32_t parseRequest()
595 {
596 int32_t ret, seglen;
597 tlvStructType snmpreq, requestid, errStatus, errIndex;
598 int32_t size = 0, respLoc, reqType;
599
600 parseTLV(request_msg.buffer, request_msg.index, &snmpreq);
601
602 reqType = request_msg.buffer[snmpreq.start];
603
604 if ( !VALID_REQUEST(reqType) ) return -1;
605
606 seglen = snmpreq.vstart - snmpreq.start;
607 respLoc = snmpreq.start;
608 size += seglen;
609 COPY_SEGMENT(snmpreq);
610
611 response_msg.buffer[snmpreq.start] = GET_RESPONSE;
612
613 parseTLV(request_msg.buffer, request_msg.index, &requestid);
614 seglen = requestid.nstart - requestid.start;
615 size += seglen;
616 COPY_SEGMENT(requestid);
617
618 parseTLV(request_msg.buffer, request_msg.index, &errStatus);
619 seglen = errStatus.nstart - errStatus.start;
620 size += seglen;
621 COPY_SEGMENT(errStatus);
622
623 parseTLV(request_msg.buffer, request_msg.index, &errIndex);
624 seglen = errIndex.nstart - errIndex.start;
625 size += seglen;
626 COPY_SEGMENT(errIndex);
627
628 ret = parseSequenceOf(reqType);
629 if (ret == -1) return -1;
630 else size += ret;
631
632 insertRespLen(snmpreq.start, respLoc, size);
633
634 if (errorStatus)
635 {
636 response_msg.buffer[errStatus.vstart] = errorStatus;
637 response_msg.buffer[errIndex.vstart] = errorIndex + 1;
638 }
639
640 return size;
641 }
642
643
644 int32_t parseCommunity()
645 {
646 int32_t seglen;
647 tlvStructType community;
648 int32_t size=0;
649
650 parseTLV(request_msg.buffer, request_msg.index, &community);
651
652 if (!((request_msg.buffer[community.start] == SNMPDTYPE_OCTET_STRING) && (community.len == COMMUNITY_SIZE)))
653 {
654 return -1;
655 }
656
657 if (!memcmp(&request_msg.buffer[community.vstart], (int8_t *)COMMUNITY, COMMUNITY_SIZE))
658 {
659 seglen = community.nstart - community.start;
660 size += seglen;
661 COPY_SEGMENT(community);
662
663 size += parseRequest();
664 }
665 else
666 {
667 return -1;
668 }
669
670 return size;
671 }
672
673
674 int32_t parseVersion()
675 {
676 int32_t size = 0, seglen;
677 tlvStructType tlv;
678
679 size = parseTLV(request_msg.buffer, request_msg.index, &tlv);
680
681 if (!((request_msg.buffer[tlv.start] == SNMPDTYPE_INTEGER) && (request_msg.buffer[tlv.vstart] == SNMP_V1)))
682 return -1;
683
684 seglen = tlv.nstart - tlv.start;
685 size += seglen;
686 COPY_SEGMENT(tlv);
687 size = parseCommunity();
688
689 if (size == -1) return size;
690 else return (size + seglen);
691 }
692
693
694 int32_t parseSNMPMessage()
695 {
696 int32_t size = 0, seglen, respLoc;
697 tlvStructType tlv;
698
699 parseTLV(request_msg.buffer, request_msg.index, &tlv);
700
701 if (request_msg.buffer[tlv.start] != SNMPDTYPE_SEQUENCE_OF) return -1;
702
703 seglen = tlv.vstart - tlv.start;
704 respLoc = tlv.start;
705 COPY_SEGMENT(tlv);
706
707 size = parseVersion();
708
709 if (size == -1) return -1;
710 else size += seglen;
711
712 insertRespLen(tlv.start, respLoc, size);
713
714 return 0;
715 }
716
717 void ipToByteArray(int8_t *ip, uint8_t *pDes)
718 {
719 uint32_t i, ip1=0, ip2=0, ip3=0, ip4=0;
720 int8_t buff[32];
721 uint32_t len = (uint32_t)strlen((char const*)ip);
722 strcpy((char *)buff, (char const*)ip);
723
724 for (i=0; i<len; i++)
725 {
726 if ( buff[i]=='.' ) buff[i] = ' ';
727 }
728
729 sscanf((char const*)buff, "%u %u %u %u", &ip1, &ip2, &ip3, &ip4);
730 pDes[0] = ip1; pDes[1] = ip2; pDes[2] = ip3; pDes[3] = ip4;
731 }
732
733
734 int32_t makeTrapVariableBindings(dataEntryType *oid_data, void *ptr, uint32_t *len)
735 {
736 uint32_t j;
737
738 ((uint8_t*)ptr)[0] = 0x30;
739 ((uint8_t*)ptr)[1] = 0xff;
740 ((uint8_t*)ptr)[2] = 0x06;
741 ((uint8_t*)ptr)[3] = oid_data->oidlen;
742
743 for (j = 0 ; j < oid_data->oidlen ; j++)
744 {
745 ((uint8_t*)ptr)[j+4] = oid_data->oid[j];
746 }
747
748 switch(oid_data->dataType)
749 {
750 case SNMPDTYPE_OCTET_STRING :
751 case SNMPDTYPE_OBJ_ID :
752 {
753 uint8_t *string = &((uint8_t*)ptr)[4+oid_data->oidlen+2];
754
755 if ( oid_data->dataType==SNMPDTYPE_OCTET_STRING )
756 {
757 oid_data->dataLen = (uint8_t)strlen((char const*)&oid_data->u.octetstring);
758 }
759 for (j = 0 ; j < oid_data->dataLen ; j++)
760 {
761 string[j] = oid_data->u.octetstring[j];
762 }
763
764 ((uint8_t*)ptr)[4+oid_data->oidlen] = oid_data->dataType;
765 ((uint8_t*)ptr)[4+oid_data->oidlen+1] = oid_data->dataLen;
766 ((uint8_t*)ptr)[1] = 2 + oid_data->oidlen + 2 + oid_data->dataLen;
767 *len = 4 + oid_data->oidlen + 2 + oid_data->dataLen;
768 }
769 break;
770
771 case SNMPDTYPE_INTEGER :
772 case SNMPDTYPE_TIME_TICKS :
773 case SNMPDTYPE_COUNTER :
774 case SNMPDTYPE_GAUGE :
775 {
776 oid_data->dataLen = 4;
777
778 *(int32_t*)(&((uint8_t*)ptr)[4+oid_data->oidlen+2]) = HTONL(oid_data->u.intval);
779
780 ((uint8_t*)ptr)[4+oid_data->oidlen] = oid_data->dataType;
781 ((uint8_t*)ptr)[4+oid_data->oidlen+1] = oid_data->dataLen;
782 ((uint8_t*)ptr)[1] = 2 + oid_data->oidlen + 2 + oid_data->dataLen;
783 *len = 4 + oid_data->oidlen + 2 + oid_data->dataLen;
784 }
785 break;
786
787 default :
788 return INVALID_DATA_TYPE;
789 }
790
791 return SNMP_SUCCESS;
792 }
793
794
795 int32_t snmp_sendTrap(uint8_t * managerIP, uint8_t * agentIP, int8_t* community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count, ...)
796 {
797 uint32_t i;
798 int32_t packet_index = 0;
799 int32_t packet_buff1 = 0;
800 int32_t packet_buff2 = 0;
801 int32_t packet_buff3 = 0;
802
803 va_list ap;
804 uint32_t length_var_bindings = 0;
805 uint32_t length_buff = 0;
806
807 //SNMP Trap packet generation
808 packet_trap[packet_index++] = 0x30; // ASN.1 Header
809
810 packet_trap[packet_index] = 0xff; // pdu_length, temp
811 packet_buff1 = packet_index++;
812
813 packet_trap[packet_index++] = 0x02; // Version
814 packet_trap[packet_index++] = 0x01;
815 packet_trap[packet_index++] = 0x00;
816
817 packet_trap[packet_index++] = 0x04; // Community
818 packet_trap[packet_index++] = (uint8_t)strlen((char const*)community);
819 memcpy(&(packet_trap[packet_index]), community, strlen((char const*)community));
820
821 packet_index = packet_index + (uint8_t)strlen((char const*)community);
822
823 packet_trap[packet_index++] = 0xa4; // trap
824 packet_trap[packet_index] = 0xff; // length, temp
825 packet_buff2 = packet_index++;
826
827 packet_trap[packet_index++] = 0x06; // enterprise_oid
828 packet_trap[packet_index++] = enterprise_oid.oidlen;
829 for (i=0; i<enterprise_oid.oidlen; i++)
830 {
831 packet_trap[packet_index++] = enterprise_oid.oid[i];
832 }
833
834 packet_trap[packet_index++] = 0x40; // agent ip
835 packet_trap[packet_index++] = 0x04;
836 packet_trap[packet_index++] = agentIP[0];
837 packet_trap[packet_index++] = agentIP[1];
838 packet_trap[packet_index++] = agentIP[2];
839 packet_trap[packet_index++] = agentIP[3];
840
841 packet_trap[packet_index++] = 0x02; // Generic Trap
842 packet_trap[packet_index++] = 0x01;
843 packet_trap[packet_index++] = (uint8_t)genericTrap;
844
845 packet_trap[packet_index++] = 0x02; // Specific Trap
846 packet_trap[packet_index++] = 0x01;
847 packet_trap[packet_index++] = (uint8_t)specificTrap;
848
849 packet_trap[packet_index++] = 0x43; // Timestamp
850 packet_trap[packet_index++] = 0x01;
851 packet_trap[packet_index++] = 0x00;
852
853 packet_trap[packet_index++] = 0x30; // Sequence of variable-bindings
854 packet_trap[packet_index] = 0xff;
855 packet_buff3 = packet_index++;
856
857 // variable-bindings
858 {
859 va_start (ap, va_count);
860
861 for (i=0; i<va_count; i++)
862 {
863 dataEntryType* fff = va_arg(ap, dataEntryType*);
864 makeTrapVariableBindings(fff, &(packet_trap[packet_index]), &length_buff);
865 packet_index = packet_index + length_buff;
866 length_var_bindings = length_var_bindings + length_buff;
867 }
868
869 packet_trap[packet_buff3] = length_var_bindings;
870
871 va_end (ap);
872 }
873
874
875 packet_trap[packet_buff1] = packet_index - 2;
876 packet_trap[packet_buff2] = packet_index - (9 + (uint8_t)strlen((char const*)community));
877
878 // Send SNMP Trap Packet to NMS
879 {
880 socket(SOCK_SNMP_TRAP, Sn_MR_UDP, PORT_SNMP_TRAP, 0);
881 sendto(SOCK_SNMP_TRAP, packet_trap, packet_index, managerIP, PORT_SNMP_TRAP);
882
883 close(SOCK_SNMP_TRAP);
884 return 0;
885 }
886 }
887
888 #ifdef _SNMP_DEBUG_
889 void dumpCode(uint8_t* header, uint8_t* tail, uint8_t *buff, int32_t len)
890 {
891 int i;
892
893 printf((char const*)header);
894
895 for (i=0; i<len; i++)
896 {
897 if ( i%16==0 ) printf("0x%04x : ", i);
898 printf("%02x ",buff[i]);
899
900 if ( i%16-15==0 )
901 {
902 int j;
903 printf(" ");
904 for (j=i-15; j<=i; j++)
905 {
906 if ( isprint(buff[j]) ) printf("%c", buff[j]);
907 else printf(".");
908 }
909 printf("\r\n");
910 }
911 }
912
913 if ( i%16!=0 )
914 {
915 int j;
916 int spaces=(len-i+16-i%16)*3+2;
917 for (j=0; j<spaces; j++) printf(" ");
918 for (j=i-i%16; j<len; j++)
919 {
920 if ( isprint(buff[j]) ) printf("%c", buff[j]);
921 else printf(".");
922 }
923 }
924 printf((char const*)tail);
925 }
926 #endif
927
packet_trap
uint8_t packet_trap[MAX_TRAPMSG_LEN]
Definition: snmp.c:56
MAX_SNMPMSG_LEN
#define MAX_SNMPMSG_LEN
Definition: snmp.h:14
snmp.h
tlvStructType::len
int32_t len
Definition: snmp.h:95
parseCommunity
int32_t parseCommunity()
Definition: snmp.c:644
dataEntryType::intval
uint32_t intval
Definition: snmp.h:81
SET_REQUEST
#define SET_REQUEST
Definition: snmp.h:32
SOCK_UDP
#define SOCK_UDP
UDP socket.
Definition: w5100.h:982
INVALID_ENTRY_ID
#define INVALID_ENTRY_ID
Definition: snmp.h:22
HTONL
#define HTONL(x)
Definition: snmp.h:67
INVALID_DATA_TYPE
#define INVALID_DATA_TYPE
Definition: snmp.h:23
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
initial_Trap
void initial_Trap(uint8_t *managerIP, uint8_t *agentIP)
Definition: snmp_custom.c:137
snmpd_init
void snmpd_init(uint8_t *managerIP, uint8_t *agentIP, uint8_t sn_agent, uint8_t sn_trap)
Definition: snmp.c:100
messageStruct
Definition: snmp.h:87
dataEntryType::dataType
uint8_t dataType
Definition: snmp.h:77
ipToByteArray
void ipToByteArray(int8_t *ip, uint8_t *pDes)
Definition: snmp.c:717
maxData
const int32_t maxData
Definition: snmp_custom.c:94
SNMP_SUCCESS
#define SNMP_SUCCESS
Definition: snmp.h:18
SNMP_V1
#define SNMP_V1
Definition: snmp.h:10
VALID_REQUEST
#define VALID_REQUEST(x)
Definition: snmp.h:35
SNMPDTYPE_TIME_TICKS
#define SNMPDTYPE_TIME_TICKS
Definition: snmp.h:47
PORT_SNMP_AGENT
#define PORT_SNMP_AGENT
Definition: snmp.h:7
COPY_SEGMENT
#define COPY_SEGMENT(x)
Definition: snmp.h:59
errorIndex
uint8_t errorIndex
Definition: snmp.c:57
dataEntryType::octetstring
uint8_t octetstring[MAX_STRING]
Definition: snmp.h:80
SNMPDTYPE_OCTET_STRING
#define SNMPDTYPE_OCTET_STRING
Definition: snmp.h:39
parseSequenceOf
int32_t parseSequenceOf(int32_t reqType)
Definition: snmp.c:568
NO_SUCH_NAME
#define NO_SUCH_NAME
Definition: snmp.h:25
dataEntryType
Definition: snmp.h:74
errorStatus
uint8_t errorStatus
Definition: snmp.c:57
snmpData
dataEntryType snmpData[]
Definition: snmp_custom.c:18
OID_NOT_FOUND
#define OID_NOT_FOUND
Definition: snmp.h:19
GET_RESPONSE
#define GET_RESPONSE
Definition: snmp.h:31
parseTLV
int32_t parseTLV(const uint8_t *msg, int32_t index, tlvStructType *tlv)
Definition: snmp.c:410
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
parseLength
int32_t parseLength(const uint8_t *msg, int32_t *len)
Definition: snmp.c:386
dumpCode
void dumpCode(uint8_t *header, uint8_t *tail, uint8_t *buff, int32_t len)
Definition: snmp.c:889
makeTrapVariableBindings
int32_t makeTrapVariableBindings(dataEntryType *oid_data, void *ptr, uint32_t *len)
Definition: snmp.c:734
SNMP_time_handler
void SNMP_time_handler(void)
Definition: snmp.c:72
SNMPDTYPE_OBJ_ID
#define SNMPDTYPE_OBJ_ID
Definition: snmp.h:41
snmp_custom.h
GET_NEXT_REQUEST
#define GET_NEXT_REQUEST
Definition: snmp.h:30
initTable
void initTable()
Definition: snmp_custom.c:96
parseSequence
int32_t parseSequence(int32_t reqType, int32_t index)
Definition: snmp.c:546
SOCK_CLOSED
#define SOCK_CLOSED
Closed.
Definition: w5100.h:893
Sn_MR_UDP
#define Sn_MR_UDP
UDP.
Definition: w5100.h:654
snmpd_run
int32_t snmpd_run(void)
Definition: snmp.c:145
dataEntryType::oidlen
uint8_t oidlen
Definition: snmp.h:75
SNMPDTYPE_INTEGER
#define SNMPDTYPE_INTEGER
Definition: snmp.h:38
parseVersion
int32_t parseVersion()
Definition: snmp.c:674
request_msg
struct messageStruct request_msg
Definition: snmp.c:45
dataEntryType::getfunction
void(* getfunction)(void *, uint8_t *)
Definition: snmp.h:83
parseSNMPMessage
int32_t parseSNMPMessage()
Definition: snmp.c:694
currentUptime
void currentUptime(void *ptr, uint8_t *len)
Definition: snmp.c:63
getValue
int32_t getValue(uint8_t *vptr, int32_t vlen)
Definition: snmp.c:240
COMMUNITY_SIZE
#define COMMUNITY_SIZE
Definition: snmp_custom.h:18
SNMPDTYPE_COUNTER
#define SNMPDTYPE_COUNTER
Definition: snmp.h:45
dataEntryType::oid
uint8_t oid[MAX_OID]
Definition: snmp.h:76
setEntry
int32_t setEntry(int32_t id, void *val, int32_t vlen, uint8_t dataType, int32_t index)
Definition: snmp.c:331
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
GET_REQUEST
#define GET_REQUEST
Definition: snmp.h:29
MAX_TRAPMSG_LEN
#define MAX_TRAPMSG_LEN
Definition: snmp.h:15
sendto
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.
Definition: socket.c:489
getOID
int32_t getOID(int32_t id, uint8_t *oid, uint8_t *len)
Definition: snmp.c:223
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
tlvStructType::vstart
int32_t vstart
Definition: snmp.h:96
PORT_SNMP_TRAP
#define PORT_SNMP_TRAP
Definition: snmp.h:8
messageStruct::len
int32_t len
Definition: snmp.h:89
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
dataEntryType::u
union dataEntryType::@7 u
parseVarBind
int32_t parseVarBind(int32_t reqType, int32_t index)
Definition: snmp.c:462
dataEntryType::dataLen
uint8_t dataLen
Definition: snmp.h:78
SNMPDTYPE_SEQUENCE_OF
#define SNMPDTYPE_SEQUENCE_OF
Definition: snmp.h:43
snmp_sendTrap
int32_t snmp_sendTrap(uint8_t *managerIP, uint8_t *agentIP, int8_t *community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count,...)
Definition: snmp.c:795
response_msg
struct messageStruct response_msg
Definition: snmp.c:46
insertRespLen
void insertRespLen(int32_t reqStart, int32_t respStart, int32_t size)
Definition: snmp.c:437
SNMPDTYPE_SEQUENCE
#define SNMPDTYPE_SEQUENCE
Definition: snmp.h:42
tlvStructType::start
int32_t start
Definition: snmp.h:94
COMMUNITY
#define COMMUNITY
Definition: snmp_custom.h:17
_WIZCHIP_SOCK_NUM_
#define _WIZCHIP_SOCK_NUM_
The count of independant socket of WIZCHIP.
Definition: wizchip_conf.h:212
dataEntryType::setfunction
void(* setfunction)(int32_t)
Definition: snmp.h:84
messageStruct::buffer
uint8_t buffer[MAX_SNMPMSG_LEN]
Definition: snmp.h:88
tlvStructType
Definition: snmp.h:93
getEntry
int32_t getEntry(int32_t id, uint8_t *dataType, void *ptr, int32_t *len)
Definition: snmp.c:255
SNMPDTYPE_GAUGE
#define SNMPDTYPE_GAUGE
Definition: snmp.h:46
messageStruct::index
int32_t index
Definition: snmp.h:90
tlvStructType::nstart
int32_t nstart
Definition: snmp.h:97
findEntry
int32_t findEntry(uint8_t *oid, int32_t len)
Definition: snmp.c:207
BAD_VALUE
#define BAD_VALUE
Definition: snmp.h:26
socket.h
SOCKET APIs Header file.
parseRequest
int32_t parseRequest()
Definition: snmp.c:594
snmp_tick_10ms
volatile uint32_t snmp_tick_10ms
Definition: snmp.c:50
getSNMPTimeTick
uint32_t getSNMPTimeTick(void)
Definition: snmp.c:78


ioLibrary: Internet/SNMP/snmp.h Source File

  • Internet
  • SNMP
snmp.h
Go to the documentation of this file.
1 #ifndef _SNMP_H_
2 #define _SNMP_H_
3
4 // SNMP Debug Message (dump) Enable
5 #define _SNMP_DEBUG_
6
7 #define PORT_SNMP_AGENT 161
8 #define PORT_SNMP_TRAP 162
9
10 #define SNMP_V1 0
11
12 #define MAX_OID 12
13 #define MAX_STRING 64
14 #define MAX_SNMPMSG_LEN 512
15 #define MAX_TRAPMSG_LEN 512
16
17 // SNMP Error code
18 #define SNMP_SUCCESS 0
19 #define OID_NOT_FOUND -1
20 #define TABLE_FULL -2
21 #define ILLEGAL_LENGTH -3
22 #define INVALID_ENTRY_ID -4
23 #define INVALID_DATA_TYPE -5
24
25 #define NO_SUCH_NAME 2
26 #define BAD_VALUE 3
27
28 // SNMPv1 Commands
29 #define GET_REQUEST 0xa0
30 #define GET_NEXT_REQUEST 0xa1
31 #define GET_RESPONSE 0xa2
32 #define SET_REQUEST 0xa3
33
34 // Macros: SNMPv1 request validation checker
35 #define VALID_REQUEST(x) ((x == GET_REQUEST) || (x == GET_NEXT_REQUEST) || (x == SET_REQUEST))
36
37 // SNMPv1 Return Types
38 #define SNMPDTYPE_INTEGER 0x02
39 #define SNMPDTYPE_OCTET_STRING 0x04
40 #define SNMPDTYPE_NULL_ITEM 0x05
41 #define SNMPDTYPE_OBJ_ID 0x06
42 #define SNMPDTYPE_SEQUENCE 0x30
43 #define SNMPDTYPE_SEQUENCE_OF SNMPDTYPE_SEQUENCE
44
45 #define SNMPDTYPE_COUNTER 0x41
46 #define SNMPDTYPE_GAUGE 0x42
47 #define SNMPDTYPE_TIME_TICKS 0x43
48 #define SNMPDTYPE_OPAQUE 0x44
49
50 // SNMP Trap: Standard Trap Types (Generic)
51 #define SNMPTRAP_COLDSTART 0x00 // Generic trap-type 0: Cold Start
52 #define SNMPTRAP_WARMSTART 0x01 // Generic trap-type 1: Warm Start
53 #define SNMPTRAP_LINKDOWN 0x02 // Generic trap-type 2: Link Down
54 #define SNMPTRAP_LINKUP 0x03 // Generic trap-type 3: Link Up
55 #define SNMPTRAP_AUTHENTICATION 0x04 // Generic trap-type 4: Authentication Failure
56 #define SNMPTRAP_EGPNEIGHBORLOSS 0x05 // Generic trap-type 5: EGP Neighbor Loss
57
58 // Macros
59 #define COPY_SEGMENT(x) \
60 { \
61 request_msg.index += seglen; \
62 memcpy(&response_msg.buffer[response_msg.index], &request_msg.buffer[x.start], seglen ); \
63 response_msg.index += seglen; \
64 }
65
66 #ifndef HTONL
67 #define HTONL(x) \
68 ((((x) >> 24) & 0x000000ff) | \
69 (((x) >> 8) & 0x0000ff00) | \
70 (((x) << 8) & 0x00ff0000) | \
71 (((x) << 24) & 0xff000000))
72 #endif
73
74 typedef struct {
75 uint8_t oidlen;
76 uint8_t oid[MAX_OID];
77 uint8_t dataType;
78 uint8_t dataLen;
79 union {
80 uint8_t octetstring[MAX_STRING];
81 uint32_t intval;
82 } u;
83 void (*getfunction)(void *, uint8_t *);
84 void (*setfunction)(int32_t);
85 } dataEntryType;
86
87 struct messageStruct {
88 uint8_t buffer[MAX_SNMPMSG_LEN];
89 int32_t len;
90 int32_t index;
91 };
92
93 typedef struct {
94 int32_t start; /* Absolute Index of the TLV */
95 int32_t len; /* The L value of the TLV */
96 int32_t vstart; /* Absolute Index of this TLV's Value */
97 int32_t nstart; /* Absolute Index of the next TLV */
98 } tlvStructType;
99
100
101 /********************************************************************************************/
102 /* SNMP : Functions */
103 /********************************************************************************************/
104 // SNMP Main functions
105 void snmpd_init(uint8_t * managerIP, uint8_t * agentIP, uint8_t sn_agent, uint8_t sn_trap);
106 int32_t snmpd_run(void);
107 int32_t snmp_sendTrap(uint8_t * managerIP, uint8_t * agentIP, int8_t* community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count, ...);
108
109 // SNMP Time handler functions
110 void SNMP_time_handler(void);
111 uint32_t getSNMPTimeTick(void);
112 void currentUptime(void *ptr, uint8_t *len);
113
114 #endif
MAX_SNMPMSG_LEN
#define MAX_SNMPMSG_LEN
Definition: snmp.h:14
tlvStructType::len
int32_t len
Definition: snmp.h:95
dataEntryType::intval
uint32_t intval
Definition: snmp.h:81
snmpd_init
void snmpd_init(uint8_t *managerIP, uint8_t *agentIP, uint8_t sn_agent, uint8_t sn_trap)
Definition: snmp.c:100
messageStruct
Definition: snmp.h:87
dataEntryType::dataType
uint8_t dataType
Definition: snmp.h:77
MAX_STRING
#define MAX_STRING
Definition: snmp.h:13
dataEntryType
Definition: snmp.h:74
snmpd_run
int32_t snmpd_run(void)
Definition: snmp.c:145
currentUptime
void currentUptime(void *ptr, uint8_t *len)
Definition: snmp.c:63
dataEntryType::oidlen
uint8_t oidlen
Definition: snmp.h:75
tlvStructType::vstart
int32_t vstart
Definition: snmp.h:96
messageStruct::len
int32_t len
Definition: snmp.h:89
dataEntryType::dataLen
uint8_t dataLen
Definition: snmp.h:78
snmp_sendTrap
int32_t snmp_sendTrap(uint8_t *managerIP, uint8_t *agentIP, int8_t *community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count,...)
Definition: snmp.c:795
tlvStructType::start
int32_t start
Definition: snmp.h:94
messageStruct::buffer
uint8_t buffer[MAX_SNMPMSG_LEN]
Definition: snmp.h:88
tlvStructType
Definition: snmp.h:93
MAX_OID
#define MAX_OID
Definition: snmp.h:12
getSNMPTimeTick
uint32_t getSNMPTimeTick(void)
Definition: snmp.c:78
messageStruct::index
int32_t index
Definition: snmp.h:90
tlvStructType::nstart
int32_t nstart
Definition: snmp.h:97
SNMP_time_handler
void SNMP_time_handler(void)
Definition: snmp.c:72


ioLibrary: Internet/SNMP/snmp_custom.c Source File

  • Internet
  • SNMP
snmp_custom.c
Go to the documentation of this file.
1
2 /********************************************************************************************
3 * SNMP : User Customization Part
4 * - OID Registration
5 * - User defined functions for OID related
6 * + Integer value, String
7 * + I/O control / Chip registers
8 * + Network Informations
9 * + Etc.
10 *
11 *********************************************************************************************/
12 #include "snmp_custom.h"
13
14 #ifdef _USE_WIZNET_W5500_EVB_
15 #include "board.h"
16 #endif
17
18 dataEntryType snmpData[] =
19 {
20 // System MIB
21 // SysDescr Entry
22 {8, {0x2b, 6, 1, 2, 1, 1, 1, 0},
23 SNMPDTYPE_OCTET_STRING, 30, {"WIZnet Embedded SNMP Agent"},
24 NULL, NULL},
25
26 // SysObjectID Entry
27 {8, {0x2b, 6, 1, 2, 1, 1, 2, 0},
28 SNMPDTYPE_OBJ_ID, 8, {"\x2b\x06\x01\x02\x01\x01\x02\x00"},
29 NULL, NULL},
30
31 // SysUptime Entry
32 {8, {0x2b, 6, 1, 2, 1, 1, 3, 0},
33 SNMPDTYPE_TIME_TICKS, 0, {""},
34 currentUptime, NULL},
35
36 // sysContact Entry
37 {8, {0x2b, 6, 1, 2, 1, 1, 4, 0},
38 SNMPDTYPE_OCTET_STRING, 30, {"http://www.wizwiki.net/forum"},
39 NULL, NULL},
40
41 // sysName Entry
42 {8, {0x2b, 6, 1, 2, 1, 1, 5, 0},
43 SNMPDTYPE_OCTET_STRING, 30, {"http://www.wiznet.co.kr"},
44 NULL, NULL},
45
46 // Location Entry
47 {8, {0x2b, 6, 1, 2, 1, 1, 6, 0},
48 SNMPDTYPE_OCTET_STRING, 30, {"4F Humax Village"},
49 NULL, NULL},
50
51 // SysServices
52 {8, {0x2b, 6, 1, 2, 1, 1, 7, 0},
53 SNMPDTYPE_INTEGER, 4, {""},
54 NULL, NULL},
55
56 #ifdef _USE_WIZNET_W5500_EVB_
57 // Get the WIZnet W5500-EVB LED Status
58 {8, {0x2b, 6, 1, 4, 1, 6, 1, 0},
59 SNMPDTYPE_OCTET_STRING, 40, {""},
60 get_LEDStatus_all, NULL},
61
62 // Set the LED_R (RGB LED)
63 {8, {0x2b, 6, 1, 4, 1, 6, 1, 1},
64 SNMPDTYPE_INTEGER, 4, {""},
65 NULL, set_LEDStatus_R},
66
67 // Set the LED_G (RGB LED)
68 {8, {0x2b, 6, 1, 4, 1, 6, 1, 2},
69 SNMPDTYPE_INTEGER, 4, {""},
70 NULL, set_LEDStatus_G},
71
72 // Set the LED_B (RGB LED)
73 {8, {0x2b, 6, 1, 4, 1, 6, 1, 3},
74 SNMPDTYPE_INTEGER, 4, {""},
75 NULL, set_LEDStatus_B},
76 #endif
77
78 // OID Test #1 (long-length OID example, 19865)
79 {0x0a, {0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0x9b, 0x19, 0x01, 0x00},
80 SNMPDTYPE_OCTET_STRING, 30, {"long-length OID Test #1"},
81 NULL, NULL},
82
83 // OID Test #2 (long-length OID example, 22210)
84 {0x0a, {0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0xad, 0x42, 0x01, 0x00},
85 SNMPDTYPE_OCTET_STRING, 35, {"long-length OID Test #2"},
86 NULL, NULL},
87
88 // OID Test #2: SysObjectID Entry
89 {0x0a, {0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0xad, 0x42, 0x02, 0x00},
90 SNMPDTYPE_OBJ_ID, 0x0a, {"\x2b\x06\x01\x04\x01\x81\xad\x42\x02\x00"},
91 NULL, NULL},
92 };
93
94 const int32_t maxData = (sizeof(snmpData) / sizeof(dataEntryType));
95
96 void initTable()
97 {
98 // Example integer value for [OID 1.3.6.1.2.1.1.7.0]
99 snmpData[6].u.intval = -5;
100
101 }
102
103
104 // W5500-EVB: LED Control ///////////////////////////////////////////////////////////////////////////
105 #ifdef _USE_WIZNET_W5500_EVB_
106 void get_LEDStatus_all(void *ptr, uint8_t *len)
107 {
108 uint8_t led_status[3] = {0, };
109
110 led_status[LED_R] = (uint8_t)Board_LED_Test(LED_R);
111 led_status[LED_G] = (uint8_t)Board_LED_Test(LED_G);
112 led_status[LED_B] = (uint8_t)Board_LED_Test(LED_B);
113
114 *len = sprintf((char *)ptr, "LED R [%s] / G [%s] / B [%s]", led_status[LED_R]?"On":"Off", led_status[LED_G]?"On":"Off", led_status[LED_B]?"On":"Off");
115 }
116
117 void set_LEDStatus_R(int32_t val)
118 {
119 if(val == 0) Board_LED_Set(LED_R, false);
120 else Board_LED_Set(LED_R, true);
121 }
122
123 void set_LEDStatus_G(int32_t val)
124 {
125 if(val == 0) Board_LED_Set(LED_G, false);
126 else Board_LED_Set(LED_G, true);
127 }
128
129 void set_LEDStatus_B(int32_t val)
130 {
131 if(val == 0) Board_LED_Set(LED_B, false);
132 else Board_LED_Set(LED_B, true);
133 }
134 #endif
135
137 void initial_Trap(uint8_t * managerIP, uint8_t * agentIP)
138 {
139 // SNMP Trap: WarmStart(1) Trap
140 {
141 dataEntryType enterprise_oid = {0x0a, {0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0x9b, 0x19, 0x01, 0x00},
142 SNMPDTYPE_OBJ_ID, 0x0a, {"\x2b\x06\x01\x04\x01\x81\x9b\x19\x10\x00"}, NULL, NULL};
143 // Generic Trap: warmStart COMMUNITY
144 snmp_sendTrap(managerIP, agentIP, (void *)COMMUNITY, enterprise_oid, SNMPTRAP_WARMSTART, 0, 0);
145 }
146
147 }
dataEntryType::intval
uint32_t intval
Definition: snmp.h:81
initial_Trap
void initial_Trap(uint8_t *managerIP, uint8_t *agentIP)
Definition: snmp_custom.c:137
maxData
const int32_t maxData
Definition: snmp_custom.c:94
SNMPDTYPE_TIME_TICKS
#define SNMPDTYPE_TIME_TICKS
Definition: snmp.h:47
SNMPDTYPE_OCTET_STRING
#define SNMPDTYPE_OCTET_STRING
Definition: snmp.h:39
dataEntryType
Definition: snmp.h:74
snmpData
dataEntryType snmpData[]
Definition: snmp_custom.c:18
SNMPDTYPE_OBJ_ID
#define SNMPDTYPE_OBJ_ID
Definition: snmp.h:41
snmp_custom.h
initTable
void initTable()
Definition: snmp_custom.c:96
SNMPDTYPE_INTEGER
#define SNMPDTYPE_INTEGER
Definition: snmp.h:38
currentUptime
void currentUptime(void *ptr, uint8_t *len)
Definition: snmp.c:63
SNMPTRAP_WARMSTART
#define SNMPTRAP_WARMSTART
Definition: snmp.h:52
dataEntryType::u
union dataEntryType::@7 u
snmp_sendTrap
int32_t snmp_sendTrap(uint8_t *managerIP, uint8_t *agentIP, int8_t *community, dataEntryType enterprise_oid, uint32_t genericTrap, uint32_t specificTrap, uint32_t va_count,...)
Definition: snmp.c:795
COMMUNITY
#define COMMUNITY
Definition: snmp_custom.h:17


ioLibrary: Internet/SNMP/snmp_custom.h Source File

  • Internet
  • SNMP
snmp_custom.h
Go to the documentation of this file.
1 #ifndef _SNMP_CUSTOM_H_
2 #define _SNMP_CUSTOM_H_
3
4 #include <stdio.h>
5 #include <string.h>
6 #include <stdarg.h>
7 #include <stdint.h>
8
9 #include "snmp.h"
10
11 extern dataEntryType snmpData[];
12 extern const int32_t maxData;
13
14 // Define for using W5500-EVB: H/W Dependency (e.g., LEDs...)
15 //#define _USE_WIZNET_W5500_EVB_
16
17 #define COMMUNITY "public\0"
18 #define COMMUNITY_SIZE (strlen(COMMUNITY))
19
20 /* Predefined function: Response value control */
21 void initTable();
22
23 /* User defined functions: LED control examples */
24 #ifdef _USE_WIZNET_W5500_EVB_
25 void get_LEDStatus_all(void *ptr, uint8_t *len);
26 void set_LEDStatus_R(int32_t val);
27 void set_LEDStatus_G(int32_t val);
28 void set_LEDStatus_B(int32_t val);
29 #endif
30 /* SNMP Trap: warmStart(1) */
31 void initial_Trap(uint8_t * managerIP, uint8_t * agentIP);
32
33 #endif
snmp.h
snmpData
dataEntryType snmpData[]
Definition: snmp_custom.c:18
dataEntryType
Definition: snmp.h:74
initTable
void initTable()
Definition: snmp_custom.c:96
maxData
const int32_t maxData
Definition: snmp_custom.c:94
initial_Trap
void initial_Trap(uint8_t *managerIP, uint8_t *agentIP)
Definition: snmp_custom.c:137


ioLibrary: Internet/SNTP/sntp.c Source File

  • Internet
  • SNTP
sntp.c
Go to the documentation of this file.
1 /*
2 * sntp.c
3 *
4 * Created on: 2014. 12. 15.
5 * Author: Administrator
6 */
7
8
9 #include <string.h>
10
11 #include "sntp.h"
12 #include "socket.h"
13
14 ntpformat NTPformat;
15 datetime Nowdatetime;
16 uint8_t ntpmessage[48];
17 uint8_t *data_buf;
18 uint8_t NTP_SOCKET;
19 uint8_t time_zone;
20 uint16_t ntp_retry_cnt=0; //counting the ntp retry number
21
22 /*
23 00)UTC-12:00 Baker Island, Howland Island (both uninhabited)
24 01) UTC-11:00 American Samoa, Samoa
25 02) UTC-10:00 (Summer)French Polynesia (most), United States (Aleutian Islands, Hawaii)
26 03) UTC-09:30 Marquesas Islands
27 04) UTC-09:00 Gambier Islands;(Summer)United States (most of Alaska)
28 05) UTC-08:00 (Summer)Canada (most of British Columbia), Mexico (Baja California)
29 06) UTC-08:00 United States (California, most of Nevada, most of Oregon, Washington (state))
30 07) UTC-07:00 Mexico (Sonora), United States (Arizona); (Summer)Canada (Alberta)
31 08) UTC-07:00 Mexico (Chihuahua), United States (Colorado)
32 09) UTC-06:00 Costa Rica, El Salvador, Ecuador (Galapagos Islands), Guatemala, Honduras
33 10) UTC-06:00 Mexico (most), Nicaragua;(Summer)Canada (Manitoba, Saskatchewan), United States (Illinois, most of Texas)
34 11) UTC-05:00 Colombia, Cuba, Ecuador (continental), Haiti, Jamaica, Panama, Peru
35 12) UTC-05:00 (Summer)Canada (most of Ontario, most of Quebec)
36 13) UTC-05:00 United States (most of Florida, Georgia, Massachusetts, most of Michigan, New York, North Carolina, Ohio, Washington D.C.)
37 14) UTC-04:30 Venezuela
38 15) UTC-04:00 Bolivia, Brazil (Amazonas), Chile (continental), Dominican Republic, Canada (Nova Scotia), Paraguay,
39 16) UTC-04:00 Puerto Rico, Trinidad and Tobago
40 17) UTC-03:30 Canada (Newfoundland)
41 18) UTC-03:00 Argentina; (Summer) Brazil (Brasilia, Rio de Janeiro, Sao Paulo), most of Greenland, Uruguay
42 19) UTC-02:00 Brazil (Fernando de Noronha), South Georgia and the South Sandwich Islands
43 20) UTC-01:00 Portugal (Azores), Cape Verde
44 21) UTC&#177;00:00 Cote d'Ivoire, Faroe Islands, Ghana, Iceland, Senegal; (Summer) Ireland, Portugal (continental and Madeira)
45 22) UTC&#177;00:00 Spain (Canary Islands), Morocco, United Kingdom
46 23) UTC+01:00 Angola, Cameroon, Nigeria, Tunisia; (Summer)Albania, Algeria, Austria, Belgium, Bosnia and Herzegovina,
47 24) UTC+01:00 Spain (continental), Croatia, Czech Republic, Denmark, Germany, Hungary, Italy, Kinshasa, Kosovo,
48 25) UTC+01:00 Macedonia, France (metropolitan), the Netherlands, Norway, Poland, Serbia, Slovakia, Slovenia, Sweden, Switzerland
49 26) UTC+02:00 Libya, Egypt, Malawi, Mozambique, South Africa, Zambia, Zimbabwe, (Summer)Bulgaria, Cyprus, Estonia,
50 27) UTC+02:00 Finland, Greece, Israel, Jordan, Latvia, Lebanon, Lithuania, Moldova, Palestine, Romania, Syria, Turkey, Ukraine
51 28) UTC+03:00 Belarus, Djibouti, Eritrea, Ethiopia, Iraq, Kenya, Madagascar, Russia (Kaliningrad Oblast), Saudi Arabia,
52 29) UTC+03:00 South Sudan, Sudan, Somalia, South Sudan, Tanzania, Uganda, Yemen
53 30) UTC+03:30 (Summer)Iran
54 31) UTC+04:00 Armenia, Azerbaijan, Georgia, Mauritius, Oman, Russia (European), Seychelles, United Arab Emirates
55 32) UTC+04:30 Afghanistan
56 33) UTC+05:00 Kazakhstan (West), Maldives, Pakistan, Uzbekistan
57 34) UTC+05:30 India, Sri Lanka
58 35) UTC+05:45 Nepal
59 36) UTC+06:00 Kazakhstan (most), Bangladesh, Russia (Ural: Sverdlovsk Oblast, Chelyabinsk Oblast)
60 37) UTC+06:30 Cocos Islands, Myanmar
61 38) UTC+07:00 Jakarta, Russia (Novosibirsk Oblast), Thailand, Vietnam
62 39) UTC+08:00 China, Hong Kong, Russia (Krasnoyarsk Krai), Malaysia, Philippines, Singapore, Taiwan, most of Mongolia, Western Australia
63 40) UTC+09:00 Korea, East Timor, Russia (Irkutsk Oblast), Japan
64 41) UTC+09:30 Australia (Northern Territory);(Summer)Australia (South Australia))
65 42) UTC+10:00 Russia (Zabaykalsky Krai); (Summer)Australia (New South Wales, Queensland, Tasmania, Victoria)
66 43) UTC+10:30 Lord Howe Island
67 44) UTC+11:00 New Caledonia, Russia (Primorsky Krai), Solomon Islands
68 45) UTC+11:30 Norfolk Island
69 46) UTC+12:00 Fiji, Russia (Kamchatka Krai);(Summer)New Zealand
70 47) UTC+12:45 (Summer)New Zealand
71 48) UTC+13:00 Tonga
72 49) UTC+14:00 Kiribati (Line Islands)
73 */
74 void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
75 {
76 tstamp seconds = 0;
77 uint8_t i=0;
78 for (i = 0; i < 4; i++)
79 {
80 seconds = (seconds << 8) | buf[idx + i];
81 }
82 switch (time_zone)
83 {
84 case 0:
85 seconds -= 12*3600;
86 break;
87 case 1:
88 seconds -= 11*3600;
89 break;
90 case 2:
91 seconds -= 10*3600;
92 break;
93 case 3:
94 seconds -= (9*3600+30*60);
95 break;
96 case 4:
97 seconds -= 9*3600;
98 break;
99 case 5:
100 case 6:
101 seconds -= 8*3600;
102 break;
103 case 7:
104 case 8:
105 seconds -= 7*3600;
106 break;
107 case 9:
108 case 10:
109 seconds -= 6*3600;
110 break;
111 case 11:
112 case 12:
113 case 13:
114 seconds -= 5*3600;
115 break;
116 case 14:
117 seconds -= (4*3600+30*60);
118 break;
119 case 15:
120 case 16:
121 seconds -= 4*3600;
122 break;
123 case 17:
124 seconds -= (3*3600+30*60);
125 break;
126 case 18:
127 seconds -= 3*3600;
128 break;
129 case 19:
130 seconds -= 2*3600;
131 break;
132 case 20:
133 seconds -= 1*3600;
134 break;
135 case 21: //ï¼?
136 case 22:
137 break;
138 case 23:
139 case 24:
140 case 25:
141 seconds += 1*3600;
142 break;
143 case 26:
144 case 27:
145 seconds += 2*3600;
146 break;
147 case 28:
148 case 29:
149 seconds += 3*3600;
150 break;
151 case 30:
152 seconds += (3*3600+30*60);
153 break;
154 case 31:
155 seconds += 4*3600;
156 break;
157 case 32:
158 seconds += (4*3600+30*60);
159 break;
160 case 33:
161 seconds += 5*3600;
162 break;
163 case 34:
164 seconds += (5*3600+30*60);
165 break;
166 case 35:
167 seconds += (5*3600+45*60);
168 break;
169 case 36:
170 seconds += 6*3600;
171 break;
172 case 37:
173 seconds += (6*3600+30*60);
174 break;
175 case 38:
176 seconds += 7*3600;
177 break;
178 case 39:
179 seconds += 8*3600;
180 break;
181 case 40:
182 seconds += 9*3600;
183 break;
184 case 41:
185 seconds += (9*3600+30*60);
186 break;
187 case 42:
188 seconds += 10*3600;
189 break;
190 case 43:
191 seconds += (10*3600+30*60);
192 break;
193 case 44:
194 seconds += 11*3600;
195 break;
196 case 45:
197 seconds += (11*3600+30*60);
198 break;
199 case 46:
200 seconds += 12*3600;
201 break;
202 case 47:
203 seconds += (12*3600+45*60);
204 break;
205 case 48:
206 seconds += 13*3600;
207 break;
208 case 49:
209 seconds += 14*3600;
210 break;
211
212 }
213
214 //calculation for date
215 calcdatetime(seconds);
216 }
217
218 void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf)
219 {
220 NTP_SOCKET = s;
221
222 NTPformat.dstaddr[0] = ntp_server[0];
223 NTPformat.dstaddr[1] = ntp_server[1];
224 NTPformat.dstaddr[2] = ntp_server[2];
225 NTPformat.dstaddr[3] = ntp_server[3];
226
227 time_zone = tz;
228
229 data_buf = buf;
230
231 uint8_t Flag;
232 NTPformat.leap = 0; /* leap indicator */
233 NTPformat.version = 4; /* version number */
234 NTPformat.mode = 3; /* mode */
235 NTPformat.stratum = 0; /* stratum */
236 NTPformat.poll = 0; /* poll interval */
237 NTPformat.precision = 0; /* precision */
238 NTPformat.rootdelay = 0; /* root delay */
239 NTPformat.rootdisp = 0; /* root dispersion */
240 NTPformat.refid = 0; /* reference ID */
241 NTPformat.reftime = 0; /* reference time */
242 NTPformat.org = 0; /* origin timestamp */
243 NTPformat.rec = 0; /* receive timestamp */
244 NTPformat.xmt = 1; /* transmit timestamp */
245
246 Flag = (NTPformat.leap<<6)+(NTPformat.version<<3)+NTPformat.mode; //one byte Flag
247 memcpy(ntpmessage,(void const*)(&Flag),1);
248 }
249
250 int8_t SNTP_run(datetime *time)
251 {
252 uint16_t RSR_len;
253 uint32_t destip = 0;
254 uint16_t destport;
255 uint16_t startindex = 40; //last 8-byte of data_buf[size is 48 byte] is xmt, so the startindex should be 40
256
257 switch(getSn_SR(NTP_SOCKET))
258 {
259 case SOCK_UDP:
260 if ((RSR_len = getSn_RX_RSR(NTP_SOCKET)) > 0)
261 {
262 if (RSR_len > MAX_SNTP_BUF_SIZE) RSR_len = MAX_SNTP_BUF_SIZE; // if Rx data size is lager than TX_RX_MAX_BUF_SIZE
263 recvfrom(NTP_SOCKET, data_buf, RSR_len, (uint8_t *)&destip, &destport);
264
265 get_seconds_from_ntp_server(data_buf,startindex);
266 time->yy = Nowdatetime.yy;
267 time->mo = Nowdatetime.mo;
268 time->dd = Nowdatetime.dd;
269 time->hh = Nowdatetime.hh;
270 time->mm = Nowdatetime.mm;
271 time->ss = Nowdatetime.ss;
272
273 ntp_retry_cnt=0;
274 close(NTP_SOCKET);
275
276 return 1;
277 }
278
279 if(ntp_retry_cnt<0xFFFF)
280 {
281 if(ntp_retry_cnt==0)//first send request, no need to wait
282 {
283 sendto(NTP_SOCKET,ntpmessage,sizeof(ntpmessage),NTPformat.dstaddr,ntp_port);
284 ntp_retry_cnt++;
285 }
286 else // send request again? it should wait for a while
287 {
288 if((ntp_retry_cnt % 0xFFF) == 0) //wait time
289 {
290 sendto(NTP_SOCKET,ntpmessage,sizeof(ntpmessage),NTPformat.dstaddr,ntp_port);
291 #ifdef _SNTP_DEBUG_
292 printf("ntp retry: %d\r\n", ntp_retry_cnt);
293 #endif
294 ntp_retry_cnt++;
295 }
296 }
297 }
298 else //ntp retry fail
299 {
300 ntp_retry_cnt=0;
301 #ifdef _SNTP_DEBUG_
302 printf("ntp retry failed!\r\n");
303 #endif
304 close(NTP_SOCKET);
305 }
306 break;
307 case SOCK_CLOSED:
308 socket(NTP_SOCKET,Sn_MR_UDP,ntp_port,0);
309 break;
310 }
311 // Return value
312 // 0 - failed / 1 - success
313 return 0;
314 }
315
316 void calcdatetime(tstamp seconds)
317 {
318 uint8_t yf=0;
319 tstamp n=0,d=0,total_d=0,rz=0;
320 uint16_t y=0,r=0,yr=0;
321 signed long long yd=0;
322
323 n = seconds;
324 total_d = seconds/(SECS_PERDAY);
325 d=0;
326 uint32_t p_year_total_sec=SECS_PERDAY*365;
327 uint32_t r_year_total_sec=SECS_PERDAY*366;
328 while(n>=p_year_total_sec)
329 {
330 if((EPOCH+r)%400==0 || ((EPOCH+r)%100!=0 && (EPOCH+r)%4==0))
331 {
332 n = n -(r_year_total_sec);
333 d = d + 366;
334 }
335 else
336 {
337 n = n - (p_year_total_sec);
338 d = d + 365;
339 }
340 r+=1;
341 y+=1;
342
343 }
344
345 y += EPOCH;
346
347 Nowdatetime.yy = y;
348
349 yd=0;
350 yd = total_d - d;
351
352 yf=1;
353 while(yd>=28)
354 {
355
356 if(yf==1 || yf==3 || yf==5 || yf==7 || yf==8 || yf==10 || yf==12)
357 {
358 yd -= 31;
359 if(yd<0)break;
360 rz += 31;
361 }
362
363 if (yf==2)
364 {
365 if (y%400==0 || (y%100!=0 && y%4==0))
366 {
367 yd -= 29;
368 if(yd<0)break;
369 rz += 29;
370 }
371 else
372 {
373 yd -= 28;
374 if(yd<0)break;
375 rz += 28;
376 }
377 }
378 if(yf==4 || yf==6 || yf==9 || yf==11 )
379 {
380 yd -= 30;
381 if(yd<0)break;
382 rz += 30;
383 }
384 yf += 1;
385
386 }
387 Nowdatetime.mo=yf;
388 yr = total_d-d-rz;
389
390 yr += 1;
391
392 Nowdatetime.dd=yr;
393
394 //calculation for time
395 seconds = seconds%SECS_PERDAY;
396 Nowdatetime.hh = seconds/3600;
397 Nowdatetime.mm = (seconds%3600)/60;
398 Nowdatetime.ss = (seconds%3600)%60;
399
400 }
401
402 tstamp changedatetime_to_seconds(void)
403 {
404 tstamp seconds=0;
405 uint32_t total_day=0;
406 uint16_t i=0,run_year_cnt=0,l=0;
407
408 l = Nowdatetime.yy;//low
409
410
411 for(i=EPOCH;i<l;i++)
412 {
413 if((i%400==0) || ((i%100!=0) && (i%4==0)))
414 {
415 run_year_cnt += 1;
416 }
417 }
418
419 total_day=(l-EPOCH-run_year_cnt)*365+run_year_cnt*366;
420
421 for(i=1;i<=Nowdatetime.mo;i++)
422 {
423 if(i==5 || i==7 || i==10 || i==12)
424 {
425 total_day += 30;
426 }
427 if (i==3)
428 {
429 if (l%400==0 && l%100!=0 && l%4==0)
430 {
431 total_day += 29;
432 }
433 else
434 {
435 total_day += 28;
436 }
437 }
438 if(i==2 || i==4 || i==6 || i==8 || i==9 || i==11)
439 {
440 total_day += 31;
441 }
442 }
443
444 seconds = (total_day+Nowdatetime.dd-1)*24*3600;
445 seconds += Nowdatetime.ss;//seconds
446 seconds += Nowdatetime.mm*60;//minute
447 seconds += Nowdatetime.hh*3600;//hour
448
449 return seconds;
450 }
get_seconds_from_ntp_server
void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
Definition: sntp.c:74
_ntpformat::xmt
tstamp xmt
Definition: sntp.h:42
_ntpformat::mode
char mode
Definition: sntp.h:32
SOCK_UDP
#define SOCK_UDP
UDP socket.
Definition: w5100.h:982
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
time_zone
uint8_t time_zone
Definition: sntp.c:19
sntp.h
_ntpformat::rec
tstamp rec
Definition: sntp.h:41
_ntpformat
Definition: sntp.h:26
NTPformat
ntpformat NTPformat
Definition: sntp.c:14
SNTP_run
int8_t SNTP_run(datetime *time)
Definition: sntp.c:250
_ntpformat::reftime
tstamp reftime
Definition: sntp.h:39
_datetime::yy
uint16_t yy
Definition: sntp.h:49
ntp_port
#define ntp_port
Definition: sntp.h:57
SECS_PERDAY
#define SECS_PERDAY
Definition: sntp.h:58
_ntpformat::stratum
char stratum
Definition: sntp.h:33
_ntpformat::org
tstamp org
Definition: sntp.h:40
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
_ntpformat::dstaddr
uint8_t dstaddr[4]
Definition: sntp.h:29
_datetime::ss
uint8_t ss
Definition: sntp.h:54
_ntpformat::rootdisp
tdist rootdisp
Definition: sntp.h:37
SOCK_CLOSED
#define SOCK_CLOSED
Closed.
Definition: w5100.h:893
Sn_MR_UDP
#define Sn_MR_UDP
UDP.
Definition: w5100.h:654
_ntpformat::leap
char leap
Definition: sntp.h:31
_ntpformat::rootdelay
tdist rootdelay
Definition: sntp.h:36
MAX_SNTP_BUF_SIZE
#define MAX_SNTP_BUF_SIZE
maximum size of DNS buffer. */
Definition: sntp.h:19
calcdatetime
void calcdatetime(tstamp seconds)
Definition: sntp.c:316
Nowdatetime
datetime Nowdatetime
Definition: sntp.c:15
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
_datetime::mo
uint8_t mo
Definition: sntp.h:50
sendto
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.
Definition: socket.c:489
_ntpformat::version
char version
Definition: sntp.h:30
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
_ntpformat::refid
char refid
Definition: sntp.h:38
_datetime::hh
uint8_t hh
Definition: sntp.h:52
NTP_SOCKET
uint8_t NTP_SOCKET
Definition: sntp.c:18
data_buf
uint8_t * data_buf
Definition: sntp.c:17
_ntpformat::precision
s_char precision
Definition: sntp.h:35
tstamp
unsigned long long tstamp
Definition: sntp.h:23
changedatetime_to_seconds
tstamp changedatetime_to_seconds(void)
Definition: sntp.c:402
ntpmessage
uint8_t ntpmessage[48]
Definition: sntp.c:16
socket.h
SOCKET APIs Header file.
_datetime
Definition: sntp.h:47
ntp_retry_cnt
uint16_t ntp_retry_cnt
Definition: sntp.c:20
SNTP_init
void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf)
Definition: sntp.c:218
_datetime::dd
uint8_t dd
Definition: sntp.h:51
_ntpformat::poll
char poll
Definition: sntp.h:34
EPOCH
#define EPOCH
Definition: sntp.h:60
_datetime::mm
uint8_t mm
Definition: sntp.h:53


ioLibrary: Internet/SNTP/sntp.h Source File

  • Internet
  • SNTP
sntp.h
Go to the documentation of this file.
1 /*
2 * sntp.h
3 *
4 * Created on: 2014. 12. 15.
5 * Author: Administrator
6 */
7
8 #ifndef SNTP_H_
9 #define SNTP_H_
10
11 #include <stdint.h>
12
13 /*
14 * @brief Define it for Debug & Monitor DNS processing.
15 * @note If defined, it dependens on <stdio.h>
16 */
17 //#define _SNTP_DEBUG_
18
19 #define MAX_SNTP_BUF_SIZE sizeof(ntpformat)
20
21 /* for ntpclient */
22 typedef signed char s_char;
23 typedef unsigned long long tstamp;
24 typedef unsigned int tdist;
25
26 typedef struct _ntpformat
27 {
28
29 uint8_t dstaddr[4]; /* destination (local) address */
30 char version; /* version number */
31 char leap; /* leap indicator */
32 char mode; /* mode */
33 char stratum; /* stratum */
34 char poll; /* poll interval */
35 s_char precision; /* precision */
36 tdist rootdelay; /* root delay */
37 tdist rootdisp; /* root dispersion */
38 char refid; /* reference ID */
39 tstamp reftime; /* reference time */
40 tstamp org; /* origin timestamp */
41 tstamp rec; /* receive timestamp */
42 tstamp xmt; /* transmit timestamp */
43
44
45 } ntpformat;
46
47 typedef struct _datetime
48 {
49 uint16_t yy;
50 uint8_t mo;
51 uint8_t dd;
52 uint8_t hh;
53 uint8_t mm;
54 uint8_t ss;
55 } datetime;
56
57 #define ntp_port 123 //ntp server port number
58 #define SECS_PERDAY 86400UL // seconds in a day = 60*60*24
59 #define UTC_ADJ_HRS 9 // SEOUL : GMT+9
60 #define EPOCH 1900 // NTP start year
61
62 void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx);
63 void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf);
64 int8_t SNTP_run(datetime *time);
65 tstamp changedatetime_to_seconds(void);
66 void calcdatetime(tstamp seconds);
67
68 #endif /* SNTP_H_ */
_ntpformat::xmt
tstamp xmt
Definition: sntp.h:42
_ntpformat::mode
char mode
Definition: sntp.h:32
_ntpformat::rec
tstamp rec
Definition: sntp.h:41
_ntpformat
Definition: sntp.h:26
_ntpformat::reftime
tstamp reftime
Definition: sntp.h:39
_datetime::yy
uint16_t yy
Definition: sntp.h:49
_ntpformat::stratum
char stratum
Definition: sntp.h:33
_ntpformat::org
tstamp org
Definition: sntp.h:40
_ntpformat::dstaddr
uint8_t dstaddr[4]
Definition: sntp.h:29
_datetime::ss
uint8_t ss
Definition: sntp.h:54
_ntpformat::rootdisp
tdist rootdisp
Definition: sntp.h:37
SNTP_init
void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf)
Definition: sntp.c:218
_ntpformat::leap
char leap
Definition: sntp.h:31
_ntpformat::rootdelay
tdist rootdelay
Definition: sntp.h:36
ntpformat
struct _ntpformat ntpformat
s_char
signed char s_char
Definition: sntp.h:22
_datetime::mo
uint8_t mo
Definition: sntp.h:50
calcdatetime
void calcdatetime(tstamp seconds)
Definition: sntp.c:316
_ntpformat::version
char version
Definition: sntp.h:30
_ntpformat::refid
char refid
Definition: sntp.h:38
datetime
struct _datetime datetime
changedatetime_to_seconds
tstamp changedatetime_to_seconds(void)
Definition: sntp.c:402
tdist
unsigned int tdist
Definition: sntp.h:24
_datetime::hh
uint8_t hh
Definition: sntp.h:52
_ntpformat::precision
s_char precision
Definition: sntp.h:35
tstamp
unsigned long long tstamp
Definition: sntp.h:23
SNTP_run
int8_t SNTP_run(datetime *time)
Definition: sntp.c:250
_datetime
Definition: sntp.h:47
_datetime::dd
uint8_t dd
Definition: sntp.h:51
get_seconds_from_ntp_server
void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
Definition: sntp.c:74
_ntpformat::poll
char poll
Definition: sntp.h:34
_datetime::mm
uint8_t mm
Definition: sntp.h:53


ioLibrary: 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
66 static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,};
67
68 //M20150601 : For extern decleation
69 //static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,};
70 uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,};
71 //
72
73 #if _WIZCHIP_ == 5200
74 static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,};
75 #endif
76
77 //A20150601 : For integrating with W5300
78 #if _WIZCHIP_ == 5300
79 uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data()
80 #endif
81
82
83 #define CHECK_SOCKNUM() \
84 do{ \
85 if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \
86 }while(0); \
87
88 #define CHECK_SOCKMODE(mode) \
89 do{ \
90 if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \
91 }while(0); \
92
93 #define CHECK_SOCKINIT() \
94 do{ \
95 if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \
96 }while(0); \
97
98 #define CHECK_SOCKDATA() \
99 do{ \
100 if(len == 0) return SOCKERR_DATALEN; \
101 }while(0); \
102
103
104
105 int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
106 {
107 CHECK_SOCKNUM();
108 switch(protocol)
109 {
110 case Sn_MR_TCP :
111 {
112 //M20150601 : Fixed the warning - taddr will never be NULL
113 /*
114 uint8_t taddr[4];
115 getSIPR(taddr);
116 */
117 uint32_t taddr;
118 getSIPR((uint8_t*)&taddr);
119 if(taddr == 0) return SOCKERR_SOCKINIT;
120 }
121 case Sn_MR_UDP :
122 case Sn_MR_MACRAW :
123 case Sn_MR_IPRAW :
124 break;
125 #if ( _WIZCHIP_ < 5200 )
126 case Sn_MR_PPPoE :
127 break;
128 #endif
129 default :
130 return SOCKERR_SOCKMODE;
131 }
132 //M20150601 : For SF_TCP_ALIGN & W5300
133 //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG;
134 if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG;
135 #if _WIZCHIP_ == 5200
136 if(flag & 0x10) return SOCKERR_SOCKFLAG;
137 #endif
138
139 if(flag != 0)
140 {
141 switch(protocol)
142 {
143 case Sn_MR_TCP:
144 //M20150601 : For SF_TCP_ALIGN & W5300
145 #if _WIZCHIP_ == 5300
146 if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG;
147 #else
148 if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG;
149 #endif
150
151 break;
152 case Sn_MR_UDP:
153 if(flag & SF_IGMP_VER2)
154 {
155 if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG;
156 }
157 #if _WIZCHIP_ == 5500
158 if(flag & SF_UNI_BLOCK)
159 {
160 if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG;
161 }
162 #endif
163 break;
164 default:
165 break;
166 }
167 }
168 close(sn);
169 //M20150601
170 #if _WIZCHIP_ == 5300
171 setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) );
172 #else
173 setSn_MR(sn, (protocol | (flag & 0xF0)));
174 #endif
175 if(!port)
176 {
177 port = sock_any_port++;
178 if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM;
179 }
180 setSn_PORT(sn,port);
181 setSn_CR(sn,Sn_CR_OPEN);
182 while(getSn_CR(sn));
183 //A20150401 : For release the previous sock_io_mode
184 sock_io_mode &= ~(1 <<sn);
185 //
186 sock_io_mode |= ((flag & SF_IO_NONBLOCK) << sn);
187 sock_is_sending &= ~(1<<sn);
188 sock_remained_size[sn] = 0;
189 //M20150601 : repalce 0 with PACK_COMPLETED
190 //sock_pack_info[sn] = 0;
191 sock_pack_info[sn] = PACK_COMPLETED;
192 //
193 while(getSn_SR(sn) == SOCK_CLOSED);
194 return (int8_t)sn;
195 }
196
197 int8_t close(uint8_t sn)
198 {
199 CHECK_SOCKNUM();
200 //A20160426 : Applied the erratum 1 of W5300
201 #if (_WIZCHIP_ == 5300)
202 //M20160503 : Wrong socket parameter. s -> sn
203 //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) )
204 if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) )
205 {
206 uint8_t destip[4] = {0, 0, 0, 1};
207 // TODO
208 // You can wait for completing to sending data;
209 // wait about 1 second;
210 // if you have completed to send data, skip the code of erratum 1
211 // ex> wait_1s();
212 // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue;
213 //
214 //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~
215 //socket(s,Sn_MR_UDP,0x3000,0);
216 //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1).
217 setSn_MR(sn,Sn_MR_UDP);
218 setSn_PORTR(sn, 0x3000);
219 setSn_CR(sn,Sn_CR_OPEN);
220 while(getSn_CR(sn) != 0);
221 while(getSn_SR(sn) != SOCK_UDP);
222 sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1).
223 };
224 #endif
225 setSn_CR(sn,Sn_CR_CLOSE);
226 /* wait to process the command... */
227 while( getSn_CR(sn) );
228 /* clear all interrupt of the socket. */
229 setSn_IR(sn, 0xFF);
230 //A20150401 : Release the sock_io_mode of socket n.
231 sock_io_mode &= ~(1<<sn);
232 //
233 sock_is_sending &= ~(1<<sn);
234 sock_remained_size[sn] = 0;
235 sock_pack_info[sn] = 0;
236 while(getSn_SR(sn) != SOCK_CLOSED);
237 return SOCK_OK;
238 }
239
240 int8_t listen(uint8_t sn)
241 {
242 CHECK_SOCKNUM();
243 CHECK_SOCKMODE(Sn_MR_TCP);
244 CHECK_SOCKINIT();
245 setSn_CR(sn,Sn_CR_LISTEN);
246 while(getSn_CR(sn));
247 while(getSn_SR(sn) != SOCK_LISTEN)
248 {
249 close(sn);
250 return SOCKERR_SOCKCLOSED;
251 }
252 return SOCK_OK;
253 }
254
255
256 int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port)
257 {
258 CHECK_SOCKNUM();
259 CHECK_SOCKMODE(Sn_MR_TCP);
260 CHECK_SOCKINIT();
261 //M20140501 : For avoiding fatal error on memory align mismatched
262 //if( *((uint32_t*)addr) == 0xFFFFFFFF || *((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
263 {
264 uint32_t taddr;
265 taddr = ((uint32_t)addr[0] & 0x000000FF);
266 taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF);
267 taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF);
268 taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF);
269 if( taddr == 0xFFFFFFFF || taddr == 0) return SOCKERR_IPINVALID;
270 }
271 //
272
273 if(port == 0) return SOCKERR_PORTZERO;
274 setSn_DIPR(sn,addr);
275 setSn_DPORT(sn,port);
276 setSn_CR(sn,Sn_CR_CONNECT);
277 while(getSn_CR(sn));
278 if(sock_io_mode & (1<<sn)) return SOCK_BUSY;
279 while(getSn_SR(sn) != SOCK_ESTABLISHED)
280 {
281 if (getSn_IR(sn) & Sn_IR_TIMEOUT)
282 {
283 setSn_IR(sn, Sn_IR_TIMEOUT);
284 return SOCKERR_TIMEOUT;
285 }
286
287 if (getSn_SR(sn) == SOCK_CLOSED)
288 {
289 return SOCKERR_SOCKCLOSED;
290 }
291 }
292
293 return SOCK_OK;
294 }
295
296 int8_t disconnect(uint8_t sn)
297 {
298 CHECK_SOCKNUM();
299 CHECK_SOCKMODE(Sn_MR_TCP);
300 setSn_CR(sn,Sn_CR_DISCON);
301 /* wait to process the command... */
302 while(getSn_CR(sn));
303 sock_is_sending &= ~(1<<sn);
304 if(sock_io_mode & (1<<sn)) return SOCK_BUSY;
305 while(getSn_SR(sn) != SOCK_CLOSED)
306 {
307 if(getSn_IR(sn) & Sn_IR_TIMEOUT)
308 {
309 close(sn);
310 return SOCKERR_TIMEOUT;
311 }
312 }
313 return SOCK_OK;
314 }
315
316 int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
317 {
318 uint8_t tmp=0;
319 uint16_t freesize=0;
320
321 CHECK_SOCKNUM();
322 CHECK_SOCKMODE(Sn_MR_TCP);
323 CHECK_SOCKDATA();
324 tmp = getSn_SR(sn);
325 if(tmp != SOCK_ESTABLISHED && tmp != SOCK_CLOSE_WAIT) return SOCKERR_SOCKSTATUS;
326 if( sock_is_sending & (1<<sn) )
327 {
328 tmp = getSn_IR(sn);
329 if(tmp & Sn_IR_SENDOK)
330 {
331 setSn_IR(sn, Sn_IR_SENDOK);
332 //M20150401 : Typing Error
333 //#if _WZICHIP_ == 5200
334 #if _WIZCHIP_ == 5200
335 if(getSn_TX_RD(sn) != sock_next_rd[sn])
336 {
337 setSn_CR(sn,Sn_CR_SEND);
338 while(getSn_CR(sn));
339 return SOCK_BUSY;
340 }
341 #endif
342 sock_is_sending &= ~(1<<sn);
343 }
344 else if(tmp & Sn_IR_TIMEOUT)
345 {
346 close(sn);
347 return SOCKERR_TIMEOUT;
348 }
349 else return SOCK_BUSY;
350 }
351 freesize = getSn_TxMAX(sn);
352 if (len > freesize) len = freesize; // check size not to exceed MAX size.
353 while(1)
354 {
355 freesize = getSn_TX_FSR(sn);
356 tmp = getSn_SR(sn);
357 if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT))
358 {
359 close(sn);
360 return SOCKERR_SOCKSTATUS;
361 }
362 if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
363 if(len <= freesize) break;
364 }
365 wiz_send_data(sn, buf, len);
366 #if _WIZCHIP_ == 5200
367 sock_next_rd[sn] = getSn_TX_RD(sn) + len;
368 #endif
369
370 #if _WIZCHIP_ == 5300
371 setSn_TX_WRSR(sn,len);
372 #endif
373
374 setSn_CR(sn,Sn_CR_SEND);
375 /* wait to process the command... */
376 while(getSn_CR(sn));
377 sock_is_sending |= (1 << sn);
378 //M20150409 : Explicit Type Casting
379 //return len;
380 return (int32_t)len;
381 }
382
383
384 int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len)
385 {
386 uint8_t tmp = 0;
387 uint16_t recvsize = 0;
388 //A20150601 : For integarating with W5300
389 #if _WIZCHIP_ == 5300
390 uint8_t head[2];
391 uint16_t mr;
392 #endif
393 //
394 CHECK_SOCKNUM();
395 CHECK_SOCKMODE(Sn_MR_TCP);
396 CHECK_SOCKDATA();
397
398 recvsize = getSn_RxMAX(sn);
399 if(recvsize < len) len = recvsize;
400
401 //A20150601 : For Integrating with W5300
402 #if _WIZCHIP_ == 5300
403 //sock_pack_info[sn] = PACK_COMPLETED; // for clear
404 if(sock_remained_size[sn] == 0)
405 {
406 #endif
407 //
408 while(1)
409 {
410 recvsize = getSn_RX_RSR(sn);
411 tmp = getSn_SR(sn);
412 if (tmp != SOCK_ESTABLISHED)
413 {
414 if(tmp == SOCK_CLOSE_WAIT)
415 {
416 if(recvsize != 0) break;
417 else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn))
418 {
419 close(sn);
420 return SOCKERR_SOCKSTATUS;
421 }
422 }
423 else
424 {
425 close(sn);
426 return SOCKERR_SOCKSTATUS;
427 }
428 }
429 if((sock_io_mode & (1<<sn)) && (recvsize == 0)) return SOCK_BUSY;
430 if(recvsize != 0) break;
431 };
432 #if _WIZCHIP_ == 5300
433 }
434 #endif
435
436 //A20150601 : For integrating with W5300
437 #if _WIZCHIP_ == 5300
438 if((sock_remained_size[sn] == 0) || (getSn_MR(sn) & Sn_MR_ALIGN))
439 {
440 mr = getMR();
441 if((getSn_MR(sn) & Sn_MR_ALIGN)==0)
442 {
443 wiz_recv_data(sn,head,2);
444 if(mr & MR_FS)
445 recvsize = (((uint16_t)head[1]) << 8) | ((uint16_t)head[0]);
446 else
447 recvsize = (((uint16_t)head[0]) << 8) | ((uint16_t)head[1]);
448 sock_pack_info[sn] = PACK_FIRST;
449 }
450 sock_remained_size[sn] = recvsize;
451 }
452 if(len > sock_remained_size[sn]) len = sock_remained_size[sn];
453 recvsize = len;
454 if(sock_pack_info[sn] & PACK_FIFOBYTE)
455 {
456 *buf = sock_remained_byte[sn];
457 buf++;
458 sock_pack_info[sn] &= ~(PACK_FIFOBYTE);
459 recvsize -= 1;
460 sock_remained_size[sn] -= 1;
461 }
462 if(recvsize != 0)
463 {
464 wiz_recv_data(sn, buf, recvsize);
465 setSn_CR(sn,Sn_CR_RECV);
466 while(getSn_CR(sn));
467 }
468 sock_remained_size[sn] -= recvsize;
469 if(sock_remained_size[sn] != 0)
470 {
471 sock_pack_info[sn] |= PACK_REMAINED;
472 if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE;
473 }
474 else sock_pack_info[sn] = PACK_COMPLETED;
475 if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0;
476 //len = recvsize;
477 #else
478 if(recvsize < len) len = recvsize;
479 wiz_recv_data(sn, buf, len);
480 setSn_CR(sn,Sn_CR_RECV);
481 while(getSn_CR(sn));
482 #endif
483
484 //M20150409 : Explicit Type Casting
485 //return len;
486 return (int32_t)len;
487 }
488
489 int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port)
490 {
491 uint8_t tmp = 0;
492 uint16_t freesize = 0;
493 uint32_t taddr;
494
495 CHECK_SOCKNUM();
496 switch(getSn_MR(sn) & 0x0F)
497 {
498 case Sn_MR_UDP:
499 case Sn_MR_MACRAW:
500 // break;
501 // #if ( _WIZCHIP_ < 5200 )
502 case Sn_MR_IPRAW:
503 break;
504 // #endif
505 default:
506 return SOCKERR_SOCKMODE;
507 }
508 CHECK_SOCKDATA();
509 //M20140501 : For avoiding fatal error on memory align mismatched
510 //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
511 //{
512 //uint32_t taddr;
513 taddr = ((uint32_t)addr[0]) & 0x000000FF;
514 taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF);
515 taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF);
516 taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF);
517 //}
518 //
519 //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
520 if((taddr == 0) && (getSn_MR(sn)&Sn_MR_MACRAW != Sn_MR_MACRAW)) return SOCKERR_IPINVALID;
521 if((port == 0) && (getSn_MR(sn)&Sn_MR_MACRAW != Sn_MR_MACRAW)) return SOCKERR_PORTZERO;
522 tmp = getSn_SR(sn);
523 //#if ( _WIZCHIP_ < 5200 )
524 if(tmp != SOCK_MACRAW && tmp != SOCK_UDP && tmp != SOCK_IPRAW) return SOCKERR_SOCKSTATUS;
525 //#else
526 // if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS;
527 //#endif
528
529 setSn_DIPR(sn,addr);
530 setSn_DPORT(sn,port);
531 freesize = getSn_TxMAX(sn);
532 if (len > freesize) len = freesize; // check size not to exceed MAX size.
533 while(1)
534 {
535 freesize = getSn_TX_FSR(sn);
536 if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED;
537 if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
538 if(len <= freesize) break;
539 };
540 wiz_send_data(sn, buf, len);
541
542 #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata)
543 getSIPR((uint8_t*)&taddr);
544 if(taddr == 0)
545 {
546 getSUBR((uint8_t*)&taddr);
547 setSUBR((uint8_t*)"\x00\x00\x00\x00");
548 }
549 else taddr = 0;
550 #endif
551
552 //A20150601 : For W5300
553 #if _WIZCHIP_ == 5300
554 setSn_TX_WRSR(sn, len);
555 #endif
556 //
557 setSn_CR(sn,Sn_CR_SEND);
558 /* wait to process the command... */
559 while(getSn_CR(sn));
560 while(1)
561 {
562 tmp = getSn_IR(sn);
563 if(tmp & Sn_IR_SENDOK)
564 {
565 setSn_IR(sn, Sn_IR_SENDOK);
566 break;
567 }
568 //M:20131104
569 //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT;
570 else if(tmp & Sn_IR_TIMEOUT)
571 {
572 setSn_IR(sn, Sn_IR_TIMEOUT);
573 //M20150409 : Fixed the lost of sign bits by type casting.
574 //len = (uint16_t)SOCKERR_TIMEOUT;
575 //break;
576 #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata)
577 if(taddr) setSUBR((uint8_t*)&taddr);
578 #endif
579 return SOCKERR_TIMEOUT;
580 }
582 }
583 #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata)
584 if(taddr) setSUBR((uint8_t*)&taddr);
585 #endif
586 //M20150409 : Explicit Type Casting
587 //return len;
588 return (int32_t)len;
589 }
590
591
592
593 int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port)
594 {
595 //M20150601 : For W5300
596 #if _WIZCHIP_ == 5300
597 uint16_t mr;
598 uint16_t mr1;
599 #else
600 uint8_t mr;
601 #endif
602 //
603 uint8_t head[8];
604 uint16_t pack_len=0;
605
606 CHECK_SOCKNUM();
607 //CHECK_SOCKMODE(Sn_MR_UDP);
608 //A20150601
609 #if _WIZCHIP_ == 5300
610 mr1 = getMR();
611 #endif
612
613 switch((mr=getSn_MR(sn)) & 0x0F)
614 {
615 case Sn_MR_UDP:
616 case Sn_MR_IPRAW:
617 case Sn_MR_MACRAW:
618 break;
619 #if ( _WIZCHIP_ < 5200 )
620 case Sn_MR_PPPoE:
621 break;
622 #endif
623 default:
624 return SOCKERR_SOCKMODE;
625 }
626 CHECK_SOCKDATA();
627 if(sock_remained_size[sn] == 0)
628 {
629 while(1)
630 {
631 pack_len = getSn_RX_RSR(sn);
632 if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED;
633 if( (sock_io_mode & (1<<sn)) && (pack_len == 0) ) return SOCK_BUSY;
634 if(pack_len != 0) break;
635 };
636 }
637 //D20150601 : Move it to bottom
638 // sock_pack_info[sn] = PACK_COMPLETED;
639 switch (mr & 0x07)
640 {
641 case Sn_MR_UDP :
642 if(sock_remained_size[sn] == 0)
643 {
644 wiz_recv_data(sn, head, 8);
645 setSn_CR(sn,Sn_CR_RECV);
646 while(getSn_CR(sn));
647 // read peer's IP address, port number & packet length
648 //A20150601 : For W5300
649 #if _WIZCHIP_ == 5300
650 if(mr1 & MR_FS)
651 {
652 addr[0] = head[1];
653 addr[1] = head[0];
654 addr[2] = head[3];
655 addr[3] = head[2];
656 *port = head[5];
657 *port = (*port << 8) + head[4];
658 sock_remained_size[sn] = head[7];
659 sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[6];
660 }
661 else
662 {
663 #endif
664 addr[0] = head[0];
665 addr[1] = head[1];
666 addr[2] = head[2];
667 addr[3] = head[3];
668 *port = head[4];
669 *port = (*port << 8) + head[5];
670 sock_remained_size[sn] = head[6];
671 sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[7];
672 #if _WIZCHIP_ == 5300
673 }
674 #endif
675 sock_pack_info[sn] = PACK_FIRST;
676 }
677 if(len < sock_remained_size[sn]) pack_len = len;
678 else pack_len = sock_remained_size[sn];
679 //A20150601 : For W5300
680 len = pack_len;
681 #if _WIZCHIP_ == 5300
682 if(sock_pack_info[sn] & PACK_FIFOBYTE)
683 {
684 *buf++ = sock_remained_byte[sn];
685 pack_len -= 1;
686 sock_remained_size[sn] -= 1;
687 sock_pack_info[sn] &= ~PACK_FIFOBYTE;
688 }
689 #endif
690 //
691 // Need to packet length check (default 1472)
692 //
693 wiz_recv_data(sn, buf, pack_len); // data copy.
694 break;
695 case Sn_MR_MACRAW :
696 if(sock_remained_size[sn] == 0)
697 {
698 wiz_recv_data(sn, head, 2);
699 setSn_CR(sn,Sn_CR_RECV);
700 while(getSn_CR(sn));
701 // read peer's IP address, port number & packet length
702 sock_remained_size[sn] = head[0];
703 sock_remained_size[sn] = (sock_remained_size[sn] <<8) + head[1] -2;
704 #if _WIZCHIP_ == W5300
705 if(sock_remained_size[sn] & 0x01)
706 sock_remained_size[sn] = sock_remained_size[sn] + 1 - 4;
707 else
708 sock_remained_size[sn] -= 4;
709 #endif
710 if(sock_remained_size[sn] > 1514)
711 {
712 close(sn);
713 return SOCKFATAL_PACKLEN;
714 }
715 sock_pack_info[sn] = PACK_FIRST;
716 }
717 if(len < sock_remained_size[sn]) pack_len = len;
718 else pack_len = sock_remained_size[sn];
719 wiz_recv_data(sn,buf,pack_len);
720 break;
721 //#if ( _WIZCHIP_ < 5200 )
722 case Sn_MR_IPRAW:
723 if(sock_remained_size[sn] == 0)
724 {
725 wiz_recv_data(sn, head, 6);
726 setSn_CR(sn,Sn_CR_RECV);
727 while(getSn_CR(sn));
728 addr[0] = head[0];
729 addr[1] = head[1];
730 addr[2] = head[2];
731 addr[3] = head[3];
732 sock_remained_size[sn] = head[4];
733 //M20150401 : For Typing Error
734 //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5];
735 sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5];
736 sock_pack_info[sn] = PACK_FIRST;
737 }
738 //
739 // Need to packet length check
740 //
741 if(len < sock_remained_size[sn]) pack_len = len;
742 else pack_len = sock_remained_size[sn];
743 wiz_recv_data(sn, buf, pack_len); // data copy.
744 break;
745 //#endif
746 default:
747 wiz_recv_ignore(sn, pack_len); // data copy.
748 sock_remained_size[sn] = pack_len;
749 break;
750 }
751 setSn_CR(sn,Sn_CR_RECV);
752 /* wait to process the command... */
753 while(getSn_CR(sn)) ;
754 sock_remained_size[sn] -= pack_len;
755 //M20150601 :
756 //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01;
757 if(sock_remained_size[sn] != 0)
758 {
759 sock_pack_info[sn] |= PACK_REMAINED;
760 #if _WIZCHIP_ == 5300
761 if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE;
762 #endif
763 }
764 else sock_pack_info[sn] = PACK_COMPLETED;
765 #if _WIZCHIP_ == 5300
766 pack_len = len;
767 #endif
768 //
769 //M20150409 : Explicit Type Casting
770 //return pack_len;
771 return (int32_t)pack_len;
772 }
773
774
775 int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg)
776 {
777 uint8_t tmp = 0;
778 CHECK_SOCKNUM();
779 switch(cstype)
780 {
781 case CS_SET_IOMODE:
782 tmp = *((uint8_t*)arg);
783 if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1<<sn);
784 else if(tmp == SOCK_IO_BLOCK) sock_io_mode &= ~(1<<sn);
785 else return SOCKERR_ARG;
786 break;
787 case CS_GET_IOMODE:
788 //M20140501 : implict type casting -> explict type casting
789 //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001;
790 *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001);
791 //
792 break;
793 case CS_GET_MAXTXBUF:
794 *((uint16_t*)arg) = getSn_TxMAX(sn);
795 break;
796 case CS_GET_MAXRXBUF:
797 *((uint16_t*)arg) = getSn_RxMAX(sn);
798 break;
799 case CS_CLR_INTERRUPT:
800 if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG;
801 setSn_IR(sn,*(uint8_t*)arg);
802 break;
803 case CS_GET_INTERRUPT:
804 *((uint8_t*)arg) = getSn_IR(sn);
805 break;
806 #if _WIZCHIP_ != 5100
807 case CS_SET_INTMASK:
808 if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG;
809 setSn_IMR(sn,*(uint8_t*)arg);
810 break;
811 case CS_GET_INTMASK:
812 *((uint8_t*)arg) = getSn_IMR(sn);
813 break;
814 #endif
815 default:
816 return SOCKERR_ARG;
817 }
818 return SOCK_OK;
819 }
820
821 int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg)
822 {
823 // M20131220 : Remove warning
824 //uint8_t tmp;
825 CHECK_SOCKNUM();
826 switch(sotype)
827 {
828 case SO_TTL:
829 setSn_TTL(sn,*(uint8_t*)arg);
830 break;
831 case SO_TOS:
832 setSn_TOS(sn,*(uint8_t*)arg);
833 break;
834 case SO_MSS:
835 setSn_MSSR(sn,*(uint16_t*)arg);
836 break;
837 case SO_DESTIP:
838 setSn_DIPR(sn, (uint8_t*)arg);
839 break;
840 case SO_DESTPORT:
841 setSn_DPORT(sn, *(uint16_t*)arg);
842 break;
843 #if _WIZCHIP_ != 5100
844 case SO_KEEPALIVESEND:
845 CHECK_SOCKMODE(Sn_MR_TCP);
846 #if _WIZCHIP_ > 5200
847 if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT;
848 #endif
849 setSn_CR(sn,Sn_CR_SEND_KEEP);
850 while(getSn_CR(sn) != 0)
851 {
852 // M20131220
853 //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT)
854 if (getSn_IR(sn) & Sn_IR_TIMEOUT)
855 {
856 setSn_IR(sn, Sn_IR_TIMEOUT);
857 return SOCKERR_TIMEOUT;
858 }
859 }
860 break;
861 #if _WIZCHIP_ > 5200
862 case SO_KEEPALIVEAUTO:
863 CHECK_SOCKMODE(Sn_MR_TCP);
864 setSn_KPALVTR(sn,*(uint8_t*)arg);
865 break;
866 #endif
867 #endif
868 default:
869 return SOCKERR_ARG;
870 }
871 return SOCK_OK;
872 }
873
874 int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg)
875 {
876 CHECK_SOCKNUM();
877 switch(sotype)
878 {
879 case SO_FLAG:
880 *(uint8_t*)arg = getSn_MR(sn) & 0xF0;
881 break;
882 case SO_TTL:
883 *(uint8_t*) arg = getSn_TTL(sn);
884 break;
885 case SO_TOS:
886 *(uint8_t*) arg = getSn_TOS(sn);
887 break;
888 case SO_MSS:
889 *(uint16_t*) arg = getSn_MSSR(sn);
890 break;
891 case SO_DESTIP:
892 getSn_DIPR(sn, (uint8_t*)arg);
893 break;
894 case SO_DESTPORT:
895 *(uint16_t*) arg = getSn_DPORT(sn);
896 break;
897 #if _WIZCHIP_ > 5200
898 case SO_KEEPALIVEAUTO:
899 CHECK_SOCKMODE(Sn_MR_TCP);
900 *(uint16_t*) arg = getSn_KPALVTR(sn);
901 break;
902 #endif
903 case SO_SENDBUF:
904 *(uint16_t*) arg = getSn_TX_FSR(sn);
905 break;
906 case SO_RECVBUF:
907 *(uint16_t*) arg = getSn_RX_RSR(sn);
908 break;
909 case SO_STATUS:
910 *(uint8_t*) arg = getSn_SR(sn);
911 break;
912 case SO_REMAINSIZE:
913 if(getSn_MR(sn) == Sn_MR_TCP)
914 *(uint16_t*)arg = getSn_RX_RSR(sn);
915 else
916 *(uint16_t*)arg = sock_remained_size[sn];
917 break;
918 case SO_PACKINFO:
919 //CHECK_SOCKMODE(Sn_MR_TCP);
920 #if _WIZCHIP_ != 5300
921 if((getSn_MR(sn) == Sn_MR_TCP))
922 return SOCKERR_SOCKMODE;
923 #endif
924 *(uint8_t*)arg = sock_pack_info[sn];
925 break;
926 default:
927 return SOCKERR_SOCKOPT;
928 }
929 return SOCK_OK;
930 }
SO_KEEPALIVEAUTO
Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200.
Definition: socket.h:391
SO_STATUS
Valid only in getsockopt. Get the socket status. Sn_SR, getSn_SR()
Definition: socket.h:396
getSn_IR
#define getSn_IR(sn)
Get Sn_IR register.
Definition: w5100.h:1417
PACK_COMPLETED
#define PACK_COMPLETED
In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applie...
Definition: socket.h:140
SO_TTL
Set TTL. Sn_TTL ( setSn_TTL(), getSn_TTL() )
Definition: socket.h:383
ctlsocket
int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void *arg)
Control socket.
Definition: socket.c:775
SO_REMAINSIZE
Valid only in getsockopt. Get the remained packet size in other then TCP mode.
Definition: socket.h:397
SOCKERR_SOCKMODE
#define SOCKERR_SOCKMODE
Invalid socket mode for socket operation.
Definition: socket.h:101
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
CS_GET_MAXTXBUF
get the size of socket buffer allocated in TX memory
Definition: socket.h:365
SOCK_UDP
#define SOCK_UDP
UDP socket.
Definition: w5100.h:982
getSIPR
#define getSIPR(sipr)
Get SIPR.
Definition: w5100.h:1195
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
SOCK_LISTEN
#define SOCK_LISTEN
Listen state.
Definition: w5100.h:909
getSn_DIPR
#define getSn_DIPR(sn, dipr)
Get Sn_DIPR register.
Definition: w5100.h:1488
SOCKERR_ARG
#define SOCKERR_ARG
Invalid argument.
Definition: socket.h:104
setSn_MSSR
#define setSn_MSSR(sn, mss)
Set Sn_MSSR register.
Definition: w5100.h:1520
setSn_TTL
#define setSn_TTL(sn, ttl)
Set Sn_TTL register.
Definition: w5100.h:1582
Sn_MR_PPPoE
#define Sn_MR_PPPoE
PPPoE.
Definition: w5100.h:669
SOCK_OK
#define SOCK_OK
Result is OK about socket process.
Definition: socket.h:92
PACK_FIFOBYTE
#define PACK_FIFOBYTE
Valid only W5300, It indicate to have read already the Sn_RX_FIFOR.
Definition: socket.h:142
SOCK_BUSY
#define SOCK_BUSY
Socket is busy on processing the operation. Valid only Non-block IO Mode.
Definition: socket.h:93
SF_MULTI_ENABLE
#define SF_MULTI_ENABLE
In Sn_MR_UDP, Enable multicast mode.
Definition: socket.h:119
setSn_IR
#define setSn_IR(sn, ir)
Set Sn_IR register.
Definition: w5100.h:1407
SOCKERR_SOCKOPT
#define SOCKERR_SOCKOPT
Invalid socket option.
Definition: socket.h:98
getSn_TTL
#define getSn_TTL(sn)
Get Sn_TTL register.
Definition: w5100.h:1592
SF_TCP_NODELAY
#define SF_TCP_NODELAY
In Sn_MR_TCP, Use to nodelayed ack.
Definition: socket.h:118
getSn_TxMAX
#define getSn_TxMAX(sn)
Get the max TX buffer size of socket sn.
Definition: w5100.h:1768
SOCKERR_TIMEOUT
#define SOCKERR_TIMEOUT
Timeout occurred.
Definition: socket.h:107
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
setSn_MR
#define setSn_MR(sn, mr)
Set Sn_MR register.
Definition: w5100.h:1367
Sn_CR_LISTEN
#define Sn_CR_LISTEN
Wait connection request in TCP mode(Server mode)
Definition: w5100.h:741
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
Sn_CR_CONNECT
#define Sn_CR_CONNECT
Send connection request in TCP mode(Client mode)
Definition: w5100.h:753
getSn_CR
#define getSn_CR(sn)
Get Sn_CR register.
Definition: w5100.h:1397
SO_KEEPALIVESEND
Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100...
Definition: socket.h:389
getsockopt
int8_t getsockopt(uint8_t sn, sockopt_type sotype, void *arg)
get socket options
Definition: socket.c:874
Sn_MR_MACRAW
#define Sn_MR_MACRAW
MAC LAYER RAW SOCK.
Definition: w5100.h:662
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
Sn_CR_SEND_KEEP
#define Sn_CR_SEND_KEEP
Send keep alive message.
Definition: w5100.h:798
getSn_TX_RD
#define getSn_TX_RD(sn)
Get Sn_TX_RD register.
Definition: w5100.h:1653
SOCK_MACRAW
#define SOCK_MACRAW
MAC raw mode socket.
Definition: w5100.h:998
ctlsock_type
ctlsock_type
The type of ctlsocket().
Definition: socket.h:361
setSn_IMR
#define setSn_IMR(sn, imr)
Set the interrupt mask register of socket sn.
Definition: w5100s.h:3144
SOCKFATAL_PACKLEN
#define SOCKFATAL_PACKLEN
Invalid packet length. Fatal Error.
Definition: socket.h:111
MR_FS
#define MR_FS
Definition: w5300.h:893
Sn_MR_TCP
#define Sn_MR_TCP
TCP.
Definition: w5100.h:648
Sn_CR_DISCON
#define Sn_CR_DISCON
Send closing request in TCP mode.
Definition: w5100.h:766
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
SO_MSS
Set MSS. Sn_MSSR ( setSn_MSSR(), getSn_MSSR() )
Definition: socket.h:385
getSn_IMR
#define getSn_IMR(sn)
Get the interrupt mask register of socket sn.
Definition: w5100s.h:3153
PACK_FIRST
#define PACK_FIRST
In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) ...
Definition: socket.h:138
CS_GET_INTMASK
get the masked interrupt of socket. refer to sockint_kind, Not supported in W5100 ...
Definition: socket.h:371
SIK_ALL
all interrupt
Definition: socket.h:354
CS_GET_INTERRUPT
get the socket interrupt. refer to sockint_kind
Definition: socket.h:368
Sn_CR_CLOSE
#define Sn_CR_CLOSE
Close socket.
Definition: w5100.h:772
PACK_REMAINED
#define PACK_REMAINED
In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be appl...
Definition: socket.h:139
getSn_RxMAX
#define getSn_RxMAX(sn)
Get the max RX buffer size of socket sn.
Definition: w5100.h:1758
SF_IO_NONBLOCK
#define SF_IO_NONBLOCK
Socket nonblock io mode. It used parameter in socket().
Definition: socket.h:133
SOCK_CLOSED
#define SOCK_CLOSED
Closed.
Definition: w5100.h:893
Sn_MR_UDP
#define Sn_MR_UDP
UDP.
Definition: w5100.h:654
SOCK_ANY_PORT_NUM
#define SOCK_ANY_PORT_NUM
Definition: socket.c:60
SOCKERR_SOCKCLOSED
#define SOCKERR_SOCKCLOSED
Socket unexpectedly closed.
Definition: socket.h:100
setSn_TX_WRSR
#define setSn_TX_WRSR(sn, txwrs)
Set Sn_TX_WRSR register.
Definition: w5300.h:2144
setSUBR
#define setSUBR(subr)
Set SUBR.
Definition: w5100.h:1150
recv
int32_t recv(uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer.
Definition: socket.c:384
SO_SENDBUF
Valid only in getsockopt. Get the free data size of Socekt TX buffer. Sn_TX_FSR, getSn_TX_FSR() ...
Definition: socket.h:394
SOCKERR_SOCKINIT
#define SOCKERR_SOCKINIT
Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP.
Definition: socket.h:99
SF_UNI_BLOCK
#define SF_UNI_BLOCK
In Sn_MR_UDP with SF_MULTI_ENABLE. Valid only in W5500.
Definition: socket.h:125
getSn_MSSR
#define getSn_MSSR(sn)
Get Sn_MSSR register.
Definition: w5100.h:1532
getMR
#define getMR()
Get MR.
Definition: w5100.h:1120
sock_pack_info
uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_]
Definition: socket.c:70
getSn_DPORT
#define getSn_DPORT(sn)
Get Sn_DPORT register.
Definition: w5100.h:1510
SO_DESTPORT
Set the destination Port number. Sn_DPORT ( setSn_DPORT(), getSn_DPORT() )
Definition: socket.h:387
Sn_IR_SENDOK
#define Sn_IR_SENDOK
SEND_OK Interrupt.
Definition: w5100.h:861
CS_CLR_INTERRUPT
clear the interrupt of socket with sockint_kind
Definition: socket.h:367
getSn_SR
#define getSn_SR(sn)
Get Sn_SR register.
Definition: w5100.h:1426
SOCK_IO_BLOCK
#define SOCK_IO_BLOCK
Socket Block IO Mode in setsockopt().
Definition: socket.h:333
SO_FLAG
Valid only in getsockopt(), For set flag of socket refer to flag in socket().
Definition: socket.h:382
SO_TOS
Set TOS. Sn_TOS ( setSn_TOS(), getSn_TOS() )
Definition: socket.h:384
sockopt_type
sockopt_type
The type of socket option in setsockopt() or getsockopt()
Definition: socket.h:380
Sn_MR_IPRAW
#define Sn_MR_IPRAW
IP LAYER RAW SOCK.
Definition: w5100.h:655
setSn_TOS
#define setSn_TOS(sn, tos)
Set Sn_TOS register.
Definition: w5100.h:1562
sendto
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.
Definition: socket.c:489
CS_SET_IOMODE
set socket IO mode with SOCK_IO_BLOCK or SOCK_IO_NONBLOCK
Definition: socket.h:363
setsockopt
int8_t setsockopt(uint8_t sn, sockopt_type sotype, void *arg)
set socket options
Definition: socket.c:821
SOCK_CLOSE_WAIT
#define SOCK_CLOSE_WAIT
Closing state.
Definition: w5100.h:967
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
disconnect
int8_t disconnect(uint8_t sn)
Try to disconnect a connection socket.
Definition: socket.c:296
setSn_DIPR
#define setSn_DIPR(sn, dipr)
Set Sn_DIPR register.
Definition: w5100.h:1478
getSn_KPALVTR
#define getSn_KPALVTR(sn)
Get the Sn_KPALVTR value of socket sn.
Definition: w5100s.h:3189
getSUBR
#define getSUBR(subr)
Get SUBR.
Definition: w5100.h:1159
getSn_TOS
#define getSn_TOS(sn)
Get Sn_TOS register.
Definition: w5100.h:1572
SOCKERR_SOCKSTATUS
#define SOCKERR_SOCKSTATUS
Invalid socket status for socket operation.
Definition: socket.h:103
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
SO_PACKINFO
Valid only in getsockopt. Get the packet information as PACK_FIRST, PACK_REMAINED, and PACK_COMPLETED in other then TCP mode.
Definition: socket.h:398
CS_SET_INTMASK
set the interrupt mask of socket with sockint_kind, Not supported in W5100
Definition: socket.h:370
SOCKERR_IPINVALID
#define SOCKERR_IPINVALID
Invalid IP address.
Definition: socket.h:106
CHECK_SOCKMODE
#define CHECK_SOCKMODE(mode)
Definition: socket.c:88
CHECK_SOCKINIT
#define CHECK_SOCKINIT()
Definition: socket.c:93
listen
int8_t listen(uint8_t sn)
Listen to a connection request from a client.
Definition: socket.c:240
Sn_MR_ALIGN
#define Sn_MR_ALIGN
Alignment bit of Sn_MR.
Definition: w5300.h:929
Sn_CR_RECV
#define Sn_CR_RECV
Update RX buffer pointer and receive data.
Definition: w5100.h:806
setSn_CR
#define setSn_CR(sn, cr)
Set Sn_CR register.
Definition: w5100.h:1387
CS_GET_MAXRXBUF
get the size of socket buffer allocated in RX memory
Definition: socket.h:366
SOCKERR_SOCKFLAG
#define SOCKERR_SOCKFLAG
Invalid socket flag.
Definition: socket.h:102
getSn_MR
#define getSn_MR(sn)
Get Sn_MR register.
Definition: w5100.h:1377
_WIZCHIP_SOCK_NUM_
#define _WIZCHIP_SOCK_NUM_
The count of independant socket of WIZCHIP.
Definition: wizchip_conf.h:212
setSn_PORT
#define setSn_PORT(sn, port)
Set Sn_PORT register.
Definition: w5100.h:1436
SO_RECVBUF
Valid only in getsockopt. Get the received data size in socket RX buffer. Sn_RX_RSR, getSn_RX_RSR()
Definition: socket.h:395
SOCK_IPRAW
#define SOCK_IPRAW
IP raw mode socket.
Definition: w5100.h:990
setSn_DPORT
#define setSn_DPORT(sn, dport)
Set Sn_DPORT register.
Definition: w5100.h:1498
Sn_CR_SEND
#define Sn_CR_SEND
Update TX buffer pointer and send data.
Definition: w5100.h:780
SF_IGMP_VER2
#define SF_IGMP_VER2
In Sn_MR_UDP with SF_MULTI_ENABLE, Select IGMP version 2.
Definition: socket.h:117
Sn_IR_TIMEOUT
#define Sn_IR_TIMEOUT
TIMEOUT Interrupt.
Definition: w5100.h:867
setSn_KPALVTR
#define setSn_KPALVTR(sn, kpalvtr)
Set the Sn_KPALVTR value of socket sn.
Definition: w5100s.h:3180
connect
int8_t connect(uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server.
Definition: socket.c:256
SOCK_IO_NONBLOCK
#define SOCK_IO_NONBLOCK
Socket Non-block IO Mode in setsockopt().
Definition: socket.h:334
SOCKERR_PORTZERO
#define SOCKERR_PORTZERO
Port number is zero.
Definition: socket.h:105
CHECK_SOCKNUM
#define CHECK_SOCKNUM()
Definition: socket.c:83
socket.h
SOCKET APIs Header file.
CS_GET_IOMODE
get socket IO mode
Definition: socket.h:364
Sn_CR_OPEN
#define Sn_CR_OPEN
Initialize or open socket.
Definition: w5100.h:730
setSn_PORTR
#define setSn_PORTR(sn, port)
Set Sn_PORTR register.
Definition: w5300.h:1980
CHECK_SOCKDATA
#define CHECK_SOCKDATA()
Definition: socket.c:98
SOCK_ESTABLISHED
#define SOCK_ESTABLISHED
Success to connect.
Definition: w5100.h:935
send
int32_t send(uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket.
Definition: socket.c:316
SO_DESTIP
Set the destination IP address. Sn_DIPR ( setSn_DIPR(), getSn_DIPR() )
Definition: socket.h:386


ioLibrary: 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 //A201505 : For W5300
129 #if _WIZCHIP_ == 5300
130 #define SF_TCP_ALIGN 0x02
131 #endif
132
133 #define SF_IO_NONBLOCK 0x01
134
135 /*
136 * UDP & MACRAW Packet Infomation
137 */
138 #define PACK_FIRST 0x80
139 #define PACK_REMAINED 0x01
140 #define PACK_COMPLETED 0x00
141 //A20150601 : For Integrating with W5300
142 #define PACK_FIFOBYTE 0x02
143 //
144
162 int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
163
174 int8_t close(uint8_t sn);
175
187 int8_t listen(uint8_t sn);
188
210 int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port);
211
227 int8_t disconnect(uint8_t sn);
228
247 int32_t send(uint8_t sn, uint8_t * buf, uint16_t len);
248
269 int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len);
270
297 int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port);
298
327 int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port);
328
329
331 // SOCKET CONTROL & OPTION //
333 #define SOCK_IO_BLOCK 0
334 #define SOCK_IO_NONBLOCK 1
335
336
345 typedef enum
346 {
347 SIK_CONNECTED = (1 << 0),
348 SIK_DISCONNECTED = (1 << 1),
349 SIK_RECEIVED = (1 << 2),
350 SIK_TIMEOUT = (1 << 3),
351 SIK_SENT = (1 << 4),
352 //M20150410 : Remove the comma of last member
353 //SIK_ALL = 0x1F, ///< all interrupt
354 SIK_ALL = 0x1F
355 }sockint_kind;
356
361 typedef enum
362 {
363 CS_SET_IOMODE,
364 CS_GET_IOMODE,
365 CS_GET_MAXTXBUF,
366 CS_GET_MAXRXBUF,
367 CS_CLR_INTERRUPT,
368 CS_GET_INTERRUPT,
369 #if _WIZCHIP_ > 5100
370 CS_SET_INTMASK,
371 CS_GET_INTMASK
372 #endif
373 }ctlsock_type;
374
375
380 typedef enum
381 {
382 SO_FLAG,
383 SO_TTL,
384 SO_TOS,
385 SO_MSS,
386 SO_DESTIP,
387 SO_DESTPORT,
388 #if _WIZCHIP_ != 5100
389 SO_KEEPALIVESEND,
390 #if _WIZCHIP_ > 5200
391 SO_KEEPALIVEAUTO,
392 #endif
393 #endif
394 SO_SENDBUF,
395 SO_RECVBUF,
396 SO_STATUS,
397 SO_REMAINSIZE,
398 SO_PACKINFO
399 }sockopt_type;
400
418 int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg);
419
446 int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg);
447
480 int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg);
481
482 #endif // _SOCKET_H_
SO_KEEPALIVEAUTO
Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200.
Definition: socket.h:391
SO_STATUS
Valid only in getsockopt. Get the socket status. Sn_SR, getSn_SR()
Definition: socket.h:396
SO_TTL
Set TTL. Sn_TTL ( setSn_TTL(), getSn_TTL() )
Definition: socket.h:383
ctlsocket
int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void *arg)
Control socket.
Definition: socket.c:775
SO_REMAINSIZE
Valid only in getsockopt. Get the remained packet size in other then TCP mode.
Definition: socket.h:397
CS_GET_MAXTXBUF
get the size of socket buffer allocated in TX memory
Definition: socket.h:365
SIK_CONNECTED
connected
Definition: socket.h:347
SIK_SENT
send ok
Definition: socket.h:351
sockint_kind
sockint_kind
The kind of Socket Interrupt.
Definition: socket.h:345
SIK_RECEIVED
data received
Definition: socket.h:349
SO_KEEPALIVESEND
Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100...
Definition: socket.h:389
getsockopt
int8_t getsockopt(uint8_t sn, sockopt_type sotype, void *arg)
get socket options
Definition: socket.c:874
ctlsock_type
ctlsock_type
The type of ctlsocket().
Definition: socket.h:361
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
SO_MSS
Set MSS. Sn_MSSR ( setSn_MSSR(), getSn_MSSR() )
Definition: socket.h:385
CS_GET_INTMASK
get the masked interrupt of socket. refer to sockint_kind, Not supported in W5100 ...
Definition: socket.h:371
SIK_ALL
all interrupt
Definition: socket.h:354
CS_GET_INTERRUPT
get the socket interrupt. refer to sockint_kind
Definition: socket.h:368
SIK_DISCONNECTED
disconnected
Definition: socket.h:348
recv
int32_t recv(uint8_t sn, uint8_t *buf, uint16_t len)
Receive data from the connected peer.
Definition: socket.c:384
SO_SENDBUF
Valid only in getsockopt. Get the free data size of Socekt TX buffer. Sn_TX_FSR, getSn_TX_FSR() ...
Definition: socket.h:394
SO_DESTPORT
Set the destination Port number. Sn_DPORT ( setSn_DPORT(), getSn_DPORT() )
Definition: socket.h:387
CS_CLR_INTERRUPT
clear the interrupt of socket with sockint_kind
Definition: socket.h:367
SO_FLAG
Valid only in getsockopt(), For set flag of socket refer to flag in socket().
Definition: socket.h:382
SO_TOS
Set TOS. Sn_TOS ( setSn_TOS(), getSn_TOS() )
Definition: socket.h:384
sockopt_type
sockopt_type
The type of socket option in setsockopt() or getsockopt()
Definition: socket.h:380
sendto
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.
Definition: socket.c:489
CS_SET_IOMODE
set socket IO mode with SOCK_IO_BLOCK or SOCK_IO_NONBLOCK
Definition: socket.h:363
setsockopt
int8_t setsockopt(uint8_t sn, sockopt_type sotype, void *arg)
set socket options
Definition: socket.c:821
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
disconnect
int8_t disconnect(uint8_t sn)
Try to disconnect a connection socket.
Definition: socket.c:296
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
SO_PACKINFO
Valid only in getsockopt. Get the packet information as PACK_FIRST, PACK_REMAINED, and PACK_COMPLETED in other then TCP mode.
Definition: socket.h:398
CS_SET_INTMASK
set the interrupt mask of socket with sockint_kind, Not supported in W5100
Definition: socket.h:370
listen
int8_t listen(uint8_t sn)
Listen to a connection request from a client.
Definition: socket.c:240
CS_GET_MAXRXBUF
get the size of socket buffer allocated in RX memory
Definition: socket.h:366
SO_RECVBUF
Valid only in getsockopt. Get the received data size in socket RX buffer. Sn_RX_RSR, getSn_RX_RSR()
Definition: socket.h:395
connect
int8_t connect(uint8_t sn, uint8_t *addr, uint16_t port)
Try to connect a server.
Definition: socket.c:256
CS_GET_IOMODE
get socket IO mode
Definition: socket.h:364
wizchip_conf.h
WIZCHIP Config Header File.
SIK_TIMEOUT
timeout occurred
Definition: socket.h:350
send
int32_t send(uint8_t sn, uint8_t *buf, uint16_t len)
Send data to the connected peer in TCP socket.
Definition: socket.c:316
SO_DESTIP
Set the destination IP address. Sn_DIPR ( setSn_DIPR(), getSn_DIPR() )
Definition: socket.h:386


ioLibrary: Internet/TFTP/tftp.c Source File

  • Internet
  • TFTP
tftp.c
Go to the documentation of this file.
1
8 /* Includes -----------------------------------------------------*/
9 #include <string.h>
10 #include "tftp.h"
11 #include "socket.h"
12 #include "netutil.h"
13
14 /* define -------------------------------------------------------*/
15
16 /* typedef ------------------------------------------------------*/
17
18 /* Extern Variable ----------------------------------------------*/
19
20 /* Extern Functions ---------------------------------------------*/
21 #ifdef F_STORAGE
22 extern void save_data(uint8_t *data, uint32_t data_len, uint16_t block_number);
23 #endif
24
25 /* Global Variable ----------------------------------------------*/
26 static int g_tftp_socket = -1;
27
28 static uint8_t g_filename[FILE_NAME_SIZE];
29
30 static uint32_t g_server_ip = 0;
31 static uint16_t g_server_port = 0;
32 static uint16_t g_local_port = 0;
33
34 static uint32_t g_tftp_state = STATE_NONE;
35 static uint16_t g_block_num = 0;
36
37 static uint32_t g_timeout = 5;
38 static uint32_t g_resend_flag = 0;
39 static uint32_t tftp_time_cnt = 0;
40 static uint32_t tftp_retry_cnt = 0;
41
42 static uint8_t *g_tftp_rcv_buf = NULL;
43
44 static TFTP_OPTION default_tftp_opt = {
45 .code = (uint8_t *)"timeout",
46 .value = (uint8_t *)"5"
47 };
48
49 uint8_t g_progress_state = TFTP_PROGRESS;
50
51 #ifdef __TFTP_DEBUG__
52 int dbg_level = (INFO_DBG | ERROR_DBG | IPC_DBG);
53 #endif
54
55 /* static function define ---------------------------------------*/
56 static void set_filename(uint8_t *file, uint32_t file_size)
57 {
58 memcpy(g_filename, file, file_size);
59 }
60
61 static inline void set_server_ip(uint32_t ipaddr)
62 {
63 g_server_ip = ipaddr;
64 }
65
66 static inline uint32_t get_server_ip()
67 {
68 return g_server_ip;
69 }
70
71 static inline void set_server_port(uint16_t port)
72 {
73 g_server_port = port;
74 }
75
76 static inline uint16_t get_server_port()
77 {
78 return g_server_port;
79 }
80
81 static inline void set_local_port(uint16_t port)
82 {
83 g_local_port = port;
84 }
85
86 static inline uint16_t get_local_port()
87 {
88 return g_local_port;
89 }
90
91 static inline uint16_t genernate_port()
92 {
93 /* TODO */
94 return 0;
95 }
96
97 static inline void set_tftp_state(uint32_t state)
98 {
99 g_tftp_state = state;
100 }
101
102 static inline uint32_t get_tftp_state()
103 {
104 return g_tftp_state;
105 }
106
107 static inline void set_tftp_timeout(uint32_t timeout)
108 {
109 g_timeout = timeout;
110 }
111
112 static inline uint32_t get_tftp_timeout()
113 {
114 return g_timeout;
115 }
116
117 static inline void set_block_number(uint16_t block_number)
118 {
119 g_block_num = block_number;
120 }
121
122 static inline uint16_t get_block_number()
123 {
124 return g_block_num;
125 }
126
127 static int open_tftp_socket(uint8_t sock)
128 {
129 uint8_t sd, sck_state;
130
131 sd = socket(sock, Sn_MR_UDP, 51000, SF_IO_NONBLOCK);
132 if(sd != sock) {
133 //DBG_PRINT(ERROR_DBG, "[%s] socket error\r\n", __func__);
134 return -1;
135 }
136
137 do {
138 getsockopt(sd , SO_STATUS, &sck_state);
139 } while(sck_state != SOCK_UDP);
140
141 return sd;
142 }
143
144 static int send_udp_packet(int socket, uint8_t *packet, uint32_t len, uint32_t ip, uint16_t port)
145 {
146 int snd_len;
147
148 ip = htonl(ip);
149
150 snd_len = sendto(socket, packet, len, (uint8_t *)&ip, port);
151 if(snd_len != len) {
152 //DBG_PRINT(ERROR_DBG, "[%s] sendto error\r\n", __func__);
153 return -1;
154 }
155
156 return snd_len;
157 }
158
159 static int recv_udp_packet(int socket, uint8_t *packet, uint32_t len, uint32_t *ip, uint16_t *port)
160 {
161 int ret;
162 uint8_t sck_state;
163 uint16_t recv_len;
164
165 /* Receive Packet Process */
166 ret = getsockopt(socket, SO_STATUS, &sck_state);
167 if(ret != SOCK_OK) {
168 //DBG_PRINT(ERROR_DBG, "[%s] getsockopt SO_STATUS error\r\n", __func__);
169 return -1;
170 }
171
172 if(sck_state == SOCK_UDP) {
173 ret = getsockopt(socket, SO_RECVBUF, &recv_len);
174 if(ret != SOCK_OK) {
175 //DBG_PRINT(ERROR_DBG, "[%s] getsockopt SO_RECVBUF error\r\n", __func__);
176 return -1;
177 }
178
179 if(recv_len) {
180 recv_len = recvfrom(socket, packet, len, (uint8_t *)ip, port);
181 if(recv_len < 0) {
182 //DBG_PRINT(ERROR_DBG, "[%s] recvfrom error\r\n", __func__);
183 return -1;
184 }
185
186 *ip = ntohl(*ip);
187
188 return recv_len;
189 }
190 }
191 return -1;
192 }
193
194 static void close_tftp_socket(int socket)
195 {
196 close(socket);
197 }
198
199
200 static void init_tftp(void)
201 {
202 g_filename[0] = 0;
203
204 set_server_ip(0);
205 set_server_port(0);
206 set_local_port(0);
207
208 set_tftp_state(STATE_NONE);
209 set_block_number(0);
210
211 /* timeout flag */
212 g_resend_flag = 0;
213 tftp_retry_cnt = tftp_time_cnt = 0;
214
215 g_progress_state = TFTP_PROGRESS;
216 }
217
218 static void tftp_cancel_timeout(void)
219 {
220 if(g_resend_flag) {
221 g_resend_flag = 0;
222 tftp_retry_cnt = tftp_time_cnt = 0;
223 }
224 }
225
226 static void tftp_reg_timeout()
227 {
228 if(g_resend_flag == 0) {
229 g_resend_flag = 1;
230 tftp_retry_cnt = tftp_time_cnt = 0;
231 }
232 }
233
234 static void process_tftp_option(uint8_t *msg, uint32_t msg_len)
235 {
236 /* TODO Option Process */
237 }
238
239 static void send_tftp_rrq(uint8_t *filename, uint8_t *mode, TFTP_OPTION *opt, uint8_t opt_len)
240 {
241 uint8_t snd_buf[MAX_MTU_SIZE];
242 uint8_t *pkt = snd_buf;
243 uint32_t i, len;
244
245 *((uint16_t *)pkt) = htons(TFTP_RRQ);
246 pkt += 2;
247 strcpy((char *)pkt, (const char *)filename);
248 pkt += strlen((char *)filename) + 1;
249 strcpy((char *)pkt, (const char *)mode);
250 pkt += strlen((char *)mode) + 1;
251
252 for(i = 0 ; i < opt_len ; i++) {
253 strcpy((char *)pkt, (const char *)opt[i].code);
254 pkt += strlen((char *)opt[i].code) + 1;
255 strcpy((char *)pkt, (const char *)opt[i].value);
256 pkt += strlen((char *)opt[i].value) + 1;
257 }
258
259 len = pkt - snd_buf;
260
261 send_udp_packet(g_tftp_socket, snd_buf, len, get_server_ip(), TFTP_SERVER_PORT);
262 set_tftp_state(STATE_RRQ);
263 set_filename(filename, strlen((char *)filename) + 1);
264 tftp_reg_timeout();
265 #ifdef __TFTP_DEBUG__
266 DBG_PRINT(IPC_DBG, ">> TFTP RRQ : FileName(%s), Mode(%s)\r\n", filename, mode);
267 #endif
268 }
269
270 #if 0 // 2014.07.01 sskim
271 static void send_tftp_wrq(uint8_t *filename, uint8_t *mode, TFTP_OPTION *opt, uint8_t opt_len)
272 {
273 uint8_t snd_buf[MAX_MTU_SIZE];
274 uint8_t *pkt = snd_buf;
275 uint32_t i, len;
276
277 *((uint16_t *)pkt) = htons((uint16_t)TFTP_WRQ);
278 pkt += 2;
279 strcpy((char *)pkt, (const char *)filename);
280 pkt += strlen((char *)filename) + 1;
281 strcpy((char *)pkt, (const char *)mode);
282 pkt += strlen((char *)mode) + 1;
283
284 for(i = 0 ; i < opt_len ; i++) {
285 strcpy((char *)pkt, (const char *)opt[i].code);
286 pkt += strlen((char *)opt[i].code) + 1;
287 strcpy((char *)pkt, (const char *)opt[i].value);
288 pkt += strlen((char *)opt[i].value) + 1;
289 }
290
291 len = pkt - snd_buf;
292
293 send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), TFTP_SERVER_PORT);
294 set_tftp_state(STATE_WRQ);
295 set_filename(filename, strlen((char *)filename) + 1);
296 tftp_reg_timeout();
297 #ifdef __TFTP_DEBUG__
298 DBG_PRINT(IPC_DBG, ">> TFTP WRQ : FileName(%s), Mode(%s)\r\n", filename, mode);
299 #endif
300 }
301 #endif
302
303 #if 0 // 2014.07.01 sskim
304 static void send_tftp_data(uint16_t block_number, uint8_t *data, uint16_t data_len)
305 {
306 uint8_t snd_buf[MAX_MTU_SIZE];
307 uint8_t *pkt = snd_buf;
308 uint32_t len;
309
310 *((uint16_t *)pkt) = htons((uint16_t)TFTP_DATA);
311 pkt += 2;
312 *((uint16_t *)pkt) = htons(block_number);
313 pkt += 2;
314 memcpy(pkt, data, data_len);
315 pkt += data_len;
316
317 len = pkt - snd_buf;
318
319 send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), get_server_port());
320 tftp_reg_timeout();
321 #ifdef __TFTP_DEBUG__
322 DBG_PRINT(IPC_DBG, ">> TFTP DATA : Block Number(%d), Data Length(%d)\r\n", block_number, data_len);
323 #endif
324 }
325 #endif
326
327 static void send_tftp_ack(uint16_t block_number)
328 {
329 uint8_t snd_buf[4];
330 uint8_t *pkt = snd_buf;
331
332 *((uint16_t *)pkt) = htons((uint16_t)TFTP_ACK);
333 pkt += 2;
334 *((uint16_t *)pkt) = htons(block_number);
335 pkt += 2;
336
337 send_udp_packet(g_tftp_socket , snd_buf, 4, get_server_ip(), get_server_port());
338 tftp_reg_timeout();
339 #ifdef __TFTP_DEBUG__
340 DBG_PRINT(IPC_DBG, ">> TFTP ACK : Block Number(%d)\r\n", block_number);
341 #endif
342 }
343
344 #if 0 // 2014.07.01 sskim
345 static void send_tftp_oack(TFTP_OPTION *opt, uint8_t opt_len)
346 {
347 uint8_t snd_buf[MAX_MTU_SIZE];
348 uint8_t *pkt = snd_buf;
349 uint32_t i, len;
350
351 *((uint16_t *)pkt) = htons((uint16_t)TFTP_OACK);
352 pkt += 2;
353
354 for(i = 0 ; i < opt_len ; i++) {
355 strcpy((char *)pkt, (const char *)opt[i].code);
356 pkt += strlen((char *)opt[i].code) + 1;
357 strcpy((char *)pkt, (const char *)opt[i].value);
358 pkt += strlen((char *)opt[i].value) + 1;
359 }
360
361 len = pkt - snd_buf;
362
363 send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), get_server_port());
364 tftp_reg_timeout();
365 #ifdef __TFTP_DEBUG__
366 DBG_PRINT(IPC_DBG, ">> TFTP OACK \r\n");
367 #endif
368 }
369 #endif
370
371 #if 0 // 2014.07.01 sskim
372 static void send_tftp_error(uint16_t error_number, uint8_t *error_message)
373 {
374 uint8_t snd_buf[MAX_MTU_SIZE];
375 uint8_t *pkt = snd_buf;
376 uint32_t len;
377
378 *((uint16_t *)pkt) = htons((uint16_t)TFTP_ERROR);
379 pkt += 2;
380 *((uint16_t *)pkt) = htons(error_number);
381 pkt += 2;
382 strcpy((char *)pkt, (const char *)error_message);
383 pkt += strlen((char *)error_message) + 1;
384
385 len = pkt - snd_buf;
386
387 send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), get_server_port());
388 tftp_reg_timeout();
389 #ifdef __TFTP_DEBUG__
390 DBG_PRINT(IPC_DBG, ">> TFTP ERROR : Error Number(%d)\r\n", error_number);
391 #endif
392 }
393 #endif
394
395 static void recv_tftp_rrq(uint8_t *msg, uint32_t msg_len)
396 {
397 /* When TFTP Server Mode */
398 }
399
400 static void recv_tftp_wrq(uint8_t *msg, uint32_t msg_len)
401 {
402 /* When TFTP Server Mode */
403 }
404
405 static void recv_tftp_data(uint8_t *msg, uint32_t msg_len)
406 {
407 TFTP_DATA_T *data = (TFTP_DATA_T *)msg;
408
409 data->opcode = ntohs(data->opcode);
410 data->block_num = ntohs(data->block_num);
411 #ifdef __TFTP_DEBUG__
412 DBG_PRINT(IPC_DBG, "<< TFTP_DATA : opcode(%d), block_num(%d)\r\n", data->opcode, data->block_num);
413 #endif
414
415 switch(get_tftp_state())
416 {
417 case STATE_RRQ :
418 case STATE_OACK :
419 if(data->block_num == 1) {
420 set_tftp_state(STATE_DATA);
421 set_block_number(data->block_num);
422 #ifdef F_STORAGE
423 save_data(data->data, msg_len - 4, data->block_num);
424 #endif
425 tftp_cancel_timeout();
426 }
427 send_tftp_ack(data->block_num);
428
429 if((msg_len - 4) < TFTP_BLK_SIZE) {
430 init_tftp();
431 g_progress_state = TFTP_SUCCESS;
432 }
433
434 break;
435
436 case STATE_DATA :
437 if(data->block_num == (get_block_number() + 1)) {
438 set_block_number(data->block_num);
439 #ifdef F_STORAGE
440 save_data(data->data, msg_len - 4, data->block_num);
441 #endif
442 tftp_cancel_timeout();
443 }
444 send_tftp_ack(data->block_num);
445
446 if((msg_len - 4) < TFTP_BLK_SIZE) {
447 init_tftp();
448 g_progress_state = TFTP_SUCCESS;
449 }
450
451 break;
452
453 default :
454 /* invalid message */
455 break;
456 }
457 }
458
459 static void recv_tftp_ack(uint8_t *msg, uint32_t msg_len)
460 {
461 #ifdef __TFTP_DEBUG__
462 DBG_PRINT(IPC_DBG, "<< TFTP_ACK : \r\n");
463 #endif
464
465 switch(get_tftp_state())
466 {
467 case STATE_WRQ :
468 break;
469
470 case STATE_ACK :
471 break;
472
473 default :
474 /* invalid message */
475 break;
476 }
477 }
478
479 static void recv_tftp_oack(uint8_t *msg, uint32_t msg_len)
480 {
481 #ifdef __TFTP_DEBUG__
482 DBG_PRINT(IPC_DBG, "<< TFTP_OACK : \r\n");
483 #endif
484
485 switch(get_tftp_state())
486 {
487 case STATE_RRQ :
488 process_tftp_option(msg, msg_len);
489 set_tftp_state(STATE_OACK);
490 tftp_cancel_timeout();
491 send_tftp_ack(0);
492 break;
493
494 case STATE_WRQ :
495 process_tftp_option(msg, msg_len);
496 set_tftp_state(STATE_ACK);
497 tftp_cancel_timeout();
498
499 /* TODO DATA Transfer */
500 //send_tftp_data(...);
501 break;
502
503 default :
504 /* invalid message */
505 break;
506 }
507 }
508
509 static void recv_tftp_error(uint8_t *msg, uint32_t msg_len)
510 {
511 TFTP_ERROR_T *data= (TFTP_ERROR_T *)msg;
512
513 data->opcode = ntohs(data->opcode);
514 data->error_code = ntohs(data->error_code);
515
516 #ifdef __TFTP_DEBUG__
517 DBG_PRINT(IPC_DBG, "<< TFTP_ERROR : %d (%s)\r\n", data->error_code, data->error_msg);
518 DBG_PRINT(ERROR_DBG, "[%s] Error Code : %d (%s)\r\n", __func__, data->error_code, data->error_msg);
519 #endif
520 init_tftp();
521 g_progress_state = TFTP_FAIL;
522 }
523
524 static void recv_tftp_packet(uint8_t *packet, uint32_t packet_len, uint32_t from_ip, uint16_t from_port)
525 {
526 uint16_t opcode;
527
528 /* Verify Server IP */
529 if(from_ip != get_server_ip()) {
530 #ifdef __TFTP_DEBUG__
531 DBG_PRINT(ERROR_DBG, "[%s] Server IP faults\r\n", __func__);
532 DBG_PRINT(ERROR_DBG, "from IP : %08x, Server IP : %08x\r\n", from_ip, get_server_ip());
533 #endif
534 return;
535 }
536
537 opcode = ntohs(*((uint16_t *)packet));
538
539 /* Set Server Port */
540 if((get_tftp_state() == STATE_WRQ) || (get_tftp_state() == STATE_RRQ)) {
541 set_server_port(from_port);
542 #ifdef __TFTP_DEBUG__
543 DBG_PRINT(INFO_DBG, "[%s] Set Server Port : %d\r\n", __func__, from_port);
544 #endif
545 }
546
547 switch(opcode)
548 {
549 case TFTP_RRQ : /* When Server */
550 recv_tftp_rrq(packet, packet_len);
551 break;
552 case TFTP_WRQ : /* When Server */
553 recv_tftp_wrq(packet, packet_len);
554 break;
555 case TFTP_DATA :
556 recv_tftp_data(packet, packet_len);
557 break;
558 case TFTP_ACK :
559 recv_tftp_ack(packet, packet_len);
560 break;
561 case TFTP_OACK :
562 recv_tftp_oack(packet, packet_len);
563 break;
564 case TFTP_ERROR :
565 recv_tftp_error(packet, packet_len);
566 break;
567
568 default :
569 // Unknown Mesage
570 break;
571 }
572 }
573
574 /* Functions ----------------------------------------------------*/
575 void TFTP_init(uint8_t socket, uint8_t *buf)
576 {
577 init_tftp();
578
579 g_tftp_socket = open_tftp_socket(socket);
580 g_tftp_rcv_buf = buf;
581 }
582
583 void TFTP_exit(void)
584 {
585 init_tftp();
586
587 close_tftp_socket(g_tftp_socket);
588 g_tftp_socket = -1;
589
590 g_tftp_rcv_buf = NULL;
591 }
592
593 int TFTP_run(void)
594 {
595 uint16_t len, from_port;
596 uint32_t from_ip;
597
598 /* Timeout Process */
599 if(g_resend_flag) {
600 if(tftp_time_cnt >= g_timeout) {
601 switch(get_tftp_state()) {
602 case STATE_WRQ: // 미구현
603 break;
604
605 case STATE_RRQ:
606 send_tftp_rrq(g_filename, (uint8_t *)TRANS_BINARY, &default_tftp_opt, 1);
607 break;
608
609 case STATE_OACK:
610 case STATE_DATA:
611 send_tftp_ack(get_block_number());
612 break;
613
614 case STATE_ACK: // 미구현
615 break;
616
617 default:
618 break;
619 }
620
621 tftp_time_cnt = 0;
622 tftp_retry_cnt++;
623
624 if(tftp_retry_cnt >= 5) {
625 init_tftp();
626 g_progress_state = TFTP_FAIL;
627 }
628 }
629 }
630
631 /* Receive Packet Process */
632 len = recv_udp_packet(g_tftp_socket, g_tftp_rcv_buf, MAX_MTU_SIZE, &from_ip, &from_port);
633 if(len < 0) {
634 #ifdef __TFTP_DEBUG__
635 DBG_PRINT(ERROR_DBG, "[%s] recv_udp_packet error\r\n", __func__);
636 #endif
637 return g_progress_state;
638 }
639
640 recv_tftp_packet(g_tftp_rcv_buf, len, from_ip, from_port);
641
642 return g_progress_state;
643 }
644
645 void TFTP_read_request(uint32_t server_ip, uint8_t *filename)
646 {
647 set_server_ip(server_ip);
648 #ifdef __TFTP_DEBUG__
649 DBG_PRINT(INFO_DBG, "[%s] Set Tftp Server : %x\r\n", __func__, server_ip);
650 #endif
651
652 g_progress_state = TFTP_PROGRESS;
653 send_tftp_rrq(filename, (uint8_t *)TRANS_BINARY, &default_tftp_opt, 1);
654 }
655
656 void tftp_timeout_handler(void)
657 {
658 if(g_resend_flag)
659 tftp_time_cnt++;
660 }
SO_STATUS
Valid only in getsockopt. Get the socket status. Sn_SR, getSn_SR()
Definition: socket.h:396
ERROR_DBG
#define ERROR_DBG
Definition: tftp.h:20
SOCK_UDP
#define SOCK_UDP
UDP socket.
Definition: w5100.h:982
TFTP_FAIL
#define TFTP_FAIL
Definition: tftp.h:56
TFTP_SERVER_PORT
#define TFTP_SERVER_PORT
Definition: tftp.h:60
tftp_data::data
uint8_t data[0]
Definition: tftp.h:72
tftp_data::opcode
uint16_t opcode
Definition: tftp.h:70
SOCK_OK
#define SOCK_OK
Result is OK about socket process.
Definition: socket.h:92
IPC_DBG
#define IPC_DBG
Definition: tftp.h:22
FILE_NAME_SIZE
#define FILE_NAME_SIZE
Definition: tftp.h:64
htons
uint16_t htons(uint16_t hostshort)
Definition: netutil.c:99
tftp_data
Definition: tftp.h:69
getsockopt
int8_t getsockopt(uint8_t sn, sockopt_type sotype, void *arg)
get socket options
Definition: socket.c:874
save_data
void save_data(uint8_t *data, uint32_t data_len, uint16_t block_number)
tftp_option::code
uint8_t * code
Definition: tftp.h:82
TFTP_ACK
#define TFTP_ACK
Definition: tftp.h:38
tftp_option
Definition: tftp.h:81
tftp_error::error_msg
uint8_t error_msg[0]
Definition: tftp.h:78
netutil.h
close
int8_t close(uint8_t sn)
Close a socket.
Definition: socket.c:197
dbg_level
int dbg_level
Definition: tftp.c:52
SF_IO_NONBLOCK
#define SF_IO_NONBLOCK
Socket nonblock io mode. It used parameter in socket().
Definition: socket.h:133
STATE_RRQ
#define STATE_RRQ
Definition: tftp.h:44
TFTP_run
int TFTP_run(void)
Definition: tftp.c:593
Sn_MR_UDP
#define Sn_MR_UDP
UDP.
Definition: w5100.h:654
tftp_error::opcode
uint16_t opcode
Definition: tftp.h:76
STATE_NONE
#define STATE_NONE
Definition: tftp.h:43
ntohl
uint32_t ntohl(uint32_t netlong)
Definition: netutil.c:148
MAX_MTU_SIZE
#define MAX_MTU_SIZE
Definition: tftp.h:63
STATE_WRQ
#define STATE_WRQ
Definition: tftp.h:45
htonl
uint32_t htonl(uint32_t hostlong)
Definition: netutil.c:115
TFTP_PROGRESS
#define TFTP_PROGRESS
Definition: tftp.h:55
tftp.h
TFTP Header File.
tftp_error::error_code
uint16_t error_code
Definition: tftp.h:77
TRANS_BINARY
#define TRANS_BINARY
Definition: tftp.h:52
sendto
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.
Definition: socket.c:489
g_progress_state
uint8_t g_progress_state
Definition: tftp.c:49
tftp_timeout_handler
void tftp_timeout_handler(void)
Definition: tftp.c:656
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
TFTP_ERROR
#define TFTP_ERROR
Definition: tftp.h:39
TFTP_WRQ
#define TFTP_WRQ
Definition: tftp.h:36
TFTP_init
void TFTP_init(uint8_t socket, uint8_t *buf)
Definition: tftp.c:575
TFTP_OACK
#define TFTP_OACK
Definition: tftp.h:40
recvfrom
int32_t recvfrom(uint8_t sn, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
Receive datagram of UDP or MACRAW.
Definition: socket.c:593
DBG_PRINT
#define DBG_PRINT(level, format, args...)
Definition: tftp.h:24
STATE_DATA
#define STATE_DATA
Definition: tftp.h:46
TFTP_exit
void TFTP_exit(void)
Definition: tftp.c:583
TFTP_BLK_SIZE
#define TFTP_BLK_SIZE
Definition: tftp.h:62
SO_RECVBUF
Valid only in getsockopt. Get the received data size in socket RX buffer. Sn_RX_RSR, getSn_RX_RSR()
Definition: socket.h:395
STATE_OACK
#define STATE_OACK
Definition: tftp.h:48
TFTP_SUCCESS
#define TFTP_SUCCESS
Definition: tftp.h:57
INFO_DBG
#define INFO_DBG
Definition: tftp.h:19
TFTP_read_request
void TFTP_read_request(uint32_t server_ip, uint8_t *filename)
Definition: tftp.c:645
tftp_data::block_num
uint16_t block_num
Definition: tftp.h:71
TFTP_DATA
#define TFTP_DATA
Definition: tftp.h:37
socket.h
SOCKET APIs Header file.
ntohs
uint32_t ntohs(uint16_t netshort)
Definition: netutil.c:132
TFTP_RRQ
#define TFTP_RRQ
Definition: tftp.h:35
tftp_error
Definition: tftp.h:75
STATE_ACK
#define STATE_ACK
Definition: tftp.h:47


ioLibrary: Internet/TFTP/tftp.h Source File

  • Internet
  • TFTP
tftp.h
Go to the documentation of this file.
1
7 #ifndef __TFTP_H__
8 #define __TFTP_H__
9
10 #include <stdint.h>
11
12 #define F_APP_TFTP
13 #define __TFTP_DEBUG__
14
15 #define F_STORAGE // If your target support a storage, you have to activate this feature and implement.
16
17 #define SOCK_TFTP 1
18
19 #define INFO_DBG 0x01
20 #define ERROR_DBG 0x02
21 #define DEBUG_DBG 0x04
22 #define IPC_DBG 0x08
23
24 #define DBG_PRINT(level, format, args...) { \
25 if(dbg_level & level) \
26 printf(format, ##args); \
27 }
28
29 #define NORMAL_MODE 0
30 #define TFTP_MODE 1
31
32 extern int dbg_level;
33
34 /* tftp message */
35 #define TFTP_RRQ 1
36 #define TFTP_WRQ 2
37 #define TFTP_DATA 3
38 #define TFTP_ACK 4
39 #define TFTP_ERROR 5
40 #define TFTP_OACK 6
41
42 /* tftp state */
43 #define STATE_NONE 0
44 #define STATE_RRQ 1
45 #define STATE_WRQ 2
46 #define STATE_DATA 3
47 #define STATE_ACK 4
48 #define STATE_OACK 5
49
50 /* tftp transfer mode */
51 #define TRANS_ASCII "netascii"
52 #define TRANS_BINARY "octet"
53
54 /* tftp progress state */
55 #define TFTP_PROGRESS 0
56 #define TFTP_FAIL 1
57 #define TFTP_SUCCESS 2
58
59 /* define */
60 #define TFTP_SERVER_PORT 69
61 #define TFTP_TEMP_PORT 51000
62 #define TFTP_BLK_SIZE 512
63 #define MAX_MTU_SIZE 1514
64 #define FILE_NAME_SIZE 20
65
66 //#define __TFTP_DEBUG__
67
68 /* typedef */
69 typedef struct tftp_data {
70 uint16_t opcode;
71 uint16_t block_num;
72 uint8_t data[0];
73 } TFTP_DATA_T;
74
75 typedef struct tftp_error {
76 uint16_t opcode;
77 uint16_t error_code;
78 uint8_t error_msg[0];
79 } TFTP_ERROR_T;
80
81 typedef struct tftp_option {
82 uint8_t *code;
83 uint8_t *value;
84 } TFTP_OPTION;
85
86 /* Functions */
87 void TFTP_init(uint8_t socket, uint8_t *buf);
88 void TFTP_exit(void);
89 int TFTP_run(void);
90 void TFTP_read_request(uint32_t server_ip, uint8_t *filename);
91 void tftp_timeout_handler(void);
92
93 #endif /*__TFTP_H__ */
dbg_level
int dbg_level
Definition: tftp.c:52
tftp_data::data
uint8_t data[0]
Definition: tftp.h:72
tftp_timeout_handler
void tftp_timeout_handler(void)
Definition: tftp.c:656
tftp_data::opcode
uint16_t opcode
Definition: tftp.h:70
TFTP_init
void TFTP_init(uint8_t socket, uint8_t *buf)
Definition: tftp.c:575
tftp_data
Definition: tftp.h:69
tftp_option::code
uint8_t * code
Definition: tftp.h:82
tftp_option
Definition: tftp.h:81
tftp_error::error_msg
uint8_t error_msg[0]
Definition: tftp.h:78
TFTP_DATA_T
struct tftp_data TFTP_DATA_T
tftp_error::opcode
uint16_t opcode
Definition: tftp.h:76
TFTP_OPTION
struct tftp_option TFTP_OPTION
TFTP_read_request
void TFTP_read_request(uint32_t server_ip, uint8_t *filename)
Definition: tftp.c:645
TFTP_ERROR_T
struct tftp_error TFTP_ERROR_T
tftp_error::error_code
uint16_t error_code
Definition: tftp.h:77
tftp_option::value
uint8_t * value
Definition: tftp.h:83
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:105
TFTP_exit
void TFTP_exit(void)
Definition: tftp.c:583
tftp_data::block_num
uint16_t block_num
Definition: tftp.h:71
TFTP_run
int TFTP_run(void)
Definition: tftp.c:593
tftp_error
Definition: tftp.h:75


ioLibrary: 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(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(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 //M20150601 : Rename the function for integrating with ioLibrary
59 //WIZCHIP.IF.BUS._write_byte(AddrSel,wb);
60 WIZCHIP.IF.BUS._write_data(AddrSel,wb);
61 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
62
63 //add indirect bus
64 //M20150601 : Rename the function for integrating with ioLibrary
65 //WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
66 //WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
67 //WIZCHIP.IF.BUS._write_byte(IDM_DR,wb);
68 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
69 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
70 WIZCHIP.IF.BUS._write_data(IDM_DR,wb);
71 #else
72 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!"
73 #endif
74
75 WIZCHIP.CS._deselect();
76 WIZCHIP_CRITICAL_EXIT();
77 }
81 uint8_t WIZCHIP_READ(uint32_t AddrSel)
82 {
83 uint8_t ret;
84
85 WIZCHIP_CRITICAL_ENTER();
86 WIZCHIP.CS._select();
87
88 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
89 WIZCHIP.IF.SPI._write_byte(0x0F);
90 WIZCHIP.IF.SPI._write_byte((AddrSel & 0xFF00) >> 8);
91 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF) >> 0);
92 ret = WIZCHIP.IF.SPI._read_byte();
93 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
94 //M20150601 : Rename the function for integrating with ioLibrary
95 //ret = WIZCHIP.IF.BUS._read_byte(AddrSel);
96 ret = WIZCHIP.IF.BUS._read_data(AddrSel);
97 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
98
99 //add indirect bus
100 //M20150601 : Rename the function for integrating with ioLibrary
101 //WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
102 //WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
103 //ret = WIZCHIP.IF.BUS._read_byte(IDM_DR);
104 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
105 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
106 ret = WIZCHIP.IF.BUS._read_data(IDM_DR);
107
108 #else
109 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!"
110 #endif
111
112 WIZCHIP.CS._deselect();
113 WIZCHIP_CRITICAL_EXIT();
114 return ret;
115 }
116
117
121 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
122 {
123 uint16_t i = 0;
124
125 WIZCHIP_CRITICAL_ENTER();
126 WIZCHIP.CS._select(); //M20150601 : Moved here.
127
128 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
129 for(i = 0; i < len; i++)
130 {
131 //M20160715 : Depricated "M20150601 : Remove _select() to top-side"
132 // CS should be controlled every SPI frames
133 WIZCHIP.CS._select();
134 WIZCHIP.IF.SPI._write_byte(0xF0);
135 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0xFF00) >> 8);
136 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0x00FF) >> 0);
137 WIZCHIP.IF.SPI._write_byte(pBuf[i]); // Data write (write 1byte data)
138 //M20160715 : Depricated "M20150601 : Remove _select() to top-side"
139 WIZCHIP.CS._deselect();
140 }
141 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
142 for(i = 0; i < len; i++)
143 //M20150601 : Rename the function for integrating with ioLibrary
144 // WIZCHIP.IF.BUS._write_byte(AddrSel+i,pBuf[i]);
145 WIZCHIP.IF.BUS._write_data(AddrSel+i,pBuf[i]);
146 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
147 //M20150601 : Rename the function for integrating with ioLibrary
148 /*
149 WIZCHIP_WRITE(MR,WIZCHIP_READ(MR) | MR_AI);
150 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
151 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
152 for(i = 0 ; i < len; i++)
153 WIZCHIP.IF.BUS._write_byte(IDM_DR,pBuf[i]);
154 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
155 */
156 setMR(getMR()|MR_AI);
157 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
158 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
159 for(i = 0 ; i < len; i++)
160 WIZCHIP.IF.BUS._write_data(IDM_DR,pBuf[i]);
161 setMR(getMR() & ~MR_AI);
162
163 #else
164 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!!"
165 #endif
166
167 WIZCHIP.CS._deselect(); //M20150601 : Moved here.
168 WIZCHIP_CRITICAL_EXIT();
169 }
170
175 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
176 {
177 uint16_t i = 0;
178 WIZCHIP_CRITICAL_ENTER();
179 WIZCHIP.CS._select(); //M20150601 : Moved here.
180
181 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
182 for(i = 0; i < len; i++)
183 {
184 //M20160715 : Depricated "M20150601 : Remove _select() to top-side"
185 // CS should be controlled every SPI frames
186 WIZCHIP.CS._select();
187 WIZCHIP.IF.SPI._write_byte(0x0F);
188 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0xFF00) >> 8);
189 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0x00FF) >> 0);
190 pBuf[i] = WIZCHIP.IF.SPI._read_byte();
191 //M20160715 : Depricated "M20150601 : Remove _select() to top-side"
192 WIZCHIP.CS._deselect();
193 }
194 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
195 for(i = 0 ; i < len; i++)
196 //M20150601 : Rename the function for integrating with ioLibrary
197 // pBuf[i] = WIZCHIP.IF.BUS._read_byte(AddrSel+i);
198 pBuf[i] = WIZCHIP.IF.BUS._read_data(AddrSel+i);
199 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
200 //M20150601 : Rename the function for integrating with ioLibrary
201 /*
202 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) | MR_AI);
203 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
204 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
205 for(i = 0 ; i < len; i++)
206 pBuf[i] = WIZCHIP.IF.BUS._read_byte(IDM_DR);
207 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
208 */
209 setMR(getMR() | MR_AI);
210 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
211 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
212 for(i = 0 ; i < len; i++)
213 pBuf[i] = WIZCHIP.IF.BUS._read_data(IDM_DR);
214 setMR(getMR() & ~MR_AI);
215
216 #else
217 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!!"
218 #endif
219
220 WIZCHIP.CS._deselect(); //M20150601 : Moved Here.
221 WIZCHIP_CRITICAL_EXIT();
222 }
223
225 // Socket N regsiter IO function //
227
228 uint16_t getSn_TX_FSR(uint8_t sn)
229 {
230 uint16_t val=0,val1=0;
231 do
232 {
233 val1 = WIZCHIP_READ(Sn_TX_FSR(sn));
234 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
235 if (val1 != 0)
236 {
237 val = WIZCHIP_READ(Sn_TX_FSR(sn));
238 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
239 }
240 }while (val != val1);
241 return val;
242 }
243
244
245 uint16_t getSn_RX_RSR(uint8_t sn)
246 {
247 uint16_t val=0,val1=0;
248 do
249 {
250 val1 = WIZCHIP_READ(Sn_RX_RSR(sn));
251 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
252 if (val1 != 0)
253 {
254 val = WIZCHIP_READ(Sn_RX_RSR(sn));
255 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
256 }
257 }while (val != val1);
258 return val;
259 }
260
262 // Sn_TXBUF & Sn_RXBUF IO function //
264 uint32_t getSn_RxBASE(uint8_t sn)
265 {
266 int8_t i;
267 #if ( _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
268 uint32_t rxbase = _W5100_IO_BASE_ + _WIZCHIP_IO_RXBUF_;
269 #else
270 uint32_t rxbase = _WIZCHIP_IO_RXBUF_;
271 #endif
272 for(i = 0; i < sn; i++)
273 rxbase += getSn_RxMAX(i);
274
275 return rxbase;
276 }
277
278 uint32_t getSn_TxBASE(uint8_t sn)
279 {
280 int8_t i;
281 #if ( _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
282 uint32_t txbase = _W5100_IO_BASE_ + _WIZCHIP_IO_TXBUF_;
283 #else
284 uint32_t txbase = _WIZCHIP_IO_TXBUF_;
285 #endif
286 for(i = 0; i < sn; i++)
287 txbase += getSn_TxMAX(i);
288 return txbase;
289 }
290
302 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
303 {
304 uint16_t ptr;
305 uint16_t size;
306 uint16_t dst_mask;
307 uint16_t dst_ptr;
308
309 ptr = getSn_TX_WR(sn);
310
311 dst_mask = ptr & getSn_TxMASK(sn);
312 dst_ptr = getSn_TxBASE(sn) + dst_mask;
313
314 if (dst_mask + len > getSn_TxMAX(sn))
315 {
316 size = getSn_TxMAX(sn) - dst_mask;
317 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, size);
318 wizdata += size;
319 size = len - size;
320 dst_ptr = getSn_TxBASE(sn);
321 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, size);
322 }
323 else
324 {
325 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, len);
326 }
327
328 ptr += len;
329
330 setSn_TX_WR(sn, ptr);
331 }
332
333
344 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
345 {
346 uint16_t ptr;
347 uint16_t size;
348 uint16_t src_mask;
349 uint16_t src_ptr;
350
351 ptr = getSn_RX_RD(sn);
352
353 src_mask = (uint32_t)ptr & getSn_RxMASK(sn);
354 src_ptr = (getSn_RxBASE(sn) + src_mask);
355
356
357 if( (src_mask + len) > getSn_RxMAX(sn) )
358 {
359 size = getSn_RxMAX(sn) - src_mask;
360 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, size);
361 wizdata += size;
362 size = len - size;
363 src_ptr = getSn_RxBASE(sn);
364 WIZCHIP_READ_BUF(src_ptr, (uint8_t*)wizdata, size);
365 }
366 else
367 {
368 WIZCHIP_READ_BUF(src_ptr, (uint8_t*)wizdata, len);
369 }
370
371 ptr += len;
372
373 setSn_RX_RD(sn, ptr);
374 }
375
376 void wiz_recv_ignore(uint8_t sn, uint16_t len)
377 {
378 uint16_t ptr;
379
380 ptr = getSn_RX_RD(sn);
381
382 ptr += len;
383 setSn_RX_RD(sn,ptr);
384 }
385
386 #endif
getSn_TxBASE
uint32_t getSn_TxBASE(uint8_t sn)
Get the base address of socket sn TX buffer.
Definition: w5100s.c:287
__WIZCHIP::_IF::_read_data
iodata_t(* _read_data)(uint32_t AddrSel)
Definition: wizchip_conf.h:261
WIZCHIP
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
_W5100_IO_BASE_
#define _W5100_IO_BASE_
Definition: w5100.h:62
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
Definition: w5100s.c:181
getSn_RxMASK
#define getSn_RxMASK(sn)
Get the mask of socket sn RX buffer.
Definition: w5100.h:1777
getSn_TxMAX
#define getSn_TxMAX(sn)
Get the max TX buffer size of socket sn.
Definition: w5100.h:1768
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
__WIZCHIP::_IF::BUS
struct __WIZCHIP::_IF::@0 BUS
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
__WIZCHIP::_CS::_select
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:242
getSn_RxBASE
uint32_t getSn_RxBASE(uint8_t sn)
Get the base address of socket sn RX buffer.
Definition: w5100s.c:273
MR_AI
#define MR_AI
Address Auto-Increment in Indirect Bus Interface.
Definition: w5100.h:603
WIZCHIP_CRITICAL_ENTER
#define WIZCHIP_CRITICAL_ENTER()
Enter a critical section.
Definition: w5100.h:1032
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
setMR
#define setMR(mr)
Set Mode Register.
Definition: w5100.h:1108
getSn_TX_WR
#define getSn_TX_WR(sn)
Get Sn_TX_WR register.
Definition: w5100.h:1675
getSn_RxMAX
#define getSn_RxMAX(sn)
Get the max RX buffer size of socket sn.
Definition: w5100.h:1758
Sn_TX_FSR
#define Sn_TX_FSR(sn)
Transmit free memory size register(R)
Definition: w5100.h:510
__WIZCHIP::_IF::_read_byte
uint8_t(* _read_byte)(void)
Definition: wizchip_conf.h:270
__WIZCHIP::IF
union __WIZCHIP::_IF IF
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
Definition: w5100s.c:124
getMR
#define getMR()
Get MR.
Definition: w5100.h:1120
_WIZCHIP_IO_RXBUF_
#define _WIZCHIP_IO_RXBUF_
Definition: w5100.h:53
__WIZCHIP::_IF::_write_data
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Definition: wizchip_conf.h:262
Sn_RX_RSR
#define Sn_RX_RSR(sn)
Received data size register(R)
Definition: w5100.h:545
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
__WIZCHIP::_IF::_write_byte
void(* _write_byte)(uint8_t wb)
Definition: wizchip_conf.h:271
__WIZCHIP::CS
struct __WIZCHIP::_CS CS
w5100.h
W5100 HAL Header File.
setSn_TX_WR
#define setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register.
Definition: w5100.h:1663
__WIZCHIP::_CS::_deselect
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:243
WIZCHIP_CRITICAL_EXIT
#define WIZCHIP_CRITICAL_EXIT()
Exit a critical section.
Definition: w5100.h:1049
getSn_TxMASK
#define getSn_TxMASK(sn)
Get the mask of socket sn TX buffer.
Definition: w5100.h:1786
_WIZCHIP_IO_TXBUF_
#define _WIZCHIP_IO_TXBUF_
Definition: w5100.h:52
setSn_RX_RD
#define setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register.
Definition: w5100.h:1693
__WIZCHIP::_IF::SPI
struct __WIZCHIP::_IF::@1 SPI
getSn_RX_RD
#define getSn_RX_RD(sn)
Get Sn_RX_RD register.
Definition: w5100.h:1705


ioLibrary: 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
47 #if (_WIZCHIP_ == 5100)
48
50 #define _WIZCHIP_SN_BASE_ (0x0400)
51 #define _WIZCHIP_SN_SIZE_ (0x0100)
52 #define _WIZCHIP_IO_TXBUF_ (0x4000) /* Internal Tx buffer address of the iinchip */
53 #define _WIZCHIP_IO_RXBUF_ (0x6000) /* Internal Rx buffer address of the iinchip */
54
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_DIR_)
62 #define _W5100_IO_BASE_ _WIZCHIP_IO_BASE_
63 #elif (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_)
64 #define IDM_OR ((_WIZCHIP_IO_BASE + 0x0000))
65 #define IDM_AR0 ((_WIZCHIP_IO_BASE_ + 0x0001))
66 #define IDM_AR1 ((_WIZCHIP_IO_BASE_ + 0x0002))
67 #define IDM_DR ((_WIZCHIP_IO_BASE_ + 0x0003))
68 #define _W5100_IO_BASE_ 0x0000
69 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
70 #define _W5100_IO_BASE_ 0x0000
71 #endif
72
74 // Definition For Legacy Chip Driver //
76 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
77 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
78 #define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
79 #define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
80
81
82 //----------- defgroup --------------------------------
83
183 //-----------------------------------------------------------------------------------
184
185 //----------------------------- W5100 Common Registers IOMAP -----------------------------
201 #if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_
202 #define MR (_WIZCHIP_IO_BASE_ + (0x0000)) // Mode
203 #else
204 #define MR (_W5100_IO_BASE_ + (0x0000)) // Mode
205 #endif
206
212 #define GAR (_W5100_IO_BASE_ + (0x0001)) // GW Address
213
219 #define SUBR (_W5100_IO_BASE_ + (0x0005)) // SN Mask Address
220
226 #define SHAR (_W5100_IO_BASE_ + (0x0009)) // Source Hardware Address
227
233 #define SIPR (_W5100_IO_BASE_ + (0x000F)) // Source IP Address
234
235 // Reserved (_W5100_IO_BASE_ + (0x0013))
236 // Reserved (_W5100_IO_BASE_ + (0x0014))
237
256 #define IR (_W5100_IO_BASE_ + (0x0015)) // Interrupt
257
264 #define _IMR_ (_W5100_IO_BASE_ + (0x0016)) // Socket Interrupt Mask
265
274 #define _RTR_ (_W5100_IO_BASE_ + (0x0017)) // Retry Time
275
282 #define _RCR_ (_W5100_IO_BASE_ + (0x0019)) // Retry Count
283 #define RMSR (_W5100_IO_BASE_ + (0x001A)) // Receicve Memory Size
284 #define TMSR (_W5100_IO_BASE_ + (0x001B)) // Trnasmit Memory Size
285
286
293 #define PATR (_W5100_IO_BASE_ + (0x001C))
294
295
301 #define PTIMER (_W5100_IO_BASE_ + (0x0028)) // PPP LCP RequestTimer
302
308 #define PMAGIC (_W5100_IO_BASE_ + (0x0029)) // PPP LCP Magic number
309
310 #define UIPR0 (_W5100_IO_BASE_ + (0x002A))
311 #define UPORT0 (_W5100_IO_BASE + (0x002E))
312
313
314
315 //----------------------------- W5100 Socket Registers -----------------------------
316
317 //--------------------------- For Backward Compatibility ---------------------------
318
352 #define Sn_MR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000)) // socket Mode register
353
380 #define Sn_CR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001)) // channel Sn_CR register
381
401 #define Sn_IR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002)) // channel interrupt register
402
424 #define Sn_SR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003)) // channel status register
425
432 #define Sn_PORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004)) // source port register
433
440 #define Sn_DHAR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006)) // Peer MAC register address
441
450 #define Sn_DIPR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C)) // Peer IP register address
451
460 #define Sn_DPORT(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010)) // Peer port register address
461
467 #define Sn_MSSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012)) // Maximum Segment Size(Sn_MSSR0) register address
468
475 #define Sn_PROTO(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014)) // Protocol of IP Header field register in IP raw mode
476
483 #define Sn_TOS(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015) // IP Type of Service(TOS) Register
484
491 #define Sn_TTL(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016)) // IP Time to live(TTL) Register
492
493 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0017))
494 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0018))
495 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0019))
496 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001A))
497 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001B))
498 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001C))
499 // Reserved (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001D))
500
510 #define Sn_TX_FSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020)) // Transmit free memory size register
511
522 #define Sn_TX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022)) // Transmit memory read pointer register address
523
536 #define Sn_TX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024)) // Transmit memory write pointer register address
537
545 #define Sn_RX_RSR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026)) // Received data size register
546
558 #define Sn_RX_RD(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028)) // Read point of Receive memory
559
567 #define Sn_RX_WR(sn) (_W5100_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A)) // Write point of Receive memory
568
569
570 //----------------------------- W5100 Register values -----------------------------
571
572 /* MODE register values */
577 #define MR_RST 0x80
578
579
586 #define MR_PB 0x10
587
588
594 #define MR_PPPOE 0x08
595
596
603 #define MR_AI 0x02
604
605
611 #define MR_IND 0x01
612
613 /* IR register values */
618 #define IR_CONFLICT 0x80
619
620
625 #define IR_UNREACH 0x40
626
627
631 #define IR_PPPoE 0x20
632
633 #define IR_SOCK(sn) (0x01 << sn)
634
635
636 // Sn_MR values
637 /* Sn_MR Default values */
642 #define Sn_MR_CLOSE 0x00
643
644
648 #define Sn_MR_TCP 0x01
649
650
654 #define Sn_MR_UDP 0x02
655 #define Sn_MR_IPRAW 0x03
656
657
662 #define Sn_MR_MACRAW 0x04
663
664
669 #define Sn_MR_PPPoE 0x05
670
671
679 #define Sn_MR_ND 0x20
680
681
688 #define Sn_MR_MC Sn_MR_ND
689
690
700 #define Sn_MR_MF 0x40
701 #define Sn_MR_MFEN Sn_MR_MF
702
703
704 /* Sn_MR Default values */
713 #define Sn_MR_MULTI 0x80
714
715 /* Sn_CR values */
730 #define Sn_CR_OPEN 0x01
731
732
741 #define Sn_CR_LISTEN 0x02
742
743
753 #define Sn_CR_CONNECT 0x04
754
755
766 #define Sn_CR_DISCON 0x08
767
768
772 #define Sn_CR_CLOSE 0x10
773
780 #define Sn_CR_SEND 0x20
781
790 #define Sn_CR_SEND_MAC 0x21
791
798 #define Sn_CR_SEND_KEEP 0x22
799
806 #define Sn_CR_RECV 0x40
807
812 #define Sn_CR_PCON 0x23
813
818 #define Sn_CR_PDISCON 0x24
819
824 #define Sn_CR_PCR 0x25
825
830 #define Sn_CR_PCN 0x26
831
836 #define Sn_CR_PCJ 0x27
837
838 /* Sn_IR values */
843 #define Sn_IR_PRECV 0x80
844
849 #define Sn_IR_PFAIL 0x40
850
855 #define Sn_IR_PNEXT 0x20
856
861 #define Sn_IR_SENDOK 0x10
862
863
867 #define Sn_IR_TIMEOUT 0x08
868
869
873 #define Sn_IR_RECV 0x04
874
879 #define Sn_IR_DISCON 0x02
880
885 #define Sn_IR_CON 0x01
886
887 /* Sn_SR values */
893 #define SOCK_CLOSED 0x00
894
895
901 #define SOCK_INIT 0x13
902
903
909 #define SOCK_LISTEN 0x14
910
918 #define SOCK_SYNSENT 0x15
919
926 #define SOCK_SYNRECV 0x16
927
935 #define SOCK_ESTABLISHED 0x17
936
943 #define SOCK_FIN_WAIT 0x18
944
951 #define SOCK_CLOSING 0x1A
952
959 #define SOCK_TIME_WAIT 0x1B
960
967 #define SOCK_CLOSE_WAIT 0x1C
968
974 #define SOCK_LAST_ACK 0x1D
975
982 #define SOCK_UDP 0x22
983
984
990 #define SOCK_IPRAW 0x32
991
992
998 #define SOCK_MACRAW 0x42
999
1000
1007 #define SOCK_PPPOE 0x5F
1008
1009 // IP PROTOCOL
1010 #define IPPROTO_IP 0
1011 #define IPPROTO_ICMP 1
1012 #define IPPROTO_IGMP 2
1013 #define IPPROTO_GGP 3
1014 #define IPPROTO_TCP 6
1015 #define IPPROTO_PUP 12
1016 #define IPPROTO_UDP 17
1017 #define IPPROTO_IDP 22
1018 #define IPPROTO_ND 77
1019 #define IPPROTO_RAW 255
1020
1021
1032 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1033
1034 #ifdef _exit
1035 #undef _exit
1036 #endif
1037
1049 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1050
1051
1052
1054 // Basic I/O Function //
1056 //
1057 //M20150601 : uint16_t AddrSel --> uint32_t AddrSel
1058 //
1065 uint8_t WIZCHIP_READ (uint32_t AddrSel);
1066
1074 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb );
1075
1083 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1084
1092 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1093
1094
1096 // Common Register IO function //
1098
1105 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1106 #define setMR(mr) WIZCHIP_WRITE(MR,mr)
1107 #else
1108 #define setMR(mr) (*((uint8_t*)MR) = mr)
1109 #endif
1110
1117 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1118 #define getMR() WIZCHIP_READ(MR)
1119 #else
1120 #define getMR() (*(uint8_t*)MR)
1121 #endif
1122
1129 #define setGAR(gar) \
1130 WIZCHIP_WRITE_BUF(GAR,gar,4)
1131
1138 #define getGAR(gar) \
1139 WIZCHIP_READ_BUF(GAR,gar,4)
1140
1150 #define setSUBR(subr) \
1151 WIZCHIP_WRITE_BUF(SUBR,subr,4)
1152
1159 #define getSUBR(subr) \
1160 WIZCHIP_READ_BUF(SUBR, subr, 4)
1161
1168 #define setSHAR(shar) \
1169 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1170
1177 #define getSHAR(shar) \
1178 WIZCHIP_READ_BUF(SHAR, shar, 6)
1179
1186 #define setSIPR(sipr) \
1187 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1188
1195 #define getSIPR(sipr) \
1196 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1197
1204 #define setIR(ir) \
1205 WIZCHIP_WRITE(IR, (ir & 0xA0))
1206
1212 #define getIR() \
1213 (WIZCHIP_READ(IR) & 0xA0)
1214
1221 #define setIMR(imr) \
1222 WIZCHIP_WRITE(_IMR_, imr)
1223
1230 #define getIMR() \
1231 WIZCHIP_READ(_IMR_)
1232
1239 #define setRTR(rtr) {\
1240 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1241 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1242 }
1243
1250 #define getRTR() \
1251 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1252
1259 #define setRCR(rcr) \
1260 WIZCHIP_WRITE(_RCR_, rcr)
1261
1268 #define getRCR() \
1269 WIZCHIP_READ(_RCR_)
1270
1276 #define setRMSR(rmsr) \
1277 WIZCHIP_WRITE(RMSR) // Receicve Memory Size
1278
1285 #define getRMSR() \
1286 WIZCHIP_READ() // Receicve Memory Size
1287
1293 #define setTMSR(rmsr) \
1294 WIZCHIP_WRITE(TMSR) // Receicve Memory Size
1295
1309 #define getPATR() \
1310 (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
1311
1317 #define getPPPALGO() \
1318 WIZCHIP_READ(PPPALGO)
1319
1320
1327 #define setPTIMER(ptimer) \
1328 WIZCHIP_WRITE(PTIMER, ptimer)
1329
1336 #define getPTIMER() \
1337 WIZCHIP_READ(PTIMER)
1338
1345 #define setPMAGIC(pmagic) \
1346 WIZCHIP_WRITE(PMAGIC, pmagic)
1347
1354 #define getPMAGIC() \
1355 WIZCHIP_READ(PMAGIC)
1356
1358 // Socket N register I/O function //
1360
1367 #define setSn_MR(sn, mr) \
1368 WIZCHIP_WRITE(Sn_MR(sn),mr)
1369
1377 #define getSn_MR(sn) \
1378 WIZCHIP_READ(Sn_MR(sn))
1379
1387 #define setSn_CR(sn, cr) \
1388 WIZCHIP_WRITE(Sn_CR(sn), cr)
1389
1397 #define getSn_CR(sn) \
1398 WIZCHIP_READ(Sn_CR(sn))
1399
1407 #define setSn_IR(sn, ir) \
1408 WIZCHIP_WRITE(Sn_IR(sn), ir)
1409
1417 #define getSn_IR(sn) \
1418 WIZCHIP_READ(Sn_IR(sn))
1419
1426 #define getSn_SR(sn) \
1427 WIZCHIP_READ(Sn_SR(sn))
1428
1436 #define setSn_PORT(sn, port) { \
1437 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
1438 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
1439 }
1440
1448 #define getSn_PORT(sn) \
1449 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1450
1458 #define setSn_DHAR(sn, dhar) \
1459 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
1460
1468 #define getSn_DHAR(sn, dhar) \
1469 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
1470
1478 #define setSn_DIPR(sn, dipr) \
1479 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
1480
1488 #define getSn_DIPR(sn, dipr) \
1489 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
1490
1498 #define setSn_DPORT(sn, dport) { \
1499 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
1500 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
1501 }
1502
1510 #define getSn_DPORT(sn) \
1511 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1512
1520 #define setSn_MSSR(sn, mss) { \
1521 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
1522 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
1523 }
1524
1532 #define getSn_MSSR(sn) \
1533 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1534
1542 #define setSn_PROTO(sn, proto) \
1543 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1544
1552 #define getSn_PROTO(sn) \
1553 WIZCHIP_READ(Sn_TOS(sn))
1554
1562 #define setSn_TOS(sn, tos) \
1563 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1564
1572 #define getSn_TOS(sn) \
1573 WIZCHIP_READ(Sn_TOS(sn))
1574
1582 #define setSn_TTL(sn, ttl) \
1583 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
1584
1592 #define getSn_TTL(sn) \
1593 WIZCHIP_READ(Sn_TTL(sn))
1594
1602 #define setSn_RXMEM_SIZE(sn, rxmemsize) \
1603 WIZCHIP_WRITE(RMSR, (WIZCHIP_READ(RMSR) & ~(0x03 << (2*sn))) | (rxmemsize << (2*sn)))
1604 #define setSn_RXBUF_SIZE(sn,rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
1605
1613 #define getSn_RXMEM_SIZE(sn) \
1614 ((WIZCHIP_READ(RMSR) & (0x03 << (2*sn))) >> (2*sn))
1615 #define getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
1616
1624 #define setSn_TXMEM_SIZE(sn, txmemsize) \
1625 WIZCHIP_WRITE(TMSR, (WIZCHIP_READ(TMSR) & ~(0x03 << (2*sn))) | (txmemsize << (2*sn)))
1626 #define setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
1627
1635 #define getSn_TXMEM_SIZE(sn) \
1636 ((WIZCHIP_READ(TMSR) & (0x03 << (2*sn))) >> (2*sn))
1637 #define getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
1638
1645 uint16_t getSn_TX_FSR(uint8_t sn);
1646
1653 #define getSn_TX_RD(sn) \
1654 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1655
1663 #define setSn_TX_WR(sn, txwr) { \
1664 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
1665 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
1666 }
1667
1675 #define getSn_TX_WR(sn) \
1676 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1677
1684 uint16_t getSn_RX_RSR(uint8_t sn);
1685
1693 #define setSn_RX_RD(sn, rxrd) { \
1694 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
1695 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
1696 }
1697
1705 #define getSn_RX_RD(sn) \
1706 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
1707
1715 #define setSn_RX_WR(sn, rxwr) { \
1716 WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
1717 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
1718 }
1719
1720
1727 #define getSn_RX_WR(sn) \
1728 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
1729
1737 #define setSn_FRAG(sn, frag) { \
1738 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
1739 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
1740 }
1741
1749 #define getSn_FRAG(sn) \
1750 (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
1751
1758 #define getSn_RxMAX(sn) \
1759 ((uint16_t)(1 << getSn_RXMEM_SIZE(sn)) << 10)
1760
1761
1768 #define getSn_TxMAX(sn) \
1769 ((uint16_t)(1 << getSn_TXMEM_SIZE(sn)) << 10)
1770
1777 #define getSn_RxMASK(sn) \
1778 (getSn_RxMAX(sn) - 1)
1779
1786 #define getSn_TxMASK(sn) \
1787 (getSn_TxMAX(sn) - 1)
1788
1795 uint32_t getSn_RxBASE(uint8_t sn);
1796
1803 uint32_t getSn_TxBASE(uint8_t sn);
1804
1806 // Sn_TXBUF & Sn_RXBUF IO function //
1808
1822 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
1823
1838 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
1839
1847 void wiz_recv_ignore(uint8_t sn, uint16_t len);
1848
1850 #endif
1851
1853 #endif //_W5100_H_
1854
1855
1856
getSn_TxBASE
uint32_t getSn_TxBASE(uint8_t sn)
Get the base address of socket sn TX buffer.
Definition: w5100s.c:287
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
Definition: w5100s.c:181
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
getSn_RxBASE
uint32_t getSn_RxBASE(uint8_t sn)
Get the base address of socket sn RX buffer.
Definition: w5100s.c:273
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
Definition: w5100s.c:124
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
wizchip_conf.h
WIZCHIP Config Header File.


ioLibrary: image/w5100_w5200_w5500.jpg Source File

  • image
w5100_w5200_w5500.jpg
Go to the documentation of this file.
1


ioLibrary: image/w5100_w5200_w5500_w5100s.jpg Source File

  • image
w5100_w5200_w5500_w5100s.jpg
Go to the documentation of this file.
1


ioLibrary: Ethernet/W5100S/w5100s.c Source File

  • Ethernet
  • W5100S
w5100s.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
38 //
39 //*****************************************************************************
40
41 #include "w5100s.h"
42
43 #if (_WIZCHIP_ == W5100S)
44
47 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb )
48 {
49 int i;
50 WIZCHIP_CRITICAL_ENTER();
51 WIZCHIP.CS._select();
52
53 #if( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_))
54 WIZCHIP.IF.SPI._write_byte(0xF0);
55 WIZCHIP.IF.SPI._write_byte((AddrSel & 0xFF00) >> 8);
56 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF) >> 0);
57 WIZCHIP.IF.SPI._write_byte(wb); // Data write (write 1byte data)
58 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_5500_) )
59 WIZCHIP.IF.SPI._write_byte((AddrSel & 0xFF00) >> 8);
60 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF) >> 0);
61 WIZCHIP.IF.SPI._write_byte(0xF0);
62 WIZCHIP.IF.SPI._write_byte(wb); // Data write (write 1byte data)
63 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
64
65 //add indirect bus
66 //M20150601 : Rename the function for integrating with ioLibrary
67 //WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
68 //WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
69 //WIZCHIP.IF.BUS._write_byte(IDM_DR,wb);
70 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
71 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
72 WIZCHIP.IF.BUS._write_data(IDM_DR,wb);
73 #else
74 #error "Unknown _WIZCHIP_IO_MODE_ in W5100. !!!"
75 #endif
76
77 WIZCHIP.CS._deselect();
78 WIZCHIP_CRITICAL_EXIT();
79 }
83 uint8_t WIZCHIP_READ(uint32_t AddrSel)
84 {
85 uint8_t ret;
86 int i;
87 WIZCHIP_CRITICAL_ENTER();
88 WIZCHIP.CS._select();
89
90 #if( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_))
91 WIZCHIP.IF.SPI._write_byte(0x0F);
92 WIZCHIP.IF.SPI._write_byte((AddrSel & 0xFF00) >> 8);
93 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF) >> 0);
94 ret = WIZCHIP.IF.SPI._read_byte();
95 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_5500_) )
96 WIZCHIP.IF.SPI._write_byte((AddrSel & 0xFF00) >> 8);
97 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF) >> 0);
98 WIZCHIP.IF.SPI._write_byte(0x0F);
99 ret = WIZCHIP.IF.SPI._read_byte();
100 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
101
102 //add indirect bus
103 //M20150601 : Rename the function for integrating with ioLibrary
104 //WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
105 //WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
106 //ret = WIZCHIP.IF.BUS._read_byte(IDM_DR);
107 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
108 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
109 ret = WIZCHIP.IF.BUS._read_data(IDM_DR);
110
111 #else
112 #error "Unknown _WIZCHIP_IO_MODE_ in W5100S. !!!"
113 #endif
114
115 WIZCHIP.CS._deselect();
116 WIZCHIP_CRITICAL_EXIT();
117 return ret;
118 }
119
120
124 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
125 {
126 uint16_t i = 0;
127 int j,k,l;
128 WIZCHIP_CRITICAL_ENTER();
129 WIZCHIP.CS._select(); //M20150601 : Moved here.
130
131 #if((_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_))
132
133 WIZCHIP.IF.SPI._write_byte(0xF0);
134 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0xFF00) >> 8);
135 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0x00FF) >> 0);
136
137 for(i = 0; i < len; i++)
138 {
139 WIZCHIP.IF.SPI._write_byte(pBuf[i]); // Data write (write 1byte data)
140 }
141
142 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_5500_) )
143
144 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0xFF00) >> 8);
145 WIZCHIP.IF.SPI._write_byte((((uint16_t)(AddrSel+i)) & 0x00FF) >> 0);
146 WIZCHIP.IF.SPI._write_byte(0xF0);
147
148 for(i = 0; i < len; i++)
149 {
150 WIZCHIP.IF.SPI._write_byte(pBuf[i]); // Data write (write 1byte data)
151 }
152 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
153 //M20150601 : Rename the function for integrating with ioLibrary
154 /*
155 WIZCHIP_WRITE(MR,WIZCHIP_READ(MR) | MR_AI);
156 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
157 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
158 for(i = 0 ; i < len; i++)
159 WIZCHIP.IF.BUS._write_byte(IDM_DR,pBuf[i]);
160 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
161 */
162 setMR(getMR()|MR_AI);
163 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
164 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
165 for(i = 0 ; i < len; i++)
166 WIZCHIP.IF.BUS._write_data(IDM_DR,pBuf[i]);
167 setMR(getMR() & ~MR_AI);
168
169 #else
170 #error "Unknown _WIZCHIP_IO_MODE_ in W5100S. !!!!"
171 #endif
172
173 WIZCHIP.CS._deselect(); //M20150601 : Moved here.
174 WIZCHIP_CRITICAL_EXIT();
175 }
176
181 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
182 {
183 uint16_t i = 0;
184 WIZCHIP_CRITICAL_ENTER();
185 WIZCHIP.CS._select(); //M20150601 : Moved here.
186
187 #if( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_) )
188
189 WIZCHIP.IF.SPI._write_byte(0x0F);
190 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0xFF00) >> 8);
191 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0x00FF) >> 0);
192
193 for(i = 0; i < len; i++)
194 {
195 pBuf[i] = WIZCHIP.IF.SPI._read_byte();
196 }
197 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_5500_) )
198
199 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0xFF00) >> 8);
200 WIZCHIP.IF.SPI._write_byte((uint16_t)((AddrSel+i) & 0x00FF) >> 0);
201 WIZCHIP.IF.SPI._write_byte(0x0F);
202
203 for(i = 0; i < len; i++)
204 {
205 pBuf[i] = WIZCHIP.IF.SPI._read_byte();
206 }
207
208 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
209 //M20150601 : Rename the function for integrating with ioLibrary
210 /*
211 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) | MR_AI);
212 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0xFF00) >> 8);
213 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x00FF));
214 for(i = 0 ; i < len; i++)
215 pBuf[i] = WIZCHIP.IF.BUS._read_byte(IDM_DR);
216 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
217 */
218 setMR(getMR() | MR_AI);
219 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0xFF00) >> 8);
220 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x00FF));
221 for(i = 0 ; i < len; i++)
222 pBuf[i] = WIZCHIP.IF.BUS._read_data(IDM_DR);
223 setMR(getMR() & ~MR_AI);
224
225 #else
226 #error "Unknown _WIZCHIP_IO_MODE_ in W5100S. !!!!"
227 #endif
228
229 WIZCHIP.CS._deselect(); //M20150601 : Moved Here.
230 WIZCHIP_CRITICAL_EXIT();
231 }
232
234 // Socket N regsiter IO function //
236
237 uint16_t getSn_TX_FSR(uint8_t sn)
238 {
239 uint16_t val=0,val1=0;
240 do
241 {
242 val1 = WIZCHIP_READ(Sn_TX_FSR(sn));
243 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
244 if (val1 != 0)
245 {
246 val = WIZCHIP_READ(Sn_TX_FSR(sn));
247 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
248 }
249 }while (val != val1);
250 return val;
251 }
252
253
254 uint16_t getSn_RX_RSR(uint8_t sn)
255 {
256 uint16_t val=0,val1=0;
257 do
258 {
259 val1 = WIZCHIP_READ(Sn_RX_RSR(sn));
260 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
261 if (val1 != 0)
262 {
263 val = WIZCHIP_READ(Sn_RX_RSR(sn));
264 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
265 }
266 }while (val != val1);
267 return val;
268 }
269
271 // Sn_TXBUF & Sn_RXBUF IO function //
273 uint32_t getSn_RxBASE(uint8_t sn)
274 {
275 int8_t i;
276 #if ( _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
277 uint32_t rxbase = _W5100S_IO_BASE_ + _WIZCHIP_IO_RXBUF_;
278 #else
279 uint32_t rxbase = _WIZCHIP_IO_RXBUF_;
280 #endif
281 for(i = 0; i < sn; i++)
282 rxbase += getSn_RxMAX(i);
283
284 return rxbase;
285 }
286
287 uint32_t getSn_TxBASE(uint8_t sn)
288 {
289 int8_t i;
290 #if ( _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
291 uint32_t txbase = _W5100S_IO_BASE_ + _WIZCHIP_IO_TXBUF_;
292 #else
293 uint32_t txbase = _WIZCHIP_IO_TXBUF_;
294 #endif
295 for(i = 0; i < sn; i++)
296 txbase += getSn_TxMAX(i);
297 return txbase;
298 }
299
311 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
312 {
313 uint16_t ptr;
314 uint16_t size;
315 uint16_t dst_mask;
316 uint16_t dst_ptr;
317
318 ptr = getSn_TX_WR(sn);
319
320 dst_mask = ptr & getSn_TxMASK(sn);
321 dst_ptr = getSn_TxBASE(sn) + dst_mask;
322
323 if (dst_mask + len > getSn_TxMAX(sn))
324 {
325 size = getSn_TxMAX(sn) - dst_mask;
326 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, size);
327 wizdata += size;
328 size = len - size;
329 dst_ptr = getSn_TxBASE(sn);
330 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, size);
331 }
332 else
333 {
334 WIZCHIP_WRITE_BUF(dst_ptr, wizdata, len);
335 }
336
337 ptr += len;
338
339 setSn_TX_WR(sn, ptr);
340 }
341
342
353 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
354 {
355 uint16_t ptr;
356 uint16_t size;
357 uint16_t src_mask;
358 uint16_t src_ptr;
359
360 ptr = getSn_RX_RD(sn);
361
362 src_mask = (uint32_t)ptr & getSn_RxMASK(sn);
363 src_ptr = (getSn_RxBASE(sn) + src_mask);
364
365
366 if( (src_mask + len) > getSn_RxMAX(sn) )
367 {
368 size = getSn_RxMAX(sn) - src_mask;
369 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, size);
370 wizdata += size;
371 size = len - size;
372 src_ptr = getSn_RxBASE(sn);
373 WIZCHIP_READ_BUF(src_ptr, (uint8_t*)wizdata, size);
374 }
375 else
376 {
377 WIZCHIP_READ_BUF(src_ptr, (uint8_t*)wizdata, len);
378 }
379
380 ptr += len;
381
382 setSn_RX_RD(sn, ptr);
383 }
384
385 void wiz_recv_ignore(uint8_t sn, uint16_t len)
386 {
387 uint16_t ptr;
388
389 ptr = getSn_RX_RD(sn);
390
391 ptr += len;
392 setSn_RX_RD(sn,ptr);
393 }
394
395 void wiz_mdio_write(uint8_t PHYMDIO_regadr, uint16_t var)
396 {
397 WIZCHIP_WRITE(PHYRAR,PHYMDIO_regadr);
398 WIZCHIP_WRITE(PHYDIR, (uint8_t)(var >> 8));
399 WIZCHIP_WRITE(PHYDIR+1, (uint8_t)(var));
400 WIZCHIP_WRITE(PHYACR, PHYACR_WRITE);
401 while(WIZCHIP_READ(PHYACR)); //wait for command complete
402 }
403
404 uint16_t wiz_mdio_read(uint8_t PHYMDIO_regadr)
405 {
406 WIZCHIP_WRITE(PHYRAR,PHYMDIO_regadr);
407 WIZCHIP_WRITE(PHYACR, PHYACR_READ);
408 while(WIZCHIP_READ(PHYACR)); //wait for command complete
409 return ((uint16_t)WIZCHIP_READ(PHYDOR) << 8) | WIZCHIP_READ(PHYDOR+1);
410 }
411
412 void wiz_delay_ms(uint32_t milliseconds)
413 {
414 uint32_t i;
415 for(i = 0 ; i < milliseconds ; i++)
416 {
417 //Write any values to clear the TCNTCLKR register
418 setTCNTCLKR(0xff);
419
420 // Wait until counter register value reaches 10.(10 = 1ms : TCNTR is 100us tick counter register)
421 while(getTCNTR() < 0x0a){}
422 }
423 }
424
425 #endif
getSn_TxBASE
uint32_t getSn_TxBASE(uint8_t sn)
Get the base address of socket sn TX buffer.
Definition: w5100s.c:287
__WIZCHIP::_IF::_read_data
iodata_t(* _read_data)(uint32_t AddrSel)
Definition: wizchip_conf.h:261
WIZCHIP
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
PHYACR_READ
#define PHYACR_READ
Definition: w5100s.h:1741
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
PHYDIR
#define PHYDIR
PHY Data input register.
Definition: w5100s.h:449
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
This function reads into W5100S memory(Buffer)
Definition: w5100s.c:181
getSn_RxMASK
#define getSn_RxMASK(sn)
Get the mask of socket sn RX buffer.
Definition: w5100.h:1777
getSn_TxMAX
#define getSn_TxMAX(sn)
Get the max TX buffer size of socket sn.
Definition: w5100.h:1768
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
This function is being called by recv() also. This function is being used for copy the data form Rece...
Definition: w5100s.c:353
__WIZCHIP::_IF::BUS
struct __WIZCHIP::_IF::@0 BUS
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
This function reads the value from W5100S registers.
Definition: w5100s.c:83
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
This function is being called by send() and sendto() function also. for copy the data form applicatio...
Definition: w5100s.c:311
getTCNTR
#define getTCNTR()
Get TCNTR register.
Definition: w5100s.h:2665
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
__WIZCHIP::_CS::_select
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:242
getSn_RxBASE
uint32_t getSn_RxBASE(uint8_t sn)
Get the base address of socket sn RX buffer.
Definition: w5100s.c:273
MR_AI
#define MR_AI
Address Auto-Increment in Indirect Bus Interface.
Definition: w5100.h:603
WIZCHIP_CRITICAL_ENTER
#define WIZCHIP_CRITICAL_ENTER()
Enter a critical section.
Definition: w5100.h:1032
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
wiz_mdio_write
void wiz_mdio_write(uint8_t PHYMDIO_regadr, uint16_t var)
Write data to the PHY via MDC/MDIO interface.
Definition: w5100s.c:395
setMR
#define setMR(mr)
Set Mode Register.
Definition: w5100.h:1108
getSn_TX_WR
#define getSn_TX_WR(sn)
Get Sn_TX_WR register.
Definition: w5100.h:1675
getSn_RxMAX
#define getSn_RxMAX(sn)
Get the max RX buffer size of socket sn.
Definition: w5100.h:1758
Sn_TX_FSR
#define Sn_TX_FSR(sn)
Transmit free memory size register(R)
Definition: w5100.h:510
__WIZCHIP::_IF::_read_byte
uint8_t(* _read_byte)(void)
Definition: wizchip_conf.h:270
PHYACR_WRITE
#define PHYACR_WRITE
Definition: w5100s.h:1742
__WIZCHIP::IF
union __WIZCHIP::_IF IF
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
This function writes into W5100S memory(Buffer)
Definition: w5100s.c:124
getMR
#define getMR()
Get MR.
Definition: w5100.h:1120
wiz_mdio_read
uint16_t wiz_mdio_read(uint8_t PHYMDIO_regadr)
Read data from the PHY via MDC/MDIO interface.
Definition: w5100s.c:404
_WIZCHIP_IO_RXBUF_
#define _WIZCHIP_IO_RXBUF_
Definition: w5100.h:53
__WIZCHIP::_IF::_write_data
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Definition: wizchip_conf.h:262
w5100s.h
W5100S HAL Header File.
PHYRAR
#define PHYRAR
PHY Register address.
Definition: w5100s.h:442
Sn_RX_RSR
#define Sn_RX_RSR(sn)
Received data size register(R)
Definition: w5100.h:545
PHYDOR
#define PHYDOR
PHY data output register.
Definition: w5100s.h:456
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
This function writes the data into W5100S registers.
Definition: w5100s.c:47
__WIZCHIP::_IF::_write_byte
void(* _write_byte)(uint8_t wb)
Definition: wizchip_conf.h:271
__WIZCHIP::CS
struct __WIZCHIP::_CS CS
setSn_TX_WR
#define setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register.
Definition: w5100.h:1663
__WIZCHIP::_CS::_deselect
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:243
PHYACR
#define PHYACR
PHY Action register.
Definition: w5100s.h:463
WIZCHIP_CRITICAL_EXIT
#define WIZCHIP_CRITICAL_EXIT()
Exit a critical section.
Definition: w5100.h:1049
getSn_TxMASK
#define getSn_TxMASK(sn)
Get the mask of socket sn TX buffer.
Definition: w5100.h:1786
wiz_delay_ms
void wiz_delay_ms(uint32_t milliseconds)
Delay function.
Definition: w5100s.c:412
_WIZCHIP_IO_TXBUF_
#define _WIZCHIP_IO_TXBUF_
Definition: w5100.h:52
_W5100S_IO_BASE_
#define _W5100S_IO_BASE_
Definition: w5100s.h:64
setSn_RX_RD
#define setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register.
Definition: w5100.h:1693
__WIZCHIP::_IF::SPI
struct __WIZCHIP::_IF::@1 SPI
setTCNTCLKR
#define setTCNTCLKR(var)
Set TCNTR register.
Definition: w5100s.h:2676
getSn_RX_RD
#define getSn_RX_RD(sn)
Get Sn_RX_RD register.
Definition: w5100.h:1705


ioLibrary: Ethernet/W5100S/w5100s.h Source File

  • Ethernet
  • W5100S
w5100s.h
Go to the documentation of this file.
1 //* ****************************************************************************
38 //
39 //*****************************************************************************
40
41
42 #ifndef _W5100S_H_
43 #define _W5100S_H_
44
45 #include <stdint.h>
46 #include "wizchip_conf.h"
47
49 #if (_WIZCHIP_ == W5100S)
50
52 #define _WIZCHIP_SN_BASE_ (0x0400)
53 #define _WIZCHIP_SN_SIZE_ (0x0100)
54 #define _WIZCHIP_IO_TXBUF_ (0x4000) /* Internal Tx buffer address of the iinchip */
55 #define _WIZCHIP_IO_RXBUF_ (0x6000) /* Internal Rx buffer address of the iinchip */
56
57
58 #define WIZCHIP_CREG_BLOCK 0x00
59 #define WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
60
61 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
62
63 #if (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
64 #define _W5100S_IO_BASE_ _WIZCHIP_IO_BASE_
65 #elif (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_)
66 #define IDM_OR ((_WIZCHIP_IO_BASE + 0x0000))
67 #define IDM_AR0 ((_WIZCHIP_IO_BASE_ + 0x0001))
68 #define IDM_AR1 ((_WIZCHIP_IO_BASE_ + 0x0002))
69 #define IDM_DR ((_WIZCHIP_IO_BASE_ + 0x0003))
70 #define _W5100S_IO_BASE_ 0x0000
71 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
72 #define _W5100S_IO_BASE_ 0x0000
73 #endif
74
76 // Definition For Legacy Chip Driver //
78 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
79 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
80 #define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
81 #define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
82
83
84 //----------- defgroup --------------------------------
85
191 //-----------------------------------------------------------------------------------
192
193 //----------------------------- W5100S Common Registers IOMAP -----------------------------
209 #if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_
210 #define MR (_WIZCHIP_IO_BASE_ + (0x0000)) // Mode
211 #else
212 #define MR (_W5100S_IO_BASE_ + (0x0000)) // Mode
213 #endif
214
220 #define GAR (_W5100S_IO_BASE_ + (0x0001)) // GW Address
221
227 #define SUBR (_W5100S_IO_BASE_ + (0x0005)) // SN Mask Address
228
234 #define SHAR (_W5100S_IO_BASE_ + (0x0009)) // Source Hardware Address
235
241 #define SIPR (_W5100S_IO_BASE_ + (0x000F)) // Source IP Address
242
243 // Reserved (_W5100S_IO_BASE_ + (0x0013))
244 // Reserved (_W5100S_IO_BASE_ + (0x0014))
245
264 #define IR (_W5100S_IO_BASE_ + (0x0015)) // Interrupt
265
272 #define _IMR_ (_W5100S_IO_BASE_ + (0x0016)) // Socket Interrupt Mask
273
282 #define _RTR_ (_W5100S_IO_BASE_ + (0x0017)) // Retry Time
283
290 #define _RCR_ (_W5100S_IO_BASE_ + (0x0019)) // Retry Count
291
309 #define RMSR (_W5100S_IO_BASE_ + (0x001A)) // Receive Memory Size
310
328 #define TMSR (_W5100S_IO_BASE_ + (0x001B)) // Transmit Memory Size
329
341 #define IR2 (_W5100S_IO_BASE_ + (0x0020))
342
349 #define IMR2 (_W5100S_IO_BASE_ + (0x0021))
350
351
357 #define PTIMER (_W5100S_IO_BASE_ + (0x0028)) // PPP LCP RequestTimer
358
364 #define PMAGIC (_W5100S_IO_BASE_ + (0x0029)) // PPP LCP Magic number
365
371 #define UIPR (_W5100S_IO_BASE_ + (0x002A))
372
378 #define UPORTR (_W5100S_IO_BASE_ + (0x002E))
379
380 /* register for W5100S only */
381
382 /*------------------------------------------ Common registers ------------------------------------------*/
383
389 #define MR2 (_W5100S_IO_BASE_ + (0x0030))
390
391
397 #define PHAR (_W5100S_IO_BASE_ + (0x0032))
398
404 #define PSIDR (_W5100S_IO_BASE_ + (0x0038))
405
411 #define PMRUR (_W5100S_IO_BASE_ + (0x003A))
412
413
414 /*------------------------------------------ PHY registers ------------------------------------------*/
415
421 #define PHYSR (_W5100S_IO_BASE_ + (0x003C))
422
428 #define PHYSR1 (_W5100S_IO_BASE_ + (0x003D))
429
435 #define PHYAR (_W5100S_IO_BASE_ + (0x003E))
436
442 #define PHYRAR (_W5100S_IO_BASE_ + (0x003F))
443
449 #define PHYDIR (_W5100S_IO_BASE_ + (0x0040))
450
456 #define PHYDOR (_W5100S_IO_BASE_ + (0x0042))
457
463 #define PHYACR (_W5100S_IO_BASE_ + (0x0044))
464
470 #define PHYDIVR (_W5100S_IO_BASE_ + (0x0045))
471
477 #define PHYCR0 (_W5100S_IO_BASE_ + (0x0046))
478
483 #define PHYCR1 (_W5100S_IO_BASE_ + (0x0047))
484
485 /*------------------------------------------ Socket Less registers ------------------------------------------*/
486
492 #define SLCR (_W5100S_IO_BASE_ + (0x004C))
493
499 #define SLRTR (_W5100S_IO_BASE_ + (0x004D))
500
501
507 #define SLRCR (_W5100S_IO_BASE_ + (0x004F))
508
514 #define SLPIPR (_W5100S_IO_BASE_ + (0x0050))
515
521 #define SLPHAR (_W5100S_IO_BASE_ + (0x0054))
522
528 #define PINGSEQR (_W5100S_IO_BASE_ + (0x005A))
529
535 #define PINGIDR (_W5100S_IO_BASE_ + (0x005C))
536
542 #define SLIMR (_W5100S_IO_BASE_ + (0x005E))
543
549 #define SLIR (_W5100S_IO_BASE_ + (0x005F))
550
556 #define DBGOUT (_W5100S_IO_BASE_ + (0x0060))
557
563 #define NICMAXCOLR (_W5100S_IO_BASE_ + (0x0063))
564 /*------------------------------------------ CFG registers ------------------------------------------*/
565
571 #define CHIPLCKR (_W5100S_IO_BASE_ + (0x0070))
572
578 #define NETLCKR (_W5100S_IO_BASE_ + (0x0071))
579
585 #define PHYLCKR (_W5100S_IO_BASE_ + (0x0072))
586
592 #define VERR (_W5100S_IO_BASE_ + (0x0080))
593
599 #define TCNTR (_W5100S_IO_BASE_ + (0x0082))
600
606 #define TCNTCLKR (_W5100S_IO_BASE_ + (0x0088))
607
608 //----------------------------- W5100S Socket Registers -----------------------------
609
610 //--------------------------- For Backward Compatibility ---------------------------
611
645 #define Sn_MR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000)) // socket Mode register
646
673 #define Sn_CR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001)) // channel Sn_CR register
674
694 #define Sn_IR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002)) // channel interrupt register
695
717 #define Sn_SR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003)) // channel status register
718
725 #define Sn_PORT(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004)) // source port register
726
733 #define Sn_DHAR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006)) // Peer MAC register address
734
743 #define Sn_DIPR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C)) // Peer IP register address
744
753 #define Sn_DPORT(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010)) // Peer port register address
754
760 #define Sn_MSSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012)) // Maximum Segment Size(Sn_MSSR0) register address
761
768 #define Sn_PROTO(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014)) // Protocol of IP Header field register in IP raw mode
769
776 #define Sn_TOS(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + 0x0015) // IP Type of Service(TOS) Register
777
784 #define Sn_TTL(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016)) // IP Time to live(TTL) Register
785
786 // Reserved (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0017))
787 // Reserved (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0018))
788 // Reserved (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0019))
789 // Reserved (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001A))
790 // Reserved (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001B))
791 // Reserved (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001C))
792 // Reserved (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001D))
793
794
795
806 #define Sn_RXBUF_SIZE(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E))
807
817 #define Sn_TXBUF_SIZE(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F))
818
819
829 #define Sn_TX_FSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020)) // Transmit free memory size register
830
841 #define Sn_TX_RD(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022)) // Transmit memory read pointer register address
842
855 #define Sn_TX_WR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024)) // Transmit memory write pointer register address
856
864 #define Sn_RX_RSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026)) // Received data size register
865
877 #define Sn_RX_RD(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028)) // Read point of Receive memory
878
886 #define Sn_RX_WR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A)) // Write point of Receive memory
887
888
889 //todo
897 #define Sn_IMR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C))
898
905 #define Sn_FRAGR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D)) // and +1
906
913 #define Sn_MR2(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002F))
914
921 #define Sn_KPALVTR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0030))
922
929 //#define Sn_TSR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0031))
930
937 #define Sn_RTR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0032))
938
945 #define Sn_RCR(sn) (_W5100S_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0034))
946
947
948 /*----------------------------- W5100S Register values -----------------------------*/
949
950 /* MODE register values */
955 #define MR_RST 0x80
956
957
964 #define MR_PB 0x10
965
966
972 #define MR_PPPOE 0x08
973
974
981 #define MR_AI 0x02
982
983
989 #define MR_IND 0x01
990
991 /* IR register values */
996 #define IR_CONFLICT 0x80
997
998
1003 #define IR_UNREACH 0x40
1004
1005
1009 #define IR_PPPoE 0x20
1010
1011
1015 #define IR_SOCK(sn) (0x01 << sn)
1016
1017
1021 #define IMR_CONFLICT 0x80
1022
1027 #define IMR_UNREACH 0x40
1028
1033 #define IMR_PPPoE 0x20
1034
1039 #define IMR_SOCK(sn) (0x01 << sn)
1040
1045 #define SLCMD_ARP (1<<1)
1046
1051 #define SLCMD_PING (1<<0)
1052
1057 #define SLIR_TIMEOUT (1<<2)
1058
1063 #define SLIR_ARP (1<<1)
1064
1069 #define SLIR_PING (1<<0)
1070
1071
1072
1073 // Sn_MR values
1074 /* Sn_MR Default values */
1079 #define Sn_MR_CLOSE 0x00
1080
1081
1085 #define Sn_MR_TCP 0x01
1086
1087
1091 #define Sn_MR_UDP 0x02
1092 #define Sn_MR_IPRAW 0x03
1093
1094
1099 #define Sn_MR_MACRAW 0x04
1100
1101
1106 #define Sn_MR_PPPoE 0x05
1107
1108
1116 #define Sn_MR_ND 0x20
1117
1118
1125 #define Sn_MR_MC Sn_MR_ND
1126
1127
1137 #define Sn_MR_MF 0x40
1138 #define Sn_MR_MFEN Sn_MR_MF
1139
1140
1141 /* Sn_MR Default values */
1150 #define Sn_MR_MULTI 0x80
1151
1152 /* Sn_CR values */
1167 #define Sn_CR_OPEN 0x01
1168
1169
1178 #define Sn_CR_LISTEN 0x02
1179
1180
1190 #define Sn_CR_CONNECT 0x04
1191
1192
1203 #define Sn_CR_DISCON 0x08
1204
1205
1209 #define Sn_CR_CLOSE 0x10
1210
1217 #define Sn_CR_SEND 0x20
1218
1227 #define Sn_CR_SEND_MAC 0x21
1228
1235 #define Sn_CR_SEND_KEEP 0x22
1236
1243 #define Sn_CR_RECV 0x40
1244
1249 #define Sn_CR_IGMP_JOIN 0x23
1250
1255 #define Sn_CR_IGMP_LEAVE 0x24
1256
1257
1258 /* Sn_IR values */
1259
1264 #define Sn_IR_SENDOK 0x10
1265
1266
1270 #define Sn_IR_TIMEOUT 0x08
1271
1272
1276 #define Sn_IR_RECV 0x04
1277
1282 #define Sn_IR_DISCON 0x02
1283
1288 #define Sn_IR_CON 0x01
1289
1290 /* Sn_SR values */
1296 #define SOCK_CLOSED 0x00
1297
1298
1304 #define SOCK_INIT 0x13
1305
1306
1312 #define SOCK_LISTEN 0x14
1313
1321 #define SOCK_SYNSENT 0x15
1322
1329 #define SOCK_SYNRECV 0x16
1330
1338 #define SOCK_ESTABLISHED 0x17
1339
1346 #define SOCK_FIN_WAIT 0x18
1347
1354 #define SOCK_CLOSING 0x1A
1355
1362 #define SOCK_TIME_WAIT 0x1B
1363
1370 #define SOCK_CLOSE_WAIT 0x1C
1371
1377 #define SOCK_LAST_ACK 0x1D
1378
1385 #define SOCK_UDP 0x22
1386
1387
1393 #define SOCK_IPRAW 0x32
1394
1395
1401 #define SOCK_MACRAW 0x42
1402
1403
1410 #define SOCK_PPPOE 0x5F
1411
1412 // IP PROTOCOL
1413 #define IPPROTO_IP 0
1414 #define IPPROTO_ICMP 1
1415 #define IPPROTO_IGMP 2
1416 #define IPPROTO_GGP 3
1417 #define IPPROTO_TCP 6
1418 #define IPPROTO_PUP 12
1419 #define IPPROTO_UDP 17
1420 #define IPPROTO_IDP 22
1421 #define IPPROTO_ND 77
1422 #define IPPROTO_RAW 255
1423
1424
1425
1426 /*----------------------------- W5100S !!Only!! Register values -----------------------------*/
1427
1428 //todo
1429 /* MODE2 register values */
1430
1437 #define MR2_CLKSEL (1<<7)
1438
1445 #define MR2_G_IEN (1<<6)
1446
1447
1454 #define MR2_NOTCPRST (1<<5)
1455
1462 #define MR2_UDPURB (1<<4)
1463
1470 #define MR2_WOL (1<<3)
1471
1476 #define MR2_MNOSCHK (1<<2)
1477
1485 #define MR2_UDPFARP (1<<1)
1486
1492 #define MR2_SSRCHA (1<<0)
1493
1494
1495
1496 /* Common interrupt register 2 values */
1497
1502 #define IR2_MGC (1<<1)
1503
1508 #define IMR2_MGC (1<<1)
1509
1514 //#define IR2_MGD (1<<1) /* Reserved */
1515
1516
1517 /* PHY status register 0 values */
1518
1523 #define PHYSR_CABOFF (1<<7)
1524
1529 #define PHYSR_MD2 (1<<5)
1530
1535 #define PHYSR_MD1 (1<<4)
1536
1541 #define PHYSR_MD0 (1<<3)
1542
1547 #define PHYSR_DUP (1<<2)
1548
1553 #define PHYSR_SPD (1<<1)
1554
1559 #define PHYSR_LNK (1<<0)
1560
1561
1562 /* PHY status register 10 values */
1563
1568 #define PHYSR1_RXPG (1<<2)
1569
1574 #define PHYSR1_LPI (1<<1)
1575
1580 #define PHYSR1_CLDN (1<<0)
1581
1582 #define PHYCR_AUTONEGO_ENABLE (0<<2)
1583 #define PHYCR_AUTONEGO_DISABLE (1<<2)
1584
1585 #define PHYCR_SPD_10 (1<<1)
1586 #define PHYCR_SPD_100 (0<<1)
1587
1588 #define PHYCR_HALF_DUP (1<<0)
1589 #define PHYCR_FULL_DUP (0<<0)
1590
1591 #define PHYCR1_RST (0<<0)
1592
1593 #define PHYCR1_PWDN_ENABLE (1<<5)
1594 #define PHYCR1_PWDN_DISABLE (0<<5)
1595
1596
1597 /* Socket n MODE register 2 values */
1598
1603 #define Sn_MR2_MBBLK (1<<6)
1604
1609 #define Sn_MR2_MMBLK (1<<5)
1610
1615 #define Sn_MR2_IPV6BLK (1<<4)
1616
1617
1622 #define Sn_MR2_UBBLK (1<<1)
1623
1624
1629 #define Sn_MR2_FPSH Sn_MR2_UBBLK
1630
1635 #define Sn_MR2_UUBLK (1<<0)
1636
1637 /*----------------------------For PHY Control-------------------------------*/
1638
1639 /********************/
1640 /* Register Address */
1641 /********************/
1642
1643 //Basic mode control register, basic register
1644 #define PHYMDIO_BMCR 0x00
1645
1646 //Basic mode status register, basic register
1647 #define PHYMDIO_BMSR 0x01
1648
1649 //--------------------------------------Not used-------------------------------------------//
1651 //#define PHY_IDR1 0x02 //not used
1652 //
1654 //#define PHY_IDR2 0x03 //not used
1655 //
1657 //#define PHY_ANAR 0x04 //not used
1658 //
1660 //#define PHY_ANLPAR 0x05 //not used
1661 //
1663 //#define PHY_ANER 0x06 //not used
1664 //
1666 //#define PHY_ANNP 0x07 //not used
1667 //
1669 //#define PHY_ANLPNP 0x08 //not used
1670 //
1672 //#define PHY_REGCR 0x09 //not used
1673 //
1675 //#define PHY_ADDAR 0x0e //not used
1676 //--------------------------------------Not used-------------------------------------------//
1677
1678 /********************/
1679 /* Bit definitions */
1680 /********************/
1681
1682 //For BMCR register
1683 #define BMCR_RESET (1<<15)
1684 #define BMCR_MLOOPBACK (1<<14)
1685 #define BMCR_SPEED (1<<13)
1686 #define BMCR_AUTONEGO (1<<12)
1687 #define BMCR_PWDN (1<<11)
1688 #define BMCR_ISOLATE (1<<10)
1689 #define BMCR_RSTNEGO (1<<9)
1690 #define BMCR_DUP (1<<8)
1691 #define BMCR_COLTEST (1<<7)
1692
1693 //For BMSR register
1694 #define BMSR_AUTONEGO_COMPL (1<<5)
1695 #define BMSR_REMOTE_FAULT (1<<4)
1696 #define BMSR_LINK_STATUS (1<<2)
1697 #define BMSR_JAB_DETECT (1<<1)
1698 #define EXTENDED_CAPA (1<<0)
1699
1700 //--------------------------------------Not used-------------------------------------------//
1702 //#define ANAR_NP (1<<15)
1703 //#define ANAR_ACK (1<<14)
1704 //#define ANAR_RF (1<<13)
1705 //#define ANAR_ASM (3<<10)
1706 //#define ANAR_T4 (1<<9)
1707 //#define ANAR_TX_FD (1<<8)
1708 //#define ANAR_TX_HD (1<<7)
1709 //#define ANAR_10_FD (1<<6)
1710 //#define ANAR_10_HD (1<<5)
1711 //#define ANAR_SELECTOR (0x1F<<0)
1712 //
1714 //#define ANLPAR_NP (1<<15)
1715 //#define ANLPAR_ACK (1<<14)
1716 //#define ANLPAR_RF (1<<13)
1717 //#define ANLPAR_LP_DIR (1<<11)
1718 //#define ANLPAR_PAUSE (1<<10)
1719 //#define ANLPAR_T4 (1<<9)
1720 //#define ANLPAR_TX_FD (1<<8)
1721 //#define ANLPAR_TX_HD (1<<7)
1722 //#define ANLPAR_10_FD (1<<6)
1723 //#define ANLPAR_10_HD (1<<5)
1724 //#define ANLPAR_SELECTOR (0x1F<<0)
1725
1726
1727 /* MDIO register*/
1728 //PCS_CTL_1 | PCS control 1 register
1729 //PCS_STS_1 | PCS status 1 register
1730 //EEE_ABILITY | EEE capability register
1731 //WAKE_ER_CNTR | EEE wake error counter
1732 //EEE_ADVR | EEE Advertisement register
1733 //EEE_LPAR | EEE link partner ability register
1734
1735 //--------------------------------------Not used-------------------------------------------//
1736
1737 /********************/
1738 /*Functions for PHY */
1739 /********************/
1740 //todo move this definition to bit area
1741 #define PHYACR_READ 0x02
1742 #define PHYACR_WRITE 0x01
1743
1744
1745
1746
1758 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1759
1760 #ifdef _exit
1761 #undef _exit
1762 #endif
1763
1775 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1776
1777
1778
1780 // Basic I/O Function //
1782 //
1783 //M20150601 : uint16_t AddrSel --> uint32_t AddrSel
1784 //
1791 uint8_t WIZCHIP_READ (uint32_t AddrSel);
1792
1800 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb );
1801
1809 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1810
1818 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1819
1820
1822 // Common Register IO function //
1824
1831 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1832 #define setMR(mr) WIZCHIP_WRITE(MR,mr)
1833 #else
1834 #define setMR(mr) (*((uint8_t*)MR) = mr)
1835 #endif
1836
1843 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1844 #define getMR() WIZCHIP_READ(MR)
1845 #else
1846 #define getMR() (*(uint8_t*)MR)
1847 #endif
1848
1855 #define setGAR(gar) \
1856 WIZCHIP_WRITE_BUF(GAR,gar,4)
1857
1864 #define getGAR(gar) \
1865 WIZCHIP_READ_BUF(GAR,gar,4)
1866
1876 #define setSUBR(subr) \
1877 WIZCHIP_WRITE_BUF(SUBR,subr,4)
1878
1885 #define getSUBR(subr) \
1886 WIZCHIP_READ_BUF(SUBR, subr, 4)
1887
1894 #define setSHAR(shar) \
1895 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1896
1903 #define getSHAR(shar) \
1904 WIZCHIP_READ_BUF(SHAR, shar, 6)
1905
1912 #define setSIPR(sipr) \
1913 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1914
1921 #define getSIPR(sipr) \
1922 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1923
1930 #define setIR(ir) \
1931 WIZCHIP_WRITE(IR, (ir & 0xE0)) //peter 2016.11.07 unreachable interrupt bit added
1932 //WIZCHIP_WRITE(IR, (ir & 0xA0))
1939 #define getIR() \
1940 (WIZCHIP_READ(IR) & 0xE0) //peter 2016.11.07 unreachable interrupt bit added
1941 //(WIZCHIP_READ(IR) & 0xA0)
1942
1949 #define setIMR(imr) \
1950 WIZCHIP_WRITE(_IMR_, imr)
1951
1958 #define getIMR() \
1959 WIZCHIP_READ(_IMR_)
1960
1967 #define setRTR(rtr) {\
1968 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1969 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1970 }
1971
1978 #define getRTR() \
1979 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1980
1987 #define setRCR(rcr) \
1988 WIZCHIP_WRITE(_RCR_, rcr)
1989
1996 #define getRCR() \
1997 WIZCHIP_READ(_RCR_)
1998
2004 #define setRMSR(rmsr) \
2005 WIZCHIP_WRITE(RMSR,rmsr) // Receicve Memory Size
2006
2013 #define getRMSR() \
2014 WIZCHIP_READ(RMSR) // Receicve Memory Size
2015
2021 #define setTMSR(tmsr) \
2022 WIZCHIP_WRITE(TMSR,tmsr) // Receicve Memory Size
2023
2030 #define getTMSR() \
2031 WIZCHIP_READ(TMSR)
2032
2033
2039 #define getPATR() \
2040 (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
2041
2047 #define getPPPALGO() \
2048 WIZCHIP_READ(PPPALGO)
2049
2050
2057 #define setPTIMER(ptimer) \
2058 WIZCHIP_WRITE(PTIMER, ptimer)
2059
2066 #define getPTIMER() \
2067 WIZCHIP_READ(PTIMER)
2068
2075 #define setPMAGIC(pmagic) \
2076 WIZCHIP_WRITE(PMAGIC, pmagic)
2077
2084 #define getPMAGIC() \
2085 WIZCHIP_READ(PMAGIC)
2086
2087
2088 //todo Functions for W5100S
2089
2090 /*----------------------------------------------------------------------*/
2091 /* W5100S only */
2092 /*----------------------------------------------------------------------*/
2093
2100 #define setIR2(ir2) \
2101 WIZCHIP_WRITE(IR2, ir2)
2102
2109 #define getIR2() \
2110 WIZCHIP_READ(IR2)
2111
2118 #define setIMR2(imr2) \
2119 WIZCHIP_WRITE(IMR2,imr2)
2120
2127 #define getIMR2() \
2128 WIZCHIP_READ(IMR2)
2129
2136 #define setUIPR(uipr) \
2137 WIZCHIP_WRITE_BUF(UIPR,uipr,4)
2138
2145 #define getUIPR(uipr) \
2146 WIZCHIP_READ_BUF(UIPR,uipr,4)
2147
2154 #define setUPORTR(uportr) {\
2155 WIZCHIP_WRITE(UPORTR, (uint8_t)(uportr >> 8)); \
2156 WIZCHIP_WRITE(UPORTR+1, (uint8_t) uportr); \
2157 }
2158
2165 #define getUPORTR() \
2166 (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(UPORTR+1))
2167
2174 #define setMR2(mr2) \
2175 WIZCHIP_WRITE(MR2,mr2)
2176
2183 #define getMR2() \
2184 WIZCHIP_READ(MR2)
2185
2192 #define setPHAR(phar) \
2193 WIZCHIP_WRITE_BUF(PHAR,phar,6)
2194
2201 #define getPHAR(phar) \
2202 WIZCHIP_READ_BUF(PHAR,phar,6)
2203
2210 #define setPSIDR(psidr) {\
2211 WIZCHIP_WRITE(PSIDR, (uint8_t)(psidr >> 8)); \
2212 WIZCHIP_WRITE(PSIDR+1, (uint8_t) psidr); \
2213 }
2214
2221 #define getPSIDR() \
2222 (((uint16_t)WIZCHIP_READ(PSIDR) << 8) + WIZCHIP_READ(PSIDR+1))
2223
2230 #define setPMRUR(pmrur) {\
2231 WIZCHIP_WRITE(PMRUR, (uint8_t)(pmrur >> 8)); \
2232 WIZCHIP_WRITE(PMRUR+1, (uint8_t) pmrur); \
2233 }
2234
2241 #define getPMRUR() \
2242 (((uint16_t)WIZCHIP_READ(PMRUR) << 8) + WIZCHIP_READ(PMRUR+1))
2243
2250 #define getPHYSR() \
2251 WIZCHIP_READ(PHYSR)
2252
2259 #define getPHYSR1() \
2260 WIZCHIP_READ(PHYSR1)
2261
2266 #define getPHYAR() \
2267 WIZCHIP_READ(PHYAR)
2268
2275 #define getPHYRAR() \
2276 WIZCHIP_READ(PHYRAR)
2277
2284 #define setPHYRR(phyrar) \
2285 WIZCHIP_WRITE(PHYRAR, phyrar)
2286
2293 //read the value of the phy data input register
2294 #define getPHYDIR() \
2295 (((uint16_t)WIZCHIP_READ(PHYDIR+1) << 8) + WIZCHIP_READ(PHYDIR))
2296
2303 //write the value of the phy data input register
2304 #define setPHYDIR(phydir) {\
2305 WIZCHIP_WRITE(PHYDIR+1, (uint8_t)(phydir >> 8)); \
2306 WIZCHIP_WRITE(PHYDIR, (uint8_t) phydir); \
2307 }
2308
2315 //read the value of the phy data output register
2316 #define getPHYDOR() \
2317 (((uint16_t)WIZCHIP_READ(PHYDOR+1) << 8) + WIZCHIP_READ(PHYDOR))
2318
2325 //write the value of the phy data output register
2326 #define setPHYDOR(phydor) {\
2327 WIZCHIP_WRITE(PHYDOR, (uint8_t)(phydor >> 8)); \
2328 WIZCHIP_WRITE(PHYDOR+1, (uint8_t) phydor); \
2329 }
2330
2337 //read the value of the phy action register ***This register will be cleared automatically***
2338 #define getPHYACR() \
2339 WIZCHIP_READ(PHYACR)
2340
2347 //write the value of the phy action register
2348 #define setPHYACR(phyacr) \
2349 WIZCHIP_WRITE(PHYACR,phyacr)
2350
2357 #define setPHYDIVR(phydivr) \
2358 WIZCHIP_WRITE(PHYDIVR, phydivr)
2359
2366 #define getPHYDIVR() \
2367 WIZCHIP_READ(PHYDIVR)
2368
2375 #define setPHYCR0(phych0) \
2376 WIZCHIP_WRITE(PHYCR0,phych0)
2377
2384 #define getPHYCR0() \
2385 WIZCHIP_READ(PHYCR0)
2386
2393 #define setPHYCR1(phycr1) \
2394 WIZCHIP_WRITE(PHYCR1,phycr1)
2395
2402 #define getPHYCR1() \
2403 WIZCHIP_READ(PHYCR1)
2404
2411 #define setSLCR(rqcr) \
2412 WIZCHIP_WRITE(SLCR, rqcr)
2413
2420 #define getSLCR() \
2421 WIZCHIP_READ(RQCR)
2422
2429 #define setSLRTR(slrtr) \
2430 WIZCHIP_WRITE(SLRTR, (uint8_t)(slrtr >> 8)); \
2431 WIZCHIP_WRITE(SLRTR+1, (uint8_t) slrtr); \
2432
2433
2439 #define getSLRTR() \
2440 (((uint16_t)WIZCHIP_READ(SLRTR) << 8) + WIZCHIP_READ(SLRTR+1))
2441
2448 #define setSLRCR(slrcr) \
2449 WIZCHIP_WRITE(SLRCR,slrcr)
2450
2457 #define getSLRCR() \
2458 WIZCHIP_READ(SLRCR)
2459
2466 #define setSLPIPR(slpipr) \
2467 WIZCHIP_WRITE_BUF(SLPIPR,slpipr,4)
2468
2475 #define getSLPIPR(slpipr) \
2476 WIZCHIP_READ_BUF(SLPIPR,slpipr,4)
2477
2484 #define setSLPHAR(slphar) \
2485 WIZCHIP_WRITE_BUF(SLPHAR,slphar,6)
2486
2493 #define getSLPHAR(slphar) \
2494 WIZCHIP_READ_BUF(SLPHAR,slphar,6)
2495
2502 #define setPINGSEQR(pingseqr) {\
2503 WIZCHIP_WRITE(PINGSEQR, (uint8_t)(pingseqr >> 8)); \
2504 WIZCHIP_WRITE(PINGSEQR+1, (uint8_t) pingseqr); \
2505 }
2506
2513 #define getPINGSEQR() \
2514 (((uint16_t)WIZCHIP_READ(PINGSEQR) << 8) + WIZCHIP_READ(PINGSEQR+1))
2515
2522 #define setPINGIDR(pingidr) {\
2523 WIZCHIP_WRITE(PINGIDR, (uint8_t)(pingidr >> 8)); \
2524 WIZCHIP_WRITE(PINGIDR+1, (uint8_t) pingidr); \
2525 }
2526
2533 #define getPINGIDR() \
2534 (((uint16_t)WIZCHIP_READ(PINGIDR) << 8) + WIZCHIP_READ(PINGIDR+1))
2535
2542 #define setSLIMR(slimr) \
2543 WIZCHIP_WRITE(SLIMR, slimr)
2544
2551 #define getSLIMR() \
2552 WIZCHIP_READ(SLIMR)
2553
2560 #define setSLIR(slir) \
2561 WIZCHIP_WRITE(SLIR, slir)
2562
2569 #define getSLIR() \
2570 WIZCHIP_READ(SLIR)
2571
2572 /*Hidden functions for W5100S*/
2573 #define setDBGOUT(dbgout) {\
2574 WIZCHIP_WRITE(DBGOUT,(uint8_t)(dbgout >> 16)); \
2575 WIZCHIP_WRITE(DBGOUT,(uint8_t)(dbgout >> 8)); \
2576 WIZCHIP_WRITE(DBGOUT,(uint8_t)(dbgout)); \
2577 }
2578
2585 #define setNICMAXCOLR(nicmaxcolr) \
2586 WIZCHIP_WRITE(NICMAXCOLR,nicmaxcolr)
2587
2594 #define getNICMAXCOLR() \
2595 WIZCHIP_READ(NICMAXCOLR)
2596
2597 /*Clock lock/unlock*/
2598
2604 #define CHIPLOCK() \
2605 WIZCHIP_WRITE(CHIPLCKR,0xff)
2606
2612 #define CHIPUNLOCK() \
2613 WIZCHIP_WRITE(CHIPLCKR,0xCE)
2614
2615
2621 /*Network information lock/unlock*/
2622 #define NETLOCK() \
2623 WIZCHIP_WRITE(NETLCKR,0x3A)
2624
2630 #define NETUNLOCK() \
2631 WIZCHIP_WRITE(NETLCKR,0xC5)
2632
2638 /*PHY CR0,CR1 lock/unlock*/
2639 #define PHYLOCK() \
2640 WIZCHIP_WRITE(PHYLCKR,0xff)
2641
2647 #define PHYUNLOCK() \
2648 WIZCHIP_WRITE(PHYLCKR,0x53)
2649
2655 #define getVER() \
2656 (WIZCHIP_READ(VERR))
2657
2664 /*Get 100us internal counter*/
2665 #define getTCNTR() \
2666 (((uint16_t)WIZCHIP_READ(TCNTR) << 8) + WIZCHIP_READ(TCNTR+1))
2667
2675 /*Reset 100us internal counter(TCNTR)*/
2676 #define setTCNTCLKR(var) \
2677 WIZCHIP_WRITE(TCNTCLKR, var)
2678
2679 /*w5100s only end*/
2680
2681
2682
2683
2684
2686 // Socket N register I/O function //
2688
2695 #define setSn_MR(sn, mr) \
2696 WIZCHIP_WRITE(Sn_MR(sn),mr)
2697
2705 #define getSn_MR(sn) \
2706 WIZCHIP_READ(Sn_MR(sn))
2707
2715 #define setSn_CR(sn, cr) \
2716 WIZCHIP_WRITE(Sn_CR(sn), cr)
2717
2725 #define getSn_CR(sn) \
2726 WIZCHIP_READ(Sn_CR(sn))
2727
2735 #define setSn_IR(sn, ir) \
2736 WIZCHIP_WRITE(Sn_IR(sn), ir)
2737
2745 #define getSn_IR(sn) \
2746 WIZCHIP_READ(Sn_IR(sn))
2747
2754 #define getSn_SR(sn) \
2755 WIZCHIP_READ(Sn_SR(sn))
2756
2764 #define setSn_PORT(sn, port) { \
2765 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
2766 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
2767 }
2768
2776 #define getSn_PORT(sn) \
2777 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
2778
2786 #define setSn_DHAR(sn, dhar) \
2787 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
2788
2796 #define getSn_DHAR(sn, dhar) \
2797 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
2798
2806 #define setSn_DIPR(sn, dipr) \
2807 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
2808
2816 #define getSn_DIPR(sn, dipr) \
2817 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
2818
2826 #define setSn_DPORT(sn, dport) { \
2827 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
2828 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
2829 }
2830
2838 #define getSn_DPORT(sn) \
2839 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
2840
2848 #define setSn_MSSR(sn, mss) { \
2849 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
2850 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
2851 }
2852
2860 #define getSn_MSSR(sn) \
2861 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
2862
2870 #define setSn_PROTO(sn, proto) \
2871 WIZCHIP_WRITE(Sn_PROTO(sn), proto)
2872
2880 #define getSn_PROTO(sn) \
2881 WIZCHIP_READ(Sn_PROTO(sn))
2882
2890 #define setSn_TOS(sn, tos) \
2891 WIZCHIP_WRITE(Sn_TOS(sn), tos)
2892
2900 #define getSn_TOS(sn) \
2901 WIZCHIP_READ(Sn_TOS(sn))
2902
2910 #define setSn_TTL(sn, ttl) \
2911 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
2912
2920 #define getSn_TTL(sn) \
2921 WIZCHIP_READ(Sn_TTL(sn))
2922
2930 #define setSn_RXMEM_SIZE(sn, rxmemsize) \
2931 WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxmemsize)
2932 #define setSn_RXBUF_SIZE(sn,rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
2933
2941 #define getSn_RXMEM_SIZE(sn) \
2942 WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
2943 #define getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
2944
2952 #define setSn_TXMEM_SIZE(sn, txmemsize) \
2953 WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn),txmemsize)
2954 #define setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
2955
2963 #define getSn_TXMEM_SIZE(sn) \
2964 WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
2965 #define getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
2966
2973 uint16_t getSn_TX_FSR(uint8_t sn);
2974
2981 #define getSn_TX_RD(sn) \
2982 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
2983
2991 #define setSn_TX_WR(sn, txwr) { \
2992 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
2993 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
2994 }
2995
3003 #define getSn_TX_WR(sn) \
3004 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
3005
3012 uint16_t getSn_RX_RSR(uint8_t sn);
3013
3021 #define setSn_RX_RD(sn, rxrd) { \
3022 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
3023 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
3024 }
3025
3033 #define getSn_RX_RD(sn) \
3034 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
3035
3043 #define setSn_RX_WR(sn, rxwr) { \
3044 WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
3045 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
3046 }
3047
3048
3055 #define getSn_RX_WR(sn) \
3056 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
3057
3065 #define setSn_FRAGR(sn, fragr) { \
3066 WIZCHIP_WRITE(Sn_FRAGR(sn), (uint8_t)(fragr >>8)); \
3067 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAGR(sn),1), (uint8_t) fragr); \
3068 }
3069
3077 #define getSn_FRAGR(sn) \
3078 (((uint16_t)WIZCHIP_READ(Sn_FRAGR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAGR(sn),1)))
3079
3086 #define getSn_RxMAX(sn) \
3087 ((uint16_t)(getSn_RXMEM_SIZE(sn)) << 10)
3088
3089
3096 #define getSn_TxMAX(sn) \
3097 ((uint16_t)(getSn_TXMEM_SIZE(sn)) << 10)
3098
3105 #define getSn_RxMASK(sn) \
3106 (getSn_RxMAX(sn) - 1)
3107
3114 #define getSn_TxMASK(sn) \
3115 (getSn_TxMAX(sn) - 1)
3116
3117
3124 uint32_t getSn_RxBASE(uint8_t sn);
3125
3132 uint32_t getSn_TxBASE(uint8_t sn);
3133
3134
3135 /*socket register W5100S only*/
3136
3144 #define setSn_IMR(sn,imr) \
3145 WIZCHIP_WRITE(Sn_IMR(sn),imr)
3146
3153 #define getSn_IMR(sn) \
3154 WIZCHIP_READ(Sn_IMR(sn))
3155
3162 #define setSn_MR2(sn,mr2) \
3163 WIZCHIP_WRITE(Sn_MR2(sn), mr2)
3164
3171 #define getSn_MR2(sn) \
3172 WIZCHIP_READ(Sn_MR2(sn))
3173
3180 #define setSn_KPALVTR(sn,kpalvtr) \
3181 WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvtr)
3182
3189 #define getSn_KPALVTR(sn) \
3190 WIZCHIP_READ(Sn_KPALVTR(sn))
3191
3198 #define getSn_TSR(sn) \
3199 WIZCHIP_READ(Sn_TSR(sn))
3200
3207 #define setSn_RTR(sn,rtr) { \
3208 WIZCHIP_WRITE(Sn_RTR(sn), (uint8_t)(rtr >> 8)); \
3209 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RTR(sn),1), (uint8_t) rtr); \
3210 }
3211
3218 #define getSn_RTR(sn) \
3219 (((uint16_t)WIZCHIP_READ(Sn_RTR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RTR(sn),1)))
3220
3227 #define setSn_RCR(sn,rcr) \
3228 WIZCHIP_WRITE(Sn_RCR(sn),rcr)
3229
3236 #define getSn_RCR(sn) \
3237 WIZCHIP_READ(Sn_RCR(sn))
3238
3240 // Sn_TXBUF & Sn_RXBUF IO function //
3242
3256 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
3257
3272 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
3273
3281 void wiz_recv_ignore(uint8_t sn, uint16_t len);
3282
3290 void wiz_mdio_write(uint8_t PHYMDIO_regadr, uint16_t var);
3291
3299 uint16_t wiz_mdio_read(uint8_t PHYMDIO_regadr);
3300
3307 void wiz_delay_ms(uint32_t ms);
3308
3310 #endif
3311
3313 #endif //_W5100S_H_
3314
3315
3316
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
Definition: w5100s.c:181
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
wiz_mdio_write
void wiz_mdio_write(uint8_t PHYMDIO_regadr, uint16_t var)
Write data to the PHY via MDC/MDIO interface.
Definition: w5100s.c:395
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
wiz_mdio_read
uint16_t wiz_mdio_read(uint8_t PHYMDIO_regadr)
Read data from the PHY via MDC/MDIO interface.
Definition: w5100s.c:404
getSn_RxBASE
uint32_t getSn_RxBASE(uint8_t sn)
Get the base address of socket sn RX buffer.
Definition: w5100s.c:273
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
getSn_TxBASE
uint32_t getSn_TxBASE(uint8_t sn)
Get the base address of socket sn TX buffer.
Definition: w5100s.c:287
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
Definition: w5100s.c:124
wiz_delay_ms
void wiz_delay_ms(uint32_t ms)
Delay function.
Definition: w5100s.c:412
wizchip_conf.h
WIZCHIP Config Header File.
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311


ioLibrary: 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 //M20150601 : Rename the function for integrating with W5300
63 //WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
64 //WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
65 //WIZCHIP.IF.BUS._write_byte(IDM_DR,wb);
66 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
67 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
68 WIZCHIP.IF.BUS._write_data(IDM_DR,wb);
69
70 #else
71 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!"
72 #endif
73
74 WIZCHIP.CS._deselect();
75 WIZCHIP_CRITICAL_EXIT();
76 }
80 uint8_t WIZCHIP_READ(uint32_t AddrSel)
81 {
82 uint8_t ret;
83
84 WIZCHIP_CRITICAL_ENTER();
85 WIZCHIP.CS._select();
86
87 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
88 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
89 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
90 WIZCHIP.IF.SPI._write_byte(_W5200_SPI_READ_); // Read data length upper
91 WIZCHIP.IF.SPI._write_byte(0x01); // Data length lower
92 ret = WIZCHIP.IF.SPI._read_byte();
93
94 #elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
95
96 //add indirect bus
97 //M20150601 : Rename the function for integrating with W5300
98 //WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
99 //WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
100 //ret = WIZCHIP.IF.BUS._read_byte(IDM_DR);
101 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
102 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
103 ret = WIZCHIP.IF.BUS._read_data(IDM_DR);
104
105 #else
106 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!"
107 #endif
108
109 WIZCHIP.CS._deselect();
110 WIZCHIP_CRITICAL_EXIT();
111 return ret;
112 }
113
114
118 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
119 {
120 uint16_t i = 0;
121 WIZCHIP_CRITICAL_ENTER();
122 WIZCHIP.CS._select();
123
124 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
125 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
126 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
127 WIZCHIP.IF.SPI._write_byte(_W5200_SPI_WRITE_ | ((len & 0x7F00) >> 8)); // Write data op code and length upper
128 WIZCHIP.IF.SPI._write_byte((len & 0x00FF) >> 0); // length lower
129 for(i = 0; i < len; i++)
130 WIZCHIP.IF.SPI._write_byte(pBuf[i]);
131
132 #elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
133 //M20150601 : Rename the function for integrating with W5300
134 /*
135 WIZCHIP_WRITE(MR,WIZCHIP_READ(MR) | MR_AI);
136 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
137 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
138 for(i = 0 ; i < len; i++)
139 WIZCHIP.IF.BUS._write_byte(IDM_DR,pBuf[i]);
140 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
141 */
142 setMR(getMR() | MR_AI);
143 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
144 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
145 for(i = 0 ; i < len; i++)
146 WIZCHIP.IF.BUS._write_data(IDM_DR,pBuf[i]);
147 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
148 #else
149 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!!"
150 #endif
151
152 WIZCHIP.CS._deselect();
153 WIZCHIP_CRITICAL_EXIT();
154 }
155
159 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
160 {
161 uint16_t i = 0;
162 WIZCHIP_CRITICAL_ENTER();
163 WIZCHIP.CS._select();
164
165 #if( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_))
166 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8);
167 WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0);
168 WIZCHIP.IF.SPI._write_byte( _W5200_SPI_READ_ | ((len & 0x7F00) >> 8)); // Write data op code and length upper
169 WIZCHIP.IF.SPI._write_byte((len & 0x00FF) >> 0); // length lower
170 for(i = 0; i < len; i++)
171 pBuf[i] = WIZCHIP.IF.SPI._read_byte();
172
173 #elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
174 //M20150601 : Rename the function for integrating with W5300
175 /*
176 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) | MR_AI);
177 WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
178 WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
179 for(i = 0 ; i < len; i++)
180 pBuf[i] = WIZCHIP.IF.BUS._read_byte(IDM_DR);
181 WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
182 */
183 setMR(getMR() | MR_AI);
184 WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
185 WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
186 for(i = 0 ; i < len; i++)
187 pBuf[i] = WIZCHIP.IF.BUS._read_data(IDM_DR);
188 setMR(getMR() & ~MR_AI);
189 #else
190 #error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!!"
191 #endif
192
193 WIZCHIP.CS._deselect();
194 WIZCHIP_CRITICAL_EXIT();
195 }
196
198 // Socket N regsiter IO function //
200
201 uint16_t getSn_TX_FSR(uint8_t sn)
202 {
203 uint16_t val=0,val1=0;
204 do
205 {
206 val1 = WIZCHIP_READ(Sn_TX_FSR(sn));
207 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
208 if (val1 != 0)
209 {
210 val = WIZCHIP_READ(Sn_TX_FSR(sn));
211 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1));
212 }
213 }while (val != val1);
214 return val;
215 }
216
217
218 uint16_t getSn_RX_RSR(uint8_t sn)
219 {
220 uint16_t val=0,val1=0;
221 do
222 {
223 val1 = WIZCHIP_READ(Sn_RX_RSR(sn));
224 val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
225 if (val1 != 0)
226 {
227 val = WIZCHIP_READ(Sn_RX_RSR(sn));
228 val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1));
229 }
230 }while (val != val1);
231 return val;
232 }
233
235 // Sn_TXBUF & Sn_RXBUF IO function //
237
238 uint16_t getSn_RxBASE(uint8_t sn)
239 {
240 int8_t i;
241 uint16_t rxbase = _WIZCHIP_IO_RXBUF_;
242 for(i = 0; i < sn; i++)
243 rxbase += getSn_RxMAX(i);
244 return rxbase;
245 }
246
247 uint16_t getSn_TxBASE(uint8_t sn)
248 {
249 int8_t i;
250 uint16_t txbase = _WIZCHIP_IO_TXBUF_;
251 for(i = 0; i < sn; i++)
252 txbase += getSn_TxMAX(i);
253 return txbase;
254 }
255
268 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
269 {
270
271 uint16_t ptr;
272 uint16_t size;
273 uint16_t dst_mask;
274 uint8_t * dst_ptr;
275
276 ptr = getSn_TX_WR(sn);
277
278
279 dst_mask = (uint32_t)ptr & getSn_TxMASK(sn);
280 dst_ptr = (uint8_t*)((uint32_t)getSn_TxBASE(sn) + dst_mask);
281
282 if (dst_mask + len > getSn_TxMAX(sn))
283 {
284 size = getSn_TxMAX(sn) - dst_mask;
285 WIZCHIP_WRITE_BUF((uint32_t)dst_ptr, wizdata, size);
286 wizdata += size;
287 size = len - size;
288 dst_ptr = (uint8_t*)((uint32_t)getSn_TxBASE(sn));
289 WIZCHIP_WRITE_BUF((uint32_t)dst_ptr, wizdata, size);
290 }
291 else
292 {
293 WIZCHIP_WRITE_BUF((uint32_t)dst_ptr, wizdata, len);
294 }
295
296 ptr += len;
297
298 setSn_TX_WR(sn, ptr);
299 }
300
301
312 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
313 {
314 uint16_t ptr;
315 uint16_t size;
316 uint16_t src_mask;
317 uint8_t * src_ptr;
318
319 ptr = getSn_RX_RD(sn);
320
321 src_mask = (uint32_t)ptr & getSn_RxMASK(sn);
322 src_ptr = (uint8_t *)((uint32_t)getSn_RxBASE(sn) + src_mask);
323
324 if( (src_mask + len) > getSn_RxMAX(sn) )
325 {
326 size = getSn_RxMAX(sn) - src_mask;
327 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, size);
328 wizdata += size;
329 size = len - size;
330 src_ptr = (uint8_t*)((uint32_t)getSn_RxBASE(sn));
331 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, size);
332 }
333 else
334 {
335 WIZCHIP_READ_BUF((uint32_t)src_ptr, (uint8_t*)wizdata, len);
336 }
337
338 ptr += len;
339
340 setSn_RX_RD(sn, ptr);
341 }
342
343 void wiz_recv_ignore(uint8_t sn, uint16_t len)
344 {
345 uint16_t ptr;
346
347 ptr = getSn_RX_RD(sn);
348
349 ptr += len;
350 setSn_RX_RD(sn,ptr);
351 }
352
353 #endif
getSn_TxBASE
uint32_t getSn_TxBASE(uint8_t sn)
Get the base address of socket sn TX buffer.
Definition: w5100s.c:287
__WIZCHIP::_IF::_read_data
iodata_t(* _read_data)(uint32_t AddrSel)
Definition: wizchip_conf.h:261
WIZCHIP
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
w5200.h
W5200 HAL Header File.
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
Definition: w5100s.c:181
MR
#define MR
Mode Register address(R/W) MR is used for S/W reset, ping block mode, PPPoE mode and etc...
Definition: w5100.h:202
getSn_RxMASK
#define getSn_RxMASK(sn)
Get the mask of socket sn RX buffer.
Definition: w5100.h:1777
getSn_TxMAX
#define getSn_TxMAX(sn)
Get the max TX buffer size of socket sn.
Definition: w5100.h:1768
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
__WIZCHIP::_IF::BUS
struct __WIZCHIP::_IF::@0 BUS
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
__WIZCHIP::_CS::_select
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:242
getSn_RxBASE
uint32_t getSn_RxBASE(uint8_t sn)
Get the base address of socket sn RX buffer.
Definition: w5100s.c:273
MR_AI
#define MR_AI
Address Auto-Increment in Indirect Bus Interface.
Definition: w5100.h:603
WIZCHIP_CRITICAL_ENTER
#define WIZCHIP_CRITICAL_ENTER()
Enter a critical section.
Definition: w5100.h:1032
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
setMR
#define setMR(mr)
Set Mode Register.
Definition: w5100.h:1108
getSn_TX_WR
#define getSn_TX_WR(sn)
Get Sn_TX_WR register.
Definition: w5100.h:1675
_W5200_SPI_READ_
#define _W5200_SPI_READ_
SPI interface Read operation in Control Phase.
Definition: w5200.h:55
getSn_RxMAX
#define getSn_RxMAX(sn)
Get the max RX buffer size of socket sn.
Definition: w5100.h:1758
Sn_TX_FSR
#define Sn_TX_FSR(sn)
Transmit free memory size register(R)
Definition: w5100.h:510
__WIZCHIP::_IF::_read_byte
uint8_t(* _read_byte)(void)
Definition: wizchip_conf.h:270
__WIZCHIP::IF
union __WIZCHIP::_IF IF
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
Definition: w5100s.c:124
getMR
#define getMR()
Get MR.
Definition: w5100.h:1120
_WIZCHIP_IO_RXBUF_
#define _WIZCHIP_IO_RXBUF_
Definition: w5100.h:53
_W5200_SPI_WRITE_
#define _W5200_SPI_WRITE_
SPI interface Write operation in Control Phase.
Definition: w5200.h:56
__WIZCHIP::_IF::_write_data
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Definition: wizchip_conf.h:262
Sn_RX_RSR
#define Sn_RX_RSR(sn)
Received data size register(R)
Definition: w5100.h:545
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
__WIZCHIP::_IF::_write_byte
void(* _write_byte)(uint8_t wb)
Definition: wizchip_conf.h:271
__WIZCHIP::CS
struct __WIZCHIP::_CS CS
setSn_TX_WR
#define setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register.
Definition: w5100.h:1663
__WIZCHIP::_CS::_deselect
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:243
WIZCHIP_CRITICAL_EXIT
#define WIZCHIP_CRITICAL_EXIT()
Exit a critical section.
Definition: w5100.h:1049
getSn_TxMASK
#define getSn_TxMASK(sn)
Get the mask of socket sn TX buffer.
Definition: w5100.h:1786
_WIZCHIP_IO_TXBUF_
#define _WIZCHIP_IO_TXBUF_
Definition: w5100.h:52
setSn_RX_RD
#define setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register.
Definition: w5100.h:1693
__WIZCHIP::_IF::SPI
struct __WIZCHIP::_IF::@1 SPI
getSn_RX_RD
#define getSn_RX_RD(sn)
Get Sn_RX_RD register.
Definition: w5100.h:1705


ioLibrary: 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
47 #if (_WIZCHIP_ == 5200)
48
50 #define _WIZCHIP_SN_BASE_ (0x4000)
51 #define _WIZCHIP_SN_SIZE_ (0x0100)
52 #define _WIZCHIP_IO_TXBUF_ (0x8000) /* Internal Tx buffer address of the iinchip */
53 #define _WIZCHIP_IO_RXBUF_ (0xC000) /* Internal Rx buffer address of the iinchip */
54
55 #define _W5200_SPI_READ_ (0x00 << 7)
56 #define _W5200_SPI_WRITE_ (0x01 << 7)
57
58 #define WIZCHIP_CREG_BLOCK 0x00
59 #define WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
60
61 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
62
63 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
64 #define IDM_AR0 ((_WIZCHIP_IO_BASE_ + 0x0001))
65 #define IDM_AR1 ((_WIZCHIP_IO_BASE_ + 0x0002))
66 #define IDM_DR ((_WIZCHIP_IO_BASE_ + 0x0003))
67 #define _W5200_IO_BASE_ 0x0000
68 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
69 #define _W5200_IO_BASE_ 0x0000
70 #endif
71
73 // Definition For Legacy Chip Driver //
75 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
76 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
77 #define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
78 #define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
79
80
81 //----------- defgroup --------------------------------
82
185 //-----------------------------------------------------------------------------------
186
187 //----------------------------- W5200 Common Registers IOMAP -----------------------------
204 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
205 #define MR (_WIZCHIP_IO_BASE_ + (0x0000)) // Mode
206 #else
207 #define MR (_W5200_IO_BASE_ + (0x0000)) // Mode
208 #endif
209
215 #define GAR (_W5200_IO_BASE_ + (0x0001)) // GW Address
216
222 #define SUBR (_W5200_IO_BASE_ + (0x0005)) // SN Mask Address
223
229 #define SHAR (_W5200_IO_BASE_ + (0x0009)) // Source Hardware Address
230
236 #define SIPR (_W5200_IO_BASE_ + (0x000F)) // Source IP Address
237
238 // Reserved (_W5200_IO_BASE_ + (0x0013))
239 // Reserved (_W5200_IO_BASE_ + (0x0014))
240
254 #define IR (_W5200_IO_BASE_ + (0x0015)) // Interrupt
255
265 #define _IMR_ (_W5200_IO_BASE_ + (0x0016)) // Socket Interrupt Mask
266
275 #define _RTR_ (_W5200_IO_BASE_ + (0x0017)) // Retry Time
276
283 #define _RCR_ (_W5200_IO_BASE_ + (0x0019)) // Retry Count
284
285 // Reserved (_W5200_IO_BASE_ + (0x001A))
286 // Reserved (_W5200_IO_BASE_ + (0x001B))
287
294 #define PATR (_W5200_IO_BASE_ + (0x001C))
295
302 #define PPPALGO (_W5200_IO_BASE_ + (0x001E)) // Authentication Algorithm in PPPoE
303
309 #define VERSIONR (_W5200_IO_BASE_ + (0x001F)) // Chip version
310
311 // Reserved (_W5200_IO_BASE_ + (0x0020))
312 // Reserved (_W5200_IO_BASE_ + (0x0021))
313 // Reserved (_W5200_IO_BASE_ + (0x0022))
314 // Reserved (_W5200_IO_BASE_ + (0x0023))
315 // Reserved (_W5200_IO_BASE_ + (0x0024))
316 // Reserved (_W5200_IO_BASE_ + (0x0025))
317 // Reserved (_W5200_IO_BASE_ + (0x0026))
318 // Reserved (_W5200_IO_BASE_ + (0x0027))
319
325 #define PTIMER (_W5200_IO_BASE_ + (0x0028)) // PPP LCP RequestTimer
326
332 #define PMAGIC (_W5200_IO_BASE_ + (0x0029)) // PPP LCP Magic number
333
334 // Reserved (_W5200_IO_BASE_ + (0x002A))
335 // Reserved (_W5200_IO_BASE_ + (0x002B))
336 // Reserved (_W5200_IO_BASE_ + (0x002C))
337 // Reserved (_W5200_IO_BASE_ + (0x002D))
338 // Reserved (_W5200_IO_BASE_ + (0x002E))
339 // Reserved (_W5200_IO_BASE_ + (0x002F))
340
346 #define INTLEVEL (_W5200_IO_BASE_ + (0x0030)) // Interrupt Low Level Timer
347
348 // Reserved (_W5200_IO_BASE_ + (0x0032))
349 // Reserved (_W5200_IO_BASE_ + (0x0033))
350
357 #define IR2 (_W5200_IO_BASE_ + (0x0034)) // Socket Interrupt
358
371 #define PHYSTATUS (_W5200_IO_BASE_ + (0x0035)) // PHY Status
372
389 #define IMR2 (_W5200_IO_BASE_ + (0x0036)) // Interrupt Mask
390
391
392 //----------------------------- W5200 Socket Registers -----------------------------
393
394 //--------------------------- For Backward Compatibility ---------------------------
395
429 #define Sn_MR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0000)) // socket Mode register
430
457 #define Sn_CR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0001)) // channel Sn_CR register
458
478 #define Sn_IR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0002)) // channel interrupt register
479
501 #define Sn_SR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0003)) // channel status register
502
509 #define Sn_PORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004)) // source port register
510
517 #define Sn_DHAR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0006)) // Peer MAC register address
518
527 #define Sn_DIPR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x000C)) // Peer IP register address
528
537 #define Sn_DPORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0010)) // Peer port register address
538
544 #define Sn_MSSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0012)) // Maximum Segment Size(Sn_MSSR0) register address
545
552 #define Sn_PROTO(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0014)) // Protocol of IP Header field register in IP raw mode
553
560 #define Sn_TOS(sn) (WIZCHIP_SREG_BLOCK(sn) + 0x0015) // IP Type of Service(TOS) Register
561
568 #define Sn_TTL(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0016)) // IP Time to live(TTL) Register
569
570 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0017))
571 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0018))
572 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0019))
573 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001A))
574 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001B))
575 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001C))
576 // Reserved (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001D))
577
588 #define Sn_RXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001E)) // Receive memory size reigster
589
599 #define Sn_TXMEM_SIZE(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x001F)) // Transmit memory size reigster
600
610 #define Sn_TX_FSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0020)) // Transmit free memory size register
611
622 #define Sn_TX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0022)) // Transmit memory read pointer register address
623
636 #define Sn_TX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0024)) // Transmit memory write pointer register address
637
645 #define Sn_RX_RSR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0026)) // Received data size register
646
658 #define Sn_RX_RD(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0028)) // Read point of Receive memory
659
667 #define Sn_RX_WR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002A)) // Write point of Receive memory
668
677 #define Sn_IMR(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002C)) // socket interrupt mask register
678
684 #define Sn_FRAG(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x002D)) // frag field value in IP header register
685
686
687 //----------------------------- W5200 Register values -----------------------------
688
689 /* MODE register values */
694 #define MR_RST 0x80
695
696
705 #define MR_WOL 0x20
706
707
713 #define MR_PB 0x10
714
715
721 #define MR_PPPOE 0x08
722
723
730 #define MR_AI 0x02
731
732
738 #define MR_IND 0x01
739
740 /* IR register values */
745 #define IR_CONFLICT 0x80
746
747
751 #define IR_PPPoE 0x20
752
753
757 #define PHYSTATUS_LINK 0x20
758
763 #define PHYSTATUS_POWERSAVE 0x10
764
769 #define PHYSTATUS_POWERDOWN 0x08
770
771 // Sn_MR values
772 /* Sn_MR Default values */
777 #define Sn_MR_CLOSE 0x00
778
779
783 #define Sn_MR_TCP 0x01
784
785
789 #define Sn_MR_UDP 0x02
790 #define Sn_MR_IPRAW 0x03
791
792
797 #define Sn_MR_MACRAW 0x04
798
799
804 #define Sn_MR_PPPOE 0x05
805
806
814 #define Sn_MR_ND 0x20
815
816 /* Sn_MR Default values */
825 #define Sn_MR_MC Sn_MR_ND
826
827
834 #define Sn_MR_MF 0x40
835 #define Sn_MR_MFEN Sn_MR_MF
836
837 /* Sn_MR Default values */
846 #define Sn_MR_MULTI 0x80
847
848 /* Sn_CR values */
863 #define Sn_CR_OPEN 0x01
864
865
874 #define Sn_CR_LISTEN 0x02
875
876
886 #define Sn_CR_CONNECT 0x04
887
888
899 #define Sn_CR_DISCON 0x08
900
901
905 #define Sn_CR_CLOSE 0x10
906
913 #define Sn_CR_SEND 0x20
914
923 #define Sn_CR_SEND_MAC 0x21
924
931 #define Sn_CR_SEND_KEEP 0x22
932
939 #define Sn_CR_RECV 0x40
940
945 #define Sn_CR_PCON 0x23
946
951 #define Sn_CR_PDISCON 0x24
952
957 #define Sn_CR_PCR 0x25
958
963 #define Sn_CR_PCN 0x26
964
969 #define Sn_CR_PCJ 0x27
970
971 /* Sn_IR values */
976 #define Sn_IR_PRECV 0x80
977
982 #define Sn_IR_PFAIL 0x40
983
988 #define Sn_IR_PNEXT 0x20
989
994 #define Sn_IR_SENDOK 0x10
995
996
1000 #define Sn_IR_TIMEOUT 0x08
1001
1002
1006 #define Sn_IR_RECV 0x04
1007
1012 #define Sn_IR_DISCON 0x02
1013
1018 #define Sn_IR_CON 0x01
1019
1020 /* Sn_SR values */
1026 #define SOCK_CLOSED 0x00
1027
1028
1034 #define SOCK_INIT 0x13
1035
1036
1042 #define SOCK_LISTEN 0x14
1043
1051 #define SOCK_SYNSENT 0x15
1052
1059 #define SOCK_SYNRECV 0x16
1060
1068 #define SOCK_ESTABLISHED 0x17
1069
1076 #define SOCK_FIN_WAIT 0x18
1077
1084 #define SOCK_CLOSING 0x1A
1085
1092 #define SOCK_TIME_WAIT 0x1B
1093
1100 #define SOCK_CLOSE_WAIT 0x1C
1101
1107 #define SOCK_LAST_ACK 0x1D
1108
1115 #define SOCK_UDP 0x22
1116
1117
1123 #define SOCK_IPRAW 0x32
1124
1125
1131 #define SOCK_MACRAW 0x42
1132
1133
1140 #define SOCK_PPPOE 0x5F
1141
1142 // IP PROTOCOL
1143 #define IPPROTO_IP 0
1144 #define IPPROTO_ICMP 1
1145 #define IPPROTO_IGMP 2
1146 #define IPPROTO_GGP 3
1147 #define IPPROTO_TCP 6
1148 #define IPPROTO_PUP 12
1149 #define IPPROTO_UDP 17
1150 #define IPPROTO_IDP 22
1151 #define IPPROTO_ND 77
1152 #define IPPROTO_RAW 255
1153
1154
1165 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1166
1167 #ifdef _exit
1168 #undef _exit
1169 #endif
1170
1182 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1183
1184
1185
1187 // Basic I/O Function //
1189
1195 uint8_t WIZCHIP_READ (uint32_t AddrSel);
1196
1204 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb );
1205
1213 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1214
1222 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1223
1224
1226 // Common Register IO function //
1228
1235 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1236 #define setMR(mr) WIZCHIP_WRITE(MR,mr)
1237 #else
1238 #define setMR(mr) (*((uint8_t*)MR) = mr)
1239 #endif
1240
1247 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
1248 #define getMR() WIZCHIP_READ(MR)
1249 #else
1250 #define getMR() (*(uint8_t*)MR)
1251 #endif
1252
1259 #define setGAR(gar) \
1260 WIZCHIP_WRITE_BUF(GAR,gar,4)
1261
1268 #define getGAR(gar) \
1269 WIZCHIP_READ_BUF(GAR,gar,4)
1270
1280 #define setSUBR(subr) \
1281 WIZCHIP_WRITE_BUF(SUBR, subr,4)
1282
1289 #define getSUBR(subr) \
1290 WIZCHIP_READ_BUF(SUBR, subr, 4)
1291
1298 #define setSHAR(shar) \
1299 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1300
1307 #define getSHAR(shar) \
1308 WIZCHIP_READ_BUF(SHAR, shar, 6)
1309
1316 #define setSIPR(sipr) \
1317 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1318
1325 #define getSIPR(sipr) \
1326 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1327
1334 #define setIR(ir) \
1335 WIZCHIP_WRITE(IR, (ir & 0xA0))
1336
1342 #define getIR() \
1343 (WIZCHIP_READ(IR) & 0xA0)
1344
1351 //M20150410 : Replace _IMR_ with IMR2 for integrating with ioLibrary
1352 /*
1353 #define setIMR(imr) \
1354 WIZCHIP_WRITE(_IMR_, imr)
1355 */
1356 #define setIMR(imr) \
1357 WIZCHIP_WRITE(IMR2, imr & 0xA0)
1358
1365 //M20150410 : Replace _IMR_ with IMR2 for integrating with ioLibrary
1366 /*
1367 #define getIMR() \
1368 WIZCHIP_READ(_IMR_)
1369 */
1370 #define getIMR() \
1371 (WIZCHIP_READ(IMR2) & 0xA0)
1372
1379 #define setRTR(rtr) {\
1380 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1381 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1382 }
1383
1390 #define getRTR() \
1391 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1392
1399 #define setRCR(rcr) \
1400 WIZCHIP_WRITE(_RCR_, rcr)
1401
1408 #define getRCR() \
1409 WIZCHIP_READ(_RCR_)
1410
1416 #define getPATR() \
1417 (((uint16_t)WIZCHIP_READ(PATR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PATR,1)))
1418
1424 #define getPPPALGO() \
1425 WIZCHIP_READ(PPPALGO)
1426
1427
1433 #define getVERSIONR() \
1434 WIZCHIP_READ(VERSIONR)
1435
1442 #define setPTIMER(ptimer) \
1443 WIZCHIP_WRITE(PTIMER, ptimer)
1444
1451 #define getPTIMER() \
1452 WIZCHIP_READ(PTIMER)
1453
1460 #define setPMAGIC(pmagic) \
1461 WIZCHIP_WRITE(PMAGIC, pmagic)
1462
1469 #define getPMAGIC() \
1470 WIZCHIP_READ(PMAGIC)
1471
1478 #define setINTLEVEL(intlevel) {\
1479 WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \
1480 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \
1481 }
1482
1488 #define getINTLEVEL() \
1489 (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
1490
1497 #define setIR2(ir2) \
1498 WIZCHIP_WRITE(IR2, ir2)
1499 #define setSIR(ir2) setIR2(ir2)
1500
1507 #define getIR2() \
1508 WIZCHIP_READ(IR2)
1509 #define getSIR() getIR2()
1510
1516 #define getPHYSTATUS() \
1517 WIZCHIP_READ(PHYSTATUS)
1518
1526 //M20150410 : Replace IMR2 with _IMR_ for integrating with ioLibrary
1527 /*
1528 #define setIMR2(imr2) \
1529 WIZCHIP_WRITE(IMR2, (imr2 & 0xA0))
1530 */
1531 #define setIMR2(imr2) \
1532 WIZCHIP_WRITE(_IMR_, imr2)
1533 #define setSIMR(imr2) setIMR2(imr2)
1534
1541 //M20150410 : Replace IMR2 with _IMR_ for integrating with ioLibrary
1542 /*
1543 #define getIMR2() \
1544 (WIZCHIP_READ(IMR2) & 0xA0)
1545 */
1546 #define getIMR2() \
1547 WIZCHIP_READ(_IMR_)
1548 #define getSIMR() getIMR2()
1549 // Socket N register I/O function //
1552
1559 #define setSn_MR(sn, mr) \
1560 WIZCHIP_WRITE(Sn_MR(sn),mr)
1561
1569 #define getSn_MR(sn) \
1570 WIZCHIP_READ(Sn_MR(sn))
1571
1579 #define setSn_CR(sn, cr) \
1580 WIZCHIP_WRITE(Sn_CR(sn), cr)
1581
1589 #define getSn_CR(sn) \
1590 WIZCHIP_READ(Sn_CR(sn))
1591
1599 #define setSn_IR(sn, ir) \
1600 WIZCHIP_WRITE(Sn_IR(sn), ir)
1601
1609 #define getSn_IR(sn) \
1610 WIZCHIP_READ(Sn_IR(sn))
1611
1619 #define setSn_IMR(sn, imr) \
1620 WIZCHIP_WRITE(Sn_IMR(sn), imr)
1621
1629 #define getSn_IMR(sn) \
1630 WIZCHIP_READ(Sn_IMR(sn))
1631
1638 #define getSn_SR(sn) \
1639 WIZCHIP_READ(Sn_SR(sn))
1640
1648 #define setSn_PORT(sn, port) { \
1649 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
1650 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
1651 }
1652
1660 #define getSn_PORT(sn) \
1661 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1662
1670 #define setSn_DHAR(sn, dhar) \
1671 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
1672
1680 #define getSn_DHAR(sn, dhar) \
1681 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
1682
1690 #define setSn_DIPR(sn, dipr) \
1691 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
1692
1700 #define getSn_DIPR(sn, dipr) \
1701 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
1702
1710 #define setSn_DPORT(sn, dport) { \
1711 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
1712 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
1713 }
1714
1722 #define getSn_DPORT(sn) \
1723 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1724
1732 #define setSn_MSSR(sn, mss) { \
1733 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
1734 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
1735 }
1736
1744 #define getSn_MSSR(sn) \
1745 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1746
1754 //M20150601 : Fixed Wrong Register address
1755 /*
1756 #define setSn_PROTO(sn, proto) \
1757 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1758 */
1759 #define setSn_PROTO(sn, proto) \
1760 WIZCHIP_WRITE(Sn_PROTO(sn), proto)
1761
1769 //M20150601 : Fixed Wrong Register address
1770 /*
1771 #define getSn_PROTO(sn) \
1772 WIZCHIP_READ(Sn_TOS(sn))
1773 */
1774 #define getSn_PROTO(sn) \
1775 WIZCHIP_READ(Sn_PROTO(sn))
1776
1784 #define setSn_TOS(sn, tos) \
1785 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1786
1794 #define getSn_TOS(sn) \
1795 WIZCHIP_READ(Sn_TOS(sn))
1796
1804 #define setSn_TTL(sn, ttl) \
1805 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
1806
1814 #define getSn_TTL(sn) \
1815 WIZCHIP_READ(Sn_TTL(sn))
1816
1824 #define setSn_RXMEM_SIZE(sn, rxmemsize) \
1825 WIZCHIP_WRITE(Sn_RXMEM_SIZE(sn),rxmemsize)
1826
1827 #define setSn_RXBUF_SIZE(sn,rxmemsize) setSn_RXMEM_SIZE(sn,rxmemsize)
1828
1836 #define getSn_RXMEM_SIZE(sn) \
1837 WIZCHIP_READ(Sn_RXMEM_SIZE(sn))
1838
1839 #define getSn_RXBUF_SIZE(sn) getSn_RXMEM_SIZE(sn)
1840
1848 #define setSn_TXMEM_SIZE(sn, txmemsize) \
1849 WIZCHIP_WRITE(Sn_TXMEM_SIZE(sn), txmemsize)
1850
1851 #define setSn_TXBUF_SIZE(sn, txmemsize) setSn_TXMEM_SIZE(sn,txmemsize)
1852
1860 #define getSn_TXMEM_SIZE(sn) \
1861 WIZCHIP_READ(Sn_TXMEM_SIZE(sn))
1862
1863 #define getSn_TXBUF_SIZE(sn) getSn_TXMEM_SIZE(sn)
1864
1871 uint16_t getSn_TX_FSR(uint8_t sn);
1872
1879 #define getSn_TX_RD(sn) \
1880 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1881
1889 #define setSn_TX_WR(sn, txwr) { \
1890 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
1891 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
1892 }
1893
1901 #define getSn_TX_WR(sn) \
1902 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1903
1910 uint16_t getSn_RX_RSR(uint8_t sn);
1911
1919 #define setSn_RX_RD(sn, rxrd) { \
1920 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
1921 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
1922 }
1923
1931 #define getSn_RX_RD(sn) \
1932 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
1933
1941 #define setSn_RX_WR(sn, rxwr) { \
1942 WIZCHIP_WRITE(Sn_RX_WR(sn), (uint8_t)(rxwr>>8)); \
1943 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1), (uint8_t) rxwr); \
1944 }
1945
1946
1953 #define getSn_RX_WR(sn) \
1954 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
1955
1963 #define setSn_IMR(sn ,imr) \
1964 WIZCHIP_WRITE(Sn_IMR(sn), imr)
1965
1973 #define getSn_IMR(sn) \
1974 WIZCHIP_READ(Sn_IMR(sn))
1975
1983 #define setSn_FRAG(sn, frag) { \
1984 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
1985 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
1986 }
1987
1995 #define getSn_FRAG(sn) \
1996 (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
1997
2004 #define getSn_RxMAX(sn) \
2005 ((uint16_t)getSn_RXMEM_SIZE(sn) << 10)
2006
2013 #define getSn_TxMAX(sn) \
2014 ((uint16_t)getSn_TXMEM_SIZE(sn) << 10)
2015
2022 #define getSn_RxMASK(sn) \
2023 ((uint16_t)getSn_RxMAX(sn) - 1)
2024
2031 #define getSn_TxMASK(sn) \
2032 ((uint16_t)getSn_TxMAX(sn) - 1)
2033
2040 uint16_t getSn_RxBASE(uint8_t sn);
2041
2048 uint16_t getSn_TxBASE(uint8_t sn);
2049
2051 // Sn_TXBUF & Sn_RXBUF IO function //
2053
2067 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2068
2083 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2084
2092 void wiz_recv_ignore(uint8_t sn, uint16_t len);
2093
2095 #endif
2096
2098 #endif //_W5200_H_
2099
2100
2101
getSn_RxBASE
uint16_t getSn_RxBASE(uint8_t sn)
Get the base address of socket sn RX buffer.
Definition: w5100s.c:273
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
Definition: w5100s.c:124
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
Definition: w5100s.c:181
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
getSn_TxBASE
uint16_t getSn_TxBASE(uint8_t sn)
Get the base address of socket sn TX buffer.
Definition: w5100s.c:287
wizchip_conf.h
WIZCHIP Config Header File.


ioLibrary: image/w5200_w5500.jpg Source File

  • image
w5200_w5500.jpg
Go to the documentation of this file.
1


ioLibrary: Ethernet/W5300/w5300.c Source File

  • Ethernet
  • W5300
w5300.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
41 //
42 //*****************************************************************************
43
44 #include <stdint.h>
45 #include "wizchip_conf.h"
46
47 #if _WIZCHIP_ == 5300
48
49 extern uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_];
50 extern uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_];
51
52
53 /***********************
54 * Basic I/O Function *
55 ***********************/
56
57 void WIZCHIP_WRITE(uint32_t AddrSel, uint16_t wb )
58 {
59 WIZCHIP_CRITICAL_ENTER();
60 WIZCHIP.CS._select();
61
62 #if ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
63 #if(_WIZCHIP_IO_BUS_WIDTH_ == 8)
64 WIZCHIP.IF.BUS._write_data(AddrSel, (uint8_t)(wb>>8));
65 WIZCHIP.IF.BUS._write_data(WIZCHIP_OFFSET_INC(AddrSel,1),(uint8_t)wb);
66 #elif(_WIZCHIP_IO_BUS_WIDTH_ == 16)
67 WIZCHIP.IF.BUS._write_data(AddrSel, wb);
68 #else
69 #error "Abnoraml _WIZCHIP_IO_BUS_WIDTH_. Should be 8 or 16"
70 #endif
71 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
72 #if(_WIZCHIP_IO_BUS_WIDTH_ == 8)
73 WIZCHIP.IF.BUS._write_data(IDM_AR, (uint8_t)(AddrSel >> 8));
74 WIZCHIP.IF.BUS._write_data(WIZCHIP_OFFSET_INC(IDM_AR,1),(uint8_t)AddrSel);
75 WIZCHIP.IF.BUS._write_data(IDM_DR,(uint8_t)(wb>>8));
76 WIZCHIP.IF.BUS._write_data(WIZCHIP_OFFSET_INC(IDM_DR,1),(uint8_t)wb);
77 #elif(_WIZCHIP_IO_BUS_WIDTH_ == 16)
78 WIZCHIP.IF.BUS._write_data(IDM_AR, (uint16_t)AddrSel);
79 WIZCHIP.IF.BUS._write_data(IDM_DR, wb);
80 #else
81 #error "Abnoraml _WIZCHIP_IO_BUS_WIDTH_. Should be 8 or 16"
82 #endif
83 #else
84 #error "Unknown _WIZCHIP_IO_MODE_ in W5300. !!!"
85 #endif
86
87 WIZCHIP.CS._deselect();
88 WIZCHIP_CRITICAL_EXIT();
89 }
90
91 uint16_t WIZCHIP_READ(uint32_t AddrSel)
92 {
93 uint16_t ret;
94
95 WIZCHIP_CRITICAL_ENTER();
96 WIZCHIP.CS._select();
97
98 #if ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_) )
99 #if (_WIZCHIP_IO_BUS_WIDTH_ == 8)
100 ret = (((uint16_t)WIZCHIP.IF.BUS._read_data(AddrSel)) << 8) |
101 (((uint16_t)WIZCHIP.IF.BUS._read_data(WIZCHIP_OFFSET_INC(AddrSel,1))) & 0x00FF) ;
102 #elif(_WIZCHIP_IO_BUS_WIDTH_ == 16)
103 ret = WIZCHIP.IF.BUS._read_data(AddrSel);
104 #else
105 #error "Abnoraml _WIZCHIP_IO_BUS_WIDTH_. Should be 8 or 16"
106 #endif
107 #elif ( (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_) )
108 #if(_WIZCHIP_IO_BUS_WIDTH_ == 8)
109 WIZCHIP.IF.BUS._write_data(IDM_AR, (uint8_t)(AddrSel >> 8));
110 WIZCHIP.IF.BUS._write_data(WIZCHIP_OFFSET_INC(IDM_AR,1),(uint8_t)AddrSel);
111 ret = (((uint16_t)WIZCHIP.IF.BUS._read_data(IDM_DR)) << 8) |
112 (((uint16_t)WIZCHIP.IF.BUS._read_data(WIZCHIP_OFFSET_INC(IDM_DR,1))) & 0x00FF);
113 #elif(_WIZCHIP_IO_BUS_WIDTH_ == 16)
114 WIZCHIP.IF.BUS._write_data(IDM_AR, (uint16_t)AddrSel);
115 ret = WIZCHIP.IF.BUS._read_data(IDM_DR);
116 #else
117 #error "Abnoraml _WIZCHIP_IO_BUS_WIDTH_. Should be 8 or 16"
118 #endif
119 #else
120 #error "Unknown _WIZCHIP_IO_MODE_ in W5300. !!!"
121 #endif
122
123 WIZCHIP.CS._deselect();
124 WIZCHIP_CRITICAL_EXIT();
125 return ret;
126 }
127
128
129 void setTMSR(uint8_t sn,uint8_t tmsr)
130 {
131 uint16_t tmem;
132 tmem = WIZCHIP_READ(WIZCHIP_OFFSET_INC(TMS01R, (sn & 0xFE)));
133 if(sn & 0x01) tmem = (tmem & 0xFF00) | (((uint16_t)tmsr ) & 0x00FF) ;
134 else tmem = (tmem & 0x00FF) | (((uint16_t)tmsr) << 8) ;
135 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(TMS01R, (sn & 0xFE)),tmem);
136 }
137
138 uint8_t getTMSR(uint8_t sn)
139 {
140 if(sn & 0x01)
141 return (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(TMS01R, (sn & 0xFE))) & 0x00FF);
142 return (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(TMS01R, (sn & 0xFE))) >> 8);
143 }
144
145 void setRMSR(uint8_t sn,uint8_t rmsr)
146 {
147 uint16_t rmem;
148 rmem = WIZCHIP_READ(WIZCHIP_OFFSET_INC(RMS01R, (sn & 0xFE)));
149 if(sn & 0x01) rmem = (rmem & 0xFF00) | (((uint16_t)rmsr ) & 0x00FF) ;
150 else rmem = (rmem & 0x00FF) | (((uint16_t)rmsr) << 8) ;
151 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(RMS01R, (sn & 0xFE)),rmem);
152 }
153
154 uint8_t getRMSR(uint8_t sn)
155 {
156 if(sn & 0x01)
157 return (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(RMS01R, (sn & 0xFE))) & 0x00FF);
158 return (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(RMS01R, (sn & 0xFE))) >> 8);
159 }
160
161 uint32_t getSn_TX_FSR(uint8_t sn)
162 {
163 uint32_t free_tx_size=0;
164 uint32_t free_tx_size1=1;
165 while(1)
166 {
167 free_tx_size = (((uint32_t)WIZCHIP_READ(Sn_TX_FSR(sn))) << 16) |
168 (((uint32_t)WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),2))) & 0x0000FFFF); // read
169 if(free_tx_size == free_tx_size1) break; // if first == sencond, Sn_TX_FSR value is valid.
170 free_tx_size1 = free_tx_size; // save second value into first
171 }
172 return free_tx_size;
173 }
174
175 uint32_t getSn_RX_RSR(uint8_t sn)
176 {
177 uint32_t received_rx_size=0;
178 uint32_t received_rx_size1=1;
179 while(1)
180 {
181 received_rx_size = (((uint32_t)WIZCHIP_READ(Sn_RX_RSR(sn))) << 16) |
182 (((uint32_t)WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),2))) & 0x0000FFFF);
183 if(received_rx_size == received_rx_size1) break;
184 received_rx_size1 = received_rx_size; // if first == sencond, Sn_RX_RSR value is valid.
185 } // save second value into first
186 return received_rx_size + (uint32_t)((sock_pack_info[sn] & 0x02) ? 1 : 0);
187 }
188
189
190 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint32_t len)
191 {
192 uint32_t i = 0;
193 if(len == 0) return;
194
195 for(i = 0; i < len ; i += 2)
196 setSn_TX_FIFOR(sn, (((uint16_t)wizdata[i]) << 8) | (((uint16_t)wizdata[i+1]) & 0x00FF))
197 }
198
199 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint32_t len)
200 {
201 uint16_t rd = 0;
202 uint32_t i = 0;
203
204 if(len == 0) return;
205
206 for(i = 0; i < len; i++)
207 {
208 if((i & 0x01)==0)
209 {
210 rd = getSn_RX_FIFOR(sn);
211 wizdata[i] = (uint8_t)(rd >> 8);
212 }
213 else wizdata[i] = (uint8_t)rd; // For checking the memory access violation
214 }
215 sock_remained_byte[sn] = (uint8_t)rd; // back up the remaind fifo byte.
216 }
217
218 void wiz_recv_ignore(uint8_t sn, uint32_t len)
219 {
220 uint32_t i = 0;
221 for(i = 0; i < len ; i += 2) getSn_RX_FIFOR(sn);
222 }
223
224
225 #endif
__WIZCHIP::_IF::_read_data
iodata_t(* _read_data)(uint32_t AddrSel)
Definition: wizchip_conf.h:261
WIZCHIP
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
__WIZCHIP::_IF::BUS
struct __WIZCHIP::_IF::@0 BUS
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
__WIZCHIP::_CS::_select
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:242
WIZCHIP_CRITICAL_ENTER
#define WIZCHIP_CRITICAL_ENTER()
Enter a critical section.
Definition: w5100.h:1032
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
TMS01R
#define TMS01R
TX memory size of SOCKET 0 & 1.
Definition: w5300.h:316
setTMSR
void setTMSR(uint8_t sn, uint8_t tmsr)
Set TMSR0 ~ TMSR7 register.
Sn_TX_FSR
#define Sn_TX_FSR(sn)
Transmit free memory size register(R)
Definition: w5100.h:510
getTMSR
uint8_t getTMSR(uint8_t sn)
Get TMSR0 ~ TMSR7 register.
__WIZCHIP::IF
union __WIZCHIP::_IF IF
setSn_TX_FIFOR
#define setSn_TX_FIFOR(sn, txfifo)
Set Sn_TX_FIFOR register.
Definition: w5300.h:2181
sock_pack_info
uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_]
Definition: socket.c:70
__WIZCHIP::_IF::_write_data
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Definition: wizchip_conf.h:262
Sn_RX_RSR
#define Sn_RX_RSR(sn)
Received data size register(R)
Definition: w5100.h:545
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
__WIZCHIP::CS
struct __WIZCHIP::_CS CS
__WIZCHIP::_CS::_deselect
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:243
getRMSR
uint8_t getRMSR(uint8_t sn)
Get RMS01R ~ RMS67R register.
setRMSR
void setRMSR(uint8_t sn, uint8_t rmsr)
Set RMS01R ~ RMS67R register.
_WIZCHIP_SOCK_NUM_
#define _WIZCHIP_SOCK_NUM_
The count of independant socket of WIZCHIP.
Definition: wizchip_conf.h:212
WIZCHIP_CRITICAL_EXIT
#define WIZCHIP_CRITICAL_EXIT()
Exit a critical section.
Definition: w5100.h:1049
RMS01R
#define RMS01R
RX memory size of SOCKET 0 & 1.
Definition: w5300.h:403
wizchip_conf.h
WIZCHIP Config Header File.
getSn_RX_FIFOR
#define getSn_RX_FIFOR(sn)
Get Sn_RX_FIFOR register.
Definition: w5300.h:2190


ioLibrary: Ethernet/W5300/w5300.h Source File

  • Ethernet
  • W5300
w5300.h
Go to the documentation of this file.
1 #ifndef _W5300_H_
2 #define _W5300_H_
3 //*****************************************************************************
4 //
43 //
44 //*****************************************************************************
45
46 #include <stdint.h>
47 #include "wizchip_conf.h"
48
50 #if (_WIZCHIP_ == 5300)
51
53 #define _WIZCHIP_SN_BASE_ (0x0200)
54 #define _WIZCHIP_SN_SIZE_ (0x0040)
55
56
57 #define WIZCHIP_CREG_BLOCK 0x00
58 #define WIZCHIP_SREG_BLOCK(N) (_WIZCHIP_SN_BASE_+ _WIZCHIP_SN_SIZE_*N)
59
60 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + N)
61
62 #if (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_DIR_)
63 #define _W5300_IO_BASE_ _WIZCHIP_IO_BASE_
64 #elif (_WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_)
65 #define IDM_AR ((_WIZCHIP_IO_BASE_ + 0x0002))
66 #define IDM_DR ((_WIZCHIP_IO_BASE_ + 0x0004))
67 #define _W5300_IO_BASE_ 0x0000
68 #elif (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
69 #error "Unkonw _WIZCHIP_IO_MODE_"
70 #endif
71
73 // Definition For Legacy Chip Driver //
75 #define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR)
76 #define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL)
77 //#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN)
78 //#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN)
79
80 //-------------------------- defgroup ---------------------------------
199 //------------------------------- defgroup end --------------------------------------------
200
201 //----------------------------- W5300 Common Registers -----------------------------
224 #define MR (_WIZCHIP_IO_BASE_)
225
246 #define IR (_W5300_IO_BASE_ + 0x02)
247
256 #define _IMR_ (_W5300_IO_BASE_ + 0x04)
257
258
259 //#define ICFGR (_W5300_IO_BASE_ + 0x06)
260 //#define INTLEVEL ICFGR
261
267 #define SHAR (_W5300_IO_BASE_ + 0x08)
268
269
275 #define GAR (_W5300_IO_BASE_ + 0x10)
276
282 #define SUBR (_W5300_IO_BASE_ + 0x14)
283
289 #define SIPR (_W5300_IO_BASE_ + 0x18)
290
299 #define _RTR_ (_W5300_IO_BASE_ + 0x1C)
300
307 #define _RCR_ (_W5300_IO_BASE_ + 0x1E)
308
316 #define TMS01R (_W5300_IO_BASE_ + 0x20)
317
323 #define TMS23R (TMS01R + 2)
324
330 #define TMS45R (TMS01R + 4)
331
337 #define TMS67R (TMS01R + 6)
338
344 #define TMSR0 TMS01R
345
351 #define TMSR1 (TMSR0 + 1)
352
358 #define TMSR2 (TMSR0 + 2)
359
365 #define TMSR3 (TMSR0 + 3)
366
372 #define TMSR4 (TMSR0 + 4)
373
379 #define TMSR5 (TMSR0 + 5)
380
386 #define TMSR6 (TMSR0 + 6)
387
393 #define TMSR7 (TMSR0 + 7)
394
395
403 #define RMS01R (_W5300_IO_BASE_ + 0x28)
404
410 #define RMS23R (RMS01R + 2)
411
417 #define RMS45R (RMS01R + 4)
418
424 #define RMS67R (RMS01R + 6)
425
431 #define RMSR0 RMS01R
432
438 #define RMSR1 (RMSR0 + 1)
439
445 #define RMSR2 (RMSR0 + 2)
446
452 #define RMSR3 (RMSR0 + 3)
453
459 #define RMSR4 (RMSR0 + 4)
460
466 #define RMSR5 (RMSR0 + 5)
467
473 #define RMSR6 (RMSR0 + 6)
474
480 #define RMSR7 (RMSR0 + 7)
481
482
483
493 #define MTYPER (_W5300_IO_BASE_ + 0x30)
494
503 #define PATR (_W5300_IO_BASE_ + 0x32)
504
505 //#define PPPALGOR (_W5300_IO_BASE_ + 0x34)
506
512 #define PTIMER (_W5300_IO_BASE_ + 0x36)
513
519 #define PMAGICR (_W5300_IO_BASE_ + 0x38)
520
521 //#define PSTATER (_W5300_IO_BASE_ + 0x3A)
522
528 #define PSIDR (_W5300_IO_BASE_ + 0x3C)
529
535 #define PDHAR (_W5300_IO_BASE_ + 0x40)
536
545 #define UIPR (_W5300_IO_BASE_ + 0x48)
546
552 #define UPORTR (_W5300_IO_BASE_ + 0x4C)
553
561 #define FMTUR (_W5300_IO_BASE_ + 0x4E)
562
563 //#define Sn_RTCR(n) (_W5300_IO_BASE_ + 0x50 + n*2)
564
584 #define Pn_BRDYR(n) (_W5300_IO_BASE_ + 0x60 + n*4)
585
594 #define Pn_BDPTHR(n) (_W5300_IO_BASE_ + 0x60 + n*4 + 2)
595
601 #define IDR (_W5300_IO_BASE_ + 0xFE)
602 #define VERSIONR IDR
603
604
605 //----------------------------- W5300 SOCKET Registers -----------------------------
606
642 #define Sn_MR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x00)
643
666 #define Sn_CR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x02)
667
676 #define Sn_IMR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x04)
677
699 #define Sn_IR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x06)
700
725 #define Sn_SSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x08)
726 #define Sn_SR(n) Sn_SSR(n)
727
728
734 #define Sn_PORTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0A)
735 #define Sn_PORT(n) Sn_PORTR(n)
736
737
743 #define Sn_DHAR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0C)
744
753 #define Sn_DPORTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x12)
754 #define Sn_DPORT(n) Sn_DPORTR(n)
755
756
765 #define Sn_DIPR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x14)
766
772 #define Sn_MSSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x18)
773
785 #define Sn_KPALVTR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1A)
786
793 #define Sn_PROTOR(n) Sn_KPALVTR(n)
794
795
802 #define Sn_TOSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1C)
803 #define Sn_TOS(n) Sn_TOSR(n)
804
805
811 #define Sn_TTLR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x1E)
812 #define Sn_TTL(n) Sn_TTLR(n)
813
814
821 #define Sn_TX_WRSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x20)
822
832 #define Sn_TX_FSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0024)
833
841 #define Sn_RX_RSR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x0028)
842
848 #define Sn_FRAGR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x002C)
849 #define Sn_FRAG(n) Sn_FRAGR(n)
850
859 #define Sn_TX_FIFOR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x2E)
860
869 #define Sn_RX_FIFOR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x30)
870
871 //#define Sn_TX_SADR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x32)
872
873 //#define Sn_RX_SADR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x34)
874
875 //#define Sn_TX_RD(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x36)
876
877 //#define Sn_TX_WR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x38)
878
879 //#define Sn_TX_ACK(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x3A)
880
881 //#define Sn_RX_RD(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x3C)
882
883 //#define Sn_RX_WR(n) (_W5300_IO_BASE_ + WIZCHIP_SREG_BLOCK(n) + 0x3E)
884
885
886 /************************************/
887 /* The bit of MR regsiter defintion */
888 /************************************/
889 #define MR_DBW (1 << 15)
890 #define MR_MPF (1 << 14)
891 #define MR_WDF(X) ((X & 0x07) << 11)
892 #define MR_RDH (1 << 10)
893 #define MR_FS (1 << 8)
894 #define MR_RST (1 << 7)
895 #define MR_MT (1 << 5)
896 #define MR_PB (1 << 4)
897 #define MR_PPPoE (1 << 3)
898 #define MR_DBS (1 << 2)
899 #define MR_IND (1 << 0)
902 /************************************/
903 /* The bit of IR regsiter defintion */
904 /************************************/
905 #define IR_IPCF (1 << 15)
906 #define IR_DPUR (1 << 14)
907 #define IR_PPPT (1 << 13)
908 #define IR_FMTU (1 << 12)
909 #define IR_SnINT(n) (0x01 << n)
911 /*****************************************/
912 /* The bit of Pn_BRDYR regsiter defintion*/
913 /*****************************************/
914 #define Pn_PEN (1 << 7)
915 #define Pn_MT (1 << 6)
916 #define Pn_PPL (1 << 5)
917 #define Pn_SN(n) ((n & 0x07) << 0)
920 /***************************************/
921 /* The bit of Sn_MR regsiter defintion */
922 /***************************************/
929 #define Sn_MR_ALIGN (1 << 8)
930
937 #define Sn_MR_MULTI (1 << 7)
938
947 #define Sn_MR_MF (1 << 6)
948
955 #define Sn_MR_IGMPv (1 << 5)
956 #define Sn_MR_MC Sn_MR_IGMPv
957
958
966 #define Sn_MR_ND (1 << 5)
967
973 #define Sn_MR_CLOSE 0x00
974
980 #define Sn_MR_TCP 0x01
981
987 #define Sn_MR_UDP 0x02
994 #define Sn_MR_IPRAW 0x03
1002 #define Sn_MR_MACRAW 0x04
1003
1010 #define Sn_MR_PPPoE 0x05
1012 #define SOCK_STREAM Sn_MR_TCP
1013 #define SOCK_DGRAM Sn_MR_UDP
1017 /******************************/
1018 /* The values of CR defintion */
1019 /******************************/
1034 #define Sn_CR_OPEN 0x01
1035
1045 #define Sn_CR_LISTEN 0x02
1046
1057 #define Sn_CR_CONNECT 0x04
1058
1070 #define Sn_CR_DISCON 0x08
1071
1076 #define Sn_CR_CLOSE 0x10
1077
1083 #define Sn_CR_SEND 0x20
1084
1093 #define Sn_CR_SEND_MAC 0x21
1094
1101 #define Sn_CR_SEND_KEEP 0x22
1102
1108 #define Sn_CR_RECV 0x40
1110 #define Sn_CR_PCON 0x23
1111 #define Sn_CR_PDISCON 0x24
1112 #define Sn_CR_PCR 0x25
1113 #define Sn_CR_PCN 0x26
1114 #define Sn_CR_PCJ 0x27
1117 /*********************************/
1118 /* The values of Sn_IR defintion */
1119 /*********************************/
1120 #define Sn_IR_PRECV 0x80
1121 #define Sn_IR_PFAIL 0x40
1122 #define Sn_IR_PNEXT 0x20
1123 #define Sn_IR_SENDOK 0x10
1124 #define Sn_IR_TIMEOUT 0x08
1125 #define Sn_IR_RECV 0x04
1126 #define Sn_IR_DISCON 0x02
1127 #define Sn_IR_CON 0x01
1129 /**********************************/
1130 /* The values of Sn_SSR defintion */
1131 /**********************************/
1137 #define SOCK_CLOSED 0x00
1138
1144 #define SOCK_ARP 0x01
1152 #define SOCK_INIT 0x13
1153
1160 #define SOCK_LISTEN 0x14
1161
1169 #define SOCK_SYNSENT 0x15
1170
1177 #define SOCK_SYNRECV 0x16
1178
1186 #define SOCK_ESTABLISHED 0x17
1187
1194 #define SOCK_FIN_WAIT 0x18
1195
1202 #define SOCK_CLOSING 0x1A
1203
1210 #define SOCK_TIME_WAIT 0x1B
1211
1218 #define SOCK_CLOSE_WAIT 0x1C
1219
1225 #define SOCK_LAST_ACK 0x1D
1226
1233 #define SOCK_UDP 0x22
1234
1241 #define SOCK_IPRAW 0x32
1242
1249 #define SOCK_MACRAW 0x42
1257 #define SOCK_PPPoE 0x5F
1259 /* IP PROTOCOL */
1260 #define IPPROTO_IP 0 //< Dummy for IP
1261 #define IPPROTO_ICMP 1 //< Control message protocol
1262 #define IPPROTO_IGMP 2 //< Internet group management protocol
1263 #define IPPROTO_GGP 3 //< Gateway^2 (deprecated)
1264 #define IPPROTO_TCP 6 //< TCP
1265 #define IPPROTO_PUP 12 //< PUP
1266 #define IPPROTO_UDP 17 //< UDP
1267 #define IPPROTO_IDP 22 //< XNS idp
1268 #define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol
1269 #define IPPROTO_RAW 255 //< Raw IP packet
1270
1271
1283 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1284
1285 #ifdef _exit
1286 #undef _exit
1287 #endif
1288
1300 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1301
1303 // Basic I/O Function //
1305
1312 uint16_t WIZCHIP_READ (uint32_t AddrSel);
1313
1321 void WIZCHIP_WRITE(uint32_t AddrSel, uint16_t wb );
1322
1323 /***********************************
1324 * COMMON Register Access Function *
1325 ***********************************/
1326
1333 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
1334 #if (_WIZCHIP_IO_BUS_WIDTH_ == 8)
1335 #define setMR(mr) \
1336 (*((uint8_t*)MR) = (uint8_t)((mr) >> 8)); (*((uint8_t*)WIZCHIP_OFFSET_INC(MR,1)) = (uint8_t)((mr) & 0xFF))
1337 #elif (_WIZCHIP_IO_BUS_WIDTH_ == 16)
1338 #define setMR(mr) (*((uint16_t*)MR) = (uint16_t)((mr) & 0xFFFF))
1339 #else
1340 #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. You should be define _WIZCHIP_IO_BUS_WIDTH as 8 or 16."
1341 #endif
1342 #else
1343 #error "Unknown _WIZCHIP_IO_MODE_"
1344 #endif
1345
1352 #if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_)
1353 #if (_WIZCHIP_IO_BUS_WIDTH_ == 8)
1354 #define getMR() (((uint16_t)(*((uint8_t*)MR)) << 8) + (((uint16_t)(*((uint8_t*)WIZCHIP_OFFSET_INC(MR,1)))) & 0x00FF))
1355 #elif(_WIZCHIP_IO_BUS_WIDTH_ == 16)
1356 #define getMR() (*((uint16_t*)MR))
1357 #else
1358 #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. You should be define _WIZCHIP_IO_BUS_WIDTH as 8 or 16."
1359 #endif
1360 #else
1361 #error "Unknown _WIZCHIP_IO_MODE_"
1362 #endif
1363
1370 #define setIR(ir) \
1371 WIZCHIP_WRITE(IR, ir & 0xF0FF)
1372
1379 #define getIR() \
1380 (WIZCHIP_READ(IR) & 0xF0FF)
1381
1382
1389 #define setIMR(imr) \
1390 WIZCHIP_WRITE(_IMR_, imr & 0xF0FF)
1391
1398 #define getIMR() \
1399 (WIZCHIP_READ(_IMR_) & 0xF0FF)
1400
1407 #define setSHAR(shar) { \
1408 WIZCHIP_WRITE(SHAR, (((uint16_t)((shar)[0])) << 8) + (((uint16_t)((shar)[1])) & 0x00FF)); \
1409 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SHAR,2), (((uint16_t)((shar)[2])) << 8) + (((uint16_t)((shar)[3])) & 0x00FF)); \
1410 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SHAR,4), (((uint16_t)((shar)[4])) << 8) + (((uint16_t)((shar)[5])) & 0x00FF)); \
1411 }
1412
1419 #define getSHAR(shar) { \
1420 (shar)[0] = (uint8_t)(WIZCHIP_READ(SHAR) >> 8); \
1421 (shar)[1] = (uint8_t)(WIZCHIP_READ(SHAR)); \
1422 (shar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,2)) >> 8); \
1423 (shar)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,2))); \
1424 (shar)[4] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,4)) >> 8); \
1425 (shar)[5] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SHAR,4))); \
1426 }
1427
1434 #define setGAR(gar) { \
1435 WIZCHIP_WRITE(GAR, (((uint16_t)((gar)[0])) << 8) + (((uint16_t)((gar)[1])) & 0x00FF)); \
1436 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(GAR,2), (((uint16_t)((gar)[2])) << 8) + (((uint16_t)((gar)[3])) & 0x00FF)); \
1437 }
1438
1445 #define getGAR(gar) { \
1446 (gar)[0] = (uint8_t)(WIZCHIP_READ(GAR) >> 8); \
1447 (gar)[1] = (uint8_t)(WIZCHIP_READ(GAR)); \
1448 (gar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(GAR,2)) >> 8); \
1449 (gar)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(GAR,2))); \
1450 }
1451
1458 #define setSUBR(subr) { \
1459 WIZCHIP_WRITE(SUBR, (((uint16_t)((subr)[0])) << 8) + (((uint16_t)((subr)[1])) & 0x00FF)); \
1460 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SUBR,2), (((uint16_t)((subr)[2])) << 8) + (((uint16_t)((subr)[3])) & 0x00FF)); \
1461 }
1462
1469 #define getSUBR(subr) { \
1470 (subr)[0] = (uint8_t)(WIZCHIP_READ(SUBR) >> 8); \
1471 (subr)[1] = (uint8_t)(WIZCHIP_READ(SUBR)); \
1472 (subr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SUBR,2)) >> 8); \
1473 (subr)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SUBR,2))); \
1474 }
1475
1482 #define setSIPR(sipr) { \
1483 WIZCHIP_WRITE(SIPR, (((uint16_t)((sipr)[0])) << 8) + (((uint16_t)((sipr)[1])) & 0x00FF)); \
1484 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(SIPR,2), (((uint16_t)((sipr)[2])) << 8) + (((uint16_t)((sipr)[3])) & 0x00FF)); \
1485 }
1486
1493 #define getSIPR(sipr) { \
1494 (sipr)[0] = (uint8_t)(WIZCHIP_READ(SIPR) >> 8); \
1495 (sipr)[1] = (uint8_t)(WIZCHIP_READ(SIPR)); \
1496 (sipr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SIPR,2)) >> 8); \
1497 (sipr)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(SIPR,2))); \
1498 }
1499
1500
1507 #define setRTR(rtr) \
1508 WIZCHIP_WRITE(_RTR_, rtr)
1509
1516 #define getRTR() \
1517 WIZCHIP_READ(_RTR_)
1518
1525 #define setRCR(rcr) \
1526 WIZCHIP_WRITE(_RCR_, ((uint16_t)rcr)&0x00FF)
1527
1534 #define getRCR() \
1535 ((uint8_t)(WIZCHIP_READ(_RCR_) & 0x00FF))
1536
1543 #define setTMS01R(tms01r) \
1544 WIZCHIP_WRITE(TMS01R,tms01r)
1545
1552 #define getTMS01R() \
1553 WIZCHIP_READ(TMS01R)
1554
1561 #define setTMS23R(tms23r) \
1562 WIZCHIP_WRITE(TMS23R,tms23r)
1563
1570 #define getTMS23R() \
1571 WIZCHIP_READ(TMS23R)
1572
1579 #define setTMS45R(tms45r) \
1580 WIZCHIP_WRITE(TMS45R,tms45r)
1581
1588 #define getTMS45R() \
1589 WIZCHIP_READ(TMS45R)
1590
1597 #define setTMS67R(tms67r) \
1598 WIZCHIP_WRITE(TMS67R,tms67r)
1599
1606 #define getTMS67R() \
1607 WIZCHIP_READ(TMS67R)
1608
1616 void setTMSR(uint8_t sn,uint8_t tmsr);
1617 #define setSn_TXBUF_SIZE(sn, tmsr) setTMSR(sn, tmsr)
1618
1619
1626 uint8_t getTMSR(uint8_t sn);
1627 #define getSn_TXBUF_SIZE(sn) getTMSR(sn)
1628
1629
1635 #define setRMS01R(rms01r) \
1636 WIZCHIP_WRITE(RMS01R,rms01r)
1637
1644 #define getRMS01R() \
1645 WIZCHIP_READ(RMS01R)
1646
1653 #define setRMS23R(rms23r) \
1654 WIZCHIP_WRITE(RMS23R,rms23r)
1655
1662 #define getRMS23R() \
1663 WIZCHIP_READ(RMS23R)
1664
1671 #define setRMS45R(rms45r) \
1672 WIZCHIP_WRITE(RMS45R,rms45r)
1673
1680 #define getRMS45R() \
1681 WIZCHIP_READ(RMS45R)
1682
1689 #define setRMS67R(rms67r) \
1690 WIZCHIP_WRITE(RMS67R,rms67r)
1691
1698 #define getRMS67R() \
1699 WIZCHIP_READ(RMS67R)
1700
1708 void setRMSR(uint8_t sn,uint8_t rmsr);
1709 #define setSn_RXBUF_SIZE(sn,rmsr) setRMSR(sn, rmsr)
1710
1711
1718 uint8_t getRMSR(uint8_t sn);
1719 #define getSn_RXBUF_SIZE(sn) getRMSR(sn)
1720
1721
1727 #define setMTYPER(mtype) \
1728 WIZCHIP_WRITE(MTYPER, mtype)
1729
1736 #define getMTYPER() \
1737 WIZCHIP_READ(MTYPER)
1738
1744 #define getPATR() \
1745 WIZCHIP_READ(PATR)
1746
1753 #define setPTIMER(ptimer) \
1754 WIZCHIP_WRITE(PTIMER, ((uint16_t)ptimer) & 0x00FF)
1755
1762 #define getPTIMER() \
1763 ((uint8_t)(WIZCHIP_READ(PTIMER) & 0x00FF))
1764
1771 #define setPMAGIC(pmagic) \
1772 WIZCHIP_WRITE(PMAGIC, ((uint16_t)pmagic) & 0x00FF)
1773
1780 #define getPMAGIC() \
1781 ((uint8_t)(WIZCHIP_READ(PMAGIC) & 0x00FF))
1782
1788 #define getPSIDR() \
1789 WIZCHIP_READ(PSIDR)
1790
1796 #define getPDHAR(pdhar) { \
1797 (pdhar)[0] = (uint8_t)(WIZCHIP_READ(PDHAR) >> 8); \
1798 (pdhar)[1] = (uint8_t)(WIZCHIP_READ(PDHAR)); \
1799 (pdhar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,2)) >> 8); \
1800 (pdhar)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,2))); \
1801 (pdhar)[4] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,4)) >> 8); \
1802 (pdhar)[5] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(PDHAR,4))); \
1803 }
1804
1810 #define getUIPR(uipr) { \
1811 (uipr)[0] = (uint8_t)(WIZCHIP_READ(UIPR) >> 8); \
1812 (uipr)[1] = (uint8_t)(WIZCHIP_READ(UIPR)); \
1813 (uipr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(UIPR,2)) >> 8); \
1814 (uipr)[3] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(UIPR,2))); \
1815 }
1816
1822 #define getUPORTR() \
1823 WIZCHIP_READ(UPORTR)
1824
1830 #define getFMTUR() \
1831 WIZCHIP_READ(FMTUR)
1832
1833
1839 #define getPn_BRDYR(p) \
1840 ((uint8_t)(WIZCHIP_READ(Pn_BRDYR(p)) & 0x00FF))
1841
1848 #define setPn_BRDYR(p, brdyr) \
1849 WIZCHIP_WRITE(Pn_BRDYR(p), brdyr & 0x00E7)
1850
1857 #define getPn_BDPTHR(p) \
1858 WIZCHIP_READ(Pn_BDPTHR(p))
1859
1866 #define setPn_BDPTHR(p, bdpthr) \
1867 WIZCHIP_WRITE(Pn_BDPTHR(p),bdpthr)
1868
1869
1875 #define getIDR() \
1876 WIZCHIP_READ(IDR)
1877
1878
1879 /***********************************
1880 * SOCKET Register Access Function *
1881 ***********************************/
1882
1890 #define setSn_MR(sn, mr) \
1891 WIZCHIP_WRITE(Sn_MR(sn),mr)
1892
1900 #define getSn_MR(sn) \
1901 WIZCHIP_READ(Sn_MR(sn))
1902
1910 #define setSn_CR(sn, cr) \
1911 WIZCHIP_WRITE(Sn_CR(sn), ((uint16_t)cr) & 0x00FF)
1912
1920 #define getSn_CR(sn) \
1921 ((uint8_t)WIZCHIP_READ(Sn_CR(sn)))
1922
1930 #define setSn_IMR(sn, imr) \
1931 WIZCHIP_WRITE(Sn_IMR(sn), ((uint16_t)imr) & 0x00FF)
1932
1940 #define getSn_IMR(sn) \
1941 ((uint8_t)WIZCHIP_READ(Sn_IMR(sn)))
1942
1950 #define setSn_IR(sn, ir) \
1951 WIZCHIP_WRITE(Sn_IR(sn), ((uint16_t)ir) & 0x00FF)
1952
1960 #define getSn_IR(sn) \
1961 ((uint8_t)WIZCHIP_READ(Sn_IR(sn)))
1962
1969 #define getSn_SSR(sn) \
1970 ((uint8_t)WIZCHIP_READ(Sn_SR(sn)))
1971 #define getSn_SR(sn) getSn_SSR(sn)
1972
1973
1980 #define setSn_PORTR(sn, port) \
1981 WIZCHIP_WRITE(Sn_PORTR(sn), port)
1982 #define setSn_PORT(sn, port) setSn_PORTR(sn, port)
1983
1984
1991 #define getSn_PORTR(sn, port) \
1992 WIZCHIP_READ(Sn_PORTR(sn))
1993 #define getSn_PORT(sn) getSn_PORTR(sn)
1994
1995
2002 #define setSn_DHAR(sn, dhar) { \
2003 WIZCHIP_WRITE(Sn_DHAR(sn), (((uint16_t)((dhar)[0])) << 8) + (((uint16_t)((dhar)[1])) & 0x00FF)); \
2004 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),2), (((uint16_t)((dhar)[0])) << 8) + (((uint16_t)((dhar)[1])) & 0x00FF)); \
2005 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),4), (((uint16_t)((dhar)[0])) << 8) + (((uint16_t)((dhar)[1])) & 0x00FF)); \
2006 }
2007
2015 #define getSn_DHAR(sn, dhar) { \
2016 (dhar)[0] = (uint8_t)(WIZCHIP_READ(Sn_DHAR(sn)) >> 8); \
2017 (dhar)[1] = (uint8_t) WIZCHIP_READ(Sn_DHAR(sn)); \
2018 (dhar)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),2)) >> 8); \
2019 (dhar)[3] = (uint8_t) WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),2)); \
2020 (dhar)[4] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),4)) >> 8); \
2021 (dhar)[5] = (uint8_t) WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DHAR(sn),4)); \
2022 }
2023
2031 #define setSn_DPORTR(sn, dport) \
2032 WIZCHIP_WRITE(Sn_DPORTR(sn),dport)
2033 #define setSn_DPORT(sn, dport) setSn_DPORTR(sn,dport)
2034
2035
2045 #define getSn_DPORTR(sn) \
2046 WIZCHIP_READ(Sn_DPORTR(sn))
2047 #define getSn_DPORT(sn) getSn_DPORTR(sn)
2048
2049
2056 #define setSn_DIPR(sn, dipr) { \
2057 WIZCHIP_WRITE(Sn_DIPR(sn), (((uint16_t)((dipr)[0])) << 8) + (((uint16_t)((dipr)[1])) & 0x00FF)); \
2058 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DIPR(sn),2), (((uint16_t)((dipr)[2])) << 8) + (((uint16_t)((dipr)[3])) & 0x00FF)); \
2059 }
2060
2068 #define getSn_DIPR(sn, dipr) { \
2069 (dipr)[0] = (uint8_t)(WIZCHIP_READ(Sn_DIPR(sn)) >> 8); \
2070 (dipr)[1] = (uint8_t) WIZCHIP_READ(Sn_DIPR(sn)); \
2071 (dipr)[2] = (uint8_t)(WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DIPR(sn),2)) >> 8); \
2072 (dipr)[3] = (uint8_t) WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DIPR(sn),2)); \
2073 }
2074
2082 #define setSn_MSSR(sn, mss) \
2083 WIZCHIP_WRITE(Sn_MSSR(sn), mss)
2084
2092 #define getSn_MSSR(sn) \
2093 WIZCHIP_READ(Sn_MSSR(sn))
2094
2102 #define setSn_KPALVTR(sn, kpalvt) \
2103 WIZCHIP_WRITE(Sn_KPALVTR(sn), (WIZCHIP_READ(Sn_KPALVTR(sn)) & 0x00FF) | (((uint16_t)kpalvt)<<8))
2104
2112 #define getSn_KPALVTR(sn) \
2113 ((uint8_t)(WIZCHIP_READ(Sn_KPALVTR(sn)) >> 8))
2114
2122 #define setSn_PROTOR(sn, proto) \
2123 WIZCHIP_WRITE(Sn_PROTOR(sn),(WIZCHIP_READ(Sn_PROTOR(sn) & 0xFF00) | (((uint16_t)proto) & 0x00FF))
2124 #define setSn_PROTO(sn,proto) setSn_PROTOR(sn,proto)
2125
2126
2133 #define getSn_PROTOR(sn) \
2134 ((uint8_t)WIZCHIP_READ(Sn_PROTOR(sn)))
2135 #define getSn_PROTO(sn) getSn_PROTOR(sn)
2136
2137
2144 #define setSn_TX_WRSR(sn, txwrs) { \
2145 WIZCHIP_WRITE(Sn_TX_WRSR(sn), (uint16_t)(((uint32_t)txwrs) >> 16)); \
2146 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WRSR(sn),2), (uint16_t)txwrs); \
2147 }
2148
2156 #define getSn_TX_WRSR(sn) \
2157 ( (((uint32_t)WIZCHIP_READ(Sn_TX_WRSR(sn))) << 16) + (((uint32_t)WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WRSR(sn),1))) & 0x0000FFFF) )
2158
2165 uint32_t getSn_TX_FSR(uint8_t sn);
2166
2173 uint32_t getSn_RX_RSR(uint8_t sn);
2174
2181 #define setSn_TX_FIFOR(sn, txfifo) \
2182 WIZCHIP_WRITE(Sn_TX_FIFOR(sn), txfifo);
2183
2190 #define getSn_RX_FIFOR(sn) \
2191 WIZCHIP_READ(Sn_RX_FIFOR(sn));
2192
2200 #define setSn_TOSR(sn, tos) \
2201 WIZCHIP_WRITE(Sn_TOS(sn), ((uint16_t)tos) & 0x00FF)
2202 #define setSn_TOS(sn,tos) setSn_TOSR(sn,tos)
2203
2204
2211 #define getSn_TOSR(sn) \
2212 ((uint8_t)WIZCHIP_READ(Sn_TOSR(sn)))
2213 #define getSn_TOS(sn) getSn_TOSR(sn)
2214
2215
2222 #define setSn_TTLR(sn, ttl) \
2223 WIZCHIP_WRITE(Sn_TTLR(sn), ((uint16_t)ttl) & 0x00FF)
2224 #define setSn_TTL(sn,ttl) setSn_TTLR(sn,ttl)
2225
2226
2233 #define getSn_TTLR(sn) \
2234 ((uint8_t)WIZCHIP_READ(Sn_TTL(sn)))
2235 #define getSn_TTL(sn) getSn_TTLR(sn)
2236
2237
2244 #define setSn_FRAGR(sn, frag) \
2245 WIZCHIP_WRITE(Sn_FRAGR(sn), (uint16_t)(frag >>8))
2246 #define setSn_FRAG(sn,frag) setSn_FRAGR(sn,flag)
2247
2255 #define getSn_FRAGR(sn) \
2256 (WIZCHIP_READ(Sn_FRAG(sn)) << 8)
2257 #define getSn_FRAG(sn) getSn_FRAGR(sn)
2258
2259
2261 // Sn_TXBUF & Sn_RXBUF IO function //
2263
2270 #define getSn_RxMAX(sn) \
2271 (((uint32_t)getSn_RXBUF_SIZE(sn)) << 10)
2272
2279 #define getSn_TxMAX(sn) \
2280 (((uint32_t)getSn_TXBUF_SIZE(sn)) << 10)
2281
2296 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint32_t len);
2297
2312 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint32_t len);
2313
2321 void wiz_recv_ignore(uint8_t sn, uint32_t len);
2322
2324 #endif
2325
2327 #endif // _W5300_H_
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint32_t len)
It copies data to your buffer from internal RX memory.
WIZCHIP_READ
uint16_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
setTMSR
void setTMSR(uint8_t sn, uint8_t tmsr)
Set TMSR0 ~ TMSR7 register.
getSn_TX_FSR
uint32_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
getTMSR
uint8_t getTMSR(uint8_t sn)
Get TMSR0 ~ TMSR7 register.
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint16_t wb)
It writes 1 byte value to a register.
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint32_t len)
It discard the received data in RX memory.
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint32_t len)
It copies data to internal TX memory.
getSn_RX_RSR
uint32_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
getRMSR
uint8_t getRMSR(uint8_t sn)
Get RMS01R ~ RMS67R register.
setRMSR
void setRMSR(uint8_t sn, uint8_t rmsr)
Set RMS01R ~ RMS67R register.
wizchip_conf.h
WIZCHIP Config Header File.


ioLibrary: 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
WIZCHIP
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
__WIZCHIP::_IF::_read_burst
void(* _read_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:272
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
Definition: w5100s.c:181
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
__WIZCHIP::_CS::_select
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:242
w5500.h
W5500 HAL Header File.
WIZCHIP_CRITICAL_ENTER
#define WIZCHIP_CRITICAL_ENTER()
Enter a critical section.
Definition: w5100.h:1032
__WIZCHIP::_IF::_write_burst
void(* _write_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:273
WIZCHIP_OFFSET_INC
#define WIZCHIP_OFFSET_INC(ADDR, N)
Increase offset address.
Definition: w5100.h:59
getSn_TX_WR
#define getSn_TX_WR(sn)
Get Sn_TX_WR register.
Definition: w5100.h:1675
_W5500_SPI_READ_
#define _W5500_SPI_READ_
Definition: w5500.h:60
Sn_TX_FSR
#define Sn_TX_FSR(sn)
Transmit free memory size register(R)
Definition: w5100.h:510
__WIZCHIP::_IF::_read_byte
uint8_t(* _read_byte)(void)
Definition: wizchip_conf.h:270
_W5500_SPI_WRITE_
#define _W5500_SPI_WRITE_
Definition: w5500.h:61
__WIZCHIP::IF
union __WIZCHIP::_IF IF
_W5500_SPI_VDM_OP_
#define _W5500_SPI_VDM_OP_
Definition: w5500.c:57
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
Definition: w5100s.c:124
Sn_RX_RSR
#define Sn_RX_RSR(sn)
Received data size register(R)
Definition: w5100.h:545
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
__WIZCHIP::_IF::_write_byte
void(* _write_byte)(uint8_t wb)
Definition: wizchip_conf.h:271
WIZCHIP_RXBUF_BLOCK
#define WIZCHIP_RXBUF_BLOCK(N)
Definition: w5500.h:66
__WIZCHIP::CS
struct __WIZCHIP::_CS CS
setSn_TX_WR
#define setSn_TX_WR(sn, txwr)
Set Sn_TX_WR register.
Definition: w5100.h:1663
__WIZCHIP::_CS::_deselect
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:243
WIZCHIP_CRITICAL_EXIT
#define WIZCHIP_CRITICAL_EXIT()
Exit a critical section.
Definition: w5100.h:1049
setSn_RX_RD
#define setSn_RX_RD(sn, rxrd)
Set Sn_RX_RD register.
Definition: w5100.h:1693
__WIZCHIP::_IF::SPI
struct __WIZCHIP::_IF::@1 SPI
WIZCHIP_TXBUF_BLOCK
#define WIZCHIP_TXBUF_BLOCK(N)
Definition: w5500.h:65
getSn_RX_RD
#define getSn_RX_RD(sn)
Get Sn_RX_RD register.
Definition: w5100.h:1705


ioLibrary: 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
55 #if (_WIZCHIP_ == 5500)
56
58 #define _W5500_IO_BASE_ 0x00000000
59
60 #define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase
61 #define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase
62
63 #define WIZCHIP_CREG_BLOCK 0x00 //< Common register block
64 #define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block
65 #define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block
66 #define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block
67
68 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address
69
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 //-------------------------- defgroup ---------------------------------
197 //------------------------------- defgroup end --------------------------------------------
198 //----------------------------- W5500 Common Registers IOMAP -----------------------------
214 #define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3))
215
221 #define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3))
222
228 #define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3))
229
235 #define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3))
236
242 #define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3))
243
249 #define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3))
250
266 #define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3))
267
284 //M20150401 : Rename SYMBOE ( Re-define error in a compile)
285 //#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))
286 #define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))
287
294 #define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3))
295
303 #define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))
304
313 //M20150401 : Rename SYMBOE ( Re-define error in a compile)
314 //#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))
315 #define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))
316
323 //M20150401 : Rename SYMBOE ( Re-define error in a compile)
324 //#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))
325 #define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))
326
332 #define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3))
333
339 #define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3))
340
346 #define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3))
347
353 #define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3))
354
360 #define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3))
361
369 #define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3))
370
378 #define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3))
379
385 #define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3))
386
387 // Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3))
388 // Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3))
389 // Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3))
390 // Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3))
391 // Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3))
392 // Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3))
393 // Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3))
394 // Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3))
395 // Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3))
396 // Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3))
397
403 #define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3))
404
405
406 //----------------------------- W5500 Socket Registers IOMAP -----------------------------
437 #define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
438
456 #define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
457
474 #define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
475
497 #define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
498
505 #define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
506
513 #define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
514
523 #define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
524
533 #define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
534
540 #define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
541
542 // Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
543
550 #define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
551
557 #define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
558 // Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
559 // Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
560 // Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
561 // Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
562 // Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
563 // Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
564 // Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
565
576 #define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
577
587 #define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
588
598 #define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
599
610 #define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
611
624 #define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
625
633 #define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
634
646 #define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
647
655 #define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
656
665 #define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
666
672 #define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
673
685 #define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
686
687 //#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
688
689
690 //----------------------------- W5500 Register values -----------------------------
691
692 /* MODE register values */
697 #define MR_RST 0x80
698
708 #define MR_WOL 0x20
709
716 #define MR_PB 0x10
717
724 #define MR_PPPOE 0x08
725
732 #define MR_FARP 0x02
733
734 /* IR register values */
739 #define IR_CONFLICT 0x80
740
746 #define IR_UNREACH 0x40
747
752 #define IR_PPPoE 0x20
753
758 #define IR_MP 0x10
759
760
761 /* PHYCFGR register value */
762 #define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask.
763 #define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value
764 #define PHYCFGR_OPMDC_ALLA (7<<3)
765 #define PHYCFGR_OPMDC_PDOWN (6<<3)
766 #define PHYCFGR_OPMDC_NA (5<<3)
767 #define PHYCFGR_OPMDC_100FA (4<<3)
768 #define PHYCFGR_OPMDC_100F (3<<3)
769 #define PHYCFGR_OPMDC_100H (2<<3)
770 #define PHYCFGR_OPMDC_10F (1<<3)
771 #define PHYCFGR_OPMDC_10H (0<<3)
772 #define PHYCFGR_DPX_FULL (1<<2)
773 #define PHYCFGR_DPX_HALF (0<<2)
774 #define PHYCFGR_SPD_100 (1<<1)
775 #define PHYCFGR_SPD_10 (0<<1)
776 #define PHYCFGR_LNK_ON (1<<0)
777 #define PHYCFGR_LNK_OFF (0<<0)
778
779 /* IMR register values */
785 #define IM_IR7 0x80
786
792 #define IM_IR6 0x40
793
799 #define IM_IR5 0x20
800
806 #define IM_IR4 0x10
807
808 /* Sn_MR Default values */
817 #define Sn_MR_MULTI 0x80
818
826 #define Sn_MR_BCASTB 0x40
827
836 #define Sn_MR_ND 0x20
837
844 #define Sn_MR_UCASTB 0x10
845
851 #define Sn_MR_MACRAW 0x04
852
853 #define Sn_MR_IPRAW 0x03
859 #define Sn_MR_UDP 0x02
860
865 #define Sn_MR_TCP 0x01
866
871 #define Sn_MR_CLOSE 0x00
872
873 /* Sn_MR values used with Sn_MR_MACRAW */
884 #define Sn_MR_MFEN Sn_MR_MULTI
885
893 #define Sn_MR_MMB Sn_MR_ND
894
901 #define Sn_MR_MIP6B Sn_MR_UCASTB
902
903 /* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */
910 #define Sn_MR_MC Sn_MR_ND
911
912 /* Sn_MR alternate values */
916 #define SOCK_STREAM Sn_MR_TCP
917
921 #define SOCK_DGRAM Sn_MR_UDP
922
923
924 /* Sn_CR values */
937 #define Sn_CR_OPEN 0x01
938
948 #define Sn_CR_LISTEN 0x02
949
960 #define Sn_CR_CONNECT 0x04
961
973 #define Sn_CR_DISCON 0x08
974
979 #define Sn_CR_CLOSE 0x10
980
987 #define Sn_CR_SEND 0x20
988
997 #define Sn_CR_SEND_MAC 0x21
998
1005 #define Sn_CR_SEND_KEEP 0x22
1006
1013 #define Sn_CR_RECV 0x40
1014
1015 /* Sn_IR values */
1020 #define Sn_IR_SENDOK 0x10
1021
1026 #define Sn_IR_TIMEOUT 0x08
1027
1032 #define Sn_IR_RECV 0x04
1033
1038 #define Sn_IR_DISCON 0x02
1039
1044 #define Sn_IR_CON 0x01
1045
1046 /* Sn_SR values */
1052 #define SOCK_CLOSED 0x00
1053
1060 #define SOCK_INIT 0x13
1061
1068 #define SOCK_LISTEN 0x14
1069
1077 #define SOCK_SYNSENT 0x15
1078
1085 #define SOCK_SYNRECV 0x16
1086
1094 #define SOCK_ESTABLISHED 0x17
1095
1102 #define SOCK_FIN_WAIT 0x18
1103
1110 #define SOCK_CLOSING 0x1A
1111
1118 #define SOCK_TIME_WAIT 0x1B
1119
1126 #define SOCK_CLOSE_WAIT 0x1C
1127
1133 #define SOCK_LAST_ACK 0x1D
1134
1141 #define SOCK_UDP 0x22
1142
1143 #define SOCK_IPRAW 0x32
1151 #define SOCK_MACRAW 0x42
1152
1153 //#define SOCK_PPPOE 0x5F
1154
1155 /* IP PROTOCOL */
1156 #define IPPROTO_IP 0 //< Dummy for IP
1157 #define IPPROTO_ICMP 1 //< Control message protocol
1158 #define IPPROTO_IGMP 2 //< Internet group management protocol
1159 #define IPPROTO_GGP 3 //< Gateway^2 (deprecated)
1160 #define IPPROTO_TCP 6 //< TCP
1161 #define IPPROTO_PUP 12 //< PUP
1162 #define IPPROTO_UDP 17 //< UDP
1163 #define IPPROTO_IDP 22 //< XNS idp
1164 #define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol
1165 #define IPPROTO_RAW 255 //< Raw IP packet
1166
1167
1179 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
1180
1181 #ifdef _exit
1182 #undef _exit
1183 #endif
1184
1196 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
1197
1198
1200 // Basic I/O Function //
1202
1209 uint8_t WIZCHIP_READ (uint32_t AddrSel);
1210
1218 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb );
1219
1227 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1228
1236 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
1237
1239 // Common Register I/O function //
1241
1247 #define setMR(mr) \
1248 WIZCHIP_WRITE(MR,mr)
1249
1250
1257 #define getMR() \
1258 WIZCHIP_READ(MR)
1259
1266 #define setGAR(gar) \
1267 WIZCHIP_WRITE_BUF(GAR,gar,4)
1268
1275 #define getGAR(gar) \
1276 WIZCHIP_READ_BUF(GAR,gar,4)
1277
1284 #define setSUBR(subr) \
1285 WIZCHIP_WRITE_BUF(SUBR, subr,4)
1286
1287
1294 #define getSUBR(subr) \
1295 WIZCHIP_READ_BUF(SUBR, subr, 4)
1296
1303 #define setSHAR(shar) \
1304 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
1305
1312 #define getSHAR(shar) \
1313 WIZCHIP_READ_BUF(SHAR, shar, 6)
1314
1321 #define setSIPR(sipr) \
1322 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
1323
1330 #define getSIPR(sipr) \
1331 WIZCHIP_READ_BUF(SIPR, sipr, 4)
1332
1339 #define setINTLEVEL(intlevel) {\
1340 WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \
1341 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \
1342 }
1343
1344
1351 //M20150401 : Type explict declaration
1352 /*
1353 #define getINTLEVEL() \
1354 ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
1355 */
1356 #define getINTLEVEL() \
1357 (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
1358
1365 #define setIR(ir) \
1366 WIZCHIP_WRITE(IR, (ir & 0xF0))
1367
1374 #define getIR() \
1375 (WIZCHIP_READ(IR) & 0xF0)
1376
1382 #define setIMR(imr) \
1383 WIZCHIP_WRITE(_IMR_, imr)
1384
1391 #define getIMR() \
1392 WIZCHIP_READ(_IMR_)
1393
1400 #define setSIR(sir) \
1401 WIZCHIP_WRITE(SIR, sir)
1402
1409 #define getSIR() \
1410 WIZCHIP_READ(SIR)
1411
1417 #define setSIMR(simr) \
1418 WIZCHIP_WRITE(SIMR, simr)
1419
1426 #define getSIMR() \
1427 WIZCHIP_READ(SIMR)
1428
1435 #define setRTR(rtr) {\
1436 WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \
1437 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \
1438 }
1439
1446 //M20150401 : Type explict declaration
1447 /*
1448 #define getRTR() \
1449 ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1450 */
1451 #define getRTR() \
1452 (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1)))
1453
1454
1461 #define setRCR(rcr) \
1462 WIZCHIP_WRITE(_RCR_, rcr)
1463
1470 #define getRCR() \
1471 WIZCHIP_READ(_RCR_)
1472
1473 //================================================== test done ===========================================================
1474
1481 #define setPTIMER(ptimer) \
1482 WIZCHIP_WRITE(PTIMER, ptimer)
1483
1490 #define getPTIMER() \
1491 WIZCHIP_READ(PTIMER)
1492
1499 #define setPMAGIC(pmagic) \
1500 WIZCHIP_WRITE(PMAGIC, pmagic)
1501
1508 #define getPMAGIC() \
1509 WIZCHIP_READ(PMAGIC)
1510
1517 #define setPHAR(phar) \
1518 WIZCHIP_WRITE_BUF(PHAR, phar, 6)
1519
1526 #define getPHAR(phar) \
1527 WIZCHIP_READ_BUF(PHAR, phar, 6)
1528
1535 #define setPSID(psid) {\
1536 WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \
1537 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \
1538 }
1539
1546 //uint16_t getPSID(void);
1547 //M20150401 : Type explict declaration
1548 /*
1549 #define getPSID() \
1550 ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))
1551 */
1552 #define getPSID() \
1553 (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))
1554
1561 #define setPMRU(pmru) { \
1562 WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \
1563 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \
1564 }
1565
1572 //M20150401 : Type explict declaration
1573 /*
1574 #define getPMRU() \
1575 ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))
1576 */
1577 #define getPMRU() \
1578 (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))
1579
1585 //M20150401 : Size Error of UIPR (6 -> 4)
1586 /*
1587 #define getUIPR(uipr) \
1588 WIZCHIP_READ_BUF(UIPR,uipr,6)
1589 */
1590 #define getUIPR(uipr) \
1591 WIZCHIP_READ_BUF(UIPR,uipr,4)
1592
1598 //M20150401 : Type explict declaration
1599 /*
1600 #define getUPORTR() \
1601 ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))
1602 */
1603 #define getUPORTR() \
1604 (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))
1605
1612 #define setPHYCFGR(phycfgr) \
1613 WIZCHIP_WRITE(PHYCFGR, phycfgr)
1614
1621 #define getPHYCFGR() \
1622 WIZCHIP_READ(PHYCFGR)
1623
1629 #define getVERSIONR() \
1630 WIZCHIP_READ(VERSIONR)
1631
1633
1635 // Socket N register I/O function //
1637
1644 #define setSn_MR(sn, mr) \
1645 WIZCHIP_WRITE(Sn_MR(sn),mr)
1646
1654 #define getSn_MR(sn) \
1655 WIZCHIP_READ(Sn_MR(sn))
1656
1664 #define setSn_CR(sn, cr) \
1665 WIZCHIP_WRITE(Sn_CR(sn), cr)
1666
1674 #define getSn_CR(sn) \
1675 WIZCHIP_READ(Sn_CR(sn))
1676
1684 #define setSn_IR(sn, ir) \
1685 WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F))
1686
1694 #define getSn_IR(sn) \
1695 (WIZCHIP_READ(Sn_IR(sn)) & 0x1F)
1696
1704 #define setSn_IMR(sn, imr) \
1705 WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F))
1706
1714 #define getSn_IMR(sn) \
1715 (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F)
1716
1723 #define getSn_SR(sn) \
1724 WIZCHIP_READ(Sn_SR(sn))
1725
1733 #define setSn_PORT(sn, port) { \
1734 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
1735 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
1736 }
1737
1745 //M20150401 : Type explict declaration
1746 /*
1747 #define getSn_PORT(sn) \
1748 ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1749 */
1750 #define getSn_PORT(sn) \
1751 (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
1752
1760 #define setSn_DHAR(sn, dhar) \
1761 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
1762
1770 #define getSn_DHAR(sn, dhar) \
1771 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
1772
1780 #define setSn_DIPR(sn, dipr) \
1781 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
1782
1790 #define getSn_DIPR(sn, dipr) \
1791 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
1792
1800 #define setSn_DPORT(sn, dport) { \
1801 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
1802 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
1803 }
1804
1812 //M20150401 : Type explict declaration
1813 /*
1814 #define getSn_DPORT(sn) \
1815 ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1816 */
1817 #define getSn_DPORT(sn) \
1818 (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
1819
1827 #define setSn_MSSR(sn, mss) { \
1828 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
1829 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
1830 }
1831
1839 //M20150401 : Type explict declaration
1840 /*
1841 #define getSn_MSSR(sn) \
1842 ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1843 */
1844 #define getSn_MSSR(sn) \
1845 (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
1846
1854 #define setSn_TOS(sn, tos) \
1855 WIZCHIP_WRITE(Sn_TOS(sn), tos)
1856
1864 #define getSn_TOS(sn) \
1865 WIZCHIP_READ(Sn_TOS(sn))
1866
1874 #define setSn_TTL(sn, ttl) \
1875 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
1876
1877
1885 #define getSn_TTL(sn) \
1886 WIZCHIP_READ(Sn_TTL(sn))
1887
1888
1896 #define setSn_RXBUF_SIZE(sn, rxbufsize) \
1897 WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize)
1898
1899
1907 #define getSn_RXBUF_SIZE(sn) \
1908 WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
1909
1917 #define setSn_TXBUF_SIZE(sn, txbufsize) \
1918 WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize)
1919
1927 #define getSn_TXBUF_SIZE(sn) \
1928 WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
1929
1936 uint16_t getSn_TX_FSR(uint8_t sn);
1937
1944 //M20150401 : Type explict declaration
1945 /*
1946 #define getSn_TX_RD(sn) \
1947 ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1948 */
1949 #define getSn_TX_RD(sn) \
1950 (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
1951
1959 #define setSn_TX_WR(sn, txwr) { \
1960 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
1961 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
1962 }
1963
1971 //M20150401 : Type explict declaration
1972 /*
1973 #define getSn_TX_WR(sn) \
1974 ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1975 */
1976 #define getSn_TX_WR(sn) \
1977 (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
1978
1979
1986 uint16_t getSn_RX_RSR(uint8_t sn);
1987
1988
1996 #define setSn_RX_RD(sn, rxrd) { \
1997 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
1998 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
1999 }
2000
2008 //M20150401 : Type explict declaration
2009 /*
2010 #define getSn_RX_RD(sn) \
2011 ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
2012 */
2013 #define getSn_RX_RD(sn) \
2014 (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
2015
2022 //M20150401 : Type explict declaration
2023 /*
2024 #define getSn_RX_WR(sn) \
2025 ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
2026 */
2027 #define getSn_RX_WR(sn) \
2028 (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
2029
2037 #define setSn_FRAG(sn, frag) { \
2038 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
2039 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
2040 }
2041
2049 //M20150401 : Type explict declaration
2050 /*
2051 #define getSn_FRAG(sn) \
2052 ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
2053 */
2054 #define getSn_FRAG(sn) \
2055 (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
2056
2064 #define setSn_KPALVTR(sn, kpalvt) \
2065 WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt)
2066
2074 #define getSn_KPALVTR(sn) \
2075 WIZCHIP_READ(Sn_KPALVTR(sn))
2076
2078
2080 // Sn_TXBUF & Sn_RXBUF IO function //
2082
2088 //M20150401 : Type explict declaration
2089 /*
2090 #define getSn_RxMAX(sn) \
2091 (getSn_RXBUF_SIZE(sn) << 10)
2092 */
2093 #define getSn_RxMAX(sn) \
2094 (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10)
2095
2102 //M20150401 : Type explict declaration
2103 /*
2104 #define getSn_TxMAX(sn) \
2105 (getSn_TXBUF_SIZE(sn) << 10)
2106 */
2107 #define getSn_TxMAX(sn) \
2108 (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10)
2109
2124 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2125
2140 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
2141
2149 void wiz_recv_ignore(uint8_t sn, uint16_t len);
2150
2152 #endif
2153
2155 #endif // _W5500_H_
getSn_TX_FSR
uint16_t getSn_TX_FSR(uint8_t sn)
Get Sn_TX_FSR register.
Definition: w5100s.c:237
getSn_RX_RSR
uint16_t getSn_RX_RSR(uint8_t sn)
Get Sn_RX_RSR register.
Definition: w5100s.c:254
wiz_recv_data
void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to your buffer from internal RX memory.
Definition: w5100s.c:353
WIZCHIP_READ_BUF
void WIZCHIP_READ_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It reads sequence data from registers.
Definition: w5100s.c:181
wiz_send_data
void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len)
It copies data to internal TX memory.
Definition: w5100s.c:311
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
Definition: w5100s.c:47
WIZCHIP_WRITE_BUF
void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t *pBuf, uint16_t len)
It writes sequence data to registers.
Definition: w5100s.c:124
wiz_recv_ignore
void wiz_recv_ignore(uint8_t sn, uint16_t len)
It discard the received data in RX memory.
Definition: w5100s.c:385
WIZCHIP_READ
uint8_t WIZCHIP_READ(uint32_t AddrSel)
It reads 1 byte value from a register.
Definition: w5100s.c:83
wizchip_conf.h
WIZCHIP Config Header File.


ioLibrary: image/w5500.jpg Source File

  • image
w5500.jpg
Go to the documentation of this file.
1


ioLibrary: 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 //M20150601 : Rename the function for integrating with W5300
99 //uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); }
100 iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); }
101
107 //M20150601 : Rename the function for integrating with W5300
108 //void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; }
109 void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; }
110
116 //uint8_t wizchip_spi_readbyte(void) {return 0;};
117 uint8_t wizchip_spi_readbyte(void) {return 0;}
118
124 //void wizchip_spi_writebyte(uint8_t wb) {};
125 void wizchip_spi_writebyte(uint8_t wb) {}
126
132 //void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {};
133 void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}
134
140 //void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {};
141 void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}
142
146 //
147 //M20150401 : For a compiler didnot support a member of structure
148 // Replace the assignment of struct members with the assingment of array
149 //
150 /*
151 _WIZCHIP WIZCHIP =
152 {
153 .id = _WIZCHIP_ID_,
154 .if_mode = _WIZCHIP_IO_MODE_,
155 .CRIS._enter = wizchip_cris_enter,
156 .CRIS._exit = wizchip_cris_exit,
157 .CS._select = wizchip_cs_select,
158 .CS._deselect = wizchip_cs_deselect,
159 .IF.BUS._read_byte = wizchip_bus_readbyte,
160 .IF.BUS._write_byte = wizchip_bus_writebyte
161 // .IF.SPI._read_byte = wizchip_spi_readbyte,
162 // .IF.SPI._write_byte = wizchip_spi_writebyte
163 };
164 */
165 _WIZCHIP WIZCHIP =
166 {
167 _WIZCHIP_IO_MODE_,
168 _WIZCHIP_ID_ ,
169 wizchip_cris_enter,
170 wizchip_cris_exit,
171 wizchip_cs_select,
172 wizchip_cs_deselect,
173 //M20150601 : Rename the function
174 //wizchip_bus_readbyte,
175 //wizchip_bus_writebyte
176 wizchip_bus_readdata,
177 wizchip_bus_writedata,
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 //M20150515 : For integrating with W5300
215 //void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb))
216 void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb))
217 {
218 while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_));
219 //M20150601 : Rename call back function for integrating with W5300
220 /*
221 if(!bus_rb || !bus_wb)
222 {
223 WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte;
224 WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte;
225 }
226 else
227 {
228 WIZCHIP.IF.BUS._read_byte = bus_rb;
229 WIZCHIP.IF.BUS._write_byte = bus_wb;
230 }
231 */
232 if(!bus_rb || !bus_wb)
233 {
234 WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata;
235 WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata;
236 }
237 else
238 {
239 WIZCHIP.IF.BUS._read_data = bus_rb;
240 WIZCHIP.IF.BUS._write_data = bus_wb;
241 }
242 }
243
244 void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb))
245 {
246 while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_));
247
248 if(!spi_rb || !spi_wb)
249 {
250 WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte;
251 WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte;
252 }
253 else
254 {
255 WIZCHIP.IF.SPI._read_byte = spi_rb;
256 WIZCHIP.IF.SPI._write_byte = spi_wb;
257 }
258 }
259
260 // 20140626 Eric Added for SPI burst operations
261 void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len))
262 {
263 while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_));
264
265 if(!spi_rb || !spi_wb)
266 {
267 WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst;
268 WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst;
269 }
270 else
271 {
272 WIZCHIP.IF.SPI._read_burst = spi_rb;
273 WIZCHIP.IF.SPI._write_burst = spi_wb;
274 }
275 }
276
277 int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg)
278 {
279 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500
280 uint8_t tmp = 0;
281 #endif
282 uint8_t* ptmp[2] = {0,0};
283 switch(cwtype)
284 {
285 case CW_RESET_WIZCHIP:
286 wizchip_sw_reset();
287 break;
288 case CW_INIT_WIZCHIP:
289 if(arg != 0)
290 {
291 ptmp[0] = (uint8_t*)arg;
292 ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_;
293 }
294 return wizchip_init(ptmp[0], ptmp[1]);
295 case CW_CLR_INTERRUPT:
296 wizchip_clrinterrupt(*((intr_kind*)arg));
297 break;
298 case CW_GET_INTERRUPT:
299 *((intr_kind*)arg) = wizchip_getinterrupt();
300 break;
301 case CW_SET_INTRMASK:
302 wizchip_setinterruptmask(*((intr_kind*)arg));
303 break;
304 case CW_GET_INTRMASK:
305 *((intr_kind*)arg) = wizchip_getinterruptmask();
306 break;
307 //M20150601 : This can be supported by W5200, W5500
308 //#if _WIZCHIP_ > W5100
309 #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500)
310 case CW_SET_INTRTIME:
311 setINTLEVEL(*(uint16_t*)arg);
312 break;
313 case CW_GET_INTRTIME:
314 *(uint16_t*)arg = getINTLEVEL();
315 break;
316 #endif
317 case CW_GET_ID:
318 ((uint8_t*)arg)[0] = WIZCHIP.id[0];
319 ((uint8_t*)arg)[1] = WIZCHIP.id[1];
320 ((uint8_t*)arg)[2] = WIZCHIP.id[2];
321 ((uint8_t*)arg)[3] = WIZCHIP.id[3];
322 ((uint8_t*)arg)[4] = WIZCHIP.id[4];
323 ((uint8_t*)arg)[5] = 0;
324 break;
325 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500
326 case CW_RESET_PHY:
327 wizphy_reset();
328 break;
329 case CW_SET_PHYCONF:
330 wizphy_setphyconf((wiz_PhyConf*)arg);
331 break;
332 case CW_GET_PHYCONF:
333 wizphy_getphyconf((wiz_PhyConf*)arg);
334 break;
335 case CW_GET_PHYSTATUS:
336 break;
337 case CW_SET_PHYPOWMODE:
338 return wizphy_setphypmode(*(uint8_t*)arg);
339 #endif
340 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500
341 case CW_GET_PHYPOWMODE:
342 tmp = wizphy_getphypmode();
343 if((int8_t)tmp == -1) return -1;
344 *(uint8_t*)arg = tmp;
345 break;
346 case CW_GET_PHYLINK:
347 tmp = wizphy_getphylink();
348 if((int8_t)tmp == -1) return -1;
349 *(uint8_t*)arg = tmp;
350 break;
351 #endif
352 default:
353 return -1;
354 }
355 return 0;
356 }
357
358
359 int8_t ctlnetwork(ctlnetwork_type cntype, void* arg)
360 {
361
362 switch(cntype)
363 {
364 case CN_SET_NETINFO:
365 wizchip_setnetinfo((wiz_NetInfo*)arg);
366 break;
367 case CN_GET_NETINFO:
368 wizchip_getnetinfo((wiz_NetInfo*)arg);
369 break;
370 case CN_SET_NETMODE:
371 return wizchip_setnetmode(*(netmode_type*)arg);
372 case CN_GET_NETMODE:
373 *(netmode_type*)arg = wizchip_getnetmode();
374 break;
375 case CN_SET_TIMEOUT:
376 wizchip_settimeout((wiz_NetTimeout*)arg);
377 break;
378 case CN_GET_TIMEOUT:
379 wizchip_gettimeout((wiz_NetTimeout*)arg);
380 break;
381 default:
382 return -1;
383 }
384 return 0;
385 }
386
387 void wizchip_sw_reset(void)
388 {
389 uint8_t gw[4], sn[4], sip[4];
390 uint8_t mac[6];
391 //A20150601
392 #if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_
393 uint16_t mr = (uint16_t)getMR();
394 setMR(mr | MR_IND);
395 #endif
396 //
397 getSHAR(mac);
398 getGAR(gw); getSUBR(sn); getSIPR(sip);
399 setMR(MR_RST);
400 getMR(); // for delay
401 //A2015051 : For indirect bus mode
402 #if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_
403 setMR(mr | MR_IND);
404 #endif
405 //
406 setSHAR(mac);
407 setGAR(gw);
408 setSUBR(sn);
409 setSIPR(sip);
410 }
411
412 int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize)
413 {
414 int8_t i,j;
415 int8_t tmp = 0;
416 wizchip_sw_reset();
417 if(txsize)
418 {
419 tmp = 0;
420 //M20150601 : For integrating with W5300
421 #if _WIZCHIP_ == W5300
422 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
423 {
424 if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation
425 tmp += txsize[i];
426 if(tmp > 128) return -1;
427 }
428 if(tmp % 8) return -1;
429 #else
430 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
431 {
432 tmp += txsize[i];
433 #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s
434 if(tmp > 8) return -1;
435 #else
436 if(tmp > 16) return -1;
437 #endif
438 }
439
440 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
441 {
442 #if __WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s
443 j = 0;
444 while(txsize[i] >> j != 1){j++;}
445 setSn_TXBUF_SIZE(i, j);
446 #else
447 setSn_TXBUF_SIZE(i, txsize[i]);
448 #endif
449 }
450 #endif
451 }
452 if(rxsize)
453 {
454 tmp = 0;
455 #if _WIZCHIP_ == W5300
456 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
457 {
458 if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation
459 tmp += rxsize[i];
460 if(tmp > 128) return -1;
461 }
462 if(tmp % 8) return -1;
463 #else
464 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
465 {
466 tmp += rxsize[i];
467 #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s
468 if(tmp > 8) return -1;
469 #else
470 if(tmp > 16) return -1;
471 #endif
472 }
473
474 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++)
475 {
476 #if __WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s
477 j = 0;
478 while(rxsize[i] >> j != 1){j++;}
479 setSn_RXBUF_SIZE(i, j);
480 #else
481 setSn_RXBUF_SIZE(i, txsize[i]);
482 #endif
483 }
484 #endif
485 }
486 return 0;
487 }
488
489 void wizchip_clrinterrupt(intr_kind intr)
490 {
491 uint8_t ir = (uint8_t)intr;
492 uint8_t sir = (uint8_t)((uint16_t)intr >> 8);
493 #if _WIZCHIP_ < W5500
494 ir |= (1<<4); // IK_WOL
495 #endif
496 #if _WIZCHIP_ == W5200
497 ir |= (1 << 6);
498 #endif
499
500 #if _WIZCHIP_ < W5200
501 sir &= 0x0F;
502 #endif
503
504 #if _WIZCHIP_ <= W5100S
505 ir |= sir;
506 setIR(ir);
507 //A20150601 : For integrating with W5300
508 #elif _WIZCHIP_ == W5300
509 setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) );
510 #else
511 setIR(ir);
512 setSIR(sir);
513 #endif
514 }
515
516 intr_kind wizchip_getinterrupt(void)
517 {
518 uint8_t ir = 0;
519 uint8_t sir = 0;
520 uint16_t ret = 0;
521 #if _WIZCHIP_ <= W5100S
522 ir = getIR();
523 sir = ir & 0x0F;
524 //A20150601 : For integrating with W5300
525 #elif _WIZCHIP_ == W5300
526 ret = getIR();
527 ir = (uint8_t)(ret >> 8);
528 sir = (uint8_t)ret;
529 #else
530 ir = getIR();
531 sir = getSIR();
532 #endif
533
534 //M20150601 : For Integrating with W5300
535 //#if _WIZCHIP_ < W5500
536 #if _WIZCHIP_ < W5200
537 ir &= ~(1<<4); // IK_WOL
538 #endif
539 #if _WIZCHIP_ == W5200
540 ir &= ~(1 << 6);
541 #endif
542 ret = sir;
543 ret = (ret << 8) + ir;
544 return (intr_kind)ret;
545 }
546
547 void wizchip_setinterruptmask(intr_kind intr)
548 {
549 uint8_t imr = (uint8_t)intr;
550 uint8_t simr = (uint8_t)((uint16_t)intr >> 8);
551 #if _WIZCHIP_ < W5500
552 imr &= ~(1<<4); // IK_WOL
553 #endif
554 #if _WIZCHIP_ == W5200
555 imr &= ~(1 << 6);
556 #endif
557
558 #if _WIZCHIP_ < W5200
559 simr &= 0x0F;
560 imr |= simr;
561 setIMR(imr);
562 //A20150601 : For integrating with W5300
563 #elif _WIZCHIP_ == W5300
564 setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) );
565 #else
566 setIMR(imr);
567 setSIMR(simr);
568 #endif
569 }
570
571 intr_kind wizchip_getinterruptmask(void)
572 {
573 uint8_t imr = 0;
574 uint8_t simr = 0;
575 uint16_t ret = 0;
576 #if _WIZCHIP_ < W5200
577 imr = getIMR();
578 simr = imr & 0x0F;
579 //A20150601 : For integrating with W5300
580 #elif _WIZCHIP_ == W5300
581 ret = getIMR();
582 imr = (uint8_t)(ret >> 8);
583 simr = (uint8_t)ret;
584 #else
585 imr = getIMR();
586 simr = getSIMR();
587 #endif
588
589 #if _WIZCHIP_ < W5500
590 imr &= ~(1<<4); // IK_WOL
591 #endif
592 #if _WIZCHIP_ == W5200
593 imr &= ~(1 << 6); // IK_DEST_UNREACH
594 #endif
595 ret = simr;
596 ret = (ret << 8) + imr;
597 return (intr_kind)ret;
598 }
599
600 int8_t wizphy_getphylink(void)
601 {
602 int8_t tmp;
603 #if _WIZCHIP_ == W5100S
604 if(getPHYSR() & PHYSR_LNK)
605 tmp = PHY_LINK_ON;
606 else
607 tmp = PHY_LINK_OFF;
608 #elif _WIZCHIP_ == W5200
609 if(getPHYSTATUS() & PHYSTATUS_LINK)
610 tmp = PHY_LINK_ON;
611 else
612 tmp = PHY_LINK_OFF;
613 #elif _WIZCHIP_ == W5500
614 if(getPHYCFGR() & PHYCFGR_LNK_ON)
615 tmp = PHY_LINK_ON;
616 tmp = PHY_LINK_OFF;
617 #else
618 tmp = -1;
619 #endif
620 return tmp;
621 }
622
623 #if _WIZCHIP_ > W5100
624
625 int8_t wizphy_getphypmode(void)
626 {
627 int8_t tmp = 0;
628 #if _WIZCHIP_ == W5200
629 if(getPHYSTATUS() & PHYSTATUS_POWERDOWN)
630 tmp = PHY_POWER_DOWN;
631 else
632 tmp = PHY_POWER_NORM;
633 #elif _WIZCHIP_ == 5500
634 if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN)
635 tmp = PHY_POWER_DOWN;
636 else
637 tmp = PHY_POWER_NORM;
638 #else
639 tmp = -1;
640 #endif
641 return tmp;
642 }
643 #endif
644
645 #if _WIZCHIP_ == W5100S
646 void wizphy_reset(void)
647 {
648 uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR);
649 tmp |= BMCR_RESET;
650 wiz_mdio_write(PHYMDIO_BMCR, tmp);
651 while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){}
652 }
653
654 void wizphy_setphyconf(wiz_PhyConf* phyconf)
655 {
656 uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR);
657 if(phyconf->mode == PHY_MODE_AUTONEGO)
658 tmp |= BMCR_AUTONEGO;
659 else
660 {
661 tmp &= ~BMCR_AUTONEGO;
662 if(phyconf->duplex == PHY_DUPLEX_FULL)
663 {
664 tmp |= BMCR_DUP;
665 }
666 else
667 {
668 tmp &= ~BMCR_DUP;
669 }
670 if(phyconf->speed == PHY_SPEED_100)
671 {
672 tmp |= BMCR_SPEED;
673 }
674 else
675 {
676 tmp &= ~BMCR_SPEED;
677 }
678 }
679 wiz_mdio_write(PHYMDIO_BMCR, tmp);
680 }
681
682 void wizphy_getphyconf(wiz_PhyConf* phyconf)
683 {
684 uint16_t tmp = 0;
685 tmp = wiz_mdio_read(PHYMDIO_BMCR);
686 phyconf->by = PHY_CONFBY_SW;
687 if(tmp & BMCR_AUTONEGO)
688 {
689 phyconf->mode = PHY_MODE_AUTONEGO;
690 }
691 else
692 {
693 phyconf->mode = PHY_MODE_MANUAL;
694 if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL;
695 else phyconf->duplex = PHY_DUPLEX_HALF;
696 if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100;
697 else phyconf->speed = PHY_SPEED_10;
698 }
699 }
700
701 int8_t wizphy_setphypmode(uint8_t pmode)
702 {
703 uint16_t tmp = 0;
704 tmp = wiz_mdio_read(PHYMDIO_BMCR);
705 if( pmode == PHY_POWER_DOWN)
706 {
707 tmp |= BMCR_PWDN;
708 }
709 else
710 {
711 tmp &= ~BMCR_PWDN;
712 }
713 wiz_mdio_write(PHYMDIO_BMCR, tmp);
714 tmp = wiz_mdio_read(PHYMDIO_BMCR);
715 if( pmode == PHY_POWER_DOWN)
716 {
717 if(tmp & BMCR_PWDN) return 0;
718 }
719 else
720 {
721 if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0;
722 }
723 return -1;
724 }
725
726 #endif
727 #if _WIZCHIP_ == W5500
728 void wizphy_reset(void)
729 {
730 uint8_t tmp = getPHYCFGR();
731 tmp &= PHYCFGR_RST;
732 setPHYCFGR(tmp);
733 tmp = getPHYCFGR();
734 tmp |= ~PHYCFGR_RST;
735 setPHYCFGR(tmp);
736 }
737
738 void wizphy_setphyconf(wiz_PhyConf* phyconf)
739 {
740 uint8_t tmp = 0;
741 if(phyconf->by == PHY_CONFBY_SW)
742 tmp |= PHYCFGR_OPMD;
743 else
744 tmp &= ~PHYCFGR_OPMD;
745 if(phyconf->mode == PHY_MODE_AUTONEGO)
746 tmp |= PHYCFGR_OPMDC_ALLA;
747 else
748 {
749 if(phyconf->duplex == PHY_DUPLEX_FULL)
750 {
751 if(phyconf->speed == PHY_SPEED_100)
752 tmp |= PHYCFGR_OPMDC_100F;
753 else
754 tmp |= PHYCFGR_OPMDC_10F;
755 }
756 else
757 {
758 if(phyconf->speed == PHY_SPEED_100)
759 tmp |= PHYCFGR_OPMDC_100H;
760 else
761 tmp |= PHYCFGR_OPMDC_10H;
762 }
763 }
764 setPHYCFGR(tmp);
765 wizphy_reset();
766 }
767
768 void wizphy_getphyconf(wiz_PhyConf* phyconf)
769 {
770 uint8_t tmp = 0;
771 tmp = getPHYCFGR();
772 phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW;
773 switch(tmp & PHYCFGR_OPMDC_ALLA)
774 {
775 case PHYCFGR_OPMDC_ALLA:
776 case PHYCFGR_OPMDC_100FA:
777 phyconf->mode = PHY_MODE_AUTONEGO;
778 break;
779 default:
780 phyconf->mode = PHY_MODE_MANUAL;
781 break;
782 }
783 switch(tmp & PHYCFGR_OPMDC_ALLA)
784 {
785 case PHYCFGR_OPMDC_100FA:
786 case PHYCFGR_OPMDC_100F:
787 case PHYCFGR_OPMDC_100H:
788 phyconf->speed = PHY_SPEED_100;
789 break;
790 default:
791 phyconf->speed = PHY_SPEED_10;
792 break;
793 }
794 switch(tmp & PHYCFGR_OPMDC_ALLA)
795 {
796 case PHYCFGR_OPMDC_100FA:
797 case PHYCFGR_OPMDC_100F:
798 case PHYCFGR_OPMDC_10F:
799 phyconf->duplex = PHY_DUPLEX_FULL;
800 break;
801 default:
802 phyconf->duplex = PHY_DUPLEX_HALF;
803 break;
804 }
805 }
806
807 void wizphy_getphystat(wiz_PhyConf* phyconf)
808 {
809 uint8_t tmp = getPHYCFGR();
810 phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF;
811 phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10;
812 }
813
814 int8_t wizphy_setphypmode(uint8_t pmode)
815 {
816 uint8_t tmp = 0;
817 tmp = getPHYCFGR();
818 if((tmp & PHYCFGR_OPMD)== 0) return -1;
819 tmp &= ~PHYCFGR_OPMDC_ALLA;
820 if( pmode == PHY_POWER_DOWN)
821 tmp |= PHYCFGR_OPMDC_PDOWN;
822 else
823 tmp |= PHYCFGR_OPMDC_ALLA;
824 setPHYCFGR(tmp);
825 wizphy_reset();
826 tmp = getPHYCFGR();
827 if( pmode == PHY_POWER_DOWN)
828 {
829 if(tmp & PHYCFGR_OPMDC_PDOWN) return 0;
830 }
831 else
832 {
833 if(tmp & PHYCFGR_OPMDC_ALLA) return 0;
834 }
835 return -1;
836 }
837 #endif
838
839
840 void wizchip_setnetinfo(wiz_NetInfo* pnetinfo)
841 {
842 int i,j,k;
843 setSHAR(pnetinfo->mac);
844 setGAR(pnetinfo->gw);
845 setSUBR(pnetinfo->sn);
846 setSIPR(pnetinfo->ip);
847 _DNS_[0] = pnetinfo->dns[0];
848 _DNS_[1] = pnetinfo->dns[1];
849 _DNS_[2] = pnetinfo->dns[2];
850 _DNS_[3] = pnetinfo->dns[3];
851 _DHCP_ = pnetinfo->dhcp;
852 }
853
854 void wizchip_getnetinfo(wiz_NetInfo* pnetinfo)
855 {
856 getSHAR(pnetinfo->mac);
857 getGAR(pnetinfo->gw);
858 getSUBR(pnetinfo->sn);
859 getSIPR(pnetinfo->ip);
860 pnetinfo->dns[0]= _DNS_[0];
861 pnetinfo->dns[1]= _DNS_[1];
862 pnetinfo->dns[2]= _DNS_[2];
863 pnetinfo->dns[3]= _DNS_[3];
864 pnetinfo->dhcp = _DHCP_;
865 }
866
867 int8_t wizchip_setnetmode(netmode_type netmode)
868 {
869 uint8_t tmp = 0;
870 #if _WIZCHIP_ != W5500
871 if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1;
872 #else
873 if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1;
874 #endif
875 tmp = getMR();
876 tmp |= (uint8_t)netmode;
877 setMR(tmp);
878 return 0;
879 }
880
881 netmode_type wizchip_getnetmode(void)
882 {
883 return (netmode_type) getMR();
884 }
885
886 void wizchip_settimeout(wiz_NetTimeout* nettime)
887 {
888 setRCR(nettime->retry_cnt);
889 setRTR(nettime->time_100us);
890 }
891
892 void wizchip_gettimeout(wiz_NetTimeout* nettime)
893 {
894 nettime->retry_cnt = getRCR();
895 nettime->time_100us = getRTR();
896 }
wizchip_getnetmode
netmode_type wizchip_getnetmode(void)
Get the network mode such WOL, PPPoE, Ping Block, and etc.
Definition: wizchip_conf.c:881
__WIZCHIP::_IF::_read_data
iodata_t(* _read_data)(uint32_t AddrSel)
Definition: wizchip_conf.h:261
__WIZCHIP::_CRIS::_exit
void(* _exit)(void)
critial section exit
Definition: wizchip_conf.h:235
wizchip_gettimeout
void wizchip_gettimeout(wiz_NetTimeout *nettime)
Get retry time value(RTR) and retry count(RCR).
Definition: wizchip_conf.c:892
WIZCHIP
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
getSIMR
#define getSIMR()
Definition: w5200.h:1548
getSIR
#define getSIR()
Definition: w5200.h:1509
CN_GET_NETINFO
Get Network with wiz_NetInfo.
Definition: wizchip_conf.h:320
wizphy_setphyconf
void wizphy_setphyconf(wiz_PhyConf *phyconf)
Set the phy information for WIZCHIP without power mode.
Definition: wizchip_conf.c:738
BMCR_PWDN
#define BMCR_PWDN
Definition: w5100s.h:1687
wizchip_cs_select
void wizchip_cs_select(void)
Default function to select chip.
Definition: wizchip_conf.c:83
getSIPR
#define getSIPR(sipr)
Get SIPR.
Definition: w5100.h:1195
wizchip_clrinterrupt
void wizchip_clrinterrupt(intr_kind intr)
Clear Interrupt of WIZCHIP.
Definition: wizchip_conf.c:489
CN_GET_NETMODE
Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
Definition: wizchip_conf.h:322
wizchip_cs_deselect
void wizchip_cs_deselect(void)
Default function to deselect chip.
Definition: wizchip_conf.c:91
wizchip_spi_writeburst
void wizchip_spi_writeburst(uint8_t *pBuf, uint16_t len)
Default function to burst write in SPI interface.
Definition: wizchip_conf.c:141
PHY_DUPLEX_FULL
#define PHY_DUPLEX_FULL
Link Full-Duplex.
Definition: wizchip_conf.h:374
setSIPR
#define setSIPR(sipr)
Set SIPR.
Definition: w5100.h:1186
wizphy_getphyconf
void wizphy_getphyconf(wiz_PhyConf *phyconf)
Get phy configuration information.
Definition: wizchip_conf.c:768
__WIZCHIP::_IF::_read_burst
void(* _read_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:272
wizchip_spi_readburst
void wizchip_spi_readburst(uint8_t *pBuf, uint16_t len)
Default function to burst read in SPI interface.
Definition: wizchip_conf.c:133
CW_GET_PHYCONF
Get PHY operation mode in internal register. Valid Only W5500.
Definition: wizchip_conf.h:302
reg_wizchip_bus_cbfunc
void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, iodata_t wb))
Registers call back function for bus interface.
Definition: wizchip_conf.c:216
_WIZCHIP_IO_MODE_SPI_
#define _WIZCHIP_IO_MODE_SPI_
Definition: wizchip_conf.h:76
_WIZCHIP_ID_
#define _WIZCHIP_ID_
Definition: wizchip_conf.h:132
PHY_CONFBY_SW
#define PHY_CONFBY_SW
Configured PHY operation mode by SW register.
Definition: wizchip_conf.h:368
PHYCFGR_OPMDC_ALLA
#define PHYCFGR_OPMDC_ALLA
Definition: w5500.h:764
CW_GET_INTRMASK
Get interrupt mask.
Definition: wizchip_conf.h:293
MR_IND
#define MR_IND
Indirect Bus Interface mode.
Definition: w5100.h:611
PHY_MODE_MANUAL
#define PHY_MODE_MANUAL
Configured PHY operation mode with user setting.
Definition: wizchip_conf.h:369
CN_SET_NETINFO
Set Network with wiz_NetInfo.
Definition: wizchip_conf.h:319
CN_GET_TIMEOUT
Get network timeout as retry count and time.
Definition: wizchip_conf.h:324
wizphy_reset
void wizphy_reset(void)
Reset phy. Vailid only in W5500.
Definition: wizchip_conf.c:728
PHYCFGR_LNK_ON
#define PHYCFGR_LNK_ON
Definition: w5500.h:776
CW_GET_INTERRUPT
Get Interrupt status of WIZCHIP.
Definition: wizchip_conf.h:290
getINTLEVEL
#define getINTLEVEL()
Get INTLEVEL register.
Definition: w5200.h:1488
getPHYSR
#define getPHYSR()
Get PHYSR register.
Definition: w5100s.h:2250
__WIZCHIP::_IF::BUS
struct __WIZCHIP::_IF::@0 BUS
CW_GET_PHYPOWMODE
Get PHY Power mode as down or normal, Valid Only W5100, W5200.
Definition: wizchip_conf.h:308
wiz_NetInfo_t::ip
uint8_t ip[4]
Source IP Address.
Definition: wizchip_conf.h:416
PHYCFGR_OPMDC_100H
#define PHYCFGR_OPMDC_100H
Definition: w5500.h:769
CN_SET_NETMODE
Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
Definition: wizchip_conf.h:321
__WIZCHIP::_CS::_select
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:242
wiz_NetTimeout_t::retry_cnt
uint8_t retry_cnt
retry count
Definition: wizchip_conf.h:443
wiz_PhyConf_t::duplex
uint8_t duplex
set by PHY_DUPLEX_HALF PHY_DUPLEX_FULL
Definition: wizchip_conf.h:393
setGAR
#define setGAR(gar)
Set GAR.
Definition: w5100.h:1129
PHYCFGR_OPMDC_100FA
#define PHYCFGR_OPMDC_100FA
Definition: w5500.h:767
CW_GET_ID
Gets WIZCHIP name.
Definition: wizchip_conf.h:296
wiz_NetInfo_t::dhcp
dhcp_mode dhcp
1 - Static, 2 - DHCP
Definition: wizchip_conf.h:420
PHYCFGR_OPMDC_100F
#define PHYCFGR_OPMDC_100F
Definition: w5500.h:768
PHY_SPEED_100
#define PHY_SPEED_100
Link Speed 100.
Definition: wizchip_conf.h:372
PHY_CONFBY_HW
#define PHY_CONFBY_HW
Configured PHY operation mode by HW pin.
Definition: wizchip_conf.h:367
PHYSTATUS_LINK
#define PHYSTATUS_LINK
Link Status [Read Only].
Definition: w5200.h:757
PHYCFGR_OPMDC_PDOWN
#define PHYCFGR_OPMDC_PDOWN
Definition: w5500.h:765
CW_CLR_INTERRUPT
Clears interrupt.
Definition: wizchip_conf.h:291
reg_wizchip_cs_cbfunc
void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void))
Registers call back function for WIZCHIP select & deselect.
Definition: wizchip_conf.c:200
__WIZCHIP::CRIS
struct __WIZCHIP::_CRIS CRIS
wizchip_getnetinfo
void wizchip_getnetinfo(wiz_NetInfo *pnetinfo)
Get the network information for WIZCHIP.
Definition: wizchip_conf.c:854
__WIZCHIP::_IF::_write_burst
void(* _write_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:273
setIR
#define setIR(ir)
Set IR register.
Definition: w5100.h:1204
wizchip_spi_readbyte
uint8_t wizchip_spi_readbyte(void)
Default function to read in SPI interface.
Definition: wizchip_conf.c:117
setSIR
#define setSIR(ir2)
Definition: w5200.h:1499
wiz_mdio_write
void wiz_mdio_write(uint8_t PHYMDIO_regadr, uint16_t var)
Write data to the PHY via MDC/MDIO interface.
Definition: w5100s.c:395
PHYCFGR_OPMDC_10F
#define PHYCFGR_OPMDC_10F
Definition: w5500.h:770
PHYCFGR_OPMD
#define PHYCFGR_OPMD
Definition: w5500.h:763
setMR
#define setMR(mr)
Set Mode Register.
Definition: w5100.h:1108
wiz_NetInfo_t::sn
uint8_t sn[4]
Subnet Mask.
Definition: wizchip_conf.h:417
PHYSR_LNK
#define PHYSR_LNK
LINKDONE register.
Definition: w5100s.h:1559
getIR
#define getIR()
Get IR register.
Definition: w5100.h:1212
wizchip_getinterruptmask
intr_kind wizchip_getinterruptmask(void)
Get Interrupt mask of WIZCHIP.
Definition: wizchip_conf.c:571
wiz_NetInfo_t::gw
uint8_t gw[4]
Gateway IP Address.
Definition: wizchip_conf.h:418
PHY_DUPLEX_HALF
#define PHY_DUPLEX_HALF
Link Half-Duplex.
Definition: wizchip_conf.h:373
CW_GET_PHYSTATUS
Get real PHY status on operating. Valid Only W5500.
Definition: wizchip_conf.h:303
PHYSTATUS_POWERDOWN
#define PHYSTATUS_POWERDOWN
Power down mode of PHY.
Definition: w5200.h:769
PHY_POWER_DOWN
#define PHY_POWER_DOWN
PHY power down mode.
Definition: wizchip_conf.h:378
getGAR
#define getGAR(gar)
Get GAR.
Definition: w5100.h:1138
__WIZCHIP::_IF::_read_byte
uint8_t(* _read_byte)(void)
Definition: wizchip_conf.h:270
ctlnetwork
int8_t ctlnetwork(ctlnetwork_type cntype, void *arg)
Controls to network.
Definition: wizchip_conf.c:359
__WIZCHIP::IF
union __WIZCHIP::_IF IF
NM_WAKEONLAN
Wake On Lan.
Definition: wizchip_conf.h:432
BMCR_DUP
#define BMCR_DUP
Definition: w5100s.h:1690
setSUBR
#define setSUBR(subr)
Set SUBR.
Definition: w5100.h:1150
PHY_MODE_AUTONEGO
#define PHY_MODE_AUTONEGO
Configured PHY operation mode with auto-negotiation.
Definition: wizchip_conf.h:370
CW_GET_INTRTIME
Set interval time between the current and next interrupt.
Definition: wizchip_conf.h:295
PHY_POWER_NORM
#define PHY_POWER_NORM
PHY power normal mode.
Definition: wizchip_conf.h:377
wizchip_bus_readdata
iodata_t wizchip_bus_readdata(uint32_t AddrSel)
Default function to read in direct or indirect interface.
Definition: wizchip_conf.c:100
wizphy_getphypmode
int8_t wizphy_getphypmode(void)
get the power mode of PHY in WIZCHIP. No use in W5100
Definition: wizchip_conf.c:625
getMR
#define getMR()
Get MR.
Definition: w5100.h:1120
wiz_mdio_read
uint16_t wiz_mdio_read(uint8_t PHYMDIO_regadr)
Read data from the PHY via MDC/MDIO interface.
Definition: w5100s.c:404
NM_FORCEARP
Force to APP send whenever udp data is sent. Valid only in W5500.
Definition: wizchip_conf.h:430
BMCR_SPEED
#define BMCR_SPEED
Definition: w5100s.h:1685
setPHYCFGR
#define setPHYCFGR(phycfgr)
Set PHYCFGR register.
Definition: w5500.h:1612
getPHYSTATUS
#define getPHYSTATUS()
Get PHYSTATUS register.
Definition: w5200.h:1516
getSHAR
#define getSHAR(shar)
Get SHAR.
Definition: w5100.h:1177
__WIZCHIP::_CRIS::_enter
void(* _enter)(void)
crtical section enter
Definition: wizchip_conf.h:234
__WIZCHIP::_IF::_write_data
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Definition: wizchip_conf.h:262
reg_wizchip_cris_cbfunc
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.
Definition: wizchip_conf.c:186
setRCR
#define setRCR(rcr)
Set RCR register.
Definition: w5100.h:1259
_WIZCHIP_IO_MODE_
#define _WIZCHIP_IO_MODE_
Define interface mode. .
Definition: wizchip_conf.h:149
PHY_LINK_ON
#define PHY_LINK_ON
Link On.
Definition: wizchip_conf.h:376
CW_INIT_WIZCHIP
Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t.
Definition: wizchip_conf.h:289
__WIZCHIP::id
uint8_t id[6]
WIZCHIP ID such as 5100, 5200, 5500, and so on.
Definition: wizchip_conf.h:228
CW_RESET_WIZCHIP
Resets WIZCHIP by softly.
Definition: wizchip_conf.h:288
_WIZCHIP_IO_MODE_BUS_
#define _WIZCHIP_IO_MODE_BUS_
Definition: wizchip_conf.h:75
wizchip_setinterruptmask
void wizchip_setinterruptmask(intr_kind intr)
Mask or Unmask Interrupt of WIZCHIP.
Definition: wizchip_conf.c:547
wizchip_getinterrupt
intr_kind wizchip_getinterrupt(void)
Get Interrupt of WIZCHIP.
Definition: wizchip_conf.c:516
__WIZCHIP
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions.
Definition: wizchip_conf.h:225
wizchip_cris_enter
void wizchip_cris_enter(void)
Default function to enable interrupt.
Definition: wizchip_conf.c:67
wiz_NetTimeout_t
Definition: wizchip_conf.h:441
setSHAR
#define setSHAR(shar)
Set SHAR.
Definition: w5100.h:1168
PHYCFGR_DPX_FULL
#define PHYCFGR_DPX_FULL
Definition: w5500.h:772
CW_SET_PHYPOWMODE
Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500. ...
Definition: wizchip_conf.h:304
getSUBR
#define getSUBR(subr)
Get SUBR.
Definition: w5100.h:1159
__WIZCHIP::_IF::_write_byte
void(* _write_byte)(uint8_t wb)
Definition: wizchip_conf.h:271
ctlnetwork_type
ctlnetwork_type
Definition: wizchip_conf.h:317
__WIZCHIP::CS
struct __WIZCHIP::_CS CS
wizphy_setphypmode
int8_t wizphy_setphypmode(uint8_t pmode)
set the power mode of phy inside WIZCHIP. Refer to PHYCFGR in W5500, PHYSTATUS in W5200 ...
Definition: wizchip_conf.c:814
getRCR
#define getRCR()
Get RCR register.
Definition: w5100.h:1268
setRTR
#define setRTR(rtr)
Set RTR register.
Definition: w5100.h:1239
CW_RESET_PHY
Resets internal PHY. Valid Only W5500.
Definition: wizchip_conf.h:300
__WIZCHIP::_CS::_deselect
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:243
wiz_PhyConf_t::speed
uint8_t speed
set by PHY_SPEED_10 or PHY_SPEED_100
Definition: wizchip_conf.h:392
CW_SET_INTRMASK
Masks interrupt.
Definition: wizchip_conf.h:292
wizchip_init
int8_t wizchip_init(uint8_t *txsize, uint8_t *rxsize)
Initializes WIZCHIP with socket buffer size.
Definition: wizchip_conf.c:412
wizchip_settimeout
void wizchip_settimeout(wiz_NetTimeout *nettime)
Set retry time value(RTR) and retry count(RCR).
Definition: wizchip_conf.c:886
setSn_RXBUF_SIZE
#define setSn_RXBUF_SIZE(sn, rxmemsize)
Definition: w5100.h:1604
wizchip_sw_reset
void wizchip_sw_reset(void)
Reset WIZCHIP by softly.
Definition: wizchip_conf.c:387
_WIZCHIP_SOCK_NUM_
#define _WIZCHIP_SOCK_NUM_
The count of independant socket of WIZCHIP.
Definition: wizchip_conf.h:212
PHYCFGR_OPMDC_10H
#define PHYCFGR_OPMDC_10H
Definition: w5500.h:771
getRTR
#define getRTR()
Get RTR register.
Definition: w5100.h:1250
wizchip_setnetinfo
void wizchip_setnetinfo(wiz_NetInfo *pnetinfo)
Set the network information for WIZCHIP.
Definition: wizchip_conf.c:840
wizchip_spi_writebyte
void wizchip_spi_writebyte(uint8_t wb)
Default function to write in SPI interface.
Definition: wizchip_conf.c:125
CW_SET_INTRTIME
Set interval time between the current and next interrupt.
Definition: wizchip_conf.h:294
ctlwizchip
int8_t ctlwizchip(ctlwizchip_type cwtype, void *arg)
Controls to the WIZCHIP.
Definition: wizchip_conf.c:277
wiz_PhyConf_t::by
uint8_t by
set by PHY_CONFBY_HW or PHY_CONFBY_SW
Definition: wizchip_conf.h:390
iodata_t
uint8_t iodata_t
Definition: wizchip_conf.h:152
wiz_PhyConf_t::mode
uint8_t mode
set by PHY_MODE_MANUAL or PHY_MODE_AUTONEGO
Definition: wizchip_conf.h:391
intr_kind
intr_kind
Definition: wizchip_conf.h:333
PHYMDIO_BMCR
#define PHYMDIO_BMCR
Definition: w5100s.h:1644
CN_SET_TIMEOUT
Set network timeout as retry count and time.
Definition: wizchip_conf.h:323
getIMR
#define getIMR()
Get IMR register.
Definition: w5100.h:1230
wizchip_cris_exit
void wizchip_cris_exit(void)
Default function to disable interrupt.
Definition: wizchip_conf.c:75
wizphy_getphystat
void wizphy_getphystat(wiz_PhyConf *phyconf)
Get phy status.
Definition: wizchip_conf.c:807
wizchip_setnetmode
int8_t wizchip_setnetmode(netmode_type netmode)
Set the network mode such WOL, PPPoE, Ping Block, and etc.
Definition: wizchip_conf.c:867
wiz_NetInfo_t::mac
uint8_t mac[6]
Source Mac Address.
Definition: wizchip_conf.h:415
wiz_NetInfo_t
Definition: wizchip_conf.h:413
setIMR
#define setIMR(imr)
Set IMR register.
Definition: w5100.h:1221
PHYCFGR_SPD_100
#define PHYCFGR_SPD_100
Definition: w5500.h:774
getPHYCFGR
#define getPHYCFGR()
Get PHYCFGR register.
Definition: w5500.h:1621
wiz_PhyConf_t
Definition: wizchip_conf.h:388
reg_wizchip_spiburst_cbfunc
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.
Definition: wizchip_conf.c:261
CW_SET_PHYCONF
When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000.
Definition: wizchip_conf.h:301
netmode_type
netmode_type
Definition: wizchip_conf.h:427
reg_wizchip_spi_cbfunc
void reg_wizchip_spi_cbfunc(uint8_t(*spi_rb)(void), void(*spi_wb)(uint8_t wb))
Registers call back function for SPI interface.
Definition: wizchip_conf.c:244
wizchip_conf.h
WIZCHIP Config Header File.
__WIZCHIP::if_mode
uint16_t if_mode
host interface mode
Definition: wizchip_conf.h:227
dhcp_mode
dhcp_mode
Definition: wizchip_conf.h:403
PHYCFGR_RST
#define PHYCFGR_RST
Definition: w5500.h:762
CW_GET_PHYLINK
Get PHY Link status, Valid Only W5100, W5200.
Definition: wizchip_conf.h:309
setINTLEVEL
#define setINTLEVEL(intlevel)
Set INTLEVEL register.
Definition: w5200.h:1478
wizphy_getphylink
int8_t wizphy_getphylink(void)
get the link status of phy in WIZCHIP. No use in W5100
Definition: wizchip_conf.c:600
BMCR_RESET
#define BMCR_RESET
Definition: w5100s.h:1683
ctlwizchip_type
ctlwizchip_type
Definition: wizchip_conf.h:286
MR_RST
#define MR_RST
Reset.
Definition: w5100.h:577
wizchip_bus_writedata
void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb)
Default function to write in direct or indirect interface.
Definition: wizchip_conf.c:109
NM_PPPOE
PPPoE mode.
Definition: wizchip_conf.h:434
wiz_NetInfo_t::dns
uint8_t dns[4]
DNS server IP Address.
Definition: wizchip_conf.h:419
PHY_LINK_OFF
#define PHY_LINK_OFF
Link Off.
Definition: wizchip_conf.h:375
setSIMR
#define setSIMR(imr2)
Definition: w5200.h:1533
NM_PINGBLOCK
Block ping-request.
Definition: wizchip_conf.h:433
__WIZCHIP::_IF::SPI
struct __WIZCHIP::_IF::@1 SPI
PHY_SPEED_10
#define PHY_SPEED_10
Link Speed 10.
Definition: wizchip_conf.h:371
setSn_TXBUF_SIZE
#define setSn_TXBUF_SIZE(sn, txmemsize)
Definition: w5100.h:1626
BMCR_AUTONEGO
#define BMCR_AUTONEGO
Definition: w5100s.h:1686
wiz_NetTimeout_t::time_100us
uint16_t time_100us
time unit 100us
Definition: wizchip_conf.h:444


ioLibrary: 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>
64 #define W5100 5100
65 #define W5100S 5100+5
66 #define W5200 5200
67 #define W5300 5300
68 #define W5500 5500
69
70 #ifndef _WIZCHIP_
71 #define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500
72 #endif
73
74 #define _WIZCHIP_IO_MODE_NONE_ 0x0000
75 #define _WIZCHIP_IO_MODE_BUS_ 0x0100
76 #define _WIZCHIP_IO_MODE_SPI_ 0x0200
77 //#define _WIZCHIP_IO_MODE_IIC_ 0x0400
78 //#define _WIZCHIP_IO_MODE_SDIO_ 0x0800
79 // Add to
80 //
81
82 #define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1)
83 #define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2)
85 #define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1)
86 #define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2)
87 #define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3)
89 #if (_WIZCHIP_ == W5100)
90 #define _WIZCHIP_ID_ "W5100\0"
91
95 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_
96 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
97 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_
98
99 //A20150601 : Define the unit of IO DATA.
100 typedef uint8_t iodata_t;
101 //A20150401 : Indclude W5100.h file
102 #include "W5100/w5100.h"
103
104 #elif (_WIZCHIP_ == W5100S)
105 #define _WIZCHIP_ID_ "W5100S\0"
106
110 //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
111 //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_
112 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_
113
114 //A20150601 : Define the unit of IO DATA.
115 typedef uint8_t iodata_t;
116 //A20150401 : Indclude W5100.h file
117 #include "W5100S/w5100s.h"
118 #elif (_WIZCHIP_ == W5200)
119 #define _WIZCHIP_ID_ "W5200\0"
120
124 #ifndef _WIZCHIP_IO_MODE_
125 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
126 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_
127 #endif
128 //A20150601 : Define the unit of IO DATA.
129 typedef uint8_t iodata_t;
130 #include "W5200/w5200.h"
131 #elif (_WIZCHIP_ == W5500)
132 #define _WIZCHIP_ID_ "W5500\0"
133
147 #ifndef _WIZCHIP_IO_MODE_
148 //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_
149 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
150 #endif
151 //A20150601 : Define the unit of IO DATA.
152 typedef uint8_t iodata_t;
153 #include "W5500/w5500.h"
154 #elif ( _WIZCHIP_ == W5300)
155 #define _WIZCHIP_ID_ "W5300\0"
156
160 #ifndef _WIZCHIP_IO_MODE_
161 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_
162 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
163 #endif
164
165 //A20150601 : Define the unit and bus width of IO DATA.
170 #ifndef _WIZCHIP_IO_BUS_WIDTH_
171 #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16
172 #endif
173 #if _WIZCHIP_IO_BUS_WIDTH_ == 8
174 typedef uint8_t iodata_t;
175 #elif _WIZCHIP_IO_BUS_WIDTH_ == 16
176 typedef uint16_t iodata_t;
177 #else
178 #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16."
179 #endif
180 //
181 #include "W5300/w5300.h"
182 #else
183 #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!"
184 #endif
185
186 #ifndef _WIZCHIP_IO_MODE_
187 #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!"
188 #endif
189
196 #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND
197 //#define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI
198
199 #ifndef _WIZCHIP_IO_BASE_
200 #define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000
201 #endif
202
203 //M20150401 : Typing Error
204 //#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS
205 #if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_
206 #ifndef _WIZCHIP_IO_BASE_
207 #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map."
208 #endif
209 #endif
210
211 #if _WIZCHIP_ >= W5200
212 #define _WIZCHIP_SOCK_NUM_ 8
213 #else
214 #define _WIZCHIP_SOCK_NUM_ 4
215 #endif
216
217
218 /********************************************************
219 * WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC.
220 *********************************************************/
225 typedef struct __WIZCHIP
226 {
227 uint16_t if_mode;
228 uint8_t id[6];
229
232 struct _CRIS
233 {
234 void (*_enter) (void);
235 void (*_exit) (void);
236 }CRIS;
240 struct _CS
241 {
242 void (*_select) (void);
243 void (*_deselect)(void);
244 }CS;
248 union _IF
249 {
253 //M20156501 : Modify the function name for integrating with W5300
254 //struct
255 //{
256 // uint8_t (*_read_byte) (uint32_t AddrSel);
257 // void (*_write_byte) (uint32_t AddrSel, uint8_t wb);
258 //}BUS;
259 struct
260 {
261 iodata_t (*_read_data) (uint32_t AddrSel);
262 void (*_write_data) (uint32_t AddrSel, iodata_t wb);
263 }BUS;
264
268 struct
269 {
270 uint8_t (*_read_byte) (void);
271 void (*_write_byte) (uint8_t wb);
272 void (*_read_burst) (uint8_t* pBuf, uint16_t len);
273 void (*_write_burst) (uint8_t* pBuf, uint16_t len);
274 }SPI;
275 // To be added
276 //
277 }IF;
278 }_WIZCHIP;
279
280 extern _WIZCHIP WIZCHIP;
281
286 typedef enum
287 {
288 CW_RESET_WIZCHIP,
289 CW_INIT_WIZCHIP,
290 CW_GET_INTERRUPT,
291 CW_CLR_INTERRUPT,
292 CW_SET_INTRMASK,
293 CW_GET_INTRMASK,
294 CW_SET_INTRTIME,
295 CW_GET_INTRTIME,
296 CW_GET_ID,
297
298 //D20150601 : For no modification your application code
299 //#if _WIZCHIP_ == W5500
300 CW_RESET_PHY,
301 CW_SET_PHYCONF,
302 CW_GET_PHYCONF,
303 CW_GET_PHYSTATUS,
304 CW_SET_PHYPOWMODE,
305 //#endif
306 //D20150601 : For no modification your application code
307 //#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500
308 CW_GET_PHYPOWMODE,
309 CW_GET_PHYLINK
310 //#endif
311 }ctlwizchip_type;
312
317 typedef enum
318 {
319 CN_SET_NETINFO,
320 CN_GET_NETINFO,
321 CN_SET_NETMODE,
322 CN_GET_NETMODE,
323 CN_SET_TIMEOUT,
324 CN_GET_TIMEOUT,
325 }ctlnetwork_type;
326
333 typedef enum
334 {
335 #if _WIZCHIP_ == W5500
336 IK_WOL = (1 << 4),
337 #elif _WIZCHIP_ == W5300
338 IK_FMTU = (1 << 4),
339 #endif
340
341 IK_PPPOE_TERMINATED = (1 << 5),
342
343 #if _WIZCHIP_ != W5200
344 IK_DEST_UNREACH = (1 << 6),
345 #endif
346
347 IK_IP_CONFLICT = (1 << 7),
348
349 IK_SOCK_0 = (1 << 8),
350 IK_SOCK_1 = (1 << 9),
351 IK_SOCK_2 = (1 << 10),
352 IK_SOCK_3 = (1 << 11),
353 #if _WIZCHIP_ > W5100S
354 IK_SOCK_4 = (1 << 12),
355 IK_SOCK_5 = (1 << 13),
356 IK_SOCK_6 = (1 << 14),
357 IK_SOCK_7 = (1 << 15),
358 #endif
359
360 #if _WIZCHIP_ > W5100S
361 IK_SOCK_ALL = (0xFF << 8)
362 #else
363 IK_SOCK_ALL = (0x0F << 8)
364 #endif
365 }intr_kind;
366
367 #define PHY_CONFBY_HW 0
368 #define PHY_CONFBY_SW 1
369 #define PHY_MODE_MANUAL 0
370 #define PHY_MODE_AUTONEGO 1
371 #define PHY_SPEED_10 0
372 #define PHY_SPEED_100 1
373 #define PHY_DUPLEX_HALF 0
374 #define PHY_DUPLEX_FULL 1
375 #define PHY_LINK_OFF 0
376 #define PHY_LINK_ON 1
377 #define PHY_POWER_NORM 0
378 #define PHY_POWER_DOWN 1
379
380
381 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500
382
388 typedef struct wiz_PhyConf_t
389 {
390 uint8_t by;
391 uint8_t mode;
392 uint8_t speed;
393 uint8_t duplex;
394 //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN
395 //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF
396 }wiz_PhyConf;
397 #endif
398
403 typedef enum
404 {
405 NETINFO_STATIC = 1,
406 NETINFO_DHCP
407 }dhcp_mode;
408
413 typedef struct wiz_NetInfo_t
414 {
415 uint8_t mac[6];
416 uint8_t ip[4];
417 uint8_t sn[4];
418 uint8_t gw[4];
419 uint8_t dns[4];
420 dhcp_mode dhcp;
421 }wiz_NetInfo;
422
427 typedef enum
428 {
429 #if _WIZCHIP_ == W5500
430 NM_FORCEARP = (1<<1),
431 #endif
432 NM_WAKEONLAN = (1<<5),
433 NM_PINGBLOCK = (1<<4),
434 NM_PPPOE = (1<<3),
435 }netmode_type;
436
441 typedef struct wiz_NetTimeout_t
442 {
443 uint8_t retry_cnt;
444 uint16_t time_100us;
445 }wiz_NetTimeout;
446
455 void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void));
456
457
465 void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void));
466
475 //M20150601 : For integrating with W5300
476 //void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb));
477 void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb));
478
487 void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb));
488
497 void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len));
498
509 int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
510
520 int8_t ctlnetwork(ctlnetwork_type cntype, void* arg);
521
522
523 /*
524 * The following functions are implemented for internal use.
525 * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork().
526 */
527
532 void wizchip_sw_reset(void);
533
542 int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize);
543
549 void wizchip_clrinterrupt(intr_kind intr);
550
556 intr_kind wizchip_getinterrupt(void);
557
563 void wizchip_setinterruptmask(intr_kind intr);
564
570 intr_kind wizchip_getinterruptmask(void);
571
572 //todo
573 #if _WIZCHIP_ > W5100
574 int8_t wizphy_getphylink(void);
575 int8_t wizphy_getphypmode(void);
576 #endif
577
578 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500
579 void wizphy_reset(void);
580
585 void wizphy_setphyconf(wiz_PhyConf* phyconf);
591 void wizphy_getphyconf(wiz_PhyConf* phyconf);
597 void wizphy_getphystat(wiz_PhyConf* phyconf);
603 int8_t wizphy_setphypmode(uint8_t pmode);
604 #endif
605
611 void wizchip_setnetinfo(wiz_NetInfo* pnetinfo);
612
618 void wizchip_getnetinfo(wiz_NetInfo* pnetinfo);
619
625 int8_t wizchip_setnetmode(netmode_type netmode);
626
632 netmode_type wizchip_getnetmode(void);
633
640 void wizchip_settimeout(wiz_NetTimeout* nettime);
641
648 void wizchip_gettimeout(wiz_NetTimeout* nettime);
649
650 #endif // _WIZCHIP_CONF_H_
wizchip_getnetmode
netmode_type wizchip_getnetmode(void)
Get the network mode such WOL, PPPoE, Ping Block, and etc.
Definition: wizchip_conf.c:881
__WIZCHIP::_IF::_read_data
iodata_t(* _read_data)(uint32_t AddrSel)
Definition: wizchip_conf.h:261
__WIZCHIP::_CRIS::_exit
void(* _exit)(void)
critial section exit
Definition: wizchip_conf.h:235
wizchip_gettimeout
void wizchip_gettimeout(wiz_NetTimeout *nettime)
Get retry time value(RTR) and retry count(RCR).
Definition: wizchip_conf.c:892
CN_GET_NETINFO
Get Network with wiz_NetInfo.
Definition: wizchip_conf.h:320
wizphy_setphyconf
void wizphy_setphyconf(wiz_PhyConf *phyconf)
Set the phy information for WIZCHIP without power mode.
Definition: wizchip_conf.c:738
__WIZCHIP::_CRIS
Definition: wizchip_conf.h:232
wizchip_clrinterrupt
void wizchip_clrinterrupt(intr_kind intr)
Clear Interrupt of WIZCHIP.
Definition: wizchip_conf.c:489
_WIZCHIP
struct __WIZCHIP _WIZCHIP
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions.
CN_GET_NETMODE
Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
Definition: wizchip_conf.h:322
wizphy_getphyconf
void wizphy_getphyconf(wiz_PhyConf *phyconf)
Get phy configuration information.
Definition: wizchip_conf.c:768
__WIZCHIP::_IF::_read_burst
void(* _read_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:272
CW_GET_PHYCONF
Get PHY operation mode in internal register. Valid Only W5500.
Definition: wizchip_conf.h:302
w5200.h
W5200 HAL Header File.
CW_GET_INTRMASK
Get interrupt mask.
Definition: wizchip_conf.h:293
__WIZCHIP::_CS
Definition: wizchip_conf.h:240
CN_SET_NETINFO
Set Network with wiz_NetInfo.
Definition: wizchip_conf.h:319
CN_GET_TIMEOUT
Get network timeout as retry count and time.
Definition: wizchip_conf.h:324
reg_wizchip_bus_cbfunc
void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void(*bus_wb)(uint32_t addr, iodata_t wb))
Registers call back function for bus interface.
Definition: wizchip_conf.c:216
CW_GET_INTERRUPT
Get Interrupt status of WIZCHIP.
Definition: wizchip_conf.h:290
__WIZCHIP::_IF::BUS
struct __WIZCHIP::_IF::@0 BUS
IK_SOCK_2
Socket 2 interrupt.
Definition: wizchip_conf.h:351
CW_GET_PHYPOWMODE
Get PHY Power mode as down or normal, Valid Only W5100, W5200.
Definition: wizchip_conf.h:308
__WIZCHIP::_IF
Definition: wizchip_conf.h:248
wiz_NetInfo_t::ip
uint8_t ip[4]
Source IP Address.
Definition: wizchip_conf.h:416
CN_SET_NETMODE
Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
Definition: wizchip_conf.h:321
__WIZCHIP::_CS::_select
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:242
w5500.h
W5500 HAL Header File.
wiz_NetTimeout_t::retry_cnt
uint8_t retry_cnt
retry count
Definition: wizchip_conf.h:443
W5300
#define W5300
Definition: wizchip_conf.h:67
wiz_PhyConf_t::duplex
uint8_t duplex
set by PHY_DUPLEX_HALF PHY_DUPLEX_FULL
Definition: wizchip_conf.h:393
CW_GET_ID
Gets WIZCHIP name.
Definition: wizchip_conf.h:296
wiz_NetInfo_t::dhcp
dhcp_mode dhcp
1 - Static, 2 - DHCP
Definition: wizchip_conf.h:420
wiz_PhyConf
struct wiz_PhyConf_t wiz_PhyConf
CW_CLR_INTERRUPT
Clears interrupt.
Definition: wizchip_conf.h:291
__WIZCHIP::CRIS
struct __WIZCHIP::_CRIS CRIS
wizchip_getnetinfo
void wizchip_getnetinfo(wiz_NetInfo *pnetinfo)
Get the network information for WIZCHIP.
Definition: wizchip_conf.c:854
wizphy_getphylink
int8_t wizphy_getphylink(void)
get the link status of phy in WIZCHIP. No use in W5100
Definition: wizchip_conf.c:600
__WIZCHIP::_IF::_write_burst
void(* _write_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:273
wiz_NetTimeout
struct wiz_NetTimeout_t wiz_NetTimeout
IK_SOCK_1
Socket 1 interrupt.
Definition: wizchip_conf.h:350
W5200
#define W5200
Definition: wizchip_conf.h:66
W5100S
#define W5100S
Definition: wizchip_conf.h:65
wiz_NetInfo_t::sn
uint8_t sn[4]
Subnet Mask.
Definition: wizchip_conf.h:417
wizchip_getinterruptmask
intr_kind wizchip_getinterruptmask(void)
Get Interrupt mask of WIZCHIP.
Definition: wizchip_conf.c:571
wiz_NetInfo_t::gw
uint8_t gw[4]
Gateway IP Address.
Definition: wizchip_conf.h:418
CW_GET_PHYSTATUS
Get real PHY status on operating. Valid Only W5500.
Definition: wizchip_conf.h:303
IK_SOCK_6
Socket 6 interrupt, No use in 5100.
Definition: wizchip_conf.h:356
__WIZCHIP::_IF::_read_byte
uint8_t(* _read_byte)(void)
Definition: wizchip_conf.h:270
_WIZCHIP_
#define _WIZCHIP_
Definition: wizchip_conf.h:71
ctlnetwork
int8_t ctlnetwork(ctlnetwork_type cntype, void *arg)
Controls to network.
Definition: wizchip_conf.c:359
__WIZCHIP::IF
union __WIZCHIP::_IF IF
NM_WAKEONLAN
Wake On Lan.
Definition: wizchip_conf.h:432
IK_SOCK_ALL
All Socket interrupt.
Definition: wizchip_conf.h:361
CW_GET_INTRTIME
Set interval time between the current and next interrupt.
Definition: wizchip_conf.h:295
NM_FORCEARP
Force to APP send whenever udp data is sent. Valid only in W5500.
Definition: wizchip_conf.h:430
IK_PPPOE_TERMINATED
PPPoE Disconnected.
Definition: wizchip_conf.h:341
reg_wizchip_cs_cbfunc
void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void))
Registers call back function for WIZCHIP select & deselect.
Definition: wizchip_conf.c:200
IK_WOL
Wake On Lan by receiving the magic packet. Valid in W500.
Definition: wizchip_conf.h:336
__WIZCHIP::_CRIS::_enter
void(* _enter)(void)
crtical section enter
Definition: wizchip_conf.h:234
__WIZCHIP::_IF::_write_data
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Definition: wizchip_conf.h:262
w5100s.h
W5100S HAL Header File.
IK_IP_CONFLICT
IP conflict occurred.
Definition: wizchip_conf.h:347
CW_INIT_WIZCHIP
Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t.
Definition: wizchip_conf.h:289
WIZCHIP
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
CW_RESET_WIZCHIP
Resets WIZCHIP by softly.
Definition: wizchip_conf.h:288
wizchip_setinterruptmask
void wizchip_setinterruptmask(intr_kind intr)
Mask or Unmask Interrupt of WIZCHIP.
Definition: wizchip_conf.c:547
wizchip_getinterrupt
intr_kind wizchip_getinterrupt(void)
Get Interrupt of WIZCHIP.
Definition: wizchip_conf.c:516
IK_DEST_UNREACH
Destination IP & Port Unreachable, No use in W5200.
Definition: wizchip_conf.h:344
__WIZCHIP
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions.
Definition: wizchip_conf.h:225
IK_SOCK_4
Socket 4 interrupt, No use in 5100.
Definition: wizchip_conf.h:354
wiz_NetTimeout_t
Definition: wizchip_conf.h:441
CW_SET_PHYPOWMODE
Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500. ...
Definition: wizchip_conf.h:304
wizphy_getphypmode
int8_t wizphy_getphypmode(void)
get the power mode of PHY in WIZCHIP. No use in W5100
Definition: wizchip_conf.c:625
__WIZCHIP::_IF::_write_byte
void(* _write_byte)(uint8_t wb)
Definition: wizchip_conf.h:271
ctlnetwork_type
ctlnetwork_type
Definition: wizchip_conf.h:317
__WIZCHIP::CS
struct __WIZCHIP::_CS CS
wizphy_setphypmode
int8_t wizphy_setphypmode(uint8_t pmode)
set the power mode of phy inside WIZCHIP. Refer to PHYCFGR in W5500, PHYSTATUS in W5200 ...
Definition: wizchip_conf.c:814
wiz_NetInfo
struct wiz_NetInfo_t wiz_NetInfo
w5100.h
W5100 HAL Header File.
CW_RESET_PHY
Resets internal PHY. Valid Only W5500.
Definition: wizchip_conf.h:300
__WIZCHIP::_CS::_deselect
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:243
wiz_PhyConf_t::speed
uint8_t speed
set by PHY_SPEED_10 or PHY_SPEED_100
Definition: wizchip_conf.h:392
CW_SET_INTRMASK
Masks interrupt.
Definition: wizchip_conf.h:292
wizchip_init
int8_t wizchip_init(uint8_t *txsize, uint8_t *rxsize)
Initializes WIZCHIP with socket buffer size.
Definition: wizchip_conf.c:412
wizchip_settimeout
void wizchip_settimeout(wiz_NetTimeout *nettime)
Set retry time value(RTR) and retry count(RCR).
Definition: wizchip_conf.c:886
IK_SOCK_3
Socket 3 interrupt.
Definition: wizchip_conf.h:352
wizchip_sw_reset
void wizchip_sw_reset(void)
Reset WIZCHIP by softly.
Definition: wizchip_conf.c:387
IK_SOCK_5
Socket 5 interrupt, No use in 5100.
Definition: wizchip_conf.h:355
wizchip_setnetinfo
void wizchip_setnetinfo(wiz_NetInfo *pnetinfo)
Set the network information for WIZCHIP.
Definition: wizchip_conf.c:840
NETINFO_DHCP
Dynamic IP configruation from a DHCP sever.
Definition: wizchip_conf.h:406
CW_SET_INTRTIME
Set interval time between the current and next interrupt.
Definition: wizchip_conf.h:294
wizphy_reset
void wizphy_reset(void)
Reset phy. Vailid only in W5500.
Definition: wizchip_conf.c:728
ctlwizchip
int8_t ctlwizchip(ctlwizchip_type cwtype, void *arg)
Controls to the WIZCHIP.
Definition: wizchip_conf.c:277
wiz_PhyConf_t::by
uint8_t by
set by PHY_CONFBY_HW or PHY_CONFBY_SW
Definition: wizchip_conf.h:390
w5300.h
W5300 HAL implement File.
iodata_t
uint8_t iodata_t
Definition: wizchip_conf.h:152
wiz_PhyConf_t::mode
uint8_t mode
set by PHY_MODE_MANUAL or PHY_MODE_AUTONEGO
Definition: wizchip_conf.h:391
intr_kind
intr_kind
Definition: wizchip_conf.h:333
reg_wizchip_cris_cbfunc
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.
Definition: wizchip_conf.c:186
CN_SET_TIMEOUT
Set network timeout as retry count and time.
Definition: wizchip_conf.h:323
wizphy_getphystat
void wizphy_getphystat(wiz_PhyConf *phyconf)
Get phy status.
Definition: wizchip_conf.c:807
reg_wizchip_spiburst_cbfunc
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.
Definition: wizchip_conf.c:261
wizchip_setnetmode
int8_t wizchip_setnetmode(netmode_type netmode)
Set the network mode such WOL, PPPoE, Ping Block, and etc.
Definition: wizchip_conf.c:867
reg_wizchip_spi_cbfunc
void reg_wizchip_spi_cbfunc(uint8_t(*spi_rb)(void), void(*spi_wb)(uint8_t wb))
Registers call back function for SPI interface.
Definition: wizchip_conf.c:244
wiz_NetInfo_t::mac
uint8_t mac[6]
Source Mac Address.
Definition: wizchip_conf.h:415
wiz_NetInfo_t
Definition: wizchip_conf.h:413
wiz_PhyConf_t
Definition: wizchip_conf.h:388
CW_SET_PHYCONF
When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000.
Definition: wizchip_conf.h:301
netmode_type
netmode_type
Definition: wizchip_conf.h:427
NETINFO_STATIC
Static IP configuration by manually.
Definition: wizchip_conf.h:405
__WIZCHIP::if_mode
uint16_t if_mode
host interface mode
Definition: wizchip_conf.h:227
dhcp_mode
dhcp_mode
Definition: wizchip_conf.h:403
CW_GET_PHYLINK
Get PHY Link status, Valid Only W5100, W5200.
Definition: wizchip_conf.h:309
ctlwizchip_type
ctlwizchip_type
Definition: wizchip_conf.h:286
NM_PPPOE
PPPoE mode.
Definition: wizchip_conf.h:434
wiz_NetInfo_t::dns
uint8_t dns[4]
DNS server IP Address.
Definition: wizchip_conf.h:419
NM_PINGBLOCK
Block ping-request.
Definition: wizchip_conf.h:433
IK_SOCK_7
Socket 7 interrupt, No use in 5100.
Definition: wizchip_conf.h:357
__WIZCHIP::_IF::SPI
struct __WIZCHIP::_IF::@1 SPI
IK_SOCK_0
Socket 0 interrupt.
Definition: wizchip_conf.h:349
wiz_NetTimeout_t::time_100us
uint16_t time_100us
time unit 100us
Definition: wizchip_conf.h:444