Socket APIs: Ethernet/wizchip_conf.h Source File

Wiznet Socket API

wizchip_conf.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
43 //
44 //*****************************************************************************
45 
54 #ifndef _WIZCHIP_CONF_H_
55 #define _WIZCHIP_CONF_H_
56 
57 #include <stdint.h>
63 #ifndef _WIZCHIP_
64 #define _WIZCHIP_ 5500 // 5100, 5200, 5300, 5500
65 #endif
66 
67 #define _WIZCHIP_IO_MODE_NONE_ 0x0000
68 #define _WIZCHIP_IO_MODE_BUS_ 0x0100
69 #define _WIZCHIP_IO_MODE_SPI_ 0x0200
70 //#define _WIZCHIP_IO_MODE_IIC_ 0x0400
71 //#define _WIZCHIP_IO_MODE_SDIO_ 0x0800
72 // Add to
73 //
74 
75 #define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1)
76 #define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2)
78 #define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1)
79 #define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2)
82 #if (_WIZCHIP_ == 5100)
83  #define _WIZCHIP_ID_ "W5100\0"
84 
88 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_
89 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
90  #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_
91 
92 //A20150601 : Define the unit of IO DATA.
93  typedef uint8_t iodata_t;
94 //A20150401 : Indclude W5100.h file
95  #include "W5100/w5100.h"
96 
97 #elif (_WIZCHIP_ == 5200)
98  #define _WIZCHIP_ID_ "W5200\0"
99 
103 #ifndef _WIZCHIP_IO_MODE_
104 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
105  #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_
106 #endif
107 //A20150601 : Define the unit of IO DATA.
108  typedef uint8_t iodata_t;
109  #include "W5200/w5200.h"
110 #elif (_WIZCHIP_ == 5500)
111  #define _WIZCHIP_ID_ "W5500\0"
112 
126 #ifndef _WIZCHIP_IO_MODE_
127  //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_
128  #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
129 #endif
130 //A20150601 : Define the unit of IO DATA.
131  typedef uint8_t iodata_t;
132  #include "W5500/w5500.h"
133 #elif ( _WIZCHIP_ == 5300)
134  #define _WIZCHIP_ID_ "W5300\0"
135 
139 #ifndef _WIZCHIP_IO_MODE_
140 // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_
141  #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_
142 #endif
143 
144 //A20150601 : Define the unit and bus width of IO DATA.
149  #ifndef _WIZCHIP_IO_BUS_WIDTH_
150  #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16
151  #endif
152  #if _WIZCHIP_IO_BUS_WIDTH_ == 8
153  typedef uint8_t iodata_t;
154  #elif _WIZCHIP_IO_BUS_WIDTH_ == 16
155  typedef uint16_t iodata_t;
156  #else
157  #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16."
158  #endif
159 //
160  #include "W5300/w5300.h"
161 #else
162  #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!"
163 #endif
164 
165 #ifndef _WIZCHIP_IO_MODE_
166  #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!"
167 #endif
168 
175 #ifndef _WIZCHIP_IO_BASE_
176 #define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000
177 #endif
178 
179 //M20150401 : Typing Error
180 //#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS
181 #if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_
182  #ifndef _WIZCHIP_IO_BASE_
183  #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map."
184  #endif
185 #endif
186 
187 #if _WIZCHIP_ > 5100
188  #define _WIZCHIP_SOCK_NUM_ 8
189 #else
190  #define _WIZCHIP_SOCK_NUM_ 4
191 #endif
192 
193 
194 /********************************************************
195 * WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC.
196 *********************************************************/
201 typedef struct __WIZCHIP
202 {
203  uint16_t if_mode;
204  uint8_t id[6];
205 
208  struct _CRIS
209  {
210  void (*_enter) (void);
211  void (*_exit) (void);
212  }CRIS;
216  struct _CS
217  {
218  void (*_select) (void);
219  void (*_deselect)(void);
220  }CS;
224  union _IF
225  {
229  //M20156501 : Modify the function name for integrating with W5300
230  //struct
231  //{
232  // uint8_t (*_read_byte) (uint32_t AddrSel);
233  // void (*_write_byte) (uint32_t AddrSel, uint8_t wb);
234  //}BUS;
235  struct
236  {
237  iodata_t (*_read_data) (uint32_t AddrSel);
238  void (*_write_data) (uint32_t AddrSel, iodata_t wb);
239  }BUS;
240 
244  struct
245  {
246  uint8_t (*_read_byte) (void);
247  void (*_write_byte) (uint8_t wb);
248  void (*_read_burst) (uint8_t* pBuf, uint16_t len);
249  void (*_write_burst) (uint8_t* pBuf, uint16_t len);
250  }SPI;
251  // To be added
252  //
253  }IF;
254 }_WIZCHIP;
255 
256 extern _WIZCHIP WIZCHIP;
257 
262 typedef enum
263 {
273 
274 //D20150601 : For no modification your application code
275 //#if _WIZCHIP_ == 5500
281 //#endif
282 //D20150601 : For no modification your application code
283 //#if _WIZCHIP_ == 5200 || _WIZCHIP_ == 5500
286 //#endif
288 
293 typedef enum
294 {
302 
309 typedef enum
310 {
311 #if _WIZCHIP_ == 5500
312  IK_WOL = (1 << 4),
313 #elif _WIZCHIP_ == 5300
314  IK_FMTU = (1 << 4),
315 #endif
316 
317  IK_PPPOE_TERMINATED = (1 << 5),
318 
319 #if _WIZCHIP_ != 5200
320  IK_DEST_UNREACH = (1 << 6),
321 #endif
322 
323  IK_IP_CONFLICT = (1 << 7),
324 
325  IK_SOCK_0 = (1 << 8),
326  IK_SOCK_1 = (1 << 9),
327  IK_SOCK_2 = (1 << 10),
328  IK_SOCK_3 = (1 << 11),
329 #if _WIZCHIP_ > 5100
330  IK_SOCK_4 = (1 << 12),
331  IK_SOCK_5 = (1 << 13),
332  IK_SOCK_6 = (1 << 14),
333  IK_SOCK_7 = (1 << 15),
334 #endif
335 
336 #if _WIZCHIP_ > 5100
337  IK_SOCK_ALL = (0xFF << 8)
338 #else
339  IK_SOCK_ALL = (0x0F << 8)
340 #endif
341 }intr_kind;
342 
343 #define PHY_CONFBY_HW 0
344 #define PHY_CONFBY_SW 1
345 #define PHY_MODE_MANUAL 0
346 #define PHY_MODE_AUTONEGO 1
347 #define PHY_SPEED_10 0
348 #define PHY_SPEED_100 1
349 #define PHY_DUPLEX_HALF 0
350 #define PHY_DUPLEX_FULL 1
351 #define PHY_LINK_OFF 0
352 #define PHY_LINK_ON 1
353 #define PHY_POWER_NORM 0
354 #define PHY_POWER_DOWN 1
355 
356 
357 #if _WIZCHIP_ == 5500
358 
364 typedef struct wiz_PhyConf_t
365 {
366  uint8_t by;
367  uint8_t mode;
368  uint8_t speed;
369  uint8_t duplex;
370  //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN
371  //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF
372  }wiz_PhyConf;
373 #endif
374 
379 typedef enum
380 {
383 }dhcp_mode;
384 
389 typedef struct wiz_NetInfo_t
390 {
391  uint8_t mac[6];
392  uint8_t ip[4];
393  uint8_t sn[4];
394  uint8_t gw[4];
395  uint8_t dns[4];
397 }wiz_NetInfo;
398 
403 typedef enum
404 {
405 #if _WIZCHIP_ == 5500
406  NM_FORCEARP = (1<<1),
407 #endif
408  NM_WAKEONLAN = (1<<5),
409  NM_PINGBLOCK = (1<<4),
410  NM_PPPOE = (1<<3),
411 }netmode_type;
412 
417 typedef struct wiz_NetTimeout_t
418 {
419  uint8_t retry_cnt;
420  uint16_t time_100us;
422 
431 void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void));
432 
433 
441 void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void));
442 
451 //M20150601 : For integrating with W5300
452 //void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb));
453 void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb));
454 
463 void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb));
464 
473 void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len));
474 
485 int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
486 
496 int8_t ctlnetwork(ctlnetwork_type cntype, void* arg);
497 
498 
499 /*
500  * The following functions are implemented for internal use.
501  * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork().
502  */
503 
508 void wizchip_sw_reset(void);
509 
518 int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize);
519 
526 
533 
540 
547 
548 #if _WIZCHIP_ > 5100
549  int8_t wizphy_getphylink(void);
550  int8_t wizphy_getphypmode(void);
551 #endif
552 
553 #if _WIZCHIP_ == 5500
554  void wizphy_reset(void);
555 
560  void wizphy_setphyconf(wiz_PhyConf* phyconf);
566  void wizphy_getphyconf(wiz_PhyConf* phyconf);
572  void wizphy_getphystat(wiz_PhyConf* phyconf);
578  int8_t wizphy_setphypmode(uint8_t pmode);
579 #endif
580 
586 void wizchip_setnetinfo(wiz_NetInfo* pnetinfo);
587 
593 void wizchip_getnetinfo(wiz_NetInfo* pnetinfo);
594 
600 int8_t wizchip_setnetmode(netmode_type netmode);
601 
608 
615 void wizchip_settimeout(wiz_NetTimeout* nettime);
616 
623 void wizchip_gettimeout(wiz_NetTimeout* nettime);
624 
625 #endif // _WIZCHIP_CONF_H_
netmode_type wizchip_getnetmode(void)
Get the network mode such WOL, PPPoE, Ping Block, and etc.
Definition: wizchip_conf.c:769
uint8_t(* _read_byte)(void)
Definition: wizchip_conf.h:246
void wizchip_gettimeout(wiz_NetTimeout *nettime)
Get retry time value(RTR) and retry count(RCR).
Definition: wizchip_conf.c:780
Get Network with wiz_NetInfo.
Definition: wizchip_conf.h:296
void wizphy_setphyconf(wiz_PhyConf *phyconf)
Set the phy information for WIZCHIP without power mode.
Definition: wizchip_conf.c:627
union __WIZCHIP::_IF IF
uint8_t retry_cnt
retry count
Definition: wizchip_conf.h:419
void(* _write_data)(uint32_t AddrSel, iodata_t wb)
Definition: wizchip_conf.h:238
void wizchip_clrinterrupt(intr_kind intr)
Clear Interrupt of WIZCHIP.
Definition: wizchip_conf.c:464
struct __WIZCHIP _WIZCHIP
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions.
Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
Definition: wizchip_conf.h:298
void(* _select)(void)
_WIZCHIP_ selected
Definition: wizchip_conf.h:218
void wizphy_getphyconf(wiz_PhyConf *phyconf)
Get phy configuration information.
Definition: wizchip_conf.c:657
Get PHY operation mode in internal register. Valid Only W5500.
Definition: wizchip_conf.h:278
W5200 HAL Header File.
Get interrupt mask.
Definition: wizchip_conf.h:269
Set Network with wiz_NetInfo.
Definition: wizchip_conf.h:295
Get network timeout as retry count and time.
Definition: wizchip_conf.h:300
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
uint8_t mac[6]
Source Mac Address.
Definition: wizchip_conf.h:391
Get Interrupt status of WIZCHIP.
Definition: wizchip_conf.h:266
Socket 2 interrupt.
Definition: wizchip_conf.h:327
Get PHY Power mode as down or normal, Valid Only W5100, W5200.
Definition: wizchip_conf.h:284
Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode.
Definition: wizchip_conf.h:297
void(* _exit)(void)
critial section exit
Definition: wizchip_conf.h:211
W5500 HAL Header File.
uint16_t if_mode
host interface mode
Definition: wizchip_conf.h:203
void(* _read_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:248
Gets WIZCHIP name.
Definition: wizchip_conf.h:272
struct wiz_PhyConf_t wiz_PhyConf
void(* _deselect)(void)
_WIZCHIP_ deselected
Definition: wizchip_conf.h:219
void(* _write_byte)(uint8_t wb)
Definition: wizchip_conf.h:247
Clears interrupt.
Definition: wizchip_conf.h:267
void wizchip_getnetinfo(wiz_NetInfo *pnetinfo)
Get the network information for WIZCHIP.
Definition: wizchip_conf.c:742
int8_t wizphy_getphylink(void)
get the link status of phy in WIZCHIP. No use in W5100
Definition: wizchip_conf.c:575
struct wiz_NetTimeout_t wiz_NetTimeout
iodata_t(* _read_data)(uint32_t AddrSel)
Definition: wizchip_conf.h:237
Socket 1 interrupt.
Definition: wizchip_conf.h:326
struct __WIZCHIP::_IF::@1 SPI
intr_kind wizchip_getinterruptmask(void)
Get Interrupt mask of WIZCHIP.
Definition: wizchip_conf.c:546
Get real PHY status on operating. Valid Only W5500.
Definition: wizchip_conf.h:279
Socket 6 interrupt, No use in 5100.
Definition: wizchip_conf.h:332
uint8_t dns[4]
DNS server IP Address.
Definition: wizchip_conf.h:395
uint8_t speed
set by PHY_SPEED_10 or PHY_SPEED_100
Definition: wizchip_conf.h:368
#define _WIZCHIP_
Select WIZCHIP.
Definition: wizchip_conf.h:64
int8_t ctlnetwork(ctlnetwork_type cntype, void *arg)
Controls to network.
Definition: wizchip_conf.c:359
uint8_t gw[4]
Gateway IP Address.
Definition: wizchip_conf.h:394
Wake On Lan.
Definition: wizchip_conf.h:408
struct __WIZCHIP::_CRIS CRIS
All Socket interrupt.
Definition: wizchip_conf.h:337
Set interval time between the current and next interrupt.
Definition: wizchip_conf.h:271
uint8_t duplex
set by PHY_DUPLEX_HALF PHY_DUPLEX_FULL
Definition: wizchip_conf.h:369
Force to APP send whenever udp data is sent. Valid only in W5500.
Definition: wizchip_conf.h:406
PPPoE Disconnected.
Definition: wizchip_conf.h:317
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
dhcp_mode dhcp
1 - Static, 2 - DHCP
Definition: wizchip_conf.h:396
Wake On Lan by receiving the magic packet. Valid in W500.
Definition: wizchip_conf.h:312
IP conflict occurred.
Definition: wizchip_conf.h:323
Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t.
Definition: wizchip_conf.h:265
_WIZCHIP WIZCHIP
Definition: wizchip_conf.c:165
Resets WIZCHIP by softly.
Definition: wizchip_conf.h:264
uint16_t time_100us
time unit 100us
Definition: wizchip_conf.h:420
void wizchip_setinterruptmask(intr_kind intr)
Mask or Unmask Interrupt of WIZCHIP.
Definition: wizchip_conf.c:522
intr_kind wizchip_getinterrupt(void)
Get Interrupt of WIZCHIP.
Definition: wizchip_conf.c:491
Destination IP & Port Unreachable, No use in W5200.
Definition: wizchip_conf.h:320
The set of callback functions for W5500:WIZCHIP I/O functions W5200:WIZCHIP I/O functions.
Definition: wizchip_conf.h:201
Socket 4 interrupt, No use in 5100.
Definition: wizchip_conf.h:330
Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500. ...
Definition: wizchip_conf.h:280
int8_t wizphy_getphypmode(void)
get the power mode of PHY in WIZCHIP. No use in W5100
Definition: wizchip_conf.c:596
ctlnetwork_type
Definition: wizchip_conf.h:293
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:703
struct wiz_NetInfo_t wiz_NetInfo
W5100 HAL Header File.
Resets internal PHY. Valid Only W5500.
Definition: wizchip_conf.h:276
uint8_t ip[4]
Source IP Address.
Definition: wizchip_conf.h:392
Masks interrupt.
Definition: wizchip_conf.h:268
int8_t wizchip_init(uint8_t *txsize, uint8_t *rxsize)
Initializes WIZCHIP with socket buffer size.
Definition: wizchip_conf.c:412
void wizchip_settimeout(wiz_NetTimeout *nettime)
Set retry time value(RTR) and retry count(RCR).
Definition: wizchip_conf.c:774
Socket 3 interrupt.
Definition: wizchip_conf.h:328
void wizchip_sw_reset(void)
Reset WIZCHIP by softly.
Definition: wizchip_conf.c:387
Socket 5 interrupt, No use in 5100.
Definition: wizchip_conf.h:331
void wizchip_setnetinfo(wiz_NetInfo *pnetinfo)
Set the network information for WIZCHIP.
Definition: wizchip_conf.c:729
void(* _write_burst)(uint8_t *pBuf, uint16_t len)
Definition: wizchip_conf.h:249
Dynamic IP configruation from a DHCP sever.
Definition: wizchip_conf.h:382
Set interval time between the current and next interrupt.
Definition: wizchip_conf.h:270
void wizphy_reset(void)
Reset phy. Vailid only in W5500.
Definition: wizchip_conf.c:617
int8_t ctlwizchip(ctlwizchip_type cwtype, void *arg)
Controls to the WIZCHIP.
Definition: wizchip_conf.c:277
W5300 HAL implement File.
struct __WIZCHIP::_CS CS
uint8_t iodata_t
Definition: wizchip_conf.h:131
uint8_t by
set by PHY_CONFBY_HW or PHY_CONFBY_SW
Definition: wizchip_conf.h:366
intr_kind
Definition: wizchip_conf.h:309
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
Set network timeout as retry count and time.
Definition: wizchip_conf.h:299
void wizphy_getphystat(wiz_PhyConf *phyconf)
Get phy status.
Definition: wizchip_conf.c:696
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
int8_t wizchip_setnetmode(netmode_type netmode)
Set the network mode such WOL, PPPoE, Ping Block, and etc.
Definition: wizchip_conf.c:755
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
uint8_t sn[4]
Subnet Mask.
Definition: wizchip_conf.h:393
struct __WIZCHIP::_IF::@0 BUS
uint8_t mode
set by PHY_MODE_MANUAL or PHY_MODE_AUTONEGO
Definition: wizchip_conf.h:367
When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000.
Definition: wizchip_conf.h:277
netmode_type
Definition: wizchip_conf.h:403
Static IP configuration by manually.
Definition: wizchip_conf.h:381
dhcp_mode
Definition: wizchip_conf.h:379
Get PHY Link status, Valid Only W5100, W5200.
Definition: wizchip_conf.h:285
ctlwizchip_type
Definition: wizchip_conf.h:262
PPPoE mode.
Definition: wizchip_conf.h:410
Block ping-request.
Definition: wizchip_conf.h:409
Socket 7 interrupt, No use in 5100.
Definition: wizchip_conf.h:333
void(* _enter)(void)
crtical section enter
Definition: wizchip_conf.h:210
Socket 0 interrupt.
Definition: wizchip_conf.h:325
Generated on Wed May 4 2016 16:43:58 for Socket APIs by   doxygen 1.8.9.1