This is Library using WIZnet Hardware TCP/IP chip, W5500 and WIZnet TCP/IP Offload Engine, W7500.

Dependents:   HTTP_SDcard_file_server_WIZwiki-W7500 SSD1306_smart_watch TCPEchoServer-WIZwiki-W7500 httpServer-WIZwiki-W7500 ... more

Fork of WIZnetInterface by Soohwan Kim

Embed: (wiki syntax)

« Back to documentation index

EthernetInterface Class Reference

EthernetInterface Class Reference

Interface using Wiznet chip to connect to an IP-based network. More...

#include <EthernetInterface.h>

Inherits WIZnet_Chip.

Public Member Functions

 EthernetInterface (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset)
 Constructor.
int init ()
 Initialize the interface with DHCP.
int init (uint8_t *mac, const char *ip, const char *mask, const char *gateway)
 Initialize the interface with a static IP address.
int connect ()
 Connect Bring the interface up, start DHCP if needed.
int disconnect ()
 Disconnect Bring the interface down.
char * getIPAddress ()
 Get IP address & MAC address.
void setMR (uint8_t mr)
 Set Mode Register.
uint8_t getMR ()
 Get Mode Register.
void setGAR (uint8_t *gar)
 Set gateway IP address.
void getGAR (uint8_t *gar)
 Get gateway IP address.
void setSUBR (uint8_t *subr)
 Set subnet mask address.
void getSUBR (uint8_t *subr)
 Get subnet mask address.
void setSHAR (uint8_t *shar)
 Set local MAC address.
void getSHAR (uint8_t *shar)
 Get local MAC address.
void setSIPR (uint8_t *sipr)
 Set local IP address.
void getSIPR (uint8_t *sipr)
 Get local IP address.
void setIR (uint8_t ir)
 Set IR register.
uint8_t getIR ()
 Get IR register.
void setIMR (uint8_t imr)
 Set IMR register.
uint8_t getIMR ()
 Get IMR register.
void setSIR (uint8_t sir)
 Set SIR register.
uint8_t getSIR ()
 Get SIR register.
void setSIMR (uint8_t simr)
 Set SIMR register.
uint8_t getSIMR ()
 Get SIMR register.
void setRTR (uint16_t rtr)
 Set RTR register.
uint16_t getRTR ()
 Get RTR register.
void setRCR (uint8_t rcr)
 Set RCR register.
uint8_t getRCR ()
 Get RCR register.
void setPHYCFGR (uint8_t phycfgr)
 Set PHYCFGR register.
uint8_t getPHYCFGR ()
 Get PHYCFGR register.
void setSn_MR (uint8_t sn, uint8_t mr)
 Set Sn_MR register.
uint8_t getSn_MR (uint8_t sn)
 Get Sn_MR register.
void setSn_CR (uint8_t sn, uint8_t cr)
 Set Sn_CR register.
uint8_t getSn_CR (uint8_t sn)
 Get Sn_CR register.
void setSn_IR (uint8_t sn, uint8_t ir)
 Set Sn_IR register.
uint8_t getSn_IR (uint8_t sn)
 Get Sn_IR register.
void setSn_IMR (uint8_t sn, uint8_t imr)
 Set Sn_IMR register.
uint8_t getSn_IMR (uint8_t sn)
 Get Sn_IMR register.
uint8_t getSn_SR (uint8_t sn)
 Get Sn_SR register.
void setSn_PORT (uint8_t sn, uint16_t port)
 Set Sn_PORT register.
uint16_t getSn_PORT (uint8_t sn)
 Get Sn_PORT register.
void setSn_DHAR (uint8_t sn, uint8_t *dhar)
 Set Sn_DHAR register.
void getSn_DHAR (uint8_t sn, uint8_t *dhar)
 Get Sn_MR register.
void setSn_DIPR (uint8_t sn, uint8_t *dipr)
 Set Sn_DIPR register.
void getSn_DIPR (uint8_t sn, uint8_t *dipr)
 Get Sn_DIPR register.
void setSn_DPORT (uint8_t sn, uint16_t dport)
 Set Sn_DPORT register.
uint16_t getSn_DPORT (uint8_t sn)
 Get Sn_DPORT register.
void setSn_RXBUF_SIZE (uint8_t sn, uint8_t rxbufsize)
 Set Sn_RXBUF_SIZE register.
uint8_t getSn_RXBUF_SIZE (uint8_t sn)
 Get Sn_RXBUF_SIZE register.
void setSn_TXBUF_SIZE (uint8_t sn, uint8_t txbufsize)
 Set Sn_TXBUF_SIZE register.
uint8_t getSn_TXBUF_SIZE (uint8_t sn)
 Get Sn_TXBUF_SIZE register.
