source: ctrl/firmware/Main/SES/Wiznet/Ethernet/wizchip_conf.h @ 114

Last change on this file since 114 was 79, checked in by Zed, 3 months ago

DHCP client can get IP-address from fritz!box

File size: 24.5 KB
Line 
1//*****************************************************************************
2//
3//! \file wizchip_conf.h
4//! \brief WIZCHIP Config Header File.
5//! \version 1.0.0
6//! \date 2013/10/21
7//! \par  Revision history
8//!       <2015/02/05> Notice
9//!        The version history is not updated after this point.
10//!        Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary.
11//!        >> https://github.com/Wiznet/ioLibrary_Driver
12//!       <2013/10/21> 1st Release
13//! \author MidnightCow
14//! \copyright
15//!
16//! Copyright (c)  2013, WIZnet Co., LTD.
17//! All rights reserved.
18//!
19//! Redistribution and use in source and binary forms, with or without
20//! modification, are permitted provided that the following conditions
21//! are met:
22//!
23//!     * Redistributions of source code must retain the above copyright
24//! notice, this list of conditions and the following disclaimer.
25//!     * Redistributions in binary form must reproduce the above copyright
26//! notice, this list of conditions and the following disclaimer in the
27//! documentation and/or other materials provided with the distribution.
28//!     * Neither the name of the <ORGANIZATION> nor the names of its
29//! contributors may be used to endorse or promote products derived
30//! from this software without specific prior written permission.
31//!
32//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33//! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34//! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35//! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
36//! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37//! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38//! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39//! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40//! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41//! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
42//! THE POSSIBILITY OF SUCH DAMAGE.
43//
44//*****************************************************************************
45
46/**
47 * @defgroup extra_functions 2. WIZnet Extra Functions
48 *
49 * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions.
50 * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n
51 *
52 */
53
54#ifndef  _WIZCHIP_CONF_H_
55#define  _WIZCHIP_CONF_H_
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61#include <stdint.h>
62/**
63 * @brief Select WIZCHIP.
64 * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n
65 *       ex> <code> #define \_WIZCHIP_      W5500 </code>
66 */
67
68#define W5100                                           5100
69#define W5100S                                          5100+5
70#define W5200                                           5200
71#define W5300                                           5300
72#define W5500                                           5500
73
74#ifndef _WIZCHIP_
75#define _WIZCHIP_                      W5100S   // W5100, W5100S, W5200, W5300, W5500
76#endif
77
78#define _WIZCHIP_IO_MODE_NONE_         0x0000
79#define _WIZCHIP_IO_MODE_BUS_          0x0100 /**< Bus interface mode */
80#define _WIZCHIP_IO_MODE_SPI_          0x0200 /**< SPI interface mode */
81//#define _WIZCHIP_IO_MODE_IIC_          0x0400
82//#define _WIZCHIP_IO_MODE_SDIO_         0x0800
83// Add to
84//
85
86#define _WIZCHIP_IO_MODE_BUS_DIR_      (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct  */
87#define _WIZCHIP_IO_MODE_BUS_INDIR_    (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */
88
89#define _WIZCHIP_IO_MODE_SPI_VDM_      (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/
90#define _WIZCHIP_IO_MODE_SPI_FDM_      (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/
91#define _WIZCHIP_IO_MODE_SPI_5500_     (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/
92
93#if   (_WIZCHIP_ == W5100)
94   #define _WIZCHIP_ID_                "W5100\0"
95/**
96 * @brief Define interface mode.
97 * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_
98 */
99//      #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_BUS_DIR_
100//      #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_BUS_INDIR_
101           #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_SPI_
102
103//A20150601 : Define the unit of IO DATA.
104   typedef   uint8_t   iodata_t;
105//A20150401 : Indclude W5100.h file
106   #include "W5100/w5100.h"
107
108#elif (_WIZCHIP_ == W5100S)
109#define _WIZCHIP_ID_                "W5100S\0"
110/**
111* @brief Define interface mode.
112* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_
113*/
114//      #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_BUS_INDIR_
115        //#define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_SPI_5500_
116        #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_SPI_
117
118//A20150601 : Define the unit of IO DATA.
119   typedef   uint8_t   iodata_t;
120//A20150401 : Indclude W5100.h file
121        #include "W5100S/w5100s.h"
122#elif (_WIZCHIP_ == W5200)
123   #define _WIZCHIP_ID_                "W5200\0"
124/**
125 * @brief Define interface mode.
126 * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \  _WIZCHIP_IO_MODE_BUS_INDIR_
127 */
128#ifndef _WIZCHIP_IO_MODE_
129// #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_BUS_INDIR_
130   #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_SPI_
131#endif
132//A20150601 : Define the unit of IO DATA.
133   typedef   uint8_t   iodata_t;
134   #include "W5200/w5200.h"
135#elif (_WIZCHIP_ == W5500)
136  #define _WIZCHIP_ID_                 "W5500\0"
137
138/**
139 * @brief Define interface mode. \n
140 * @todo Should select interface mode as chip.
141 *        - @ref \_WIZCHIP_IO_MODE_SPI_ \n
142 *          -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n
143 *          -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n
144 *        - @ref \_WIZCHIP_IO_MODE_BUS_ \n
145 *          - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n
146 *          - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n
147 *        - Others will be defined in future. \n\n
148 *        ex> <code> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ </code>
149 *
150 */
151#ifndef _WIZCHIP_IO_MODE_
152   //#define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_SPI_FDM_
153   #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_SPI_VDM_
154#endif
155//A20150601 : Define the unit of IO DATA.
156   typedef   uint8_t   iodata_t;
157   #include "W5500/w5500.h"
158#elif ( _WIZCHIP_ == W5300)
159   #define _WIZCHIP_ID_                 "W5300\0"
160/**
161 * @brief Define interface mode.
162 * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_
163 */
164#ifndef _WIZCHIP_IO_MODE_
165   #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_BUS_DIR_
166// #define _WIZCHIP_IO_MODE_           _WIZCHIP_IO_MODE_BUS_INDIR_
167#endif
168
169//A20150601 : Define the unit and bus width of IO DATA.
170   /**
171    * @brief Select the data width 8 or 16 bits.
172    * @todo you should select the bus width. Select one of 8 or 16.
173    */
174   #ifndef _WIZCHIP_IO_BUS_WIDTH_
175   #define _WIZCHIP_IO_BUS_WIDTH_       16  // 8
176   #endif
177   #if _WIZCHIP_IO_BUS_WIDTH_ == 8
178      typedef   uint8_t   iodata_t;
179   #elif _WIZCHIP_IO_BUS_WIDTH_ == 16
180      typedef   uint16_t   iodata_t;
181   #else
182      #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16."
183   #endif
184//
185   #include "W5300/w5300.h"
186#else
187   #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!"
188#endif
189
190#ifndef _WIZCHIP_IO_MODE_
191   #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!"
192#endif
193
194/**
195 * @brief Define I/O base address when BUS IF mode.
196 * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_,
197 *       @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n
198 *       ex> <code> #define \_WIZCHIP_IO_BASE_      0x00008000 </code>
199 */
200#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_
201//      #define _WIZCHIP_IO_BASE_                               0x60000000      // for 5100S IND
202        #define _WIZCHIP_IO_BASE_                               0x68000000      // for W5300
203#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_
204        #define _WIZCHIP_IO_BASE_                               0x00000000      // for 5100S SPI
205#endif
206
207#ifndef _WIZCHIP_IO_BASE_
208#define _WIZCHIP_IO_BASE_              0x00000000  // 0x8000
209#endif
210
211//M20150401 : Typing Error
212//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS
213#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_
214   #ifndef _WIZCHIP_IO_BASE_
215      #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map."
216   #endif
217#endif
218
219#if _WIZCHIP_ >= W5200
220   #define _WIZCHIP_SOCK_NUM_   8   ///< The count of independant socket of @b WIZCHIP
221#else
222   #define _WIZCHIP_SOCK_NUM_   4   ///< The count of independant socket of @b WIZCHIP
223#endif
224
225
226/********************************************************
227* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC.
228*********************************************************/
229/**
230 * @ingroup DATA_TYPE
231 * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200
232 */
233typedef struct __WIZCHIP
234{
235   uint16_t  if_mode;               ///< host interface mode
236   uint8_t   id[8];                 ///< @b WIZCHIP ID such as @b 5100, @b 5100S, @b 5200, @b 5500, and so on.
237   /**
238    * The set of critical section callback func.
239    */
240   struct _CRIS
241   {
242      void (*_enter)  (void);       ///< crtical section enter
243      void (*_exit) (void);         ///< critial section exit
244   }CRIS;
245   /**
246    *  The set of @ref \_WIZCHIP_ select control callback func.
247    */
248   struct _CS
249   {
250      void (*_select)  (void);      ///< @ref \_WIZCHIP_ selected
251      void (*_deselect)(void);      ///< @ref \_WIZCHIP_ deselected
252   }CS;
253   /**
254    * The set of interface IO callback func.
255    */
256   union _IF
257   {
258      /**
259       * For BUS interface IO
260       */
261      //M20156501 : Modify the function name for integrating with W5300
262      //struct
263      //{
264      //   uint8_t  (*_read_byte)  (uint32_t AddrSel);
265      //   void     (*_write_byte) (uint32_t AddrSel, uint8_t wb);
266      //}BUS;
267      struct
268      {
269         iodata_t  (*_read_data)   (uint32_t AddrSel);
270         void      (*_write_data)  (uint32_t AddrSel, iodata_t wb);
271      }BUS;
272
273      /**
274       * For SPI interface IO
275       */
276      struct
277      {
278         uint8_t (*_read_byte)   (void);
279         void    (*_write_byte)  (uint8_t wb);
280         void    (*_read_burst)  (uint8_t* pBuf, uint16_t len);
281         void    (*_write_burst) (uint8_t* pBuf, uint16_t len);
282      }SPI;
283      // To be added
284      //
285   }IF;
286}_WIZCHIP;
287
288extern _WIZCHIP  WIZCHIP;
289
290/**
291 * @ingroup DATA_TYPE
292 *  WIZCHIP control type enumration used in @ref ctlwizchip().
293 */
294typedef enum
295{
296   CW_RESET_WIZCHIP,   ///< Resets WIZCHIP by softly
297   CW_INIT_WIZCHIP,    ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t.
298   CW_GET_INTERRUPT,   ///< Get Interrupt status of WIZCHIP
299   CW_CLR_INTERRUPT,   ///< Clears interrupt
300   CW_SET_INTRMASK,    ///< Masks interrupt
301   CW_GET_INTRMASK,    ///< Get interrupt mask
302   CW_SET_INTRTIME,    ///< Set interval time between the current and next interrupt.
303   CW_GET_INTRTIME,    ///< Set interval time between the current and next interrupt.
304   CW_GET_ID,          ///< Gets WIZCHIP name.
305
306//D20150601 : For no modification your application code
307//#if _WIZCHIP_ ==  W5500
308   CW_RESET_PHY,       ///< Resets internal PHY. Valid Only W5500
309   CW_SET_PHYCONF,     ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000
310   CW_GET_PHYCONF,     ///< Get PHY operation mode in internal register. Valid Only W5500
311   CW_GET_PHYSTATUS,   ///< Get real PHY status on operating. Valid Only W5500
312   CW_SET_PHYPOWMODE,  ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500
313//#endif
314//D20150601 : For no modification your application code
315//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500
316   CW_GET_PHYPOWMODE,  ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200
317   CW_GET_PHYLINK      ///< Get PHY Link status, Valid Only W5100, W5200
318//#endif
319}ctlwizchip_type;
320
321/**
322 * @ingroup DATA_TYPE
323 *  Network control type enumration used in @ref ctlnetwork().
324 */
325typedef enum
326{
327   CN_SET_NETINFO,  ///< Set Network with @ref wiz_NetInfo
328   CN_GET_NETINFO,  ///< Get Network with @ref wiz_NetInfo
329   CN_SET_NETMODE,  ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode
330   CN_GET_NETMODE,  ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode
331   CN_SET_TIMEOUT,  ///< Set network timeout as retry count and time.
332   CN_GET_TIMEOUT,  ///< Get network timeout as retry count and time.
333}ctlnetwork_type;
334
335/**
336 * @ingroup DATA_TYPE
337 *  Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK
338 *  and CW_GET_INTRMASK is used in @ref ctlnetwork().
339 *  It can be used with OR operation.
340 */
341typedef enum
342{
343#if   _WIZCHIP_ == W5500
344   IK_WOL               = (1 << 4),   ///< Wake On Lan by receiving the magic packet. Valid in W500.
345#elif _WIZCHIP_ == W5300
346   IK_FMTU              = (1 << 4),   ///< Received a ICMP message (Fragment MTU)
347#endif
348
349   IK_PPPOE_TERMINATED  = (1 << 5),   ///< PPPoE Disconnected
350
351#if _WIZCHIP_ != W5200
352   IK_DEST_UNREACH      = (1 << 6),   ///< Destination IP & Port Unreachable, No use in W5200
353#endif
354
355   IK_IP_CONFLICT       = (1 << 7),   ///< IP conflict occurred
356
357   IK_SOCK_0            = (1 << 8),   ///< Socket 0 interrupt
358   IK_SOCK_1            = (1 << 9),   ///< Socket 1 interrupt
359   IK_SOCK_2            = (1 << 10),  ///< Socket 2 interrupt
360   IK_SOCK_3            = (1 << 11),  ///< Socket 3 interrupt
361#if _WIZCHIP_ > W5100S
362   IK_SOCK_4            = (1 << 12),  ///< Socket 4 interrupt, No use in 5100
363   IK_SOCK_5            = (1 << 13),  ///< Socket 5 interrupt, No use in 5100
364   IK_SOCK_6            = (1 << 14),  ///< Socket 6 interrupt, No use in 5100
365   IK_SOCK_7            = (1 << 15),  ///< Socket 7 interrupt, No use in 5100
366#endif
367
368#if _WIZCHIP_ > W5100S
369   IK_SOCK_ALL          = (0xFF << 8) ///< All Socket interrupt
370#else
371   IK_SOCK_ALL          = (0x0F << 8) ///< All Socket interrupt
372#endif
373}intr_kind;
374
375#define PHY_CONFBY_HW            0     ///< Configured PHY operation mode by HW pin
376#define PHY_CONFBY_SW            1     ///< Configured PHY operation mode by SW register
377#define PHY_MODE_MANUAL          0     ///< Configured PHY operation mode with user setting.
378#define PHY_MODE_AUTONEGO        1     ///< Configured PHY operation mode with auto-negotiation
379#define PHY_SPEED_10             0     ///< Link Speed 10
380#define PHY_SPEED_100            1     ///< Link Speed 100
381#define PHY_DUPLEX_HALF          0     ///< Link Half-Duplex
382#define PHY_DUPLEX_FULL          1     ///< Link Full-Duplex
383#define PHY_LINK_OFF             0     ///< Link Off
384#define PHY_LINK_ON              1     ///< Link On
385#define PHY_POWER_NORM           0     ///< PHY power normal mode
386#define PHY_POWER_DOWN           1     ///< PHY power down mode
387
388
389#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500
390/**
391 * @ingroup DATA_TYPE
392 *  It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500,
393 *  and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n
394 *  Valid only in W5500.
395 */
396typedef struct wiz_PhyConf_t
397{
398      uint8_t by;       ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW
399      uint8_t mode;     ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO
400      uint8_t speed;    ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100
401      uint8_t duplex;   ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL
402      //uint8_t power;  ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN
403      //uint8_t link;   ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF
404   }wiz_PhyConf;
405#endif
406
407/**
408 * @ingroup DATA_TYPE
409 *  It used in setting dhcp_mode of @ref wiz_NetInfo.
410 */
411typedef enum
412{
413   NETINFO_STATIC = 1,    ///< Static IP configuration by manually.
414   NETINFO_DHCP           ///< Dynamic IP configruation from a DHCP sever
415}dhcp_mode;
416
417/**
418 * @ingroup DATA_TYPE
419 *  Network Information for WIZCHIP
420 */
421typedef struct wiz_NetInfo_t
422{
423   uint8_t mac[6];  ///< Source Mac Address
424   uint8_t ip[4];   ///< Source IP Address
425   uint8_t sn[4];   ///< Subnet Mask
426   uint8_t gw[4];   ///< Gateway IP Address
427   uint8_t dns[4];  ///< DNS server IP Address
428   dhcp_mode dhcp;  ///< 1 - Static, 2 - DHCP
429}wiz_NetInfo;
430
431/**
432 * @ingroup DATA_TYPE
433 *  Network mode
434 */
435typedef enum
436{
437#if _WIZCHIP_ == W5500
438   NM_FORCEARP    = (1<<1),  ///< Force to APP send whenever udp data is sent. Valid only in W5500
439#endif
440   NM_WAKEONLAN   = (1<<5),  ///< Wake On Lan
441   NM_PINGBLOCK   = (1<<4),  ///< Block ping-request
442   NM_PPPOE       = (1<<3),  ///< PPPoE mode
443}netmode_type;
444
445/**
446 * @ingroup DATA_TYPE
447 *  Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation.
448 */
449typedef struct wiz_NetTimeout_t
450{
451   uint8_t  retry_cnt;     ///< retry count
452   uint16_t time_100us;    ///< time unit 100us
453}wiz_NetTimeout;
454
455/**
456 *@brief Registers call back function for critical section of I/O functions such as
457 *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF.
458 *@param cris_en : callback function for critical section enter.
459 *@param cris_ex : callback function for critical section exit.
460 *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions.
461 *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called.
462 */
463void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void));
464
465
466/**
467 *@brief Registers call back function for WIZCHIP select & deselect.
468 *@param cs_sel : callback function for WIZCHIP select
469 *@param cs_desel : callback fucntion for WIZCHIP deselect
470 *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions.
471 *@note If you do not describe or register, null function is called.
472 */
473void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void));
474
475/**
476 *@brief Registers call back function for bus interface.
477 *@param bus_rb   : callback function to read byte data using system bus
478 *@param bus_wb   : callback function to write byte data using system bus
479 *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function
480 *or register your functions.
481 *@note If you do not describe or register, null function is called.
482 */
483//M20150601 : For integrating with W5300
484//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb));
485void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb));
486
487/**
488 *@brief Registers call back function for SPI interface.
489 *@param spi_rb : callback function to read byte using SPI
490 *@param spi_wb : callback function to write byte using SPI
491 *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function
492 *or register your functions.
493 *@note If you do not describe or register, null function is called.
494 */
495void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb));
496
497/**
498 *@brief Registers call back function for SPI interface.
499 *@param spi_rb : callback function to burst read using SPI
500 *@param spi_wb : callback function to burst write using SPI
501 *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function
502 *or register your functions.
503 *@note If you do not describe or register, null function is called.
504 */
505void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len));
506
507/**
508 * @ingroup extra_functions
509 * @brief Controls to the WIZCHIP.
510 * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto),
511 * controls interrupt & mask and so on.
512 * @param cwtype : Decides to the control type
513 * @param arg : arg type is dependent on cwtype.
514 * @return  0 : Success \n
515 *         -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP
516 */
517int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
518
519/**
520 * @ingroup extra_functions
521 * @brief Controls to network.
522 * @details Controls to network environment, mode, timeout and so on.
523 * @param cntype : Input. Decides to the control type
524 * @param arg : Inout. arg type is dependent on cntype.
525 * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n
526 *          0 : Success
527 */
528int8_t ctlnetwork(ctlnetwork_type cntype, void* arg);
529
530
531/*
532 * The following functions are implemented for internal use.
533 * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork().
534 */
535
536/**
537 * @ingroup extra_functions
538 * @brief Reset WIZCHIP by softly.
539 */
540void   wizchip_sw_reset(void);
541
542/**
543 * @ingroup extra_functions
544 * @brief Initializes WIZCHIP with socket buffer size
545 * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB.
546 * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB.
547 * @return 0 : succcess \n
548 *        -1 : fail. Invalid buffer size
549 */
550int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize);
551
552/**
553 * @ingroup extra_functions
554 * @brief Clear Interrupt of WIZCHIP.
555 * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t.
556 */
557void wizchip_clrinterrupt(intr_kind intr);
558
559/**
560 * @ingroup extra_functions
561 * @brief Get Interrupt of WIZCHIP.
562 * @return @ref intr_kind value operated OR. It can type-cast to uint16_t.
563 */
564intr_kind wizchip_getinterrupt(void);
565
566/**
567 * @ingroup extra_functions
568 * @brief Mask or Unmask Interrupt of WIZCHIP.
569 * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t.
570 */
571void wizchip_setinterruptmask(intr_kind intr);
572
573/**
574 * @ingroup extra_functions
575 * @brief Get Interrupt mask of WIZCHIP.
576 * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t.
577 */
578intr_kind wizchip_getinterruptmask(void);
579
580//todo
581#if _WIZCHIP_ > W5100
582   int8_t wizphy_getphylink(void);              ///< get the link status of phy in WIZCHIP. No use in W5100
583   int8_t wizphy_getphypmode(void);             ///< get the power mode of PHY in WIZCHIP. No use in W5100
584#endif
585
586#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500
587   void   wizphy_reset(void);                   ///< Reset phy. Vailid only in W5500
588/**
589 * @ingroup extra_functions
590 * @brief Set the phy information for WIZCHIP without power mode
591 * @param phyconf : @ref wiz_PhyConf
592 */
593   void   wizphy_setphyconf(wiz_PhyConf* phyconf);
594 /**
595 * @ingroup extra_functions
596 * @brief Get phy configuration information.
597 * @param phyconf : @ref wiz_PhyConf
598 */
599   void   wizphy_getphyconf(wiz_PhyConf* phyconf);
600 /**
601 * @ingroup extra_functions
602 * @brief Get phy status.
603 * @param phyconf : @ref wiz_PhyConf
604 */
605   void   wizphy_getphystat(wiz_PhyConf* phyconf);
606 /**
607 * @ingroup extra_functions
608 * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200
609 * @param pmode Settig value of power down mode.
610 */
611   int8_t wizphy_setphypmode(uint8_t pmode);
612#endif
613
614/**
615* @ingroup extra_functions
616 * @brief Set the network information for WIZCHIP
617 * @param pnetinfo : @ref wizNetInfo
618 */
619void wizchip_setnetinfo(wiz_NetInfo* pnetinfo);
620
621/**
622 * @ingroup extra_functions
623 * @brief Get the network information for WIZCHIP
624 * @param pnetinfo : @ref wizNetInfo
625 */
626void wizchip_getnetinfo(wiz_NetInfo* pnetinfo);
627
628/**
629 * @ingroup extra_functions
630 * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc.
631 * @param pnetinfo Value of network mode. Refer to @ref netmode_type.
632 */
633int8_t wizchip_setnetmode(netmode_type netmode);
634
635/**
636 * @ingroup extra_functions
637 * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc.
638 * @return Value of network mode. Refer to @ref netmode_type.
639 */
640netmode_type wizchip_getnetmode(void);
641
642/**
643 * @ingroup extra_functions
644 * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_).
645 * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission.
646 * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout.
647 */
648void wizchip_settimeout(wiz_NetTimeout* nettime);
649
650/**
651 * @ingroup extra_functions
652 * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_).
653 * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission.
654 * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout.
655 */
656void wizchip_gettimeout(wiz_NetTimeout* nettime);
657#ifdef __cplusplus
658 }
659#endif
660
661#endif   // _WIZCHIP_CONF_H_
Note: See TracBrowser for help on using the repository browser.