wizchip_conf.h 21 KB

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