Wiznet W5500 driver and TCP/UDP loopback

Dependencies:   mbed

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?

UserRevisionLine numberNew 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 #ifndef _W5500_H_
jbkim 0:2513c6696bdc 19 #define _W5500_H_
jbkim 0:2513c6696bdc 20
jbkim 0:2513c6696bdc 21 #include <stdint.h>
jbkim 0:2513c6696bdc 22 #include "Ethernet/wizchip_conf.h"
jbkim 0:2513c6696bdc 23
jbkim 0:2513c6696bdc 24 #define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase
jbkim 0:2513c6696bdc 25 #define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase
jbkim 0:2513c6696bdc 26
jbkim 0:2513c6696bdc 27 #define WIZCHIP_CREG_BLOCK 0x00 //< Common register block
jbkim 0:2513c6696bdc 28 #define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block
jbkim 0:2513c6696bdc 29 #define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block
jbkim 0:2513c6696bdc 30 #define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block
jbkim 0:2513c6696bdc 31
jbkim 0:2513c6696bdc 32 #define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address
jbkim 0:2513c6696bdc 33
jbkim 0:2513c6696bdc 34
jbkim 0:2513c6696bdc 35
jbkim 0:2513c6696bdc 36 //////////////////////////////
jbkim 0:2513c6696bdc 37 //-------------------------- defgroup ---------------------------------
jbkim 0:2513c6696bdc 38 /**
jbkim 0:2513c6696bdc 39 * @defgroup W5500 W5500
jbkim 0:2513c6696bdc 40 *
jbkim 0:2513c6696bdc 41 * @brief WHIZCHIP register defines and I/O functions of @b W5500.
jbkim 0:2513c6696bdc 42 *
jbkim 0:2513c6696bdc 43 * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group
jbkim 0:2513c6696bdc 44 * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function
jbkim 0:2513c6696bdc 45 */
jbkim 0:2513c6696bdc 46
jbkim 0:2513c6696bdc 47
jbkim 0:2513c6696bdc 48 /**
jbkim 0:2513c6696bdc 49 * @defgroup WIZCHIP_register WIZCHIP register
jbkim 0:2513c6696bdc 50 * @ingroup W5500
jbkim 0:2513c6696bdc 51 *
jbkim 0:2513c6696bdc 52 * @brief WHIZCHIP register defines register group of @b W5500.
jbkim 0:2513c6696bdc 53 *
jbkim 0:2513c6696bdc 54 * - @ref Common_register_group : Common register group
jbkim 0:2513c6696bdc 55 * - @ref Socket_register_group : \c SOCKET n register group
jbkim 0:2513c6696bdc 56 */
jbkim 0:2513c6696bdc 57
jbkim 0:2513c6696bdc 58
jbkim 0:2513c6696bdc 59 /**
jbkim 0:2513c6696bdc 60 * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions
jbkim 0:2513c6696bdc 61 * @ingroup W5500
jbkim 0:2513c6696bdc 62 *
jbkim 0:2513c6696bdc 63 * @brief This supports the basic I/O functions for @ref WIZCHIP_register.
jbkim 0:2513c6696bdc 64 *
jbkim 0:2513c6696bdc 65 * - <b> Basic I/O function </b> \n
jbkim 0:2513c6696bdc 66 * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n
jbkim 0:2513c6696bdc 67 *
jbkim 0:2513c6696bdc 68 * - @ref Common_register_group <b>access functions</b> \n
jbkim 0:2513c6696bdc 69 * -# @b Mode \n
jbkim 0:2513c6696bdc 70 * getMR(), setMR()
jbkim 0:2513c6696bdc 71 * -# @b Interrupt \n
jbkim 0:2513c6696bdc 72 * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL()
jbkim 0:2513c6696bdc 73 * -# <b> Network Information </b> \n
jbkim 0:2513c6696bdc 74 * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR()
jbkim 0:2513c6696bdc 75 * -# @b Retransmission \n
jbkim 0:2513c6696bdc 76 * getRCR(), setRCR(), getRTR(), setRTR()
jbkim 0:2513c6696bdc 77 * -# @b PPPoE \n
jbkim 0:2513c6696bdc 78 * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU()
jbkim 0:2513c6696bdc 79 * -# <b> ICMP packet </b>\n
jbkim 0:2513c6696bdc 80 * getUIPR(), getUPORTR()
jbkim 0:2513c6696bdc 81 * -# @b etc. \n
jbkim 0:2513c6696bdc 82 * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n
jbkim 0:2513c6696bdc 83 *
jbkim 0:2513c6696bdc 84 * - \ref Socket_register_group <b>access functions</b> \n
jbkim 0:2513c6696bdc 85 * -# <b> SOCKET control</b> \n
jbkim 0:2513c6696bdc 86 * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR()
jbkim 0:2513c6696bdc 87 * -# <b> SOCKET information</b> \n
jbkim 0:2513c6696bdc 88 * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT()
jbkim 0:2513c6696bdc 89 * getSn_MSSR(), setSn_MSSR()
jbkim 0:2513c6696bdc 90 * -# <b> SOCKET communication </b> \n
jbkim 0:2513c6696bdc 91 * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n
jbkim 0:2513c6696bdc 92 * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n
jbkim 0:2513c6696bdc 93 * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n
jbkim 0:2513c6696bdc 94 * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR()
jbkim 0:2513c6696bdc 95 * -# <b> IP header field </b> \n
jbkim 0:2513c6696bdc 96 * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n
jbkim 0:2513c6696bdc 97 * getSn_TTL(), setSn_TTL()
jbkim 0:2513c6696bdc 98 */
jbkim 0:2513c6696bdc 99
jbkim 0:2513c6696bdc 100
jbkim 0:2513c6696bdc 101
jbkim 0:2513c6696bdc 102 /**
jbkim 0:2513c6696bdc 103 * @defgroup Common_register_group Common register
jbkim 0:2513c6696bdc 104 * @ingroup WIZCHIP_register
jbkim 0:2513c6696bdc 105 *
jbkim 0:2513c6696bdc 106 * @brief Common register group\n
jbkim 0:2513c6696bdc 107 * It set the basic for the networking\n
jbkim 0:2513c6696bdc 108 * It set the configuration such as interrupt, network information, ICMP, etc.
jbkim 0:2513c6696bdc 109 * @details
jbkim 0:2513c6696bdc 110 * @sa MR : Mode register.
jbkim 0:2513c6696bdc 111 * @sa GAR, SUBR, SHAR, SIPR
jbkim 0:2513c6696bdc 112 * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt.
jbkim 0:2513c6696bdc 113 * @sa RTR, RCR : Data retransmission.
jbkim 0:2513c6696bdc 114 * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE.
jbkim 0:2513c6696bdc 115 * @sa UIPR, UPORTR : ICMP message.
jbkim 0:2513c6696bdc 116 * @sa PHYCFGR, VERSIONR : etc.
jbkim 0:2513c6696bdc 117 */
jbkim 0:2513c6696bdc 118
jbkim 0:2513c6696bdc 119
jbkim 0:2513c6696bdc 120
jbkim 0:2513c6696bdc 121 /**
jbkim 0:2513c6696bdc 122 * @defgroup Socket_register_group Socket register
jbkim 0:2513c6696bdc 123 * @ingroup WIZCHIP_register
jbkim 0:2513c6696bdc 124 *
jbkim 0:2513c6696bdc 125 * @brief Socket register group.\n
jbkim 0:2513c6696bdc 126 * Socket register configures and control SOCKETn which is necessary to data communication.
jbkim 0:2513c6696bdc 127 * @details
jbkim 0:2513c6696bdc 128 * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control
jbkim 0:2513c6696bdc 129 * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information
jbkim 0:2513c6696bdc 130 * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol.
jbkim 0:2513c6696bdc 131 * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication
jbkim 0:2513c6696bdc 132 */
jbkim 0:2513c6696bdc 133
jbkim 0:2513c6696bdc 134
jbkim 0:2513c6696bdc 135
jbkim 0:2513c6696bdc 136 /**
jbkim 0:2513c6696bdc 137 * @defgroup Basic_IO_function Basic I/O function
jbkim 0:2513c6696bdc 138 * @ingroup WIZCHIP_IO_Functions
jbkim 0:2513c6696bdc 139 * @brief These are basic input/output functions to read values from register or write values to register.
jbkim 0:2513c6696bdc 140 */
jbkim 0:2513c6696bdc 141
jbkim 0:2513c6696bdc 142 /**
jbkim 0:2513c6696bdc 143 * @defgroup Common_register_access_function Common register access functions
jbkim 0:2513c6696bdc 144 * @ingroup WIZCHIP_IO_Functions
jbkim 0:2513c6696bdc 145 * @brief These are functions to access <b>common registers</b>.
jbkim 0:2513c6696bdc 146 */
jbkim 0:2513c6696bdc 147
jbkim 0:2513c6696bdc 148 /**
jbkim 0:2513c6696bdc 149 * @defgroup Socket_register_access_function Socket register access functions
jbkim 0:2513c6696bdc 150 * @ingroup WIZCHIP_IO_Functions
jbkim 0:2513c6696bdc 151 * @brief These are functions to access <b>socket registers</b>.
jbkim 0:2513c6696bdc 152 */
jbkim 0:2513c6696bdc 153
jbkim 0:2513c6696bdc 154 //------------------------------- defgroup end --------------------------------------------
jbkim 0:2513c6696bdc 155 //----------------------------- W5500 Common Registers IOMAP -----------------------------
jbkim 0:2513c6696bdc 156 /**
jbkim 0:2513c6696bdc 157 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 158 * @brief Mode Register address(R/W)\n
jbkim 0:2513c6696bdc 159 * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc.
jbkim 0:2513c6696bdc 160 * @details Each bit of @ref MR defined as follows.
jbkim 0:2513c6696bdc 161 * <table>
jbkim 0:2513c6696bdc 162 * <tr> <td>7</td> <td>6</td> <td>5</td> <td>4</td> <td>3</td> <td>2</td> <td>1</td> <td>0</td> </tr>
jbkim 0:2513c6696bdc 163 * <tr> <td>RST</td> <td>Reserved</td> <td>WOL</td> <td>PB</td> <td>PPPoE</td> <td>Reserved</td> <td>FARP</td> <td>Reserved</td> </tr>
jbkim 0:2513c6696bdc 164 * </table>
jbkim 0:2513c6696bdc 165 * - \ref MR_RST : Reset
jbkim 0:2513c6696bdc 166 * - \ref MR_WOL : Wake on LAN
jbkim 0:2513c6696bdc 167 * - \ref MR_PB : Ping block
jbkim 0:2513c6696bdc 168 * - \ref MR_PPPOE : PPPoE mode
jbkim 0:2513c6696bdc 169 * - \ref MR_FARP : Force ARP mode
jbkim 0:2513c6696bdc 170 */
jbkim 0:2513c6696bdc 171 #define MR ( (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 172
jbkim 0:2513c6696bdc 173 /**
jbkim 0:2513c6696bdc 174 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 175 * @brief Gateway IP Register address(R/W)
jbkim 0:2513c6696bdc 176 * @details @ref GAR configures the default gateway address.
jbkim 0:2513c6696bdc 177 */
jbkim 0:2513c6696bdc 178 #define GAR ( (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 179
jbkim 0:2513c6696bdc 180 /**
jbkim 0:2513c6696bdc 181 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 182 * @brief Subnet mask Register address(R/W)
jbkim 0:2513c6696bdc 183 * @details @ref SUBR configures the subnet mask address.
jbkim 0:2513c6696bdc 184 */
jbkim 0:2513c6696bdc 185 #define SUBR ( (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 186
jbkim 0:2513c6696bdc 187 /**
jbkim 0:2513c6696bdc 188 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 189 * @brief Source MAC Register address(R/W)
jbkim 0:2513c6696bdc 190 * @details @ref SHAR configures the source hardware address.
jbkim 0:2513c6696bdc 191 */
jbkim 0:2513c6696bdc 192 #define SHAR ( (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 193
jbkim 0:2513c6696bdc 194 /**
jbkim 0:2513c6696bdc 195 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 196 * @brief Source IP Register address(R/W)
jbkim 0:2513c6696bdc 197 * @details @ref SIPR configures the source IP address.
jbkim 0:2513c6696bdc 198 */
jbkim 0:2513c6696bdc 199 #define SIPR ( (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 200
jbkim 0:2513c6696bdc 201 /**
jbkim 0:2513c6696bdc 202 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 203 * @brief Set Interrupt low level timer register address(R/W)
jbkim 0:2513c6696bdc 204 * @details @ref INTLEVEL configures the Interrupt Assert Time.
jbkim 0:2513c6696bdc 205 */
jbkim 0:2513c6696bdc 206 #define INTLEVEL ( (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 207
jbkim 0:2513c6696bdc 208 /**
jbkim 0:2513c6696bdc 209 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 210 * @brief Interrupt Register(R/W)
jbkim 0:2513c6696bdc 211 * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host.
jbkim 0:2513c6696bdc 212 * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n
jbkim 0:2513c6696bdc 213 * Each bit of @ref IR defined as follows.
jbkim 0:2513c6696bdc 214 * <table>
jbkim 0:2513c6696bdc 215 * <tr> <td>7</td> <td>6</td> <td>5</td> <td>4</td> <td>3</td> <td>2</td> <td>1</td> <td>0</td> </tr>
jbkim 0:2513c6696bdc 216 * <tr> <td>CONFLICT</td> <td>UNREACH</td> <td>PPPoE</td> <td>MP</td> <td>Reserved</td> <td>Reserved</td> <td>Reserved</td> <td>Reserved</td> </tr>
jbkim 0:2513c6696bdc 217 * </table>
jbkim 0:2513c6696bdc 218 * - \ref IR_CONFLICT : IP conflict
jbkim 0:2513c6696bdc 219 * - \ref IR_UNREACH : Destination unreachable
jbkim 0:2513c6696bdc 220 * - \ref IR_PPPoE : PPPoE connection close
jbkim 0:2513c6696bdc 221 * - \ref IR_MP : Magic packet
jbkim 0:2513c6696bdc 222 */
jbkim 0:2513c6696bdc 223 #define IR ( (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 224
jbkim 0:2513c6696bdc 225 /**
jbkim 0:2513c6696bdc 226 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 227 * @brief Interrupt mask register(R/W)
jbkim 0:2513c6696bdc 228 * @details @ref IMR is used to mask interrupts. Each bit of @ref IMR corresponds to each bit of @ref IR.
jbkim 0:2513c6696bdc 229 * When a bit of @ref IMR is and the corresponding bit of @ref IR is an interrupt will be issued. In other words,
jbkim 0:2513c6696bdc 230 * if a bit of @ref IMR is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n
jbkim 0:2513c6696bdc 231 * Each bit of @ref IMR defined as the following.
jbkim 0:2513c6696bdc 232 * <table>
jbkim 0:2513c6696bdc 233 * <tr> <td>7</td> <td>6</td> <td>5</td> <td>4</td> <td>3</td> <td>2</td> <td>1</td> <td>0</td> </tr>
jbkim 0:2513c6696bdc 234 * <tr> <td>IM_IR7</td> <td>IM_IR6</td> <td>IM_IR5</td> <td>IM_IR4</td> <td>Reserved</td> <td>Reserved</td> <td>Reserved</td> <td>Reserved</td> </tr>
jbkim 0:2513c6696bdc 235 * </table>
jbkim 0:2513c6696bdc 236 * - \ref IM_IR7 : IP Conflict Interrupt Mask
jbkim 0:2513c6696bdc 237 * - \ref IM_IR6 : Destination unreachable Interrupt Mask
jbkim 0:2513c6696bdc 238 * - \ref IM_IR5 : PPPoE Close Interrupt Mask
jbkim 0:2513c6696bdc 239 * - \ref IM_IR4 : Magic Packet Interrupt Mask
jbkim 0:2513c6696bdc 240 */
jbkim 0:2513c6696bdc 241 #define IMR ( (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 242
jbkim 0:2513c6696bdc 243 /**
jbkim 0:2513c6696bdc 244 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 245 * @brief Socket Interrupt Register(R/W)
jbkim 0:2513c6696bdc 246 * @details @ref SIR indicates the interrupt status of Socket.\n
jbkim 0:2513c6696bdc 247 * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n
jbkim 0:2513c6696bdc 248 * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */
jbkim 0:2513c6696bdc 249 #define SIR ( (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 250
jbkim 0:2513c6696bdc 251 /**
jbkim 0:2513c6696bdc 252 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 253 * @brief Socket Interrupt Mask Register(R/W)
jbkim 0:2513c6696bdc 254 * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR.
jbkim 0:2513c6696bdc 255 * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued.
jbkim 0:2513c6696bdc 256 * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is
jbkim 0:2513c6696bdc 257 */
jbkim 0:2513c6696bdc 258 #define SIMR ( (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 259
jbkim 0:2513c6696bdc 260 /**
jbkim 0:2513c6696bdc 261 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 262 * @brief Timeout register address( 1 is 100us )(R/W)
jbkim 0:2513c6696bdc 263 * @details @ref RTR configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref RTR is x07D0or 000
jbkim 0:2513c6696bdc 264 * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref RTR, W5500 waits for the peer response
jbkim 0:2513c6696bdc 265 * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command).
jbkim 0:2513c6696bdc 266 * If the peer does not respond within the @ref RTR time, W5500 retransmits the packet or issues timeout.
jbkim 0:2513c6696bdc 267 */
jbkim 0:2513c6696bdc 268 #define RTR ( (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 269
jbkim 0:2513c6696bdc 270 /**
jbkim 0:2513c6696bdc 271 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 272 * @brief Retry count register(R/W)
jbkim 0:2513c6696bdc 273 * @details @ref RCR configures the number of time of retransmission.
jbkim 0:2513c6696bdc 274 * When retransmission occurs as many as ref RCR+1 Timeout interrupt is issued (@ref Sn_IR[TIMEOUT] = .
jbkim 0:2513c6696bdc 275 */
jbkim 0:2513c6696bdc 276 #define RCR ( (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 277
jbkim 0:2513c6696bdc 278 /**
jbkim 0:2513c6696bdc 279 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 280 * @brief PPP LCP Request Timer register in PPPoE mode(R/W)
jbkim 0:2513c6696bdc 281 * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms.
jbkim 0:2513c6696bdc 282 */
jbkim 0:2513c6696bdc 283 #define PTIMER ( (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 284
jbkim 0:2513c6696bdc 285 /**
jbkim 0:2513c6696bdc 286 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 287 * @brief PPP LCP Magic number register in PPPoE mode(R/W)
jbkim 0:2513c6696bdc 288 * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation.
jbkim 0:2513c6696bdc 289 */
jbkim 0:2513c6696bdc 290 #define PMAGIC ( (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 291
jbkim 0:2513c6696bdc 292 /**
jbkim 0:2513c6696bdc 293 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 294 * @brief PPP Destination MAC Register address(R/W)
jbkim 0:2513c6696bdc 295 * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process.
jbkim 0:2513c6696bdc 296 */
jbkim 0:2513c6696bdc 297 #define PHAR ( (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 298
jbkim 0:2513c6696bdc 299 /**
jbkim 0:2513c6696bdc 300 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 301 * @brief PPP Session Identification Register(R/W)
jbkim 0:2513c6696bdc 302 * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process.
jbkim 0:2513c6696bdc 303 */
jbkim 0:2513c6696bdc 304 #define PSID ( (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 305
jbkim 0:2513c6696bdc 306 /**
jbkim 0:2513c6696bdc 307 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 308 * @brief PPP Maximum Segment Size(MSS) register(R/W)
jbkim 0:2513c6696bdc 309 * @details @ref PMRU configures the maximum receive unit of PPPoE.
jbkim 0:2513c6696bdc 310 */
jbkim 0:2513c6696bdc 311 #define PMRU ( (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 312
jbkim 0:2513c6696bdc 313 /**
jbkim 0:2513c6696bdc 314 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 315 * @brief Unreachable IP register address in UDP mode(R)
jbkim 0:2513c6696bdc 316 * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number
jbkim 0:2513c6696bdc 317 * which socket is not open and @ref UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates
jbkim 0:2513c6696bdc 318 * the destination IP address & port number respectively.
jbkim 0:2513c6696bdc 319 */
jbkim 0:2513c6696bdc 320 #define UIPR ( (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 321
jbkim 0:2513c6696bdc 322 /**
jbkim 0:2513c6696bdc 323 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 324 * @brief Unreachable Port register address in UDP mode(R)
jbkim 0:2513c6696bdc 325 * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number
jbkim 0:2513c6696bdc 326 * which socket is not open and @ref UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR
jbkim 0:2513c6696bdc 327 * indicates the destination IP address & port number respectively.
jbkim 0:2513c6696bdc 328 */
jbkim 0:2513c6696bdc 329 #define UPORTR ( (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 330
jbkim 0:2513c6696bdc 331 /**
jbkim 0:2513c6696bdc 332 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 333 * @brief PHY Status Register(R/W)
jbkim 0:2513c6696bdc 334 * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link.
jbkim 0:2513c6696bdc 335 */
jbkim 0:2513c6696bdc 336 #define PHYCFGR ( (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 337
jbkim 0:2513c6696bdc 338 // Reserved ( (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 339 // Reserved ( (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 340 // Reserved ( (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 341 // Reserved ( (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 342 // Reserved ( (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 343 // Reserved ( (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 344 // Reserved ( (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 345 // Reserved ( (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 346 // Reserved ( (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 347 // Reserved ( (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 348
jbkim 0:2513c6696bdc 349 /**
jbkim 0:2513c6696bdc 350 * @ingroup Common_register_group
jbkim 0:2513c6696bdc 351 * @brief chip version register address(R)
jbkim 0:2513c6696bdc 352 * @details @ref VERSIONR always indicates the W5500 version as @b 0x04.
jbkim 0:2513c6696bdc 353 */
jbkim 0:2513c6696bdc 354 #define VERSIONR ( (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3))
jbkim 0:2513c6696bdc 355
jbkim 0:2513c6696bdc 356
jbkim 0:2513c6696bdc 357 //----------------------------- W5500 Socket Registers IOMAP -----------------------------
jbkim 0:2513c6696bdc 358 /**
jbkim 0:2513c6696bdc 359 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 360 * @brief socket Mode register(R/W)
jbkim 0:2513c6696bdc 361 * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n
jbkim 0:2513c6696bdc 362 * Each bit of @ref Sn_MR defined as the following.
jbkim 0:2513c6696bdc 363 * <table>
jbkim 0:2513c6696bdc 364 * <tr> <td>7</td> <td>6</td> <td>5</td> <td>4</td> <td>3</td> <td>2</td> <td>1</td> <td>0</td> </tr>
jbkim 0:2513c6696bdc 365 * <tr> <td>MULTI/MFEN</td> <td>BCASTB</td> <td>ND/MC/MMB</td> <td>UCASTB/MIP6B</td> <td>Protocol[3]</td> <td>Protocol[2]</td> <td>Protocol[1]</td> <td>Protocol[0]</td> </tr>
jbkim 0:2513c6696bdc 366 * </table>
jbkim 0:2513c6696bdc 367 * - @ref Sn_MR_MULTI : Support UDP Multicasting
jbkim 0:2513c6696bdc 368 * - @ref Sn_MR_BCASTB : Broadcast block <b>in UDP Multicasting</b>
jbkim 0:2513c6696bdc 369 * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag
jbkim 0:2513c6696bdc 370 * - @ref Sn_MR_MC : IGMP version used <b>in UDP mulitcasting</b>
jbkim 0:2513c6696bdc 371 * - @ref Sn_MR_MMB : Multicast Blocking <b>in @ref Sn_MR_MACRAW mode</b>
jbkim 0:2513c6696bdc 372 * - @ref Sn_MR_UCASTB : Unicast Block <b>in UDP Multicating</b>
jbkim 0:2513c6696bdc 373 * - @ref Sn_MR_MIP6B : IPv6 packet Blocking <b>in @ref Sn_MR_MACRAW mode</b>
jbkim 0:2513c6696bdc 374 * - <b>Protocol</b>
jbkim 0:2513c6696bdc 375 * <table>
jbkim 0:2513c6696bdc 376 * <tr> <td><b>Protocol[3]</b></td> <td><b>Protocol[2]</b></td> <td><b>Protocol[1]</b></td> <td><b>Protocol[0]</b></td> <td>@b Meaning</td> </tr>
jbkim 0:2513c6696bdc 377 * <tr> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>Closed</td> </tr>
jbkim 0:2513c6696bdc 378 * <tr> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>TCP</td> </tr>
jbkim 0:2513c6696bdc 379 * <tr> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>UDP</td> </tr>
jbkim 0:2513c6696bdc 380 * <tr> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>MACRAW</td> </tr>
jbkim 0:2513c6696bdc 381 * </table>
jbkim 0:2513c6696bdc 382 * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n
jbkim 0:2513c6696bdc 383 * - @ref Sn_MR_UDP : UDP
jbkim 0:2513c6696bdc 384 * - @ref Sn_MR_TCP : TCP
jbkim 0:2513c6696bdc 385 * - @ref Sn_MR_CLOSE : Unused socket
jbkim 0:2513c6696bdc 386 * @note MACRAW mode should be only used in Socket 0.
jbkim 0:2513c6696bdc 387 */
jbkim 0:2513c6696bdc 388 #define Sn_MR(N) ( (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 389
jbkim 0:2513c6696bdc 390 /**
jbkim 0:2513c6696bdc 391 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 392 * @brief Socket command register(R/W)
jbkim 0:2513c6696bdc 393 * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n
jbkim 0:2513c6696bdc 394 * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00.
jbkim 0:2513c6696bdc 395 * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n
jbkim 0:2513c6696bdc 396 * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR.
jbkim 0:2513c6696bdc 397 * - @ref Sn_CR_OPEN : Initialize or open socket.
jbkim 0:2513c6696bdc 398 * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(<b>Server mode</b>)
jbkim 0:2513c6696bdc 399 * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(<b>Client mode</b>)
jbkim 0:2513c6696bdc 400 * - @ref Sn_CR_DISCON : Send closing request in TCP mode.
jbkim 0:2513c6696bdc 401 * - @ref Sn_CR_CLOSE : Close socket.
jbkim 0:2513c6696bdc 402 * - @ref Sn_CR_SEND : Update TX buffer pointer and send data.
jbkim 0:2513c6696bdc 403 * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process.
jbkim 0:2513c6696bdc 404 * - @ref Sn_CR_SEND_KEEP : Send keep alive message.
jbkim 0:2513c6696bdc 405 * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data.
jbkim 0:2513c6696bdc 406 */
jbkim 0:2513c6696bdc 407 #define Sn_CR(N) ( (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 408
jbkim 0:2513c6696bdc 409 /**
jbkim 0:2513c6696bdc 410 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 411 * @brief Socket interrupt register(R)
jbkim 0:2513c6696bdc 412 * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n
jbkim 0:2513c6696bdc 413 * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n
jbkim 0:2513c6696bdc 414 * In order to clear the @ref Sn_IR bit, the host should write the bit to \n
jbkim 0:2513c6696bdc 415 * <table>
jbkim 0:2513c6696bdc 416 * <tr> <td>7</td> <td>6</td> <td>5</td> <td>4</td> <td>3</td> <td>2</td> <td>1</td> <td>0</td> </tr>
jbkim 0:2513c6696bdc 417 * <tr> <td>Reserved</td> <td>Reserved</td> <td>Reserved</td> <td>SEND_OK</td> <td>TIMEOUT</td> <td>RECV</td> <td>DISCON</td> <td>CON</td> </tr>
jbkim 0:2513c6696bdc 418 * </table>
jbkim 0:2513c6696bdc 419 * - \ref Sn_IR_SENDOK : <b>SEND_OK Interrupt</b>
jbkim 0:2513c6696bdc 420 * - \ref Sn_IR_TIMEOUT : <b>TIMEOUT Interrupt</b>
jbkim 0:2513c6696bdc 421 * - \ref Sn_IR_RECV : <b>RECV Interrupt</b>
jbkim 0:2513c6696bdc 422 * - \ref Sn_IR_DISCON : <b>DISCON Interrupt</b>
jbkim 0:2513c6696bdc 423 * - \ref Sn_IR_CON : <b>CON Interrupt</b>
jbkim 0:2513c6696bdc 424 */
jbkim 0:2513c6696bdc 425 #define Sn_IR(N) ( (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 426
jbkim 0:2513c6696bdc 427 /**
jbkim 0:2513c6696bdc 428 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 429 * @brief Socket status register(R)
jbkim 0:2513c6696bdc 430 * @details @ref Sn_SR indicates the status of Socket n.\n
jbkim 0:2513c6696bdc 431 * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP.
jbkim 0:2513c6696bdc 432 * @par Normal status
jbkim 0:2513c6696bdc 433 * - @ref SOCK_CLOSED : Closed
jbkim 0:2513c6696bdc 434 * - @ref SOCK_INIT : Initiate state
jbkim 0:2513c6696bdc 435 * - @ref SOCK_LISTEN : Listen state
jbkim 0:2513c6696bdc 436 * - @ref SOCK_ESTABLISHED : Success to connect
jbkim 0:2513c6696bdc 437 * - @ref SOCK_CLOSE_WAIT : Closing state
jbkim 0:2513c6696bdc 438 * - @ref SOCK_UDP : UDP socket
jbkim 0:2513c6696bdc 439 * - @ref SOCK_MACRAW : MAC raw mode socket
jbkim 0:2513c6696bdc 440 *@par Temporary status during changing the status of Socket n.
jbkim 0:2513c6696bdc 441 * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer.
jbkim 0:2513c6696bdc 442 * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.
jbkim 0:2513c6696bdc 443 * - @ref SOCK_FIN_WAIT : Connection state
jbkim 0:2513c6696bdc 444 * - @ref SOCK_CLOSING : Closing state
jbkim 0:2513c6696bdc 445 * - @ref SOCK_TIME_WAIT : Closing state
jbkim 0:2513c6696bdc 446 * - @ref SOCK_LAST_ACK : Closing state
jbkim 0:2513c6696bdc 447 */
jbkim 0:2513c6696bdc 448 #define Sn_SR(N) ( (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 449
jbkim 0:2513c6696bdc 450 /**
jbkim 0:2513c6696bdc 451 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 452 * @brief source port register(R/W)
jbkim 0:2513c6696bdc 453 * @details @ref Sn_PORT configures the source port number of Socket n.
jbkim 0:2513c6696bdc 454 * It is valid when Socket n is used in TCP/UPD mode. It should be set before OPEN command is ordered.
jbkim 0:2513c6696bdc 455 */
jbkim 0:2513c6696bdc 456 #define Sn_PORT(N) ( (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 457
jbkim 0:2513c6696bdc 458 /**
jbkim 0:2513c6696bdc 459 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 460 * @brief Peer MAC register address(R/W)
jbkim 0:2513c6696bdc 461 * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or
jbkim 0:2513c6696bdc 462 * it indicates that it is acquired in ARP-process by CONNECT/SEND command.
jbkim 0:2513c6696bdc 463 */
jbkim 0:2513c6696bdc 464 #define Sn_DHAR(N) ( (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 465
jbkim 0:2513c6696bdc 466 /**
jbkim 0:2513c6696bdc 467 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 468 * @brief Peer IP register address(R/W)
jbkim 0:2513c6696bdc 469 * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode.
jbkim 0:2513c6696bdc 470 * In TCP client mode, it configures an IP address of �TCP serverbefore CONNECT command.
jbkim 0:2513c6696bdc 471 * In TCP server mode, it indicates an IP address of �TCP clientafter successfully establishing connection.
jbkim 0:2513c6696bdc 472 * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command.
jbkim 0:2513c6696bdc 473 */
jbkim 0:2513c6696bdc 474 #define Sn_DIPR(N) ( (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 475
jbkim 0:2513c6696bdc 476 /**
jbkim 0:2513c6696bdc 477 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 478 * @brief Peer port register address(R/W)
jbkim 0:2513c6696bdc 479 * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode.
jbkim 0:2513c6696bdc 480 * In �TCP clientmode, it configures the listen port number of �TCP serverbefore CONNECT command.
jbkim 0:2513c6696bdc 481 * In �TCP Servermode, it indicates the port number of TCP client after successfully establishing connection.
jbkim 0:2513c6696bdc 482 * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command.
jbkim 0:2513c6696bdc 483 */
jbkim 0:2513c6696bdc 484 #define Sn_DPORT(N) ( (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 485
jbkim 0:2513c6696bdc 486 /**
jbkim 0:2513c6696bdc 487 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 488 * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W)
jbkim 0:2513c6696bdc 489 * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n.
jbkim 0:2513c6696bdc 490 */
jbkim 0:2513c6696bdc 491 #define Sn_MSSR(N) ( (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 492
jbkim 0:2513c6696bdc 493 // Reserved ( (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 494
jbkim 0:2513c6696bdc 495 /**
jbkim 0:2513c6696bdc 496 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 497 * @brief IP Type of Service(TOS) Register(R/W)
jbkim 0:2513c6696bdc 498 * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n.
jbkim 0:2513c6696bdc 499 * It is set before OPEN command.
jbkim 0:2513c6696bdc 500 */
jbkim 0:2513c6696bdc 501 #define Sn_TOS(N) ( (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 502 /**
jbkim 0:2513c6696bdc 503 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 504 * @brief IP Time to live(TTL) Register(R/W)
jbkim 0:2513c6696bdc 505 * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n.
jbkim 0:2513c6696bdc 506 * It is set before OPEN command.
jbkim 0:2513c6696bdc 507 */
jbkim 0:2513c6696bdc 508 #define Sn_TTL(N) ( (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 509 // Reserved ( (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 510 // Reserved ( (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 511 // Reserved ( (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 512 // Reserved ( (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 513 // Reserved ( (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 514 // Reserved ( (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 515 // Reserved ( (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 516
jbkim 0:2513c6696bdc 517 /**
jbkim 0:2513c6696bdc 518 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 519 * @brief Receive memory size register(R/W)
jbkim 0:2513c6696bdc 520 * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n.
jbkim 0:2513c6696bdc 521 * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes.
jbkim 0:2513c6696bdc 522 * If a different size is configured, the data cannot be normally received from a peer.
jbkim 0:2513c6696bdc 523 * Although Socket n RX Buffer Block size is initially configured to 2Kbytes,
jbkim 0:2513c6696bdc 524 * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes.
jbkim 0:2513c6696bdc 525 * When exceeded, the data reception error is occurred.
jbkim 0:2513c6696bdc 526 */
jbkim 0:2513c6696bdc 527 #define Sn_RXBUF_SIZE(N) ( (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 528
jbkim 0:2513c6696bdc 529 /**
jbkim 0:2513c6696bdc 530 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 531 * @brief Transmit memory size register(R/W)
jbkim 0:2513c6696bdc 532 * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes.
jbkim 0:2513c6696bdc 533 * If a different size is configured, the data can�t be normally transmitted to a peer.
jbkim 0:2513c6696bdc 534 * Although Socket n TX Buffer Block size is initially configured to 2Kbytes,
jbkim 0:2513c6696bdc 535 * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes.
jbkim 0:2513c6696bdc 536 * When exceeded, the data transmission error is occurred.
jbkim 0:2513c6696bdc 537 */
jbkim 0:2513c6696bdc 538 #define Sn_TXBUF_SIZE(N) ( (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 539
jbkim 0:2513c6696bdc 540 /**
jbkim 0:2513c6696bdc 541 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 542 * @brief Transmit free memory size register(R)
jbkim 0:2513c6696bdc 543 * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE.
jbkim 0:2513c6696bdc 544 * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent.
jbkim 0:2513c6696bdc 545 * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size,
jbkim 0:2513c6696bdc 546 * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size,
jbkim 0:2513c6696bdc 547 * transmit the data after dividing into the checked size and saving in the Socket n TX buffer.
jbkim 0:2513c6696bdc 548 */
jbkim 0:2513c6696bdc 549 #define Sn_TX_FSR(N) ( (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 550
jbkim 0:2513c6696bdc 551 /**
jbkim 0:2513c6696bdc 552 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 553 * @brief Transmit memory read pointer register address(R)
jbkim 0:2513c6696bdc 554 * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.
jbkim 0:2513c6696bdc 555 * After its initialization, it is auto-increased by SEND command.
jbkim 0:2513c6696bdc 556 * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer.
jbkim 0:2513c6696bdc 557 * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR.
jbkim 0:2513c6696bdc 558 * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs),
jbkim 0:2513c6696bdc 559 * then the carry bit is ignored and will automatically update with the lower 16bits value.
jbkim 0:2513c6696bdc 560 */
jbkim 0:2513c6696bdc 561 #define Sn_TX_RD(N) ( (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 562
jbkim 0:2513c6696bdc 563 /**
jbkim 0:2513c6696bdc 564 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 565 * @brief Transmit memory write pointer register address(R/W)
jbkim 0:2513c6696bdc 566 * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n
jbkim 0:2513c6696bdc 567 * It should be read or be updated like as follows.\n
jbkim 0:2513c6696bdc 568 * 1. Read the starting address for saving the transmitting data.\n
jbkim 0:2513c6696bdc 569 * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n
jbkim 0:2513c6696bdc 570 * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size.
jbkim 0:2513c6696bdc 571 * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs),
jbkim 0:2513c6696bdc 572 * then the carry bit is ignored and will automatically update with the lower 16bits value.\n
jbkim 0:2513c6696bdc 573 * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command
jbkim 0:2513c6696bdc 574 */
jbkim 0:2513c6696bdc 575 #define Sn_TX_WR(N) ( (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 576
jbkim 0:2513c6696bdc 577 /**
jbkim 0:2513c6696bdc 578 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 579 * @brief Received data size register(R)
jbkim 0:2513c6696bdc 580 * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer.
jbkim 0:2513c6696bdc 581 * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between
jbkim 0:2513c6696bdc 582 * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD)
jbkim 0:2513c6696bdc 583 */
jbkim 0:2513c6696bdc 584 #define Sn_RX_RSR(N) ( (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 585
jbkim 0:2513c6696bdc 586 /**
jbkim 0:2513c6696bdc 587 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 588 * @brief Read point of Receive memory(R/W)
jbkim 0:2513c6696bdc 589 * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n
jbkim 0:2513c6696bdc 590 * 1. Read the starting save address of the received data.\n
jbkim 0:2513c6696bdc 591 * 2. Read data from the starting address of Socket n RX Buffer.\n
jbkim 0:2513c6696bdc 592 * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size.
jbkim 0:2513c6696bdc 593 * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs,
jbkim 0:2513c6696bdc 594 * update with the lower 16bits value ignored the carry bit.\n
jbkim 0:2513c6696bdc 595 * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500.
jbkim 0:2513c6696bdc 596 */
jbkim 0:2513c6696bdc 597 #define Sn_RX_RD(N) ( (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 598
jbkim 0:2513c6696bdc 599 /**
jbkim 0:2513c6696bdc 600 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 601 * @brief Write point of Receive memory(R)
jbkim 0:2513c6696bdc 602 * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception.
jbkim 0:2513c6696bdc 603 * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs),
jbkim 0:2513c6696bdc 604 * then the carry bit is ignored and will automatically update with the lower 16bits value.
jbkim 0:2513c6696bdc 605 */
jbkim 0:2513c6696bdc 606 #define Sn_RX_WR(N) ( (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 607
jbkim 0:2513c6696bdc 608 /**
jbkim 0:2513c6696bdc 609 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 610 * @brief socket interrupt mask register(R)
jbkim 0:2513c6696bdc 611 * @details @ref Sn_IMR masks the interrupt of Socket n.
jbkim 0:2513c6696bdc 612 * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is
jbkim 0:2513c6696bdc 613 * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is
jbkim 0:2513c6696bdc 614 * Host is interrupted by asserted INTn PIN to low.
jbkim 0:2513c6696bdc 615 */
jbkim 0:2513c6696bdc 616 #define Sn_IMR(N) ( (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 617
jbkim 0:2513c6696bdc 618 /**
jbkim 0:2513c6696bdc 619 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 620 * @brief Fragment field value in IP header register(R/W)
jbkim 0:2513c6696bdc 621 * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header).
jbkim 0:2513c6696bdc 622 */
jbkim 0:2513c6696bdc 623 #define Sn_FRAG(N) ( (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 624
jbkim 0:2513c6696bdc 625 /**
jbkim 0:2513c6696bdc 626 * @ingroup Socket_register_group
jbkim 0:2513c6696bdc 627 * @brief Keep Alive Timer register(R/W)
jbkim 0:2513c6696bdc 628 * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode,
jbkim 0:2513c6696bdc 629 * and ignored in other modes. The time unit is 5s.
jbkim 0:2513c6696bdc 630 * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once.
jbkim 0:2513c6696bdc 631 * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process).
jbkim 0:2513c6696bdc 632 * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate,
jbkim 0:2513c6696bdc 633 * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process).
jbkim 0:2513c6696bdc 634 * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'.
jbkim 0:2513c6696bdc 635 */
jbkim 0:2513c6696bdc 636 #define Sn_KPALVTR(N) ( (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 637
jbkim 0:2513c6696bdc 638 //#define Sn_TSR(N) ( (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3))
jbkim 0:2513c6696bdc 639
jbkim 0:2513c6696bdc 640
jbkim 0:2513c6696bdc 641 //----------------------------- W5500 Register values -----------------------------
jbkim 0:2513c6696bdc 642
jbkim 0:2513c6696bdc 643 /* MODE register values */
jbkim 0:2513c6696bdc 644 /**
jbkim 0:2513c6696bdc 645 * @brief Reset
jbkim 0:2513c6696bdc 646 * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset.
jbkim 0:2513c6696bdc 647 */
jbkim 0:2513c6696bdc 648 #define MR_RST 0x80
jbkim 0:2513c6696bdc 649
jbkim 0:2513c6696bdc 650 /**
jbkim 0:2513c6696bdc 651 * @brief Wake on LAN
jbkim 0:2513c6696bdc 652 * @details 0 : Disable WOL mode\n
jbkim 0:2513c6696bdc 653 * 1 : Enable WOL mode\n
jbkim 0:2513c6696bdc 654 * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low.
jbkim 0:2513c6696bdc 655 * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.)
jbkim 0:2513c6696bdc 656 * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and
jbkim 0:2513c6696bdc 657 * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode.
jbkim 0:2513c6696bdc 658 */
jbkim 0:2513c6696bdc 659 #define MR_WOL 0x20
jbkim 0:2513c6696bdc 660
jbkim 0:2513c6696bdc 661 /**
jbkim 0:2513c6696bdc 662 * @brief Ping block
jbkim 0:2513c6696bdc 663 * @details 0 : Disable Ping block\n
jbkim 0:2513c6696bdc 664 * 1 : Enable Ping block\n
jbkim 0:2513c6696bdc 665 * If the bit is it blocks the response to a ping request.
jbkim 0:2513c6696bdc 666 */
jbkim 0:2513c6696bdc 667 #define MR_PB 0x10
jbkim 0:2513c6696bdc 668
jbkim 0:2513c6696bdc 669 /**
jbkim 0:2513c6696bdc 670 * @brief Enable PPPoE
jbkim 0:2513c6696bdc 671 * @details 0 : DisablePPPoE mode\n
jbkim 0:2513c6696bdc 672 * 1 : EnablePPPoE mode\n
jbkim 0:2513c6696bdc 673 * If you use ADSL, this bit should be
jbkim 0:2513c6696bdc 674 */
jbkim 0:2513c6696bdc 675 #define MR_PPPOE 0x08
jbkim 0:2513c6696bdc 676
jbkim 0:2513c6696bdc 677 /**
jbkim 0:2513c6696bdc 678 * @brief Enable UDP_FORCE_ARP CHECHK
jbkim 0:2513c6696bdc 679 * @details 0 : Disable Force ARP mode\n
jbkim 0:2513c6696bdc 680 * 1 : Enable Force ARP mode\n
jbkim 0:2513c6696bdc 681 * In Force ARP mode, It forces on sending ARP Request whenever data is sent.
jbkim 0:2513c6696bdc 682 */
jbkim 0:2513c6696bdc 683 #define MR_FARP 0x02
jbkim 0:2513c6696bdc 684
jbkim 0:2513c6696bdc 685 /* IR register values */
jbkim 0:2513c6696bdc 686 /**
jbkim 0:2513c6696bdc 687 * @brief Check IP conflict.
jbkim 0:2513c6696bdc 688 * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request.
jbkim 0:2513c6696bdc 689 */
jbkim 0:2513c6696bdc 690 #define IR_CONFLICT 0x80
jbkim 0:2513c6696bdc 691
jbkim 0:2513c6696bdc 692 /**
jbkim 0:2513c6696bdc 693 * @brief Get the destination unreachable message in UDP sending.
jbkim 0:2513c6696bdc 694 * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as
jbkim 0:2513c6696bdc 695 * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR.
jbkim 0:2513c6696bdc 696 */
jbkim 0:2513c6696bdc 697 #define IR_UNREACH 0x40
jbkim 0:2513c6696bdc 698
jbkim 0:2513c6696bdc 699 /**
jbkim 0:2513c6696bdc 700 * @brief Get the PPPoE close message.
jbkim 0:2513c6696bdc 701 * @details When PPPoE is disconnected during PPPoE mode, this bit is set.
jbkim 0:2513c6696bdc 702 */
jbkim 0:2513c6696bdc 703 #define IR_PPPoE 0x20
jbkim 0:2513c6696bdc 704
jbkim 0:2513c6696bdc 705 /**
jbkim 0:2513c6696bdc 706 * @brief Get the magic packet interrupt.
jbkim 0:2513c6696bdc 707 * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set.
jbkim 0:2513c6696bdc 708 */
jbkim 0:2513c6696bdc 709 #define IR_MP 0x10
jbkim 0:2513c6696bdc 710
jbkim 0:2513c6696bdc 711
jbkim 0:2513c6696bdc 712 /* PHYCFGR register value */
jbkim 0:2513c6696bdc 713 #define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask.
jbkim 0:2513c6696bdc 714 #define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value
jbkim 0:2513c6696bdc 715 #define PHYCFGR_OPMDC_ALLA (7<<3)
jbkim 0:2513c6696bdc 716 #define PHYCFGR_OPMDC_PDOWN (6<<3)
jbkim 0:2513c6696bdc 717 #define PHYCFGR_OPMDC_NA (5<<3)
jbkim 0:2513c6696bdc 718 #define PHYCFGR_OPMDC_100FA (4<<3)
jbkim 0:2513c6696bdc 719 #define PHYCFGR_OPMDC_100F (3<<3)
jbkim 0:2513c6696bdc 720 #define PHYCFGR_OPMDC_100H (2<<3)
jbkim 0:2513c6696bdc 721 #define PHYCFGR_OPMDC_10F (1<<3)
jbkim 0:2513c6696bdc 722 #define PHYCFGR_OPMDC_10H (0<<3)
jbkim 0:2513c6696bdc 723 #define PHYCFGR_DPX_FULL (1<<2)
jbkim 0:2513c6696bdc 724 #define PHYCFGR_DPX_HALF (0<<2)
jbkim 0:2513c6696bdc 725 #define PHYCFGR_SPD_100 (1<<1)
jbkim 0:2513c6696bdc 726 #define PHYCFGR_SPD_10 (0<<1)
jbkim 0:2513c6696bdc 727 #define PHYCFGR_LNK_ON (1<<0)
jbkim 0:2513c6696bdc 728 #define PHYCFGR_LNK_OFF (0<<0)
jbkim 0:2513c6696bdc 729
jbkim 0:2513c6696bdc 730 /* IMR register values */
jbkim 0:2513c6696bdc 731 /**
jbkim 0:2513c6696bdc 732 * @brief IP Conflict Interrupt Mask.
jbkim 0:2513c6696bdc 733 * @details 0: Disable IP Conflict Interrupt\n
jbkim 0:2513c6696bdc 734 * 1: Enable IP Conflict Interrupt
jbkim 0:2513c6696bdc 735 */
jbkim 0:2513c6696bdc 736 #define IM_IR7 0x80
jbkim 0:2513c6696bdc 737
jbkim 0:2513c6696bdc 738 /**
jbkim 0:2513c6696bdc 739 * @brief Destination unreachable Interrupt Mask.
jbkim 0:2513c6696bdc 740 * @details 0: Disable Destination unreachable Interrupt\n
jbkim 0:2513c6696bdc 741 * 1: Enable Destination unreachable Interrupt
jbkim 0:2513c6696bdc 742 */
jbkim 0:2513c6696bdc 743 #define IM_IR6 0x40
jbkim 0:2513c6696bdc 744
jbkim 0:2513c6696bdc 745 /**
jbkim 0:2513c6696bdc 746 * @brief PPPoE Close Interrupt Mask.
jbkim 0:2513c6696bdc 747 * @details 0: Disable PPPoE Close Interrupt\n
jbkim 0:2513c6696bdc 748 * 1: Enable PPPoE Close Interrupt
jbkim 0:2513c6696bdc 749 */
jbkim 0:2513c6696bdc 750 #define IM_IR5 0x20
jbkim 0:2513c6696bdc 751
jbkim 0:2513c6696bdc 752 /**
jbkim 0:2513c6696bdc 753 * @brief Magic Packet Interrupt Mask.
jbkim 0:2513c6696bdc 754 * @details 0: Disable Magic Packet Interrupt\n
jbkim 0:2513c6696bdc 755 * 1: Enable Magic Packet Interrupt
jbkim 0:2513c6696bdc 756 */
jbkim 0:2513c6696bdc 757 #define IM_IR4 0x10
jbkim 0:2513c6696bdc 758
jbkim 0:2513c6696bdc 759 /* Sn_MR Default values */
jbkim 0:2513c6696bdc 760 /**
jbkim 0:2513c6696bdc 761 * @brief Support UDP Multicasting
jbkim 0:2513c6696bdc 762 * @details 0 : disable Multicasting\n
jbkim 0:2513c6696bdc 763 * 1 : enable Multicasting\n
jbkim 0:2513c6696bdc 764 * This bit is applied only during UDP mode(P[3:0] = 010.\n
jbkim 0:2513c6696bdc 765 * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number
jbkim 0:2513c6696bdc 766 * before Socket n is opened by OPEN command of @ref Sn_CR.
jbkim 0:2513c6696bdc 767 */
jbkim 0:2513c6696bdc 768 #define Sn_MR_MULTI 0x80
jbkim 0:2513c6696bdc 769
jbkim 0:2513c6696bdc 770 /**
jbkim 0:2513c6696bdc 771 * @brief Broadcast block in UDP Multicasting.
jbkim 0:2513c6696bdc 772 * @details 0 : disable Broadcast Blocking\n
jbkim 0:2513c6696bdc 773 * 1 : enable Broadcast Blocking\n
jbkim 0:2513c6696bdc 774 * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m
jbkim 0:2513c6696bdc 775 * In addition, This bit does when MACRAW mode(P[3:0] = 100
jbkim 0:2513c6696bdc 776 */
jbkim 0:2513c6696bdc 777 #define Sn_MR_BCASTB 0x40
jbkim 0:2513c6696bdc 778
jbkim 0:2513c6696bdc 779 /**
jbkim 0:2513c6696bdc 780 * @brief No Delayed Ack(TCP), Multicast flag
jbkim 0:2513c6696bdc 781 * @details 0 : Disable No Delayed ACK option\n
jbkim 0:2513c6696bdc 782 * 1 : Enable No Delayed ACK option\n
jbkim 0:2513c6696bdc 783 * This bit is applied only during TCP mode (P[3:0] = 001.\n
jbkim 0:2513c6696bdc 784 * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n
jbkim 0:2513c6696bdc 785 * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref RTR.
jbkim 0:2513c6696bdc 786 */
jbkim 0:2513c6696bdc 787 #define Sn_MR_ND 0x20
jbkim 0:2513c6696bdc 788
jbkim 0:2513c6696bdc 789 /**
jbkim 0:2513c6696bdc 790 * @brief Unicast Block in UDP Multicasting
jbkim 0:2513c6696bdc 791 * @details 0 : disable Unicast Blocking\n
jbkim 0:2513c6696bdc 792 * 1 : enable Unicast Blocking\n
jbkim 0:2513c6696bdc 793 * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI =
jbkim 0:2513c6696bdc 794 */
jbkim 0:2513c6696bdc 795 #define Sn_MR_UCASTB 0x10
jbkim 0:2513c6696bdc 796
jbkim 0:2513c6696bdc 797 /**
jbkim 0:2513c6696bdc 798 * @brief MAC LAYER RAW SOCK
jbkim 0:2513c6696bdc 799 * @details This configures the protocol mode of Socket n.
jbkim 0:2513c6696bdc 800 * @note MACRAW mode should be only used in Socket 0.
jbkim 0:2513c6696bdc 801 */
jbkim 0:2513c6696bdc 802 #define Sn_MR_MACRAW 0x04
jbkim 0:2513c6696bdc 803
jbkim 0:2513c6696bdc 804 //#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */
jbkim 0:2513c6696bdc 805
jbkim 0:2513c6696bdc 806 /**
jbkim 0:2513c6696bdc 807 * @brief UDP
jbkim 0:2513c6696bdc 808 * @details This configures the protocol mode of Socket n.
jbkim 0:2513c6696bdc 809 */
jbkim 0:2513c6696bdc 810 #define Sn_MR_UDP 0x02
jbkim 0:2513c6696bdc 811
jbkim 0:2513c6696bdc 812 /**
jbkim 0:2513c6696bdc 813 * @brief TCP
jbkim 0:2513c6696bdc 814 * @details This configures the protocol mode of Socket n.
jbkim 0:2513c6696bdc 815 */
jbkim 0:2513c6696bdc 816 #define Sn_MR_TCP 0x01
jbkim 0:2513c6696bdc 817
jbkim 0:2513c6696bdc 818 /**
jbkim 0:2513c6696bdc 819 * @brief Unused socket
jbkim 0:2513c6696bdc 820 * @details This configures the protocol mode of Socket n.
jbkim 0:2513c6696bdc 821 */
jbkim 0:2513c6696bdc 822 #define Sn_MR_CLOSE 0x00
jbkim 0:2513c6696bdc 823
jbkim 0:2513c6696bdc 824 /* Sn_MR values used with Sn_MR_MACRAW */
jbkim 0:2513c6696bdc 825 /**
jbkim 0:2513c6696bdc 826 * @brief MAC filter enable in @ref Sn_MR_MACRAW mode
jbkim 0:2513c6696bdc 827 * @details 0 : disable MAC Filtering\n
jbkim 0:2513c6696bdc 828 * 1 : enable MAC Filtering\n
jbkim 0:2513c6696bdc 829 * This bit is applied only during MACRAW mode(P[3:0] = 100.\n
jbkim 0:2513c6696bdc 830 * When set as W5500 can only receive broadcasting packet or packet sent to itself.
jbkim 0:2513c6696bdc 831 * When this bit is W5500 can receive all packets on Ethernet.
jbkim 0:2513c6696bdc 832 * If user wants to implement Hybrid TCP/IP stack,
jbkim 0:2513c6696bdc 833 * it is recommended that this bit is set as for reducing host overhead to process the all received packets.
jbkim 0:2513c6696bdc 834 */
jbkim 0:2513c6696bdc 835 #define Sn_MR_MFEN Sn_MR_MULTI
jbkim 0:2513c6696bdc 836
jbkim 0:2513c6696bdc 837 /**
jbkim 0:2513c6696bdc 838 * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode
jbkim 0:2513c6696bdc 839 * @details 0 : using IGMP version 2\n
jbkim 0:2513c6696bdc 840 * 1 : using IGMP version 1\n
jbkim 0:2513c6696bdc 841 * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI =
jbkim 0:2513c6696bdc 842 * It configures the version for IGMP messages (Join/Leave/Report).
jbkim 0:2513c6696bdc 843 */
jbkim 0:2513c6696bdc 844 #define Sn_MR_MMB Sn_MR_ND
jbkim 0:2513c6696bdc 845
jbkim 0:2513c6696bdc 846 /**
jbkim 0:2513c6696bdc 847 * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode
jbkim 0:2513c6696bdc 848 * @details 0 : disable IPv6 Blocking\n
jbkim 0:2513c6696bdc 849 * 1 : enable IPv6 Blocking\n
jbkim 0:2513c6696bdc 850 * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet.
jbkim 0:2513c6696bdc 851 */
jbkim 0:2513c6696bdc 852 #define Sn_MR_MIP6B Sn_MR_UCASTB
jbkim 0:2513c6696bdc 853
jbkim 0:2513c6696bdc 854 /* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */
jbkim 0:2513c6696bdc 855 /**
jbkim 0:2513c6696bdc 856 * @brief IGMP version used in UDP mulitcasting
jbkim 0:2513c6696bdc 857 * @details 0 : disable Multicast Blocking\n
jbkim 0:2513c6696bdc 858 * 1 : enable Multicast Blocking\n
jbkim 0:2513c6696bdc 859 * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address.
jbkim 0:2513c6696bdc 860 */
jbkim 0:2513c6696bdc 861 #define Sn_MR_MC Sn_MR_ND
jbkim 0:2513c6696bdc 862
jbkim 0:2513c6696bdc 863 /* Sn_MR alternate values */
jbkim 0:2513c6696bdc 864 /**
jbkim 0:2513c6696bdc 865 * @brief For Berkeley Socket API
jbkim 0:2513c6696bdc 866 */
jbkim 0:2513c6696bdc 867 #define SOCK_STREAM Sn_MR_TCP
jbkim 0:2513c6696bdc 868
jbkim 0:2513c6696bdc 869 /**
jbkim 0:2513c6696bdc 870 * @brief For Berkeley Socket API
jbkim 0:2513c6696bdc 871 */
jbkim 0:2513c6696bdc 872 #define SOCK_DGRAM Sn_MR_UDP
jbkim 0:2513c6696bdc 873
jbkim 0:2513c6696bdc 874
jbkim 0:2513c6696bdc 875 /* Sn_CR values */
jbkim 0:2513c6696bdc 876 /**
jbkim 0:2513c6696bdc 877 * @brief Initialize or open socket
jbkim 0:2513c6696bdc 878 * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0).
jbkim 0:2513c6696bdc 879 * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n
jbkim 0:2513c6696bdc 880 * <table>
jbkim 0:2513c6696bdc 881 * <tr> <td>\b Sn_MR (P[3:0])</td> <td>\b Sn_SR</td> </tr>
jbkim 0:2513c6696bdc 882 * <tr> <td>Sn_MR_CLOSE (000</td> <td></td> </tr>
jbkim 0:2513c6696bdc 883 * <tr> <td>Sn_MR_TCP (001</td> <td>SOCK_INIT (0x13)</td> </tr>
jbkim 0:2513c6696bdc 884 * <tr> <td>Sn_MR_UDP (010</td> <td>SOCK_UDP (0x22)</td> </tr>
jbkim 0:2513c6696bdc 885 * <tr> <td>S0_MR_MACRAW (100</td> <td>SOCK_MACRAW (0x02)</td> </tr>
jbkim 0:2513c6696bdc 886 * </table>
jbkim 0:2513c6696bdc 887 */
jbkim 0:2513c6696bdc 888 #define Sn_CR_OPEN 0x01
jbkim 0:2513c6696bdc 889
jbkim 0:2513c6696bdc 890 /**
jbkim 0:2513c6696bdc 891 * @brief Wait connection request in TCP mode(Server mode)
jbkim 0:2513c6696bdc 892 * @details This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP).
jbkim 0:2513c6696bdc 893 * In this mode, Socket n operates as a �TCP serverand waits for connection-request (SYN packet) from any �TCP client
jbkim 0:2513c6696bdc 894 * The @ref Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN.
jbkim 0:2513c6696bdc 895 * When a �TCP clientconnection request is successfully established,
jbkim 0:2513c6696bdc 896 * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0) becomes
jbkim 0:2513c6696bdc 897 * But when a �TCP clientconnection request is failed, Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED.
jbkim 0:2513c6696bdc 898 */
jbkim 0:2513c6696bdc 899 #define Sn_CR_LISTEN 0x02
jbkim 0:2513c6696bdc 900
jbkim 0:2513c6696bdc 901 /**
jbkim 0:2513c6696bdc 902 * @brief Send connection request in TCP mode(Client mode)
jbkim 0:2513c6696bdc 903 * @details To connect, a connect-request (SYN packet) is sent to b>TCP server</b>configured by @ref Sn_DIPR & Sn_DPORT(destination address & port).
jbkim 0:2513c6696bdc 904 * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n
jbkim 0:2513c6696bdc 905 * The connect-request fails in the following three cases.\n
jbkim 0:2513c6696bdc 906 * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n
jbkim 0:2513c6696bdc 907 * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n
jbkim 0:2513c6696bdc 908 * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED.
jbkim 0:2513c6696bdc 909 * @note This is valid only in TCP mode and operates when Socket n acts as b>TCP client</b>
jbkim 0:2513c6696bdc 910 */
jbkim 0:2513c6696bdc 911 #define Sn_CR_CONNECT 0x04
jbkim 0:2513c6696bdc 912
jbkim 0:2513c6696bdc 913 /**
jbkim 0:2513c6696bdc 914 * @brief Send closing request in TCP mode
jbkim 0:2513c6696bdc 915 * @details Regardless of b>TCP server</b>or b>TCP client</b> the DISCON command processes the disconnect-process (b>Active close</b>or b>Passive close</b>.\n
jbkim 0:2513c6696bdc 916 * @par Active close
jbkim 0:2513c6696bdc 917 * it transmits disconnect-request(FIN packet) to the connected peer\n
jbkim 0:2513c6696bdc 918 * @par Passive close
jbkim 0:2513c6696bdc 919 * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n
jbkim 0:2513c6696bdc 920 * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n
jbkim 0:2513c6696bdc 921 * Otherwise, TCPTO occurs (Sn_IR(3)=)= and then @ref Sn_SR is changed to @ref SOCK_CLOSED.
jbkim 0:2513c6696bdc 922 * @note Valid only in TCP mode.
jbkim 0:2513c6696bdc 923 */
jbkim 0:2513c6696bdc 924 #define Sn_CR_DISCON 0x08
jbkim 0:2513c6696bdc 925
jbkim 0:2513c6696bdc 926 /**
jbkim 0:2513c6696bdc 927 * @brief Close socket
jbkim 0:2513c6696bdc 928 * @details Sn_SR is changed to @ref SOCK_CLOSED.
jbkim 0:2513c6696bdc 929 */
jbkim 0:2513c6696bdc 930 #define Sn_CR_CLOSE 0x10
jbkim 0:2513c6696bdc 931
jbkim 0:2513c6696bdc 932 /**
jbkim 0:2513c6696bdc 933 * @brief Update TX buffer pointer and send data
jbkim 0:2513c6696bdc 934 * @details SEND transmits all the data in the Socket n TX buffer.\n
jbkim 0:2513c6696bdc 935 * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n,
jbkim 0:2513c6696bdc 936 * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD).
jbkim 0:2513c6696bdc 937 */
jbkim 0:2513c6696bdc 938 #define Sn_CR_SEND 0x20
jbkim 0:2513c6696bdc 939
jbkim 0:2513c6696bdc 940 /**
jbkim 0:2513c6696bdc 941 * @brief Send data with MAC address, so without ARP process
jbkim 0:2513c6696bdc 942 * @details The basic operation is same as SEND.\n
jbkim 0:2513c6696bdc 943 * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n
jbkim 0:2513c6696bdc 944 * But SEND_MAC transmits data without the automatic ARP-process.\n
jbkim 0:2513c6696bdc 945 * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process.
jbkim 0:2513c6696bdc 946 * @note Valid only in UDP mode.
jbkim 0:2513c6696bdc 947 */
jbkim 0:2513c6696bdc 948 #define Sn_CR_SEND_MAC 0x21
jbkim 0:2513c6696bdc 949
jbkim 0:2513c6696bdc 950 /**
jbkim 0:2513c6696bdc 951 * @brief Send keep alive message
jbkim 0:2513c6696bdc 952 * @details It checks the connection status by sending 1byte keep-alive packet.\n
jbkim 0:2513c6696bdc 953 * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur.
jbkim 0:2513c6696bdc 954 * @note Valid only in TCP mode.
jbkim 0:2513c6696bdc 955 */
jbkim 0:2513c6696bdc 956 #define Sn_CR_SEND_KEEP 0x22
jbkim 0:2513c6696bdc 957
jbkim 0:2513c6696bdc 958 /**
jbkim 0:2513c6696bdc 959 * @brief Update RX buffer pointer and receive data
jbkim 0:2513c6696bdc 960 * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n
jbkim 0:2513c6696bdc 961 * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR),
jbkim 0:2513c6696bdc 962 * and Socket n RX Read Pointer Register (@ref Sn_RX_RD).
jbkim 0:2513c6696bdc 963 */
jbkim 0:2513c6696bdc 964 #define Sn_CR_RECV 0x40
jbkim 0:2513c6696bdc 965
jbkim 0:2513c6696bdc 966 /* Sn_IR values */
jbkim 0:2513c6696bdc 967 /**
jbkim 0:2513c6696bdc 968 * @brief SEND_OK Interrupt
jbkim 0:2513c6696bdc 969 * @details This is issued when SEND command is completed.
jbkim 0:2513c6696bdc 970 */
jbkim 0:2513c6696bdc 971 #define Sn_IR_SENDOK 0x10
jbkim 0:2513c6696bdc 972
jbkim 0:2513c6696bdc 973 /**
jbkim 0:2513c6696bdc 974 * @brief TIMEOUT Interrupt
jbkim 0:2513c6696bdc 975 * @details This is issued when ARPTO or TCPTO occurs.
jbkim 0:2513c6696bdc 976 */
jbkim 0:2513c6696bdc 977 #define Sn_IR_TIMEOUT 0x08
jbkim 0:2513c6696bdc 978
jbkim 0:2513c6696bdc 979 /**
jbkim 0:2513c6696bdc 980 * @brief RECV Interrupt
jbkim 0:2513c6696bdc 981 * @details This is issued whenever data is received from a peer.
jbkim 0:2513c6696bdc 982 */
jbkim 0:2513c6696bdc 983 #define Sn_IR_RECV 0x04
jbkim 0:2513c6696bdc 984
jbkim 0:2513c6696bdc 985 /**
jbkim 0:2513c6696bdc 986 * @brief DISCON Interrupt
jbkim 0:2513c6696bdc 987 * @details This is issued when FIN or FIN/ACK packet is received from a peer.
jbkim 0:2513c6696bdc 988 */
jbkim 0:2513c6696bdc 989 #define Sn_IR_DISCON 0x02
jbkim 0:2513c6696bdc 990
jbkim 0:2513c6696bdc 991 /**
jbkim 0:2513c6696bdc 992 * @brief CON Interrupt
jbkim 0:2513c6696bdc 993 * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED.
jbkim 0:2513c6696bdc 994 */
jbkim 0:2513c6696bdc 995 #define Sn_IR_CON 0x01
jbkim 0:2513c6696bdc 996
jbkim 0:2513c6696bdc 997 /* Sn_SR values */
jbkim 0:2513c6696bdc 998 /**
jbkim 0:2513c6696bdc 999 * @brief Closed
jbkim 0:2513c6696bdc 1000 * @details This indicates that Socket n is released.\N
jbkim 0:2513c6696bdc 1001 * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status.
jbkim 0:2513c6696bdc 1002 */
jbkim 0:2513c6696bdc 1003 #define SOCK_CLOSED 0x00
jbkim 0:2513c6696bdc 1004
jbkim 0:2513c6696bdc 1005 /**
jbkim 0:2513c6696bdc 1006 * @brief Initiate state
jbkim 0:2513c6696bdc 1007 * @details This indicates Socket n is opened with TCP mode.\N
jbkim 0:2513c6696bdc 1008 * It is changed to @ref SOCK_INIT when Sn_MR(P[3:0]) = 001and OPEN command is ordered.\N
jbkim 0:2513c6696bdc 1009 * After @ref SOCK_INIT, user can use LISTEN /CONNECT command.
jbkim 0:2513c6696bdc 1010 */
jbkim 0:2513c6696bdc 1011 #define SOCK_INIT 0x13
jbkim 0:2513c6696bdc 1012
jbkim 0:2513c6696bdc 1013 /**
jbkim 0:2513c6696bdc 1014 * @brief Listen state
jbkim 0:2513c6696bdc 1015 * @details This indicates Socket n is operating as b>TCP server</b>mode and waiting for connection-request (SYN packet) from a peer (b>TCP client</b>.\n
jbkim 0:2513c6696bdc 1016 * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n
jbkim 0:2513c6696bdc 1017 * Otherwise it will change to @ref SOCK_CLOSED after TCPTO occurred (Sn_IR(TIMEOUT) = .
jbkim 0:2513c6696bdc 1018 */
jbkim 0:2513c6696bdc 1019 #define SOCK_LISTEN 0x14
jbkim 0:2513c6696bdc 1020
jbkim 0:2513c6696bdc 1021 /**
jbkim 0:2513c6696bdc 1022 * @brief Connection state
jbkim 0:2513c6696bdc 1023 * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n
jbkim 0:2513c6696bdc 1024 * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n
jbkim 0:2513c6696bdc 1025 * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n
jbkim 0:2513c6696bdc 1026 * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = is occurred.
jbkim 0:2513c6696bdc 1027 */
jbkim 0:2513c6696bdc 1028 #define SOCK_SYNSENT 0x15
jbkim 0:2513c6696bdc 1029
jbkim 0:2513c6696bdc 1030 /**
jbkim 0:2513c6696bdc 1031 * @brief Connection state
jbkim 0:2513c6696bdc 1032 * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n
jbkim 0:2513c6696bdc 1033 * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n
jbkim 0:2513c6696bdc 1034 * If not, it changes to @ref SOCK_CLOSED after timeout occurs (@ref Sn_IR[TIMEOUT] = .
jbkim 0:2513c6696bdc 1035 */
jbkim 0:2513c6696bdc 1036 #define SOCK_SYNRECV 0x16
jbkim 0:2513c6696bdc 1037
jbkim 0:2513c6696bdc 1038 /**
jbkim 0:2513c6696bdc 1039 * @brief Success to connect
jbkim 0:2513c6696bdc 1040 * @details This indicates the status of the connection of Socket n.\n
jbkim 0:2513c6696bdc 1041 * It changes to @ref SOCK_ESTABLISHED when the b>TCP SERVER</b>processed the SYN packet from the b>TCP CLIENT</b>during @ref SOCK_LISTEN, or
jbkim 0:2513c6696bdc 1042 * when the CONNECT command is successful.\n
jbkim 0:2513c6696bdc 1043 * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command.
jbkim 0:2513c6696bdc 1044 */
jbkim 0:2513c6696bdc 1045 #define SOCK_ESTABLISHED 0x17
jbkim 0:2513c6696bdc 1046
jbkim 0:2513c6696bdc 1047 /**
jbkim 0:2513c6696bdc 1048 * @brief Closing state
jbkim 0:2513c6696bdc 1049 * @details These indicate Socket n is closing.\n
jbkim 0:2513c6696bdc 1050 * These are shown in disconnect-process such as active-close and passive-close.\n
jbkim 0:2513c6696bdc 1051 * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED.
jbkim 0:2513c6696bdc 1052 */
jbkim 0:2513c6696bdc 1053 #define SOCK_FIN_WAIT 0x18
jbkim 0:2513c6696bdc 1054
jbkim 0:2513c6696bdc 1055 /**
jbkim 0:2513c6696bdc 1056 * @brief Closing state
jbkim 0:2513c6696bdc 1057 * @details These indicate Socket n is closing.\n
jbkim 0:2513c6696bdc 1058 * These are shown in disconnect-process such as active-close and passive-close.\n
jbkim 0:2513c6696bdc 1059 * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED.
jbkim 0:2513c6696bdc 1060 */
jbkim 0:2513c6696bdc 1061 #define SOCK_CLOSING 0x1A
jbkim 0:2513c6696bdc 1062
jbkim 0:2513c6696bdc 1063 /**
jbkim 0:2513c6696bdc 1064 * @brief Closing state
jbkim 0:2513c6696bdc 1065 * @details These indicate Socket n is closing.\n
jbkim 0:2513c6696bdc 1066 * These are shown in disconnect-process such as active-close and passive-close.\n
jbkim 0:2513c6696bdc 1067 * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED.
jbkim 0:2513c6696bdc 1068 */
jbkim 0:2513c6696bdc 1069 #define SOCK_TIME_WAIT 0x1B
jbkim 0:2513c6696bdc 1070
jbkim 0:2513c6696bdc 1071 /**
jbkim 0:2513c6696bdc 1072 * @brief Closing state
jbkim 0:2513c6696bdc 1073 * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n
jbkim 0:2513c6696bdc 1074 * This is half-closing status, and data can be transferred.\n
jbkim 0:2513c6696bdc 1075 * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used.
jbkim 0:2513c6696bdc 1076 */
jbkim 0:2513c6696bdc 1077 #define SOCK_CLOSE_WAIT 0x1C
jbkim 0:2513c6696bdc 1078
jbkim 0:2513c6696bdc 1079 /**
jbkim 0:2513c6696bdc 1080 * @brief Closing state
jbkim 0:2513c6696bdc 1081 * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n
jbkim 0:2513c6696bdc 1082 * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout occurs (@ref Sn_IR[TIMEOUT] = .
jbkim 0:2513c6696bdc 1083 */
jbkim 0:2513c6696bdc 1084 #define SOCK_LAST_ACK 0x1D
jbkim 0:2513c6696bdc 1085
jbkim 0:2513c6696bdc 1086 /**
jbkim 0:2513c6696bdc 1087 * @brief UDP socket
jbkim 0:2513c6696bdc 1088 * @details This indicates Socket n is opened in UDP mode(Sn_MR(P[3:0]) = 010.\n
jbkim 0:2513c6696bdc 1089 * It changes to SOCK_UPD when Sn_MR(P[3:0]) = 010 and OPEN command is ordered.\n
jbkim 0:2513c6696bdc 1090 * Unlike TCP mode, data can be transfered without the connection-process.
jbkim 0:2513c6696bdc 1091 */
jbkim 0:2513c6696bdc 1092 #define SOCK_UDP 0x22
jbkim 0:2513c6696bdc 1093
jbkim 0:2513c6696bdc 1094 //#define SOCK_IPRAW 0x32 /**< IP raw mode socket */
jbkim 0:2513c6696bdc 1095
jbkim 0:2513c6696bdc 1096 /**
jbkim 0:2513c6696bdc 1097 * @brief MAC raw mode socket
jbkim 0:2513c6696bdc 1098 * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n
jbkim 0:2513c6696bdc 1099 * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n
jbkim 0:2513c6696bdc 1100 * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process.
jbkim 0:2513c6696bdc 1101 */
jbkim 0:2513c6696bdc 1102 #define SOCK_MACRAW 0x42
jbkim 0:2513c6696bdc 1103
jbkim 0:2513c6696bdc 1104 //#define SOCK_PPPOE 0x5F
jbkim 0:2513c6696bdc 1105
jbkim 0:2513c6696bdc 1106 /* IP PROTOCOL */
jbkim 0:2513c6696bdc 1107 #define IPPROTO_IP 0 //< Dummy for IP
jbkim 0:2513c6696bdc 1108 #define IPPROTO_ICMP 1 //< Control message protocol
jbkim 0:2513c6696bdc 1109 #define IPPROTO_IGMP 2 //< Internet group management protocol
jbkim 0:2513c6696bdc 1110 #define IPPROTO_GGP 3 //< Gateway^2 (deprecated)
jbkim 0:2513c6696bdc 1111 #define IPPROTO_TCP 6 //< TCP
jbkim 0:2513c6696bdc 1112 #define IPPROTO_PUP 12 //< PUP
jbkim 0:2513c6696bdc 1113 #define IPPROTO_UDP 17 //< UDP
jbkim 0:2513c6696bdc 1114 #define IPPROTO_IDP 22 //< XNS idp
jbkim 0:2513c6696bdc 1115 #define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol
jbkim 0:2513c6696bdc 1116 #define IPPROTO_RAW 255 //< Raw IP packet
jbkim 0:2513c6696bdc 1117
jbkim 0:2513c6696bdc 1118
jbkim 0:2513c6696bdc 1119 /**
jbkim 0:2513c6696bdc 1120 * @brief Enter a critical section
jbkim 0:2513c6696bdc 1121 *
jbkim 0:2513c6696bdc 1122 * @details It is provided to protect your shared code which are executed without distribution. \n \n
jbkim 0:2513c6696bdc 1123 *
jbkim 0:2513c6696bdc 1124 * In non-OS environment, It can be just implemented by disabling whole interrupt.\n
jbkim 0:2513c6696bdc 1125 * In OS environment, You can replace it to critical section api supported by OS.
jbkim 0:2513c6696bdc 1126 *
jbkim 0:2513c6696bdc 1127 * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
jbkim 0:2513c6696bdc 1128 * \sa WIZCHIP_CRITICAL_EXIT()
jbkim 0:2513c6696bdc 1129 */
jbkim 0:2513c6696bdc 1130 #define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter()
jbkim 0:2513c6696bdc 1131
jbkim 0:2513c6696bdc 1132 /**
jbkim 0:2513c6696bdc 1133 * @brief Exit a critical section
jbkim 0:2513c6696bdc 1134 *
jbkim 0:2513c6696bdc 1135 * @details It is provided to protect your shared code which are executed without distribution. \n\n
jbkim 0:2513c6696bdc 1136 *
jbkim 0:2513c6696bdc 1137 * In non-OS environment, It can be just implemented by disabling whole interrupt. \n
jbkim 0:2513c6696bdc 1138 * In OS environment, You can replace it to critical section api supported by OS.
jbkim 0:2513c6696bdc 1139 *
jbkim 0:2513c6696bdc 1140 * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF()
jbkim 0:2513c6696bdc 1141 * @sa WIZCHIP_CRITICAL_ENTER()
jbkim 0:2513c6696bdc 1142 */
jbkim 0:2513c6696bdc 1143 #define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit()
jbkim 0:2513c6696bdc 1144
jbkim 0:2513c6696bdc 1145
jbkim 0:2513c6696bdc 1146
jbkim 0:2513c6696bdc 1147 ////////////////////////
jbkim 0:2513c6696bdc 1148 // Basic I/O Function //
jbkim 0:2513c6696bdc 1149 ////////////////////////
jbkim 0:2513c6696bdc 1150
jbkim 0:2513c6696bdc 1151 /**
jbkim 0:2513c6696bdc 1152 * @ingroup Basic_IO_function
jbkim 0:2513c6696bdc 1153 * @brief It reads 1 byte value from a register.
jbkim 0:2513c6696bdc 1154 * @param AddrSel Register address
jbkim 0:2513c6696bdc 1155 * @return The value of register
jbkim 0:2513c6696bdc 1156 */
jbkim 0:2513c6696bdc 1157 uint8_t WIZCHIP_READ (uint32_t AddrSel);
jbkim 0:2513c6696bdc 1158
jbkim 0:2513c6696bdc 1159 /**
jbkim 0:2513c6696bdc 1160 * @ingroup Basic_IO_function
jbkim 0:2513c6696bdc 1161 * @brief It writes 1 byte value to a register.
jbkim 0:2513c6696bdc 1162 * @param AddrSel Register address
jbkim 0:2513c6696bdc 1163 * @param wb Write data
jbkim 0:2513c6696bdc 1164 * @return void
jbkim 0:2513c6696bdc 1165 */
jbkim 0:2513c6696bdc 1166 void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb );
jbkim 0:2513c6696bdc 1167
jbkim 0:2513c6696bdc 1168 /**
jbkim 0:2513c6696bdc 1169 * @ingroup Basic_IO_function
jbkim 0:2513c6696bdc 1170 * @brief It reads sequence data from registers.
jbkim 0:2513c6696bdc 1171 * @param AddrSel Register address
jbkim 0:2513c6696bdc 1172 * @param pBuf Pointer buffer to read data
jbkim 0:2513c6696bdc 1173 * @param len Data length
jbkim 0:2513c6696bdc 1174 */
jbkim 0:2513c6696bdc 1175 void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
jbkim 0:2513c6696bdc 1176
jbkim 0:2513c6696bdc 1177 /**
jbkim 0:2513c6696bdc 1178 * @ingroup Basic_IO_function
jbkim 0:2513c6696bdc 1179 * @brief It writes sequence data to registers.
jbkim 0:2513c6696bdc 1180 * @param AddrSel Register address
jbkim 0:2513c6696bdc 1181 * @param pBuf Pointer buffer to write data
jbkim 0:2513c6696bdc 1182 * @param len Data length
jbkim 0:2513c6696bdc 1183 */
jbkim 0:2513c6696bdc 1184 void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
jbkim 0:2513c6696bdc 1185
jbkim 0:2513c6696bdc 1186 /////////////////////////////////
jbkim 0:2513c6696bdc 1187 // Common Register I/O function //
jbkim 0:2513c6696bdc 1188 /////////////////////////////////
jbkim 0:2513c6696bdc 1189 /**
jbkim 0:2513c6696bdc 1190 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1191 * @brief Set Mode Register
jbkim 0:2513c6696bdc 1192 * @param (uint8_t)mr The value to be set.
jbkim 0:2513c6696bdc 1193 * @sa getMR()
jbkim 0:2513c6696bdc 1194 */
jbkim 0:2513c6696bdc 1195 #define setMR(mr) \
jbkim 0:2513c6696bdc 1196 WIZCHIP_WRITE(MR,mr)
jbkim 0:2513c6696bdc 1197
jbkim 0:2513c6696bdc 1198
jbkim 0:2513c6696bdc 1199 /**
jbkim 0:2513c6696bdc 1200 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1201 * @brief Get Mode Register
jbkim 0:2513c6696bdc 1202 * @return uint8_t. The value of Mode register.
jbkim 0:2513c6696bdc 1203 * @sa setMR()
jbkim 0:2513c6696bdc 1204 */
jbkim 0:2513c6696bdc 1205 #define getMR() \
jbkim 0:2513c6696bdc 1206 WIZCHIP_READ(MR)
jbkim 0:2513c6696bdc 1207
jbkim 0:2513c6696bdc 1208 /**
jbkim 0:2513c6696bdc 1209 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1210 * @brief Set gateway IP address
jbkim 0:2513c6696bdc 1211 * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1212 * @sa getGAR()
jbkim 0:2513c6696bdc 1213 */
jbkim 0:2513c6696bdc 1214 #define setGAR(gar) \
jbkim 0:2513c6696bdc 1215 WIZCHIP_WRITE_BUF(GAR,gar,4)
jbkim 0:2513c6696bdc 1216
jbkim 0:2513c6696bdc 1217 /**
jbkim 0:2513c6696bdc 1218 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1219 * @brief Get gateway IP address
jbkim 0:2513c6696bdc 1220 * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1221 * @sa setGAR()
jbkim 0:2513c6696bdc 1222 */
jbkim 0:2513c6696bdc 1223 #define getGAR(gar) \
jbkim 0:2513c6696bdc 1224 WIZCHIP_READ_BUF(GAR,gar,4)
jbkim 0:2513c6696bdc 1225
jbkim 0:2513c6696bdc 1226 /**
jbkim 0:2513c6696bdc 1227 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1228 * @brief Set subnet mask address
jbkim 0:2513c6696bdc 1229 * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1230 * @sa getSUBR()
jbkim 0:2513c6696bdc 1231 */
jbkim 0:2513c6696bdc 1232 #define setSUBR(subr) \
jbkim 0:2513c6696bdc 1233 WIZCHIP_WRITE_BUF(SUBR, subr,4)
jbkim 0:2513c6696bdc 1234
jbkim 0:2513c6696bdc 1235
jbkim 0:2513c6696bdc 1236 /**
jbkim 0:2513c6696bdc 1237 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1238 * @brief Get subnet mask address
jbkim 0:2513c6696bdc 1239 * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1240 * @sa setSUBR()
jbkim 0:2513c6696bdc 1241 */
jbkim 0:2513c6696bdc 1242 #define getSUBR(subr) \
jbkim 0:2513c6696bdc 1243 WIZCHIP_READ_BUF(SUBR, subr, 4)
jbkim 0:2513c6696bdc 1244
jbkim 0:2513c6696bdc 1245 /**
jbkim 0:2513c6696bdc 1246 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1247 * @brief Set local MAC address
jbkim 0:2513c6696bdc 1248 * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes.
jbkim 0:2513c6696bdc 1249 * @sa getSHAR()
jbkim 0:2513c6696bdc 1250 */
jbkim 0:2513c6696bdc 1251 #define setSHAR(shar) \
jbkim 0:2513c6696bdc 1252 WIZCHIP_WRITE_BUF(SHAR, shar, 6)
jbkim 0:2513c6696bdc 1253
jbkim 0:2513c6696bdc 1254 /**
jbkim 0:2513c6696bdc 1255 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1256 * @brief Get local MAC address
jbkim 0:2513c6696bdc 1257 * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes.
jbkim 0:2513c6696bdc 1258 * @sa setSHAR()
jbkim 0:2513c6696bdc 1259 */
jbkim 0:2513c6696bdc 1260 #define getSHAR(shar) \
jbkim 0:2513c6696bdc 1261 WIZCHIP_READ_BUF(SHAR, shar, 6)
jbkim 0:2513c6696bdc 1262
jbkim 0:2513c6696bdc 1263 /**
jbkim 0:2513c6696bdc 1264 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1265 * @brief Set local IP address
jbkim 0:2513c6696bdc 1266 * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1267 * @sa getSIPR()
jbkim 0:2513c6696bdc 1268 */
jbkim 0:2513c6696bdc 1269 #define setSIPR(sipr) \
jbkim 0:2513c6696bdc 1270 WIZCHIP_WRITE_BUF(SIPR, sipr, 4)
jbkim 0:2513c6696bdc 1271
jbkim 0:2513c6696bdc 1272 /**
jbkim 0:2513c6696bdc 1273 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1274 * @brief Get local IP address
jbkim 0:2513c6696bdc 1275 * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1276 * @sa setSIPR()
jbkim 0:2513c6696bdc 1277 */
jbkim 0:2513c6696bdc 1278 #define getSIPR(sipr) \
jbkim 0:2513c6696bdc 1279 WIZCHIP_READ_BUF(SIPR, sipr, 4)
jbkim 0:2513c6696bdc 1280
jbkim 0:2513c6696bdc 1281 /**
jbkim 0:2513c6696bdc 1282 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1283 * @brief Set INTLEVEL register
jbkim 0:2513c6696bdc 1284 * @param (uint16_t)intlevel Value to set @ref INTLEVEL register.
jbkim 0:2513c6696bdc 1285 * @sa getINTLEVEL()
jbkim 0:2513c6696bdc 1286 */
jbkim 0:2513c6696bdc 1287 #define setINTLEVEL(intlevel) {\
jbkim 0:2513c6696bdc 1288 WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \
jbkim 0:2513c6696bdc 1289 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \
jbkim 0:2513c6696bdc 1290 }
jbkim 0:2513c6696bdc 1291
jbkim 0:2513c6696bdc 1292
jbkim 0:2513c6696bdc 1293 /**
jbkim 0:2513c6696bdc 1294 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1295 * @brief Get INTLEVEL register
jbkim 0:2513c6696bdc 1296 * @return uint16_t. Value of @ref INTLEVEL register.
jbkim 0:2513c6696bdc 1297 * @sa setINTLEVEL()
jbkim 0:2513c6696bdc 1298 */
jbkim 0:2513c6696bdc 1299 #define getINTLEVEL() \
jbkim 0:2513c6696bdc 1300 ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1)))
jbkim 0:2513c6696bdc 1301
jbkim 0:2513c6696bdc 1302 /**
jbkim 0:2513c6696bdc 1303 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1304 * @brief Set @ref IR register
jbkim 0:2513c6696bdc 1305 * @param (uint8_t)ir Value to set @ref IR register.
jbkim 0:2513c6696bdc 1306 * @sa getIR()
jbkim 0:2513c6696bdc 1307 */
jbkim 0:2513c6696bdc 1308 #define setIR(ir) \
jbkim 0:2513c6696bdc 1309 WIZCHIP_WRITE(IR, (ir & 0xF0))
jbkim 0:2513c6696bdc 1310
jbkim 0:2513c6696bdc 1311 /**
jbkim 0:2513c6696bdc 1312 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1313 * @brief Get @ref IR register
jbkim 0:2513c6696bdc 1314 * @return uint8_t. Value of @ref IR register.
jbkim 0:2513c6696bdc 1315 * @sa setIR()
jbkim 0:2513c6696bdc 1316 */
jbkim 0:2513c6696bdc 1317 #define getIR() \
jbkim 0:2513c6696bdc 1318 (WIZCHIP_READ(IR) & 0xF0)
jbkim 0:2513c6696bdc 1319 /**
jbkim 0:2513c6696bdc 1320 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1321 * @brief Set @ref IMR register
jbkim 0:2513c6696bdc 1322 * @param (uint8_t)imr Value to set @ref IMR register.
jbkim 0:2513c6696bdc 1323 * @sa getIMR()
jbkim 0:2513c6696bdc 1324 */
jbkim 0:2513c6696bdc 1325 #define setIMR(imr) \
jbkim 0:2513c6696bdc 1326 WIZCHIP_WRITE(IMR, imr)
jbkim 0:2513c6696bdc 1327
jbkim 0:2513c6696bdc 1328 /**
jbkim 0:2513c6696bdc 1329 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1330 * @brief Get @ref IMR register
jbkim 0:2513c6696bdc 1331 * @return uint8_t. Value of @ref IMR register.
jbkim 0:2513c6696bdc 1332 * @sa setIMR()
jbkim 0:2513c6696bdc 1333 */
jbkim 0:2513c6696bdc 1334 #define getIMR() \
jbkim 0:2513c6696bdc 1335 WIZCHIP_READ(IMR)
jbkim 0:2513c6696bdc 1336
jbkim 0:2513c6696bdc 1337
jbkim 0:2513c6696bdc 1338 /**
jbkim 0:2513c6696bdc 1339 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1340 * @brief Set @ref SIR register
jbkim 0:2513c6696bdc 1341 * @param (uint8_t)sir Value to set @ref SIR register.
jbkim 0:2513c6696bdc 1342 * @sa getSIR()
jbkim 0:2513c6696bdc 1343 */
jbkim 0:2513c6696bdc 1344 #define setSIR(sir) \
jbkim 0:2513c6696bdc 1345 WIZCHIP_WRITE(SIR, sir)
jbkim 0:2513c6696bdc 1346
jbkim 0:2513c6696bdc 1347 /**
jbkim 0:2513c6696bdc 1348 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1349 * @brief Get @ref SIR register
jbkim 0:2513c6696bdc 1350 * @return uint8_t. Value of @ref SIR register.
jbkim 0:2513c6696bdc 1351 * @sa setSIR()
jbkim 0:2513c6696bdc 1352 */
jbkim 0:2513c6696bdc 1353 #define getSIR() \
jbkim 0:2513c6696bdc 1354 WIZCHIP_READ(SIR)
jbkim 0:2513c6696bdc 1355 /**
jbkim 0:2513c6696bdc 1356 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1357 * @brief Set @ref SIMR register
jbkim 0:2513c6696bdc 1358 * @param (uint8_t)simr Value to set @ref SIMR register.
jbkim 0:2513c6696bdc 1359 * @sa getSIMR()
jbkim 0:2513c6696bdc 1360 */
jbkim 0:2513c6696bdc 1361 #define setSIMR(simr) \
jbkim 0:2513c6696bdc 1362 WIZCHIP_WRITE(SIMR, simr)
jbkim 0:2513c6696bdc 1363
jbkim 0:2513c6696bdc 1364 /**
jbkim 0:2513c6696bdc 1365 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1366 * @brief Get @ref SIMR register
jbkim 0:2513c6696bdc 1367 * @return uint8_t. Value of @ref SIMR register.
jbkim 0:2513c6696bdc 1368 * @sa setSIMR()
jbkim 0:2513c6696bdc 1369 */
jbkim 0:2513c6696bdc 1370 #define getSIMR() \
jbkim 0:2513c6696bdc 1371 WIZCHIP_READ(SIMR)
jbkim 0:2513c6696bdc 1372
jbkim 0:2513c6696bdc 1373 /**
jbkim 0:2513c6696bdc 1374 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1375 * @brief Set @ref RTR register
jbkim 0:2513c6696bdc 1376 * @param (uint16_t)rtr Value to set @ref RTR register.
jbkim 0:2513c6696bdc 1377 * @sa getRTR()
jbkim 0:2513c6696bdc 1378 */
jbkim 0:2513c6696bdc 1379 #define setRTR(rtr) {\
jbkim 0:2513c6696bdc 1380 WIZCHIP_WRITE(RTR, (uint8_t)(rtr >> 8)); \
jbkim 0:2513c6696bdc 1381 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(RTR,1), (uint8_t) rtr); \
jbkim 0:2513c6696bdc 1382 }
jbkim 0:2513c6696bdc 1383
jbkim 0:2513c6696bdc 1384 /**
jbkim 0:2513c6696bdc 1385 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1386 * @brief Get @ref RTR register
jbkim 0:2513c6696bdc 1387 * @return uint16_t. Value of @ref RTR register.
jbkim 0:2513c6696bdc 1388 * @sa setRTR()
jbkim 0:2513c6696bdc 1389 */
jbkim 0:2513c6696bdc 1390 #define getRTR() \
jbkim 0:2513c6696bdc 1391 ((WIZCHIP_READ(RTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(RTR,1)))
jbkim 0:2513c6696bdc 1392
jbkim 0:2513c6696bdc 1393 /**
jbkim 0:2513c6696bdc 1394 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1395 * @brief Set @ref RCR register
jbkim 0:2513c6696bdc 1396 * @param (uint8_t)rcr Value to set @ref RCR register.
jbkim 0:2513c6696bdc 1397 * @sa getRCR()
jbkim 0:2513c6696bdc 1398 */
jbkim 0:2513c6696bdc 1399 #define setRCR(rcr) \
jbkim 0:2513c6696bdc 1400 WIZCHIP_WRITE(RCR, rcr)
jbkim 0:2513c6696bdc 1401
jbkim 0:2513c6696bdc 1402 /**
jbkim 0:2513c6696bdc 1403 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1404 * @brief Get @ref RCR register
jbkim 0:2513c6696bdc 1405 * @return uint8_t. Value of @ref RCR register.
jbkim 0:2513c6696bdc 1406 * @sa setRCR()
jbkim 0:2513c6696bdc 1407 */
jbkim 0:2513c6696bdc 1408 #define getRCR() \
jbkim 0:2513c6696bdc 1409 WIZCHIP_READ(RCR)
jbkim 0:2513c6696bdc 1410
jbkim 0:2513c6696bdc 1411 //================================================== test done ===========================================================
jbkim 0:2513c6696bdc 1412
jbkim 0:2513c6696bdc 1413 /**
jbkim 0:2513c6696bdc 1414 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1415 * @brief Set @ref PTIMER register
jbkim 0:2513c6696bdc 1416 * @param (uint8_t)ptimer Value to set @ref PTIMER register.
jbkim 0:2513c6696bdc 1417 * @sa getPTIMER()
jbkim 0:2513c6696bdc 1418 */
jbkim 0:2513c6696bdc 1419 #define setPTIMER(ptimer) \
jbkim 0:2513c6696bdc 1420 WIZCHIP_WRITE(PTIMER, ptimer)
jbkim 0:2513c6696bdc 1421
jbkim 0:2513c6696bdc 1422 /**
jbkim 0:2513c6696bdc 1423 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1424 * @brief Get @ref PTIMER register
jbkim 0:2513c6696bdc 1425 * @return uint8_t. Value of @ref PTIMER register.
jbkim 0:2513c6696bdc 1426 * @sa setPTIMER()
jbkim 0:2513c6696bdc 1427 */
jbkim 0:2513c6696bdc 1428 #define getPTIMER() \
jbkim 0:2513c6696bdc 1429 WIZCHIP_READ(PTIMER)
jbkim 0:2513c6696bdc 1430
jbkim 0:2513c6696bdc 1431 /**
jbkim 0:2513c6696bdc 1432 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1433 * @brief Set @ref PMAGIC register
jbkim 0:2513c6696bdc 1434 * @param (uint8_t)pmagic Value to set @ref PMAGIC register.
jbkim 0:2513c6696bdc 1435 * @sa getPMAGIC()
jbkim 0:2513c6696bdc 1436 */
jbkim 0:2513c6696bdc 1437 #define setPMAGIC(pmagic) \
jbkim 0:2513c6696bdc 1438 WIZCHIP_WRITE(PMAGIC, pmagic)
jbkim 0:2513c6696bdc 1439
jbkim 0:2513c6696bdc 1440 /**
jbkim 0:2513c6696bdc 1441 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1442 * @brief Get @ref PMAGIC register
jbkim 0:2513c6696bdc 1443 * @return uint8_t. Value of @ref PMAGIC register.
jbkim 0:2513c6696bdc 1444 * @sa setPMAGIC()
jbkim 0:2513c6696bdc 1445 */
jbkim 0:2513c6696bdc 1446 #define getPMAGIC() \
jbkim 0:2513c6696bdc 1447 WIZCHIP_READ(PMAGIC)
jbkim 0:2513c6696bdc 1448
jbkim 0:2513c6696bdc 1449 /**
jbkim 0:2513c6696bdc 1450 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1451 * @brief Set PHAR address
jbkim 0:2513c6696bdc 1452 * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes.
jbkim 0:2513c6696bdc 1453 * @sa getPHAR()
jbkim 0:2513c6696bdc 1454 */
jbkim 0:2513c6696bdc 1455 #define setPHAR(phar) \
jbkim 0:2513c6696bdc 1456 WIZCHIP_WRITE_BUF(PHAR, phar, 6)
jbkim 0:2513c6696bdc 1457
jbkim 0:2513c6696bdc 1458 /**
jbkim 0:2513c6696bdc 1459 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1460 * @brief Get local IP address
jbkim 0:2513c6696bdc 1461 * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes.
jbkim 0:2513c6696bdc 1462 * @sa setPHAR()
jbkim 0:2513c6696bdc 1463 */
jbkim 0:2513c6696bdc 1464 #define getPHAR(phar) \
jbkim 0:2513c6696bdc 1465 WIZCHIP_READ_BUF(PHAR, phar, 6)
jbkim 0:2513c6696bdc 1466
jbkim 0:2513c6696bdc 1467 /**
jbkim 0:2513c6696bdc 1468 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1469 * @brief Set @ref PSID register
jbkim 0:2513c6696bdc 1470 * @param (uint16_t)psid Value to set @ref PSID register.
jbkim 0:2513c6696bdc 1471 * @sa getPSID()
jbkim 0:2513c6696bdc 1472 */
jbkim 0:2513c6696bdc 1473 #define setPSID(psid) {\
jbkim 0:2513c6696bdc 1474 WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \
jbkim 0:2513c6696bdc 1475 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \
jbkim 0:2513c6696bdc 1476 }
jbkim 0:2513c6696bdc 1477
jbkim 0:2513c6696bdc 1478 /**
jbkim 0:2513c6696bdc 1479 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1480 * @brief Get @ref PSID register
jbkim 0:2513c6696bdc 1481 * @return uint16_t. Value of @ref PSID register.
jbkim 0:2513c6696bdc 1482 * @sa setPSID()
jbkim 0:2513c6696bdc 1483 */
jbkim 0:2513c6696bdc 1484 //uint16_t getPSID(void);
jbkim 0:2513c6696bdc 1485 #define getPSID() \
jbkim 0:2513c6696bdc 1486 ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1)))
jbkim 0:2513c6696bdc 1487
jbkim 0:2513c6696bdc 1488 /**
jbkim 0:2513c6696bdc 1489 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1490 * @brief Set @ref PMRU register
jbkim 0:2513c6696bdc 1491 * @param (uint16_t)pmru Value to set @ref PMRU register.
jbkim 0:2513c6696bdc 1492 * @sa getPMRU()
jbkim 0:2513c6696bdc 1493 */
jbkim 0:2513c6696bdc 1494 #define setPMRU(pmru) { \
jbkim 0:2513c6696bdc 1495 WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \
jbkim 0:2513c6696bdc 1496 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \
jbkim 0:2513c6696bdc 1497 }
jbkim 0:2513c6696bdc 1498
jbkim 0:2513c6696bdc 1499 /**
jbkim 0:2513c6696bdc 1500 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1501 * @brief Get @ref PMRU register
jbkim 0:2513c6696bdc 1502 * @return uint16_t. Value of @ref PMRU register.
jbkim 0:2513c6696bdc 1503 * @sa setPMRU()
jbkim 0:2513c6696bdc 1504 */
jbkim 0:2513c6696bdc 1505 #define getPMRU() \
jbkim 0:2513c6696bdc 1506 ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1)))
jbkim 0:2513c6696bdc 1507
jbkim 0:2513c6696bdc 1508 /**
jbkim 0:2513c6696bdc 1509 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1510 * @brief Get unreachable IP address
jbkim 0:2513c6696bdc 1511 * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1512 */
jbkim 0:2513c6696bdc 1513 #define getUIPR(uipr) \
jbkim 0:2513c6696bdc 1514 WIZCHIP_READ_BUF(UIPR,uipr,6)
jbkim 0:2513c6696bdc 1515
jbkim 0:2513c6696bdc 1516 /**
jbkim 0:2513c6696bdc 1517 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1518 * @brief Get @ref UPORTR register
jbkim 0:2513c6696bdc 1519 * @return uint16_t. Value of @ref UPORTR register.
jbkim 0:2513c6696bdc 1520 */
jbkim 0:2513c6696bdc 1521 #define getUPORTR() \
jbkim 0:2513c6696bdc 1522 ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1)))
jbkim 0:2513c6696bdc 1523
jbkim 0:2513c6696bdc 1524 /**
jbkim 0:2513c6696bdc 1525 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1526 * @brief Set @ref PHYCFGR register
jbkim 0:2513c6696bdc 1527 * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register.
jbkim 0:2513c6696bdc 1528 * @sa getPHYCFGR()
jbkim 0:2513c6696bdc 1529 */
jbkim 0:2513c6696bdc 1530 #define setPHYCFGR(phycfgr) \
jbkim 0:2513c6696bdc 1531 WIZCHIP_WRITE(PHYCFGR, phycfgr)
jbkim 0:2513c6696bdc 1532
jbkim 0:2513c6696bdc 1533 /**
jbkim 0:2513c6696bdc 1534 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1535 * @brief Get @ref PHYCFGR register
jbkim 0:2513c6696bdc 1536 * @return uint8_t. Value of @ref PHYCFGR register.
jbkim 0:2513c6696bdc 1537 * @sa setPHYCFGR()
jbkim 0:2513c6696bdc 1538 */
jbkim 0:2513c6696bdc 1539 #define getPHYCFGR() \
jbkim 0:2513c6696bdc 1540 WIZCHIP_READ(PHYCFGR)
jbkim 0:2513c6696bdc 1541
jbkim 0:2513c6696bdc 1542 /**
jbkim 0:2513c6696bdc 1543 * @ingroup Common_register_access_function
jbkim 0:2513c6696bdc 1544 * @brief Get @ref VERSIONR register
jbkim 0:2513c6696bdc 1545 * @return uint8_t. Value of @ref VERSIONR register.
jbkim 0:2513c6696bdc 1546 */
jbkim 0:2513c6696bdc 1547 #define getVERSIONR() \
jbkim 0:2513c6696bdc 1548 WIZCHIP_READ(VERSIONR)
jbkim 0:2513c6696bdc 1549
jbkim 0:2513c6696bdc 1550 /////////////////////////////////////
jbkim 0:2513c6696bdc 1551
jbkim 0:2513c6696bdc 1552 ///////////////////////////////////
jbkim 0:2513c6696bdc 1553 // Socket N register I/O function //
jbkim 0:2513c6696bdc 1554 ///////////////////////////////////
jbkim 0:2513c6696bdc 1555 /**
jbkim 0:2513c6696bdc 1556 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1557 * @brief Set @ref Sn_MR register
jbkim 0:2513c6696bdc 1558 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1559 * @param (uint8_t)mr Value to set @ref Sn_MR
jbkim 0:2513c6696bdc 1560 * @sa getSn_MR()
jbkim 0:2513c6696bdc 1561 */
jbkim 0:2513c6696bdc 1562 #define setSn_MR(sn, mr) \
jbkim 0:2513c6696bdc 1563 WIZCHIP_WRITE(Sn_MR(sn),mr)
jbkim 0:2513c6696bdc 1564
jbkim 0:2513c6696bdc 1565 /**
jbkim 0:2513c6696bdc 1566 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1567 * @brief Get @ref Sn_MR register
jbkim 0:2513c6696bdc 1568 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1569 * @return uint8_t. Value of @ref Sn_MR.
jbkim 0:2513c6696bdc 1570 * @sa setSn_MR()
jbkim 0:2513c6696bdc 1571 */
jbkim 0:2513c6696bdc 1572 #define getSn_MR(sn) \
jbkim 0:2513c6696bdc 1573 WIZCHIP_READ(Sn_MR(sn))
jbkim 0:2513c6696bdc 1574
jbkim 0:2513c6696bdc 1575 /**
jbkim 0:2513c6696bdc 1576 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1577 * @brief Set @ref Sn_CR register
jbkim 0:2513c6696bdc 1578 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1579 * @param (uint8_t)cr Value to set @ref Sn_CR
jbkim 0:2513c6696bdc 1580 * @sa getSn_CR()
jbkim 0:2513c6696bdc 1581 */
jbkim 0:2513c6696bdc 1582 #define setSn_CR(sn, cr) \
jbkim 0:2513c6696bdc 1583 WIZCHIP_WRITE(Sn_CR(sn), cr)
jbkim 0:2513c6696bdc 1584
jbkim 0:2513c6696bdc 1585 /**
jbkim 0:2513c6696bdc 1586 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1587 * @brief Get @ref Sn_CR register
jbkim 0:2513c6696bdc 1588 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1589 * @return uint8_t. Value of @ref Sn_CR.
jbkim 0:2513c6696bdc 1590 * @sa setSn_CR()
jbkim 0:2513c6696bdc 1591 */
jbkim 0:2513c6696bdc 1592 #define getSn_CR(sn) \
jbkim 0:2513c6696bdc 1593 WIZCHIP_READ(Sn_CR(sn))
jbkim 0:2513c6696bdc 1594
jbkim 0:2513c6696bdc 1595 /**
jbkim 0:2513c6696bdc 1596 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1597 * @brief Set @ref Sn_IR register
jbkim 0:2513c6696bdc 1598 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1599 * @param (uint8_t)ir Value to set @ref Sn_IR
jbkim 0:2513c6696bdc 1600 * @sa getSn_IR()
jbkim 0:2513c6696bdc 1601 */
jbkim 0:2513c6696bdc 1602 #define setSn_IR(sn, ir) \
jbkim 0:2513c6696bdc 1603 WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F))
jbkim 0:2513c6696bdc 1604
jbkim 0:2513c6696bdc 1605 /**
jbkim 0:2513c6696bdc 1606 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1607 * @brief Get @ref Sn_IR register
jbkim 0:2513c6696bdc 1608 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1609 * @return uint8_t. Value of @ref Sn_IR.
jbkim 0:2513c6696bdc 1610 * @sa setSn_IR()
jbkim 0:2513c6696bdc 1611 */
jbkim 0:2513c6696bdc 1612 #define getSn_IR(sn) \
jbkim 0:2513c6696bdc 1613 (WIZCHIP_READ(Sn_IR(sn)) & 0x1F)
jbkim 0:2513c6696bdc 1614
jbkim 0:2513c6696bdc 1615 /**
jbkim 0:2513c6696bdc 1616 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1617 * @brief Set @ref Sn_IMR register
jbkim 0:2513c6696bdc 1618 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1619 * @param (uint8_t)imr Value to set @ref Sn_IMR
jbkim 0:2513c6696bdc 1620 * @sa getSn_IMR()
jbkim 0:2513c6696bdc 1621 */
jbkim 0:2513c6696bdc 1622 #define setSn_IMR(sn, imr) \
jbkim 0:2513c6696bdc 1623 WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F))
jbkim 0:2513c6696bdc 1624
jbkim 0:2513c6696bdc 1625 /**
jbkim 0:2513c6696bdc 1626 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1627 * @brief Get @ref Sn_IMR register
jbkim 0:2513c6696bdc 1628 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1629 * @return uint8_t. Value of @ref Sn_IMR.
jbkim 0:2513c6696bdc 1630 * @sa setSn_IMR()
jbkim 0:2513c6696bdc 1631 */
jbkim 0:2513c6696bdc 1632 #define getSn_IMR(sn) \
jbkim 0:2513c6696bdc 1633 (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F)
jbkim 0:2513c6696bdc 1634
jbkim 0:2513c6696bdc 1635 /**
jbkim 0:2513c6696bdc 1636 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1637 * @brief Get @ref Sn_SR register
jbkim 0:2513c6696bdc 1638 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1639 * @return uint8_t. Value of @ref Sn_SR.
jbkim 0:2513c6696bdc 1640 */
jbkim 0:2513c6696bdc 1641 #define getSn_SR(sn) \
jbkim 0:2513c6696bdc 1642 WIZCHIP_READ(Sn_SR(sn))
jbkim 0:2513c6696bdc 1643
jbkim 0:2513c6696bdc 1644 /**
jbkim 0:2513c6696bdc 1645 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1646 * @brief Set @ref Sn_PORT register
jbkim 0:2513c6696bdc 1647 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1648 * @param (uint16_t)port Value to set @ref Sn_PORT.
jbkim 0:2513c6696bdc 1649 * @sa getSn_PORT()
jbkim 0:2513c6696bdc 1650 */
jbkim 0:2513c6696bdc 1651 #define setSn_PORT(sn, port) { \
jbkim 0:2513c6696bdc 1652 WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \
jbkim 0:2513c6696bdc 1653 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \
jbkim 0:2513c6696bdc 1654 }
jbkim 0:2513c6696bdc 1655
jbkim 0:2513c6696bdc 1656 /**
jbkim 0:2513c6696bdc 1657 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1658 * @brief Get @ref Sn_PORT register
jbkim 0:2513c6696bdc 1659 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1660 * @return uint16_t. Value of @ref Sn_PORT.
jbkim 0:2513c6696bdc 1661 * @sa setSn_PORT()
jbkim 0:2513c6696bdc 1662 */
jbkim 0:2513c6696bdc 1663 #define getSn_PORT(sn) \
jbkim 0:2513c6696bdc 1664 ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1)))
jbkim 0:2513c6696bdc 1665
jbkim 0:2513c6696bdc 1666 /**
jbkim 0:2513c6696bdc 1667 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1668 * @brief Set @ref Sn_DHAR register
jbkim 0:2513c6696bdc 1669 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1670 * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes.
jbkim 0:2513c6696bdc 1671 * @sa getSn_DHAR()
jbkim 0:2513c6696bdc 1672 */
jbkim 0:2513c6696bdc 1673 #define setSn_DHAR(sn, dhar) \
jbkim 0:2513c6696bdc 1674 WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6)
jbkim 0:2513c6696bdc 1675
jbkim 0:2513c6696bdc 1676 /**
jbkim 0:2513c6696bdc 1677 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1678 * @brief Get @ref Sn_MR register
jbkim 0:2513c6696bdc 1679 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1680 * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes.
jbkim 0:2513c6696bdc 1681 * @sa setSn_DHAR()
jbkim 0:2513c6696bdc 1682 */
jbkim 0:2513c6696bdc 1683 #define getSn_DHAR(sn, dhar) \
jbkim 0:2513c6696bdc 1684 WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6)
jbkim 0:2513c6696bdc 1685
jbkim 0:2513c6696bdc 1686 /**
jbkim 0:2513c6696bdc 1687 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1688 * @brief Set @ref Sn_DIPR register
jbkim 0:2513c6696bdc 1689 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1690 * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1691 * @sa getSn_DIPR()
jbkim 0:2513c6696bdc 1692 */
jbkim 0:2513c6696bdc 1693 #define setSn_DIPR(sn, dipr) \
jbkim 0:2513c6696bdc 1694 WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4)
jbkim 0:2513c6696bdc 1695
jbkim 0:2513c6696bdc 1696 /**
jbkim 0:2513c6696bdc 1697 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1698 * @brief Get @ref Sn_DIPR register
jbkim 0:2513c6696bdc 1699 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1700 * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes.
jbkim 0:2513c6696bdc 1701 * @sa SetSn_DIPR()
jbkim 0:2513c6696bdc 1702 */
jbkim 0:2513c6696bdc 1703 #define getSn_DIPR(sn, dipr) \
jbkim 0:2513c6696bdc 1704 WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4)
jbkim 0:2513c6696bdc 1705
jbkim 0:2513c6696bdc 1706 /**
jbkim 0:2513c6696bdc 1707 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1708 * @brief Set @ref Sn_DPORT register
jbkim 0:2513c6696bdc 1709 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1710 * @param (uint16_t)dport Value to set @ref Sn_DPORT
jbkim 0:2513c6696bdc 1711 * @sa getSn_DPORT()
jbkim 0:2513c6696bdc 1712 */
jbkim 0:2513c6696bdc 1713 #define setSn_DPORT(sn, dport) { \
jbkim 0:2513c6696bdc 1714 WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \
jbkim 0:2513c6696bdc 1715 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \
jbkim 0:2513c6696bdc 1716 }
jbkim 0:2513c6696bdc 1717
jbkim 0:2513c6696bdc 1718 /**
jbkim 0:2513c6696bdc 1719 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1720 * @brief Get @ref Sn_DPORT register
jbkim 0:2513c6696bdc 1721 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1722 * @return uint16_t. Value of @ref Sn_DPORT.
jbkim 0:2513c6696bdc 1723 * @sa setSn_DPORT()
jbkim 0:2513c6696bdc 1724 */
jbkim 0:2513c6696bdc 1725 #define getSn_DPORT(sn) \
jbkim 0:2513c6696bdc 1726 ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1)))
jbkim 0:2513c6696bdc 1727
jbkim 0:2513c6696bdc 1728 /**
jbkim 0:2513c6696bdc 1729 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1730 * @brief Set @ref Sn_MSSR register
jbkim 0:2513c6696bdc 1731 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1732 * @param (uint16_t)mss Value to set @ref Sn_MSSR
jbkim 0:2513c6696bdc 1733 * @sa setSn_MSSR()
jbkim 0:2513c6696bdc 1734 */
jbkim 0:2513c6696bdc 1735 #define setSn_MSSR(sn, mss) { \
jbkim 0:2513c6696bdc 1736 WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \
jbkim 0:2513c6696bdc 1737 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \
jbkim 0:2513c6696bdc 1738 }
jbkim 0:2513c6696bdc 1739
jbkim 0:2513c6696bdc 1740 /**
jbkim 0:2513c6696bdc 1741 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1742 * @brief Get @ref Sn_MSSR register
jbkim 0:2513c6696bdc 1743 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1744 * @return uint16_t. Value of @ref Sn_MSSR.
jbkim 0:2513c6696bdc 1745 * @sa setSn_MSSR()
jbkim 0:2513c6696bdc 1746 */
jbkim 0:2513c6696bdc 1747 #define getSn_MSSR(sn) \
jbkim 0:2513c6696bdc 1748 ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1)))
jbkim 0:2513c6696bdc 1749
jbkim 0:2513c6696bdc 1750 /**
jbkim 0:2513c6696bdc 1751 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1752 * @brief Set @ref Sn_TOS register
jbkim 0:2513c6696bdc 1753 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1754 * @param (uint8_t)tos Value to set @ref Sn_TOS
jbkim 0:2513c6696bdc 1755 * @sa getSn_TOS()
jbkim 0:2513c6696bdc 1756 */
jbkim 0:2513c6696bdc 1757 #define setSn_TOS(sn, tos) \
jbkim 0:2513c6696bdc 1758 WIZCHIP_WRITE(Sn_TOS(sn), tos)
jbkim 0:2513c6696bdc 1759
jbkim 0:2513c6696bdc 1760 /**
jbkim 0:2513c6696bdc 1761 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1762 * @brief Get @ref Sn_TOS register
jbkim 0:2513c6696bdc 1763 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1764 * @return uint8_t. Value of Sn_TOS.
jbkim 0:2513c6696bdc 1765 * @sa setSn_TOS()
jbkim 0:2513c6696bdc 1766 */
jbkim 0:2513c6696bdc 1767 #define getSn_TOS(sn) \
jbkim 0:2513c6696bdc 1768 WIZCHIP_READ(Sn_TOS(sn))
jbkim 0:2513c6696bdc 1769
jbkim 0:2513c6696bdc 1770 /**
jbkim 0:2513c6696bdc 1771 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1772 * @brief Set @ref Sn_TTL register
jbkim 0:2513c6696bdc 1773 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1774 * @param (uint8_t)ttl Value to set @ref Sn_TTL
jbkim 0:2513c6696bdc 1775 * @sa getSn_TTL()
jbkim 0:2513c6696bdc 1776 */
jbkim 0:2513c6696bdc 1777 #define setSn_TTL(sn, ttl) \
jbkim 0:2513c6696bdc 1778 WIZCHIP_WRITE(Sn_TTL(sn), ttl)
jbkim 0:2513c6696bdc 1779
jbkim 0:2513c6696bdc 1780
jbkim 0:2513c6696bdc 1781 /**
jbkim 0:2513c6696bdc 1782 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1783 * @brief Get @ref Sn_TTL register
jbkim 0:2513c6696bdc 1784 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1785 * @return uint8_t. Value of @ref Sn_TTL.
jbkim 0:2513c6696bdc 1786 * @sa setSn_TTL()
jbkim 0:2513c6696bdc 1787 */
jbkim 0:2513c6696bdc 1788 #define getSn_TTL(sn) \
jbkim 0:2513c6696bdc 1789 WIZCHIP_READ(Sn_TTL(sn))
jbkim 0:2513c6696bdc 1790
jbkim 0:2513c6696bdc 1791
jbkim 0:2513c6696bdc 1792 /**
jbkim 0:2513c6696bdc 1793 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1794 * @brief Set @ref Sn_RXBUF_SIZE register
jbkim 0:2513c6696bdc 1795 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1796 * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE
jbkim 0:2513c6696bdc 1797 * @sa getSn_RXBUF_SIZE()
jbkim 0:2513c6696bdc 1798 */
jbkim 0:2513c6696bdc 1799 #define setSn_RXBUF_SIZE(sn, rxbufsize) \
jbkim 0:2513c6696bdc 1800 WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize)
jbkim 0:2513c6696bdc 1801
jbkim 0:2513c6696bdc 1802
jbkim 0:2513c6696bdc 1803 /**
jbkim 0:2513c6696bdc 1804 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1805 * @brief Get @ref Sn_RXBUF_SIZE register
jbkim 0:2513c6696bdc 1806 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1807 * @return uint8_t. Value of @ref Sn_RXBUF_SIZE.
jbkim 0:2513c6696bdc 1808 * @sa setSn_RXBUF_SIZE()
jbkim 0:2513c6696bdc 1809 */
jbkim 0:2513c6696bdc 1810 #define getSn_RXBUF_SIZE(sn) \
jbkim 0:2513c6696bdc 1811 WIZCHIP_READ(Sn_RXBUF_SIZE(sn))
jbkim 0:2513c6696bdc 1812
jbkim 0:2513c6696bdc 1813 /**
jbkim 0:2513c6696bdc 1814 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1815 * @brief Set @ref Sn_TXBUF_SIZE register
jbkim 0:2513c6696bdc 1816 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1817 * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE
jbkim 0:2513c6696bdc 1818 * @sa getSn_TXBUF_SIZE()
jbkim 0:2513c6696bdc 1819 */
jbkim 0:2513c6696bdc 1820 #define setSn_TXBUF_SIZE(sn, txbufsize) \
jbkim 0:2513c6696bdc 1821 WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize)
jbkim 0:2513c6696bdc 1822
jbkim 0:2513c6696bdc 1823 /**
jbkim 0:2513c6696bdc 1824 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1825 * @brief Get @ref Sn_TXBUF_SIZE register
jbkim 0:2513c6696bdc 1826 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1827 * @return uint8_t. Value of @ref Sn_TXBUF_SIZE.
jbkim 0:2513c6696bdc 1828 * @sa setSn_TXBUF_SIZE()
jbkim 0:2513c6696bdc 1829 */
jbkim 0:2513c6696bdc 1830 #define getSn_TXBUF_SIZE(sn) \
jbkim 0:2513c6696bdc 1831 WIZCHIP_READ(Sn_TXBUF_SIZE(sn))
jbkim 0:2513c6696bdc 1832
jbkim 0:2513c6696bdc 1833 /**
jbkim 0:2513c6696bdc 1834 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1835 * @brief Get @ref Sn_TX_FSR register
jbkim 0:2513c6696bdc 1836 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1837 * @return uint16_t. Value of @ref Sn_TX_FSR.
jbkim 0:2513c6696bdc 1838 */
jbkim 0:2513c6696bdc 1839 uint16_t getSn_TX_FSR(uint8_t sn);
jbkim 0:2513c6696bdc 1840
jbkim 0:2513c6696bdc 1841 /**
jbkim 0:2513c6696bdc 1842 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1843 * @brief Get @ref Sn_TX_RD register
jbkim 0:2513c6696bdc 1844 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1845 * @return uint16_t. Value of @ref Sn_TX_RD.
jbkim 0:2513c6696bdc 1846 */
jbkim 0:2513c6696bdc 1847 #define getSn_TX_RD(sn) \
jbkim 0:2513c6696bdc 1848 ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1)))
jbkim 0:2513c6696bdc 1849
jbkim 0:2513c6696bdc 1850 /**
jbkim 0:2513c6696bdc 1851 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1852 * @brief Set @ref Sn_TX_WR register
jbkim 0:2513c6696bdc 1853 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1854 * @param (uint16_t)txwr Value to set @ref Sn_TX_WR
jbkim 0:2513c6696bdc 1855 * @sa GetSn_TX_WR()
jbkim 0:2513c6696bdc 1856 */
jbkim 0:2513c6696bdc 1857 #define setSn_TX_WR(sn, txwr) { \
jbkim 0:2513c6696bdc 1858 WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \
jbkim 0:2513c6696bdc 1859 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \
jbkim 0:2513c6696bdc 1860 }
jbkim 0:2513c6696bdc 1861
jbkim 0:2513c6696bdc 1862 /**
jbkim 0:2513c6696bdc 1863 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1864 * @brief Get @ref Sn_TX_WR register
jbkim 0:2513c6696bdc 1865 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1866 * @return uint16_t. Value of @ref Sn_TX_WR.
jbkim 0:2513c6696bdc 1867 * @sa setSn_TX_WR()
jbkim 0:2513c6696bdc 1868 */
jbkim 0:2513c6696bdc 1869 #define getSn_TX_WR(sn) \
jbkim 0:2513c6696bdc 1870 ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1)))
jbkim 0:2513c6696bdc 1871
jbkim 0:2513c6696bdc 1872
jbkim 0:2513c6696bdc 1873 /**
jbkim 0:2513c6696bdc 1874 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1875 * @brief Get @ref Sn_RX_RSR register
jbkim 0:2513c6696bdc 1876 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1877 * @return uint16_t. Value of @ref Sn_RX_RSR.
jbkim 0:2513c6696bdc 1878 */
jbkim 0:2513c6696bdc 1879 uint16_t getSn_RX_RSR(uint8_t sn);
jbkim 0:2513c6696bdc 1880
jbkim 0:2513c6696bdc 1881
jbkim 0:2513c6696bdc 1882 /**
jbkim 0:2513c6696bdc 1883 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1884 * @brief Set @ref Sn_RX_RD register
jbkim 0:2513c6696bdc 1885 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1886 * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD
jbkim 0:2513c6696bdc 1887 * @sa getSn_RX_RD()
jbkim 0:2513c6696bdc 1888 */
jbkim 0:2513c6696bdc 1889 #define setSn_RX_RD(sn, rxrd) { \
jbkim 0:2513c6696bdc 1890 WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \
jbkim 0:2513c6696bdc 1891 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \
jbkim 0:2513c6696bdc 1892 }
jbkim 0:2513c6696bdc 1893
jbkim 0:2513c6696bdc 1894 /**
jbkim 0:2513c6696bdc 1895 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1896 * @brief Get @ref Sn_RX_RD register
jbkim 0:2513c6696bdc 1897 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1898 * @regurn uint16_t. Value of @ref Sn_RX_RD.
jbkim 0:2513c6696bdc 1899 * @sa setSn_RX_RD()
jbkim 0:2513c6696bdc 1900 */
jbkim 0:2513c6696bdc 1901 #define getSn_RX_RD(sn) \
jbkim 0:2513c6696bdc 1902 ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1)))
jbkim 0:2513c6696bdc 1903
jbkim 0:2513c6696bdc 1904 /**
jbkim 0:2513c6696bdc 1905 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1906 * @brief Get @ref Sn_RX_WR register
jbkim 0:2513c6696bdc 1907 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1908 * @return uint16_t. Value of @ref Sn_RX_WR.
jbkim 0:2513c6696bdc 1909 */
jbkim 0:2513c6696bdc 1910 #define getSn_RX_WR(sn) \
jbkim 0:2513c6696bdc 1911 ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1)))
jbkim 0:2513c6696bdc 1912
jbkim 0:2513c6696bdc 1913
jbkim 0:2513c6696bdc 1914 /**
jbkim 0:2513c6696bdc 1915 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1916 * @brief Set @ref Sn_FRAG register
jbkim 0:2513c6696bdc 1917 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1918 * @param (uint16_t)frag Value to set @ref Sn_FRAG
jbkim 0:2513c6696bdc 1919 * @sa getSn_FRAD()
jbkim 0:2513c6696bdc 1920 */
jbkim 0:2513c6696bdc 1921 #define setSn_FRAG(sn, frag) { \
jbkim 0:2513c6696bdc 1922 WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
jbkim 0:2513c6696bdc 1923 WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \
jbkim 0:2513c6696bdc 1924 }
jbkim 0:2513c6696bdc 1925
jbkim 0:2513c6696bdc 1926 /**
jbkim 0:2513c6696bdc 1927 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1928 * @brief Get @ref Sn_FRAG register
jbkim 0:2513c6696bdc 1929 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1930 * @return uint16_t. Value of @ref Sn_FRAG.
jbkim 0:2513c6696bdc 1931 * @sa setSn_FRAG()
jbkim 0:2513c6696bdc 1932 */
jbkim 0:2513c6696bdc 1933 #define getSn_FRAG(sn) \
jbkim 0:2513c6696bdc 1934 ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1)))
jbkim 0:2513c6696bdc 1935
jbkim 0:2513c6696bdc 1936 /**
jbkim 0:2513c6696bdc 1937 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1938 * @brief Set @ref Sn_KPALVTR register
jbkim 0:2513c6696bdc 1939 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1940 * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR
jbkim 0:2513c6696bdc 1941 * @sa getSn_KPALVTR()
jbkim 0:2513c6696bdc 1942 */
jbkim 0:2513c6696bdc 1943 #define setSn_KPALVTR(sn, kpalvt) \
jbkim 0:2513c6696bdc 1944 WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt)
jbkim 0:2513c6696bdc 1945
jbkim 0:2513c6696bdc 1946 /**
jbkim 0:2513c6696bdc 1947 * @ingroup Socket_register_access_function
jbkim 0:2513c6696bdc 1948 * @brief Get @ref Sn_KPALVTR register
jbkim 0:2513c6696bdc 1949 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1950 * @return uint8_t. Value of @ref Sn_KPALVTR.
jbkim 0:2513c6696bdc 1951 * @sa setSn_KPALVTR()
jbkim 0:2513c6696bdc 1952 */
jbkim 0:2513c6696bdc 1953 #define getSn_KPALVTR(sn) \
jbkim 0:2513c6696bdc 1954 WIZCHIP_READ(Sn_KPALVTR(sn))
jbkim 0:2513c6696bdc 1955
jbkim 0:2513c6696bdc 1956 //////////////////////////////////////
jbkim 0:2513c6696bdc 1957
jbkim 0:2513c6696bdc 1958 /////////////////////////////////////
jbkim 0:2513c6696bdc 1959 // Sn_TXBUF & Sn_RXBUF IO function //
jbkim 0:2513c6696bdc 1960 /////////////////////////////////////
jbkim 0:2513c6696bdc 1961 /**
jbkim 0:2513c6696bdc 1962 * @brief Gets the max buffer size of socket sn passed as parameter.
jbkim 0:2513c6696bdc 1963 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1964 * @return uint16_t. Value of Socket n RX max buffer size.
jbkim 0:2513c6696bdc 1965 */
jbkim 0:2513c6696bdc 1966 #define getSn_RxMAX(sn) \
jbkim 0:2513c6696bdc 1967 (getSn_RXBUF_SIZE(sn) << 10)
jbkim 0:2513c6696bdc 1968
jbkim 0:2513c6696bdc 1969 /**
jbkim 0:2513c6696bdc 1970 * @brief Gets the max buffer size of socket sn passed as parameters.
jbkim 0:2513c6696bdc 1971 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1972 * @return uint16_t. Value of Socket n TX max buffer size.
jbkim 0:2513c6696bdc 1973 */
jbkim 0:2513c6696bdc 1974 //uint16_t getSn_TxMAX(uint8_t sn);
jbkim 0:2513c6696bdc 1975 #define getSn_TxMAX(sn) \
jbkim 0:2513c6696bdc 1976 (getSn_TXBUF_SIZE(sn) << 10)
jbkim 0:2513c6696bdc 1977
jbkim 0:2513c6696bdc 1978 /**
jbkim 0:2513c6696bdc 1979 * @ingroup Basic_IO_function
jbkim 0:2513c6696bdc 1980 * @brief It copies data to internal TX memory
jbkim 0:2513c6696bdc 1981 *
jbkim 0:2513c6696bdc 1982 * @details This function reads the Tx write pointer register and after that,
jbkim 0:2513c6696bdc 1983 * it copies the <i>wizdata(pointer buffer)</i> of the length of <i>len(variable)</i> bytes to internal TX memory
jbkim 0:2513c6696bdc 1984 * and updates the Tx write pointer register.
jbkim 0:2513c6696bdc 1985 * This function is being called by send() and sendto() function also.
jbkim 0:2513c6696bdc 1986 *
jbkim 0:2513c6696bdc 1987 * @note User should read upper byte first and lower byte later to get proper value.
jbkim 0:2513c6696bdc 1988 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 1989 * @param wizdata Pointer buffer to write data
jbkim 0:2513c6696bdc 1990 * @param len Data length
jbkim 0:2513c6696bdc 1991 * @sa wiz_recv_data()
jbkim 0:2513c6696bdc 1992 */
jbkim 0:2513c6696bdc 1993 void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
jbkim 0:2513c6696bdc 1994
jbkim 0:2513c6696bdc 1995 /**
jbkim 0:2513c6696bdc 1996 * @ingroup Basic_IO_function
jbkim 0:2513c6696bdc 1997 * @brief It copies data to your buffer from internal RX memory
jbkim 0:2513c6696bdc 1998 *
jbkim 0:2513c6696bdc 1999 * @details This function read the Rx read pointer register and after that,
jbkim 0:2513c6696bdc 2000 * it copies the received data from internal RX memory
jbkim 0:2513c6696bdc 2001 * to <i>wizdata(pointer variable)</i> of the length of <i>len(variable)</i> bytes.
jbkim 0:2513c6696bdc 2002 * This function is being called by recv() also.
jbkim 0:2513c6696bdc 2003 *
jbkim 0:2513c6696bdc 2004 * @note User should read upper byte first and lower byte later to get proper value.
jbkim 0:2513c6696bdc 2005 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 2006 * @param wizdata Pointer buffer to read data
jbkim 0:2513c6696bdc 2007 * @param len Data length
jbkim 0:2513c6696bdc 2008 * @sa wiz_send_data()
jbkim 0:2513c6696bdc 2009 */
jbkim 0:2513c6696bdc 2010 void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
jbkim 0:2513c6696bdc 2011
jbkim 0:2513c6696bdc 2012 /**
jbkim 0:2513c6696bdc 2013 * @ingroup Basic_IO_function
jbkim 0:2513c6696bdc 2014 * @brief It discard the received data in RX memory.
jbkim 0:2513c6696bdc 2015 * @details It discards the data of the length of <i>len(variable)</i> bytes in internal RX memory.
jbkim 0:2513c6696bdc 2016 * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>.
jbkim 0:2513c6696bdc 2017 * @param len Data length
jbkim 0:2513c6696bdc 2018 */
jbkim 0:2513c6696bdc 2019 void wiz_recv_ignore(uint8_t sn, uint16_t len);
jbkim 0:2513c6696bdc 2020
jbkim 0:2513c6696bdc 2021 #endif // _W5500_H_