uint16_t getSn_TX_FSR (uint8_t sn)
 Get Sn_TX_FSR register.
uint16_t getSn_TX_RD (uint8_t sn)
 Get Sn_TX_RD register.
void setSn_TX_WR (uint8_t sn, uint16_t txwr)
 Set Sn_TX_WR register.
uint16_t getSn_TX_WR (uint8_t sn)
 Get Sn_TX_WR register.
uint16_t getSn_RX_RSR (uint8_t sn)
 Get Sn_RX_RSR register.
void setSn_RX_RD (uint8_t sn, uint16_t rxrd)
 Set Sn_RX_RD register.
uint16_t getSn_RX_RD (uint8_t sn)
 Get Sn_RX_RD register.
uint16_t getSn_RX_WR (uint8_t sn)
 Get Sn_RX_WR register.
uint16_t getSn_RxMAX (uint8_t sn)
 Gets the max buffer size of socket sn passed as parameter.
uint16_t getSn_TxMAX (uint8_t sn)
 Gets the max buffer size of socket sn passed as parameters.

Detailed Description

Interface using Wiznet chip to connect to an IP-based network.

Definition at line 24 of file EthernetInterface.h.


Constructor & Destructor Documentation

EthernetInterface ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs,
PinName  reset 
)

Constructor.

Parameters:
mosimbed pin to use for SPI
misombed pin to use for SPI
sclkmbed pin to use for SPI
cschip select of the WIZnet_Chip
resetreset pin of the WIZnet_Chip

Definition at line 23 of file EthernetInterface.cpp.


Member Function Documentation

int connect (  )

Connect Bring the interface up, start DHCP if needed.

Returns:
0 on success, a negative number on failure

Definition at line 76 of file EthernetInterface.cpp.

int disconnect (  )

Disconnect Bring the interface down.

Returns:
0 on success, a negative number on failure

Definition at line 90 of file EthernetInterface.cpp.

void getGAR ( uint8_t *  gar ) [inherited]

Get gateway IP address.

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

Definition at line 427 of file W5500.h.

uint8_t getIMR (  ) [inherited]

Get IMR register.

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

Definition at line 528 of file W5500.h.

char * getIPAddress (  )

Get IP address & MAC address.

@ returns ip address

Definition at line 97 of file EthernetInterface.cpp.

uint8_t getIR (  ) [inherited]

Get IR register.

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

Definition at line 508 of file W5500.h.

uint8_t getMR (  ) [inherited]

Get Mode Register.

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

Definition at line 407 of file W5500.h.

uint8_t getPHYCFGR (  ) [inherited]

Get PHYCFGR register.

Returns:
uint8_t. Value of PHYCFGR register.
See also:
getPHYCFGR()

Definition at line 630 of file W5500.h.

uint8_t getRCR (  ) [inherited]

Get RCR register.

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

Definition at line 608 of file W5500.h.

uint16_t getRTR (  ) [inherited]

Get RTR register.

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

Definition at line 588 of file W5500.h.

void getSHAR ( uint8_t *  shar ) [inherited]

Get local MAC address.

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

Definition at line 468 of file W5500.h.

uint8_t getSIMR (  ) [inherited]

Get SIMR register.

Returns:
uint8_t. Value of SIMR register.
See also:
setSIMR()

Definition at line 568 of file W5500.h.

void getSIPR ( uint8_t *  sipr ) [inherited]

Get local IP address.

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

Definition at line 488 of file W5500.h.

uint8_t getSIR (  ) [inherited]

Get SIR register.

Returns:
uint8_t. Value of SIR register.
See also:
setSIR()

Definition at line 549 of file W5500.h.

uint8_t getSn_CR ( uint8_t  sn ) [inherited]

Get Sn_CR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint8_t. Value of Sn_CR.
See also:
setSn_CR()

Definition at line 680 of file W5500.h.

void getSn_DHAR ( uint8_t  sn,
uint8_t *  dhar 
) [inherited]

Get Sn_MR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t*)dharPointer variable to get socket n destination hardware address. It should be allocated 6 bytes.
See also:
setSn_DHAR()

Definition at line 778 of file W5500.h.

void getSn_DIPR ( uint8_t  sn,
uint8_t *  dipr 
) [inherited]

Get Sn_DIPR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t*)diprPointer variable to get socket n destination IP address. It should be allocated 4 bytes.
See also:
SetSn_DIPR()

Definition at line 800 of file W5500.h.

uint16_t getSn_DPORT ( uint8_t  sn ) [inherited]

Get Sn_DPORT register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Sn_DPORT.
See also:
setSn_DPORT()

Definition at line 822 of file W5500.h.

uint8_t getSn_IMR ( uint8_t  sn ) [inherited]

Get Sn_IMR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint8_t. Value of Sn_IMR.
See also:
setSn_IMR()

