wizchip_conf.h 25 KB

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