![](/media/cache/profiles/a9992f6c7611759605d948f6084808ed.50x50_q85.jpg)
Wiznet W5500 driver and TCP/UDP loopback
Ethernet/wizchip_conf.h@0:2513c6696bdc, 2013-12-13 (annotated)
- Committer:
- jbkim
- Date:
- Fri Dec 13 07:35:58 2013 +0000
- Revision:
- 0:2513c6696bdc
Wiznet W5500 library and TCP/UDP loopback program for mbed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbkim | 0:2513c6696bdc | 1 | /* Wiznet W5500 Library |
jbkim | 0:2513c6696bdc | 2 | * Copyright (c) 2013, WIZnet Co., LTD. |
jbkim | 0:2513c6696bdc | 3 | * |
jbkim | 0:2513c6696bdc | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
jbkim | 0:2513c6696bdc | 5 | * you may not use this file except in compliance with the License. |
jbkim | 0:2513c6696bdc | 6 | * You may obtain a copy of the License at |
jbkim | 0:2513c6696bdc | 7 | * |
jbkim | 0:2513c6696bdc | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
jbkim | 0:2513c6696bdc | 9 | * |
jbkim | 0:2513c6696bdc | 10 | * Unless required by applicable law or agreed to in writing, software |
jbkim | 0:2513c6696bdc | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
jbkim | 0:2513c6696bdc | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
jbkim | 0:2513c6696bdc | 13 | * See the License for the specific language governing permissions and |
jbkim | 0:2513c6696bdc | 14 | * limitations under the License. |
jbkim | 0:2513c6696bdc | 15 | */ |
jbkim | 0:2513c6696bdc | 16 | |
jbkim | 0:2513c6696bdc | 17 | /** |
jbkim | 0:2513c6696bdc | 18 | * @defgroup extra_functions 2. WIZnet Extra Functions |
jbkim | 0:2513c6696bdc | 19 | * |
jbkim | 0:2513c6696bdc | 20 | * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. |
jbkim | 0:2513c6696bdc | 21 | * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n |
jbkim | 0:2513c6696bdc | 22 | * |
jbkim | 0:2513c6696bdc | 23 | */ |
jbkim | 0:2513c6696bdc | 24 | #ifdef __cplusplus |
jbkim | 0:2513c6696bdc | 25 | extern "C" { |
jbkim | 0:2513c6696bdc | 26 | #endif |
jbkim | 0:2513c6696bdc | 27 | |
jbkim | 0:2513c6696bdc | 28 | #ifndef _WIZCHIP_CONF_H_ |
jbkim | 0:2513c6696bdc | 29 | #define _WIZCHIP_CONF_H_ |
jbkim | 0:2513c6696bdc | 30 | |
jbkim | 0:2513c6696bdc | 31 | #include <stdint.h> |
jbkim | 0:2513c6696bdc | 32 | #include "W5500/w5500.h" |
jbkim | 0:2513c6696bdc | 33 | |
jbkim | 0:2513c6696bdc | 34 | #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP |
jbkim | 0:2513c6696bdc | 35 | |
jbkim | 0:2513c6696bdc | 36 | |
jbkim | 0:2513c6696bdc | 37 | /******************************************************** |
jbkim | 0:2513c6696bdc | 38 | * WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. |
jbkim | 0:2513c6696bdc | 39 | *********************************************************/ |
jbkim | 0:2513c6696bdc | 40 | /** |
jbkim | 0:2513c6696bdc | 41 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 42 | * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 |
jbkim | 0:2513c6696bdc | 43 | */ |
jbkim | 0:2513c6696bdc | 44 | typedef struct __WIZCHIP |
jbkim | 0:2513c6696bdc | 45 | { |
jbkim | 0:2513c6696bdc | 46 | /** |
jbkim | 0:2513c6696bdc | 47 | * The set of critical section callback func. |
jbkim | 0:2513c6696bdc | 48 | */ |
jbkim | 0:2513c6696bdc | 49 | struct _CRIS |
jbkim | 0:2513c6696bdc | 50 | { |
jbkim | 0:2513c6696bdc | 51 | void (*_enter) (void); ///< crtical section enter |
jbkim | 0:2513c6696bdc | 52 | void (*_exit) (void); ///< critial section exit |
jbkim | 0:2513c6696bdc | 53 | }CRIS; |
jbkim | 0:2513c6696bdc | 54 | /** |
jbkim | 0:2513c6696bdc | 55 | * The set of @ref\_WIZCHIP_ select control callback func. |
jbkim | 0:2513c6696bdc | 56 | */ |
jbkim | 0:2513c6696bdc | 57 | struct _CS |
jbkim | 0:2513c6696bdc | 58 | { |
jbkim | 0:2513c6696bdc | 59 | void (*_select) (void); ///< @ref \_WIZCHIP_ selected |
jbkim | 0:2513c6696bdc | 60 | void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected |
jbkim | 0:2513c6696bdc | 61 | }CS; |
jbkim | 0:2513c6696bdc | 62 | /** |
jbkim | 0:2513c6696bdc | 63 | * The set of interface IO callback func. |
jbkim | 0:2513c6696bdc | 64 | */ |
jbkim | 0:2513c6696bdc | 65 | union _IF |
jbkim | 0:2513c6696bdc | 66 | { |
jbkim | 0:2513c6696bdc | 67 | /** |
jbkim | 0:2513c6696bdc | 68 | * For SPI interface IO |
jbkim | 0:2513c6696bdc | 69 | */ |
jbkim | 0:2513c6696bdc | 70 | struct |
jbkim | 0:2513c6696bdc | 71 | { |
jbkim | 0:2513c6696bdc | 72 | uint8_t (*_read_byte) (void); |
jbkim | 0:2513c6696bdc | 73 | void (*_write_byte) (uint8_t wb); |
jbkim | 0:2513c6696bdc | 74 | }SPI; |
jbkim | 0:2513c6696bdc | 75 | }IF; |
jbkim | 0:2513c6696bdc | 76 | }_WIZCHIP; |
jbkim | 0:2513c6696bdc | 77 | |
jbkim | 0:2513c6696bdc | 78 | extern _WIZCHIP WIZCHIP; |
jbkim | 0:2513c6696bdc | 79 | |
jbkim | 0:2513c6696bdc | 80 | /** |
jbkim | 0:2513c6696bdc | 81 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 82 | * WIZCHIP control type enumration used in @ref ctlwizchip(). |
jbkim | 0:2513c6696bdc | 83 | */ |
jbkim | 0:2513c6696bdc | 84 | typedef enum |
jbkim | 0:2513c6696bdc | 85 | { |
jbkim | 0:2513c6696bdc | 86 | CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly |
jbkim | 0:2513c6696bdc | 87 | CW_INIT_WIZCHIP, ///< Inializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. |
jbkim | 0:2513c6696bdc | 88 | CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP |
jbkim | 0:2513c6696bdc | 89 | CW_CLR_INTERRUPT, ///< Clears interrupt |
jbkim | 0:2513c6696bdc | 90 | CW_SET_INTRMASK, ///< Masks interrupt |
jbkim | 0:2513c6696bdc | 91 | CW_GET_INTRMASK, ///< Get interrupt mask |
jbkim | 0:2513c6696bdc | 92 | CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. |
jbkim | 0:2513c6696bdc | 93 | CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. |
jbkim | 0:2513c6696bdc | 94 | CW_GET_ID, ///< Gets WIZCHIP name. |
jbkim | 0:2513c6696bdc | 95 | |
jbkim | 0:2513c6696bdc | 96 | CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5000 |
jbkim | 0:2513c6696bdc | 97 | CW_SET_PHYCONF, ///< When PHY configured by interal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 |
jbkim | 0:2513c6696bdc | 98 | CW_GET_PHYCONF, ///< Get PHY operation mode in interal register. Valid Only W5000 |
jbkim | 0:2513c6696bdc | 99 | CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5000 |
jbkim | 0:2513c6696bdc | 100 | CW_SET_PHYPOWMODE, ///< Set PHY power mode as noraml and down when PHYSTATUS.OPMD == 1. Valid Only W5000 |
jbkim | 0:2513c6696bdc | 101 | |
jbkim | 0:2513c6696bdc | 102 | CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal |
jbkim | 0:2513c6696bdc | 103 | CW_GET_PHYLINK ///< Get PHY Link status |
jbkim | 0:2513c6696bdc | 104 | }ctlwizchip_type; |
jbkim | 0:2513c6696bdc | 105 | |
jbkim | 0:2513c6696bdc | 106 | /** |
jbkim | 0:2513c6696bdc | 107 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 108 | * Network control type enumration used in @ref ctlnetwork(). |
jbkim | 0:2513c6696bdc | 109 | */ |
jbkim | 0:2513c6696bdc | 110 | typedef enum |
jbkim | 0:2513c6696bdc | 111 | { |
jbkim | 0:2513c6696bdc | 112 | CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo |
jbkim | 0:2513c6696bdc | 113 | CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo |
jbkim | 0:2513c6696bdc | 114 | CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode |
jbkim | 0:2513c6696bdc | 115 | CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode |
jbkim | 0:2513c6696bdc | 116 | CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. |
jbkim | 0:2513c6696bdc | 117 | CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. |
jbkim | 0:2513c6696bdc | 118 | }ctlnetwork_type; |
jbkim | 0:2513c6696bdc | 119 | |
jbkim | 0:2513c6696bdc | 120 | /** |
jbkim | 0:2513c6696bdc | 121 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 122 | * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK |
jbkim | 0:2513c6696bdc | 123 | * and CW_GET_INTRMASK is used in @ref ctlnetwork(). |
jbkim | 0:2513c6696bdc | 124 | * It can be used with OR operation. |
jbkim | 0:2513c6696bdc | 125 | */ |
jbkim | 0:2513c6696bdc | 126 | typedef enum |
jbkim | 0:2513c6696bdc | 127 | { |
jbkim | 0:2513c6696bdc | 128 | IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. |
jbkim | 0:2513c6696bdc | 129 | |
jbkim | 0:2513c6696bdc | 130 | IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected |
jbkim | 0:2513c6696bdc | 131 | |
jbkim | 0:2513c6696bdc | 132 | IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreable, No use in W5200 |
jbkim | 0:2513c6696bdc | 133 | |
jbkim | 0:2513c6696bdc | 134 | IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred |
jbkim | 0:2513c6696bdc | 135 | |
jbkim | 0:2513c6696bdc | 136 | IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt |
jbkim | 0:2513c6696bdc | 137 | IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt |
jbkim | 0:2513c6696bdc | 138 | IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt |
jbkim | 0:2513c6696bdc | 139 | IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt |
jbkim | 0:2513c6696bdc | 140 | IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 |
jbkim | 0:2513c6696bdc | 141 | IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 |
jbkim | 0:2513c6696bdc | 142 | IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 |
jbkim | 0:2513c6696bdc | 143 | IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 |
jbkim | 0:2513c6696bdc | 144 | |
jbkim | 0:2513c6696bdc | 145 | IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrpt |
jbkim | 0:2513c6696bdc | 146 | }intr_kind; |
jbkim | 0:2513c6696bdc | 147 | |
jbkim | 0:2513c6696bdc | 148 | #define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin |
jbkim | 0:2513c6696bdc | 149 | #define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register |
jbkim | 0:2513c6696bdc | 150 | #define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. |
jbkim | 0:2513c6696bdc | 151 | #define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation |
jbkim | 0:2513c6696bdc | 152 | #define PHY_SPEED_10 0 ///< Link Speed 10 |
jbkim | 0:2513c6696bdc | 153 | #define PHY_SPEED_100 1 ///< Link Speed 100 |
jbkim | 0:2513c6696bdc | 154 | #define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex |
jbkim | 0:2513c6696bdc | 155 | #define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex |
jbkim | 0:2513c6696bdc | 156 | #define PHY_LINK_OFF 0 ///< Link Off |
jbkim | 0:2513c6696bdc | 157 | #define PHY_LINK_ON 1 ///< Link On |
jbkim | 0:2513c6696bdc | 158 | #define PHY_POWER_NORM 0 ///< PHY power normal mode |
jbkim | 0:2513c6696bdc | 159 | #define PHY_POWER_DOWN 1 ///< PHY power down mode |
jbkim | 0:2513c6696bdc | 160 | |
jbkim | 0:2513c6696bdc | 161 | |
jbkim | 0:2513c6696bdc | 162 | /** |
jbkim | 0:2513c6696bdc | 163 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 164 | * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, |
jbkim | 0:2513c6696bdc | 165 | * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n |
jbkim | 0:2513c6696bdc | 166 | * Valid only in W5500. |
jbkim | 0:2513c6696bdc | 167 | */ |
jbkim | 0:2513c6696bdc | 168 | typedef struct wiz_PhyConf_t |
jbkim | 0:2513c6696bdc | 169 | { |
jbkim | 0:2513c6696bdc | 170 | uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW |
jbkim | 0:2513c6696bdc | 171 | uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO |
jbkim | 0:2513c6696bdc | 172 | uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 |
jbkim | 0:2513c6696bdc | 173 | uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL |
jbkim | 0:2513c6696bdc | 174 | //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN |
jbkim | 0:2513c6696bdc | 175 | //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF |
jbkim | 0:2513c6696bdc | 176 | }wiz_PhyConf; |
jbkim | 0:2513c6696bdc | 177 | |
jbkim | 0:2513c6696bdc | 178 | /** |
jbkim | 0:2513c6696bdc | 179 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 180 | * It used in setting dhcp_mode of @ref wiz_NetInfo. |
jbkim | 0:2513c6696bdc | 181 | */ |
jbkim | 0:2513c6696bdc | 182 | typedef enum |
jbkim | 0:2513c6696bdc | 183 | { |
jbkim | 0:2513c6696bdc | 184 | NETINFO_STATIC = 1, ///< Static IP configuration by manually. |
jbkim | 0:2513c6696bdc | 185 | NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever |
jbkim | 0:2513c6696bdc | 186 | }dhcp_mode; |
jbkim | 0:2513c6696bdc | 187 | |
jbkim | 0:2513c6696bdc | 188 | /** |
jbkim | 0:2513c6696bdc | 189 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 190 | * Network Information for WIZCHIP |
jbkim | 0:2513c6696bdc | 191 | */ |
jbkim | 0:2513c6696bdc | 192 | typedef struct wiz_NetInfo_t |
jbkim | 0:2513c6696bdc | 193 | { |
jbkim | 0:2513c6696bdc | 194 | uint8_t mac[6]; ///< Source Mac Address |
jbkim | 0:2513c6696bdc | 195 | uint8_t ip[4]; ///< Source IP Address |
jbkim | 0:2513c6696bdc | 196 | uint8_t sn[4]; ///< Subnet Mask |
jbkim | 0:2513c6696bdc | 197 | uint8_t gw[4]; ///< Gateway IP Address |
jbkim | 0:2513c6696bdc | 198 | uint8_t dns[4]; ///< DNS server IP Address |
jbkim | 0:2513c6696bdc | 199 | dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP |
jbkim | 0:2513c6696bdc | 200 | }wiz_NetInfo; |
jbkim | 0:2513c6696bdc | 201 | |
jbkim | 0:2513c6696bdc | 202 | /** |
jbkim | 0:2513c6696bdc | 203 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 204 | * Network mode |
jbkim | 0:2513c6696bdc | 205 | */ |
jbkim | 0:2513c6696bdc | 206 | typedef enum |
jbkim | 0:2513c6696bdc | 207 | { |
jbkim | 0:2513c6696bdc | 208 | NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 |
jbkim | 0:2513c6696bdc | 209 | NM_WAKEONLAN = (1<<5), ///< Wake On Lan |
jbkim | 0:2513c6696bdc | 210 | NM_PINGBLOCK = (1<<4), ///< Block ping-request |
jbkim | 0:2513c6696bdc | 211 | NM_PPPOE = (1<<3), ///< PPPoE mode |
jbkim | 0:2513c6696bdc | 212 | }netmode_type; |
jbkim | 0:2513c6696bdc | 213 | |
jbkim | 0:2513c6696bdc | 214 | /** |
jbkim | 0:2513c6696bdc | 215 | * @ingroup DATA_TYPE |
jbkim | 0:2513c6696bdc | 216 | * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. |
jbkim | 0:2513c6696bdc | 217 | */ |
jbkim | 0:2513c6696bdc | 218 | typedef struct wiz_NetTimeout_t |
jbkim | 0:2513c6696bdc | 219 | { |
jbkim | 0:2513c6696bdc | 220 | uint8_t retry_cnt; ///< retry count |
jbkim | 0:2513c6696bdc | 221 | uint16_t time_100us; ///< time unit 100us |
jbkim | 0:2513c6696bdc | 222 | }wiz_NetTimeout; |
jbkim | 0:2513c6696bdc | 223 | |
jbkim | 0:2513c6696bdc | 224 | /** |
jbkim | 0:2513c6696bdc | 225 | *@brief Registers call back function for critical section of I/O functions such as |
jbkim | 0:2513c6696bdc | 226 | *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. |
jbkim | 0:2513c6696bdc | 227 | *@param cris_en : callback function for critical section enter. |
jbkim | 0:2513c6696bdc | 228 | *@param cris_ex : callback function for critical section exit. |
jbkim | 0:2513c6696bdc | 229 | *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. |
jbkim | 0:2513c6696bdc | 230 | *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. |
jbkim | 0:2513c6696bdc | 231 | */ |
jbkim | 0:2513c6696bdc | 232 | void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); |
jbkim | 0:2513c6696bdc | 233 | |
jbkim | 0:2513c6696bdc | 234 | |
jbkim | 0:2513c6696bdc | 235 | /** |
jbkim | 0:2513c6696bdc | 236 | *@brief Registers call back function for WIZCHIP select & deselect. |
jbkim | 0:2513c6696bdc | 237 | *@param cs_sel : callback function for WIZCHIP select |
jbkim | 0:2513c6696bdc | 238 | *@param cs_desel : callback fucntion for WIZCHIP deselect |
jbkim | 0:2513c6696bdc | 239 | *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. |
jbkim | 0:2513c6696bdc | 240 | *@note If you do not describe or register, null function is called. |
jbkim | 0:2513c6696bdc | 241 | */ |
jbkim | 0:2513c6696bdc | 242 | void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); |
jbkim | 0:2513c6696bdc | 243 | |
jbkim | 0:2513c6696bdc | 244 | /** |
jbkim | 0:2513c6696bdc | 245 | *@brief Registers call back function for SPI interface. |
jbkim | 0:2513c6696bdc | 246 | *@param spi_rb : callback function to read byte usig SPI |
jbkim | 0:2513c6696bdc | 247 | *@param spi_wb : callback function to write byte usig SPI |
jbkim | 0:2513c6696bdc | 248 | *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function |
jbkim | 0:2513c6696bdc | 249 | *or register your functions. |
jbkim | 0:2513c6696bdc | 250 | *@note If you do not describe or register, null function is called. |
jbkim | 0:2513c6696bdc | 251 | */ |
jbkim | 0:2513c6696bdc | 252 | void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); |
jbkim | 0:2513c6696bdc | 253 | |
jbkim | 0:2513c6696bdc | 254 | /** |
jbkim | 0:2513c6696bdc | 255 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 256 | * @brief Controls to the WIZCHIP. |
jbkim | 0:2513c6696bdc | 257 | * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), |
jbkim | 0:2513c6696bdc | 258 | * controls interrupt & mask and so on. |
jbkim | 0:2513c6696bdc | 259 | * @param cwtype : Decides to the control type |
jbkim | 0:2513c6696bdc | 260 | * @param arg : arg type is dependent on cwtype. |
jbkim | 0:2513c6696bdc | 261 | * @return 0 : Success \n |
jbkim | 0:2513c6696bdc | 262 | * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP |
jbkim | 0:2513c6696bdc | 263 | */ |
jbkim | 0:2513c6696bdc | 264 | int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); |
jbkim | 0:2513c6696bdc | 265 | |
jbkim | 0:2513c6696bdc | 266 | /** |
jbkim | 0:2513c6696bdc | 267 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 268 | * @brief Controls to network. |
jbkim | 0:2513c6696bdc | 269 | * @details Controls to network environment, mode, timeout and so on. |
jbkim | 0:2513c6696bdc | 270 | * @param cntype : Input. Decides to the control type |
jbkim | 0:2513c6696bdc | 271 | * @param arg : Inout. arg type is dependent on cntype. |
jbkim | 0:2513c6696bdc | 272 | * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n |
jbkim | 0:2513c6696bdc | 273 | * 0 : Success |
jbkim | 0:2513c6696bdc | 274 | */ |
jbkim | 0:2513c6696bdc | 275 | int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); |
jbkim | 0:2513c6696bdc | 276 | |
jbkim | 0:2513c6696bdc | 277 | |
jbkim | 0:2513c6696bdc | 278 | /* |
jbkim | 0:2513c6696bdc | 279 | * The following functions are implemented for internal use. |
jbkim | 0:2513c6696bdc | 280 | * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). |
jbkim | 0:2513c6696bdc | 281 | */ |
jbkim | 0:2513c6696bdc | 282 | |
jbkim | 0:2513c6696bdc | 283 | /** |
jbkim | 0:2513c6696bdc | 284 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 285 | * @brief Reset WIZCHIP by softly. |
jbkim | 0:2513c6696bdc | 286 | */ |
jbkim | 0:2513c6696bdc | 287 | void wizchip_sw_reset(void); |
jbkim | 0:2513c6696bdc | 288 | |
jbkim | 0:2513c6696bdc | 289 | /** |
jbkim | 0:2513c6696bdc | 290 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 291 | * @brief Initializes WIZCHIP with socket buffer size |
jbkim | 0:2513c6696bdc | 292 | * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. |
jbkim | 0:2513c6696bdc | 293 | * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. |
jbkim | 0:2513c6696bdc | 294 | * @return 0 : succcess \n |
jbkim | 0:2513c6696bdc | 295 | * -1 : fail. Invalid buffer size |
jbkim | 0:2513c6696bdc | 296 | */ |
jbkim | 0:2513c6696bdc | 297 | int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); |
jbkim | 0:2513c6696bdc | 298 | |
jbkim | 0:2513c6696bdc | 299 | /** |
jbkim | 0:2513c6696bdc | 300 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 301 | * @brief Clear Interrupt of WIZCHIP. |
jbkim | 0:2513c6696bdc | 302 | * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. |
jbkim | 0:2513c6696bdc | 303 | */ |
jbkim | 0:2513c6696bdc | 304 | void wizchip_clrinterrupt(intr_kind intr); |
jbkim | 0:2513c6696bdc | 305 | |
jbkim | 0:2513c6696bdc | 306 | /** |
jbkim | 0:2513c6696bdc | 307 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 308 | * @brief Get Interrupt of WIZCHIP. |
jbkim | 0:2513c6696bdc | 309 | * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. |
jbkim | 0:2513c6696bdc | 310 | */ |
jbkim | 0:2513c6696bdc | 311 | intr_kind wizchip_getinterrupt(void); |
jbkim | 0:2513c6696bdc | 312 | |
jbkim | 0:2513c6696bdc | 313 | /** |
jbkim | 0:2513c6696bdc | 314 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 315 | * @brief Mask or Unmask Interrupt of WIZCHIP. |
jbkim | 0:2513c6696bdc | 316 | * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. |
jbkim | 0:2513c6696bdc | 317 | */ |
jbkim | 0:2513c6696bdc | 318 | void wizchip_setinterruptmask(intr_kind intr); |
jbkim | 0:2513c6696bdc | 319 | |
jbkim | 0:2513c6696bdc | 320 | /** |
jbkim | 0:2513c6696bdc | 321 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 322 | * @brief Get Interrupt mask of WIZCHIP. |
jbkim | 0:2513c6696bdc | 323 | * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. |
jbkim | 0:2513c6696bdc | 324 | */ |
jbkim | 0:2513c6696bdc | 325 | intr_kind wizchip_getinterruptmask(void); |
jbkim | 0:2513c6696bdc | 326 | |
jbkim | 0:2513c6696bdc | 327 | int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 |
jbkim | 0:2513c6696bdc | 328 | int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 |
jbkim | 0:2513c6696bdc | 329 | |
jbkim | 0:2513c6696bdc | 330 | void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 |
jbkim | 0:2513c6696bdc | 331 | /** |
jbkim | 0:2513c6696bdc | 332 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 333 | * @brief Set the phy information for WIZCHIP without power mode |
jbkim | 0:2513c6696bdc | 334 | * @param phyconf : @ref wiz_PhyConf |
jbkim | 0:2513c6696bdc | 335 | */ |
jbkim | 0:2513c6696bdc | 336 | void wizphy_setphyconf(wiz_PhyConf* phyconf); |
jbkim | 0:2513c6696bdc | 337 | /** |
jbkim | 0:2513c6696bdc | 338 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 339 | * @brief Get phy configuration information. |
jbkim | 0:2513c6696bdc | 340 | * @param phyconf : @ref wiz_PhyConf |
jbkim | 0:2513c6696bdc | 341 | */ |
jbkim | 0:2513c6696bdc | 342 | void wizphy_getphyconf(wiz_PhyConf* phyconf); |
jbkim | 0:2513c6696bdc | 343 | /** |
jbkim | 0:2513c6696bdc | 344 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 345 | * @brief Get phy status. |
jbkim | 0:2513c6696bdc | 346 | * @param phyconf : @ref wiz_PhyConf |
jbkim | 0:2513c6696bdc | 347 | */ |
jbkim | 0:2513c6696bdc | 348 | void wizphy_getphystat(wiz_PhyConf* phyconf); |
jbkim | 0:2513c6696bdc | 349 | /** |
jbkim | 0:2513c6696bdc | 350 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 351 | * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 |
jbkim | 0:2513c6696bdc | 352 | * @param pmode Settig value of power down mode. |
jbkim | 0:2513c6696bdc | 353 | */ |
jbkim | 0:2513c6696bdc | 354 | int8_t wizphy_setphypmode(uint8_t pmode); |
jbkim | 0:2513c6696bdc | 355 | |
jbkim | 0:2513c6696bdc | 356 | /** |
jbkim | 0:2513c6696bdc | 357 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 358 | * @brief Set the network information for WIZCHIP |
jbkim | 0:2513c6696bdc | 359 | * @param pnetinfo : @ref wizNetInfo |
jbkim | 0:2513c6696bdc | 360 | */ |
jbkim | 0:2513c6696bdc | 361 | void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); |
jbkim | 0:2513c6696bdc | 362 | |
jbkim | 0:2513c6696bdc | 363 | /** |
jbkim | 0:2513c6696bdc | 364 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 365 | * @brief Get the network information for WIZCHIP |
jbkim | 0:2513c6696bdc | 366 | * @param pnetinfo : @ref wizNetInfo |
jbkim | 0:2513c6696bdc | 367 | */ |
jbkim | 0:2513c6696bdc | 368 | void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); |
jbkim | 0:2513c6696bdc | 369 | |
jbkim | 0:2513c6696bdc | 370 | /** |
jbkim | 0:2513c6696bdc | 371 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 372 | * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. |
jbkim | 0:2513c6696bdc | 373 | * @param pnetinfo Value of network mode. Refer to @ref netmode_type. |
jbkim | 0:2513c6696bdc | 374 | */ |
jbkim | 0:2513c6696bdc | 375 | int8_t wizchip_setnetmode(netmode_type netmode); |
jbkim | 0:2513c6696bdc | 376 | |
jbkim | 0:2513c6696bdc | 377 | /** |
jbkim | 0:2513c6696bdc | 378 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 379 | * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. |
jbkim | 0:2513c6696bdc | 380 | * @return Value of network mode. Refer to @ref netmode_type. |
jbkim | 0:2513c6696bdc | 381 | */ |
jbkim | 0:2513c6696bdc | 382 | netmode_type wizchip_getnetmode(void); |
jbkim | 0:2513c6696bdc | 383 | |
jbkim | 0:2513c6696bdc | 384 | /** |
jbkim | 0:2513c6696bdc | 385 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 386 | * @brief Set retry time value(@ref RTR) and retry count(@ref RCR). |
jbkim | 0:2513c6696bdc | 387 | * @details @ref RTR configures the retransmission timeout period and @ref RCR configures the number of time of retransmission. |
jbkim | 0:2513c6696bdc | 388 | * @param nettime @ref RTR value and @ref RCR value. Refer to @ref wiz_NetTimeout. |
jbkim | 0:2513c6696bdc | 389 | */ |
jbkim | 0:2513c6696bdc | 390 | void wizchip_settimeout(wiz_NetTimeout* nettime); |
jbkim | 0:2513c6696bdc | 391 | |
jbkim | 0:2513c6696bdc | 392 | /** |
jbkim | 0:2513c6696bdc | 393 | * @ingroup extra_functions |
jbkim | 0:2513c6696bdc | 394 | * @brief Get retry time value(@ref RTR) and retry count(@ref RCR). |
jbkim | 0:2513c6696bdc | 395 | * @details @ref RTR configures the retransmission timeout period and @ref RCR configures the number of time of retransmission. |
jbkim | 0:2513c6696bdc | 396 | * @param nettime @ref RTR value and @ref RCR value. Refer to @ref wiz_NetTimeout. |
jbkim | 0:2513c6696bdc | 397 | */ |
jbkim | 0:2513c6696bdc | 398 | void wizchip_gettimeout(wiz_NetTimeout* nettime); |
jbkim | 0:2513c6696bdc | 399 | |
jbkim | 0:2513c6696bdc | 400 | #endif // _WIZCHIP_CONF_H_ |
jbkim | 0:2513c6696bdc | 401 | |
jbkim | 0:2513c6696bdc | 402 | #ifdef __cplusplus |
jbkim | 0:2513c6696bdc | 403 | } |
jbkim | 0:2513c6696bdc | 404 | #endif |