Definition at line 724 of file W5500.h.

uint8_t getSn_IR ( uint8_t  sn ) [inherited]

Get Sn_IR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint8_t. Value of Sn_IR.
See also:
setSn_IR()

Definition at line 702 of file W5500.h.

uint8_t getSn_MR ( uint8_t  sn ) [inherited]

Get Sn_MR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint8_t. Value of Sn_MR.
See also:
setSn_MR()

Definition at line 658 of file W5500.h.

uint16_t getSn_PORT ( uint8_t  sn ) [inherited]

Get Sn_PORT register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Sn_PORT.
See also:
setSn_PORT()

Definition at line 756 of file W5500.h.

uint16_t getSn_RX_RD ( uint8_t  sn ) [inherited]

Get Sn_RX_RD register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7. uint16_t. Value of Sn_RX_RD.
See also:
setSn_RX_RD()

Definition at line 945 of file W5500.h.

uint16_t getSn_RX_RSR ( uint8_t  sn ) [inherited]

Get Sn_RX_RSR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Sn_RX_RSR.

Definition at line 922 of file W5500.h.

uint16_t getSn_RX_WR ( uint8_t  sn ) [inherited]

Get Sn_RX_WR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Sn_RX_WR.

Definition at line 955 of file W5500.h.

uint8_t getSn_RXBUF_SIZE ( uint8_t  sn ) [inherited]

Get Sn_RXBUF_SIZE register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint8_t. Value of Sn_RXBUF_SIZE.
See also:
setSn_RXBUF_SIZE()

Definition at line 846 of file W5500.h.

uint16_t getSn_RxMAX ( uint8_t  sn ) [inherited]

Gets the max buffer size of socket sn passed as parameter.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Socket n RX max buffer size.

Definition at line 970 of file W5500.h.

uint8_t getSn_SR ( uint8_t  sn ) [inherited]

Get Sn_SR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint8_t. Value of Sn_SR.

Definition at line 734 of file W5500.h.

uint16_t getSn_TX_FSR ( uint8_t  sn ) [inherited]

Get Sn_TX_FSR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Sn_TX_FSR.

Definition at line 878 of file W5500.h.

uint16_t getSn_TX_RD ( uint8_t  sn ) [inherited]

Get Sn_TX_RD register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Sn_TX_RD.

Definition at line 889 of file W5500.h.

uint16_t getSn_TX_WR ( uint8_t  sn ) [inherited]

Get Sn_TX_WR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Sn_TX_WR.
See also:
setSn_TX_WR()

Definition at line 911 of file W5500.h.

uint8_t getSn_TXBUF_SIZE ( uint8_t  sn ) [inherited]

Get Sn_TXBUF_SIZE register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint8_t. Value of Sn_TXBUF_SIZE.
See also:
setSn_TXBUF_SIZE()

Definition at line 868 of file W5500.h.

uint16_t getSn_TxMAX ( uint8_t  sn ) [inherited]

Gets the max buffer size of socket sn passed as parameters.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
Returns:
uint16_t. Value of Socket n TX max buffer size.

Definition at line 980 of file W5500.h.

void getSUBR ( uint8_t *  subr ) [inherited]

Get subnet mask address.

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

Definition at line 448 of file W5500.h.

int init (  )

Initialize the interface with DHCP.

Initialize the interface and configure it to use DHCP (no connection at this point).

Returns:
0 on success, a negative number on failure

Definition at line 36 of file EthernetInterface.cpp.

int init ( uint8_t *  mac,
const char *  ip,
const char *  mask,
const char *  gateway 
)

Initialize the interface with a static IP address.

Initialize the interface and configure it with the following static configuration (no connection at this point).

Parameters:
ipthe IP address to use
maskthe IP address mask
gatewaythe gateway to use
Returns:
0 on success, a negative number on failure

Definition at line 55 of file EthernetInterface.cpp.

void setGAR ( uint8_t *  gar ) [inherited]

Set gateway IP address.

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

Definition at line 417 of file W5500.h.

void setIMR ( uint8_t  imr ) [inherited]

Set IMR register.

Parameters:
(uint8_t)imrValue to set IMR register.
See also:
getIMR()

Definition at line 518 of file W5500.h.

void setIR ( uint8_t  ir ) [inherited]

Set IR register.

Parameters:
(uint8_t)irValue to set IR register.
See also:
getIR()

Definition at line 498 of file W5500.h.

void setMR ( uint8_t  mr ) [inherited]

Set Mode Register.

Parameters:
(uint8_t)mrThe value to be set.
See also:
getMR()

Definition at line 396 of file W5500.h.

void setPHYCFGR ( uint8_t  phycfgr ) [inherited]

Set PHYCFGR register.

Parameters:
(uint8_t)phycfgrValue to set PHYCFGR register.
See also:
setPHYCFGR()

Definition at line 620 of file W5500.h.

void setRCR ( uint8_t  rcr ) [inherited]

Set RCR register.

Parameters:
(uint8_t)rcrValue to set RCR register.
See also:
getRCR()

Definition at line 598 of file W5500.h.

void setRTR ( uint16_t  rtr ) [inherited]

Set RTR register.

Parameters:
(uint16_t)rtrValue to set RTR register.
See also:
getRTR()

Definition at line 578 of file W5500.h.

void setSHAR ( uint8_t *  shar ) [inherited]

Set local MAC address.

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

Definition at line 458 of file W5500.h.

void setSIMR ( uint8_t  simr ) [inherited]

Set SIMR register.

Parameters:
(uint8_t)simrValue to set SIMR register.
See also:
getSIMR()

Definition at line 558 of file W5500.h.

void setSIPR ( uint8_t *  sipr ) [inherited]

Set local IP address.

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

Definition at line 478 of file W5500.h.

void setSIR ( uint8_t  sir ) [inherited]

Set SIR register.

Parameters:
(uint8_t)sirValue to set SIR register.
See also:
getSIR()

Definition at line 539 of file W5500.h.

void setSn_CR ( uint8_t  sn,
uint8_t  cr 
) [inherited]

Set Sn_CR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t)crValue to set Sn_CR
See also:
getSn_CR()

Definition at line 669 of file W5500.h.

void setSn_DHAR ( uint8_t  sn,
uint8_t *  dhar 
) [inherited]

Set Sn_DHAR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t*)dharPointer variable to set socket n destination hardware address. It should be allocated 6 bytes.
See also:
getSn_DHAR()

Definition at line 767 of file W5500.h.

void setSn_DIPR ( uint8_t  sn,
uint8_t *  dipr 
) [inherited]

Set Sn_DIPR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t*)diprPointer variable to set socket n destination IP address. It should be allocated 4 bytes.
See also:
getSn_DIPR()

Definition at line 789 of file W5500.h.

void setSn_DPORT ( uint8_t  sn,
uint16_t  dport 
) [inherited]

Set Sn_DPORT register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint16_t)dportValue to set Sn_DPORT
See also:
getSn_DPORT()

Definition at line 811 of file W5500.h.

void setSn_IMR ( uint8_t  sn,
uint8_t  imr 
) [inherited]

Set Sn_IMR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t)imrValue to set Sn_IMR
See also:
getSn_IMR()

Definition at line 713 of file W5500.h.

void setSn_IR ( uint8_t  sn,
uint8_t  ir 
) [inherited]

Set Sn_IR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t)irValue to set Sn_IR
See also:
getSn_IR()

Definition at line 691 of file W5500.h.

void setSn_MR ( uint8_t  sn,
uint8_t  mr 
) [inherited]

Set Sn_MR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t)mrValue to set Sn_MR
See also:
getSn_MR()

Definition at line 647 of file W5500.h.

void setSn_PORT ( uint8_t  sn,
uint16_t  port 
) [inherited]

Set Sn_PORT register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint16_t)portValue to set Sn_PORT.
See also:
getSn_PORT()

Definition at line 745 of file W5500.h.

void setSn_RX_RD ( uint8_t  sn,
uint16_t  rxrd 
) [inherited]

Set Sn_RX_RD register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint16_t)rxrdValue to set Sn_RX_RD
See also:
getSn_RX_RD()

Definition at line 934 of file W5500.h.

void setSn_RXBUF_SIZE ( uint8_t  sn,
uint8_t  rxbufsize 
) [inherited]

Set Sn_RXBUF_SIZE register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t)rxbufsizeValue to set Sn_RXBUF_SIZE
See also:
getSn_RXBUF_SIZE()

Definition at line 834 of file W5500.h.

void setSn_TX_WR ( uint8_t  sn,
uint16_t  txwr 
) [inherited]

Set Sn_TX_WR register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint16_t)txwrValue to set Sn_TX_WR
See also:
GetSn_TX_WR()

Definition at line 900 of file W5500.h.

void setSn_TXBUF_SIZE ( uint8_t  sn,
uint8_t  txbufsize 
) [inherited]

Set Sn_TXBUF_SIZE register.

Parameters:
(uint8_t)snSocket number. It should be 0 ~ 7.
(uint8_t)txbufsizeValue to set Sn_TXBUF_SIZE
See also:
getSn_TXBUF_SIZE()

Definition at line 857 of file W5500.h.

void setSUBR ( uint8_t *  subr ) [inherited]

Set subnet mask address.

Parameters:
(uint8_t*)subrPointer variable to set subnet mask address. It should be allocated 4 bytes.
See also:
getSUBR()

Definition at line 437 of file W5500.h.