none changed
Fork of WIZnetInterface by
arch/ext/W5500.h@8:4c02de1dbf3a, 2015-06-16 (annotated)
- Committer:
- Soohwan Kim
- Date:
- Tue Jun 16 11:11:11 2015 +0900
- Revision:
- 8:4c02de1dbf3a
- Parent:
- 6:94a81e80c675
- Child:
- 9:40d25592e6a0
amened
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Soohwan Kim |
0:6f28332c466f | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
Soohwan Kim |
0:6f28332c466f | 2 | * |
Soohwan Kim |
0:6f28332c466f | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
Soohwan Kim |
0:6f28332c466f | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
Soohwan Kim |
0:6f28332c466f | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
Soohwan Kim |
0:6f28332c466f | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
Soohwan Kim |
0:6f28332c466f | 7 | * furnished to do so, subject to the following conditions: |
Soohwan Kim |
0:6f28332c466f | 8 | * |
Soohwan Kim |
0:6f28332c466f | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
Soohwan Kim |
0:6f28332c466f | 10 | * substantial portions of the Software. |
Soohwan Kim |
0:6f28332c466f | 11 | * |
Soohwan Kim |
0:6f28332c466f | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
Soohwan Kim |
0:6f28332c466f | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
Soohwan Kim |
0:6f28332c466f | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
Soohwan Kim |
0:6f28332c466f | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Soohwan Kim |
0:6f28332c466f | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Soohwan Kim |
0:6f28332c466f | 17 | * |
Soohwan Kim |
0:6f28332c466f | 18 | */ |
Soohwan Kim |
0:6f28332c466f | 19 | |
Soohwan Kim |
0:6f28332c466f | 20 | #pragma once |
Soohwan Kim |
0:6f28332c466f | 21 | |
Soohwan Kim |
0:6f28332c466f | 22 | #include "mbed.h" |
Soohwan Kim |
0:6f28332c466f | 23 | #include "mbed_debug.h" |
Soohwan Kim |
0:6f28332c466f | 24 | |
Soohwan Kim |
0:6f28332c466f | 25 | #define TEST_ASSERT(A) while(!(A)){debug("\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; |
Soohwan Kim |
0:6f28332c466f | 26 | |
Soohwan Kim |
0:6f28332c466f | 27 | #define DEFAULT_WAIT_RESP_TIMEOUT 500 |
Soohwan Kim |
0:6f28332c466f | 28 | |
Soohwan Kim |
4:4930f81bbe98 | 29 | #define SOCK_ERROR 0 |
Soohwan Kim |
4:4930f81bbe98 | 30 | #define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number |
Soohwan Kim |
4:4930f81bbe98 | 31 | #define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option |
Soohwan Kim |
4:4930f81bbe98 | 32 | #define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized |
Soohwan Kim |
4:4930f81bbe98 | 33 | #define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. |
Soohwan Kim |
4:4930f81bbe98 | 34 | #define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. |
Soohwan Kim |
4:4930f81bbe98 | 35 | #define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag |
Soohwan Kim |
4:4930f81bbe98 | 36 | #define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. |
Soohwan Kim |
4:4930f81bbe98 | 37 | #define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argrument. |
Soohwan Kim |
4:4930f81bbe98 | 38 | #define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero |
Soohwan Kim |
4:4930f81bbe98 | 39 | #define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address |
Soohwan Kim |
4:4930f81bbe98 | 40 | #define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred |
Soohwan Kim |
4:4930f81bbe98 | 41 | #define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. |
Soohwan Kim |
4:4930f81bbe98 | 42 | #define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. |
Soohwan Kim |
4:4930f81bbe98 | 43 | |
Soohwan Kim |
4:4930f81bbe98 | 44 | #define SOCK_ANY_PORT_NUM 0xC000; |
Soohwan Kim |
4:4930f81bbe98 | 45 | |
Soohwan Kim |
0:6f28332c466f | 46 | |
Soohwan Kim |
0:6f28332c466f | 47 | #define MAX_SOCK_NUM 8 |
Soohwan Kim |
0:6f28332c466f | 48 | |
Soohwan Kim |
0:6f28332c466f | 49 | #define MR 0x0000 |
Soohwan Kim |
0:6f28332c466f | 50 | #define GAR 0x0001 |
Soohwan Kim |
0:6f28332c466f | 51 | #define SUBR 0x0005 |
Soohwan Kim |
0:6f28332c466f | 52 | #define SHAR 0x0009 |
Soohwan Kim |
0:6f28332c466f | 53 | #define SIPR 0x000f |
Soohwan Kim |
4:4930f81bbe98 | 54 | #define IR 0x0015 |
Soohwan Kim |
4:4930f81bbe98 | 55 | #define IMR 0x0016 |
Soohwan Kim |
4:4930f81bbe98 | 56 | #define SIR 0x0017 |
Soohwan Kim |
4:4930f81bbe98 | 57 | #define SIMR 0x0018 |
Soohwan Kim |
4:4930f81bbe98 | 58 | #define RTR 0x0019 |
Soohwan Kim |
4:4930f81bbe98 | 59 | #define RCR 0x001b |
Soohwan Kim |
4:4930f81bbe98 | 60 | #define UIPR 0x0028 |
Soohwan Kim |
4:4930f81bbe98 | 61 | #define UPORTR 0x002c |
Soohwan Kim |
4:4930f81bbe98 | 62 | #define PHYCFGR 0x002e |
Soohwan Kim |
0:6f28332c466f | 63 | |
Soohwan Kim |
0:6f28332c466f | 64 | // W5500 socket register |
Soohwan Kim |
0:6f28332c466f | 65 | #define Sn_MR 0x0000 |
Soohwan Kim |
0:6f28332c466f | 66 | #define Sn_CR 0x0001 |
Soohwan Kim |
0:6f28332c466f | 67 | #define Sn_IR 0x0002 |
Soohwan Kim |
0:6f28332c466f | 68 | #define Sn_SR 0x0003 |
Soohwan Kim |
0:6f28332c466f | 69 | #define Sn_PORT 0x0004 |
Soohwan Kim |
4:4930f81bbe98 | 70 | #define Sn_DHAR 0x0006 |
Soohwan Kim |
0:6f28332c466f | 71 | #define Sn_DIPR 0x000c |
Soohwan Kim |
0:6f28332c466f | 72 | #define Sn_DPORT 0x0010 |
Soohwan Kim |
0:6f28332c466f | 73 | #define Sn_RXBUF_SIZE 0x001e |
Soohwan Kim |
0:6f28332c466f | 74 | #define Sn_TXBUF_SIZE 0x001f |
Soohwan Kim |
0:6f28332c466f | 75 | #define Sn_TX_FSR 0x0020 |
Soohwan Kim |
4:4930f81bbe98 | 76 | #define Sn_TX_RD 0x0022 |
Soohwan Kim |
0:6f28332c466f | 77 | #define Sn_TX_WR 0x0024 |
Soohwan Kim |
0:6f28332c466f | 78 | #define Sn_RX_RSR 0x0026 |
Soohwan Kim |
0:6f28332c466f | 79 | #define Sn_RX_RD 0x0028 |
Soohwan Kim |
4:4930f81bbe98 | 80 | #define Sn_RX_WR 0x002a |
Soohwan Kim |
4:4930f81bbe98 | 81 | #define Sn_IMR 0x002c |
Soohwan Kim |
4:4930f81bbe98 | 82 | |
Soohwan Kim |
4:4930f81bbe98 | 83 | |
Soohwan Kim |
4:4930f81bbe98 | 84 | //Define for Socket Command register option value |
Soohwan Kim |
4:4930f81bbe98 | 85 | #define Sn_CR_OPEN 0x01 |
Soohwan Kim |
4:4930f81bbe98 | 86 | #define Sn_CR_LISTEN 0x02 |
Soohwan Kim |
4:4930f81bbe98 | 87 | #define Sn_CR_CONNECT 0x04 |
Soohwan Kim |
4:4930f81bbe98 | 88 | #define Sn_CR_DISCON 0x08 |
Soohwan Kim |
4:4930f81bbe98 | 89 | #define Sn_CR_CLOSE 0x10 |
Soohwan Kim |
4:4930f81bbe98 | 90 | #define Sn_CR_SEND 0x20 |
Soohwan Kim |
4:4930f81bbe98 | 91 | #define Sn_CR_SEND_MAC 0x21 |
Soohwan Kim |
4:4930f81bbe98 | 92 | #define Sn_CR_SEND_KEEP 0x22 |
Soohwan Kim |
4:4930f81bbe98 | 93 | #define Sn_CR_RECV 0x40 |
Soohwan Kim |
4:4930f81bbe98 | 94 | |
Soohwan Kim |
4:4930f81bbe98 | 95 | |
Soohwan Kim |
4:4930f81bbe98 | 96 | //Define for Socket Mode register option value |
Soohwan Kim |
4:4930f81bbe98 | 97 | #define Sn_MR_CLOSE 0x00 |
Soohwan Kim |
4:4930f81bbe98 | 98 | #define Sn_MR_TCP 0x01 |
Soohwan Kim |
4:4930f81bbe98 | 99 | #define Sn_MR_UDP 0x02 |
Soohwan Kim |
4:4930f81bbe98 | 100 | #define Sn_MR_MACRAW 0x04 |
Soohwan Kim |
4:4930f81bbe98 | 101 | #define Sn_MR_UCASTB 0x10 |
Soohwan Kim |
4:4930f81bbe98 | 102 | #define Sn_MR_ND 0x20 |
Soohwan Kim |
4:4930f81bbe98 | 103 | #define Sn_MR_BCASTB 0x40 |
Soohwan Kim |
4:4930f81bbe98 | 104 | #define Sn_MR_MULTI 0x80 |
Soohwan Kim |
4:4930f81bbe98 | 105 | |
Soohwan Kim |
4:4930f81bbe98 | 106 | #define Sn_IR_SENDOK 0x10 |
Soohwan Kim |
4:4930f81bbe98 | 107 | |
Soohwan Kim |
4:4930f81bbe98 | 108 | //Sn_IR values |
Soohwan Kim |
4:4930f81bbe98 | 109 | |
Soohwan Kim |
4:4930f81bbe98 | 110 | #define Sn_IR_TIMEOUT 0x08 |
Soohwan Kim |
4:4930f81bbe98 | 111 | #define Sn_IR_RECV 0x04 |
Soohwan Kim |
4:4930f81bbe98 | 112 | #define Sn_IR_DISCON 0x02 |
Soohwan Kim |
4:4930f81bbe98 | 113 | #define Sn_IR_CON 0x01 |
Soohwan Kim |
4:4930f81bbe98 | 114 | |
Soohwan Kim |
4:4930f81bbe98 | 115 | /* PHYCFGR register value */ |
Soohwan Kim |
4:4930f81bbe98 | 116 | #define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. |
Soohwan Kim |
4:4930f81bbe98 | 117 | #define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value |
Soohwan Kim |
4:4930f81bbe98 | 118 | #define PHYCFGR_OPMDC_ALLA (7<<3) |
Soohwan Kim |
4:4930f81bbe98 | 119 | #define PHYCFGR_OPMDC_PDOWN (6<<3) |
Soohwan Kim |
4:4930f81bbe98 | 120 | #define PHYCFGR_OPMDC_NA (5<<3) |
Soohwan Kim |
4:4930f81bbe98 | 121 | #define PHYCFGR_OPMDC_100FA (4<<3) |
Soohwan Kim |
4:4930f81bbe98 | 122 | #define PHYCFGR_OPMDC_100F (3<<3) |
Soohwan Kim |
4:4930f81bbe98 | 123 | #define PHYCFGR_OPMDC_100H (2<<3) |
Soohwan Kim |
4:4930f81bbe98 | 124 | #define PHYCFGR_OPMDC_10F (1<<3) |
Soohwan Kim |
4:4930f81bbe98 | 125 | #define PHYCFGR_OPMDC_10H (0<<3) |
Soohwan Kim |
4:4930f81bbe98 | 126 | #define PHYCFGR_DPX_FULL (1<<2) |
Soohwan Kim |
4:4930f81bbe98 | 127 | #define PHYCFGR_DPX_HALF (0<<2) |
Soohwan Kim |
4:4930f81bbe98 | 128 | #define PHYCFGR_SPD_100 (1<<1) |
Soohwan Kim |
4:4930f81bbe98 | 129 | #define PHYCFGR_SPD_10 (0<<1) |
Soohwan Kim |
4:4930f81bbe98 | 130 | #define PHYCFGR_LNK_ON (1<<0) |
Soohwan Kim |
4:4930f81bbe98 | 131 | #define PHYCFGR_LNK_OFF (0<<0) |
Soohwan Kim |
4:4930f81bbe98 | 132 | |
Soohwan Kim |
4:4930f81bbe98 | 133 | //PHY status define |
Soohwan Kim |
4:4930f81bbe98 | 134 | #define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin |
Soohwan Kim |
4:4930f81bbe98 | 135 | #define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register |
Soohwan Kim |
4:4930f81bbe98 | 136 | #define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. |
Soohwan Kim |
4:4930f81bbe98 | 137 | #define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation |
Soohwan Kim |
4:4930f81bbe98 | 138 | #define PHY_SPEED_10 0 ///< Link Speed 10 |
Soohwan Kim |
4:4930f81bbe98 | 139 | #define PHY_SPEED_100 1 ///< Link Speed 100 |
Soohwan Kim |
4:4930f81bbe98 | 140 | #define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex |
Soohwan Kim |
4:4930f81bbe98 | 141 | #define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex |
Soohwan Kim |
4:4930f81bbe98 | 142 | #define PHY_LINK_OFF 0 ///< Link Off |
Soohwan Kim |
4:4930f81bbe98 | 143 | #define PHY_LINK_ON 1 ///< Link On |
Soohwan Kim |
4:4930f81bbe98 | 144 | #define PHY_POWER_NORM 0 ///< PHY power normal mode |
Soohwan Kim |
4:4930f81bbe98 | 145 | #define PHY_POWER_DOWN 1 ///< PHY power down mode |
Soohwan Kim |
0:6f28332c466f | 146 | |
Soohwan Kim |
8:4c02de1dbf3a | 147 | enum PHYMode { |
Soohwan Kim |
8:4c02de1dbf3a | 148 | AutoNegotiate = 0, |
Soohwan Kim |
8:4c02de1dbf3a | 149 | HalfDuplex10 = 1, |
Soohwan Kim |
8:4c02de1dbf3a | 150 | FullDuplex10 = 2, |
Soohwan Kim |
8:4c02de1dbf3a | 151 | HalfDuplex100 = 3, |
Soohwan Kim |
8:4c02de1dbf3a | 152 | FullDuplex100 = 4, |
Soohwan Kim |
8:4c02de1dbf3a | 153 | }; |
Soohwan Kim |
8:4c02de1dbf3a | 154 | |
Soohwan Kim |
0:6f28332c466f | 155 | class WIZnet_Chip { |
Soohwan Kim |
0:6f28332c466f | 156 | public: |
embeddist | 3:f8c6efc8bf83 | 157 | enum Protocol { |
embeddist | 3:f8c6efc8bf83 | 158 | CLOSED = 0, |
embeddist | 3:f8c6efc8bf83 | 159 | TCP = 1, |
embeddist | 3:f8c6efc8bf83 | 160 | UDP = 2, |
embeddist | 3:f8c6efc8bf83 | 161 | }; |
embeddist | 3:f8c6efc8bf83 | 162 | |
embeddist | 3:f8c6efc8bf83 | 163 | enum Command { |
embeddist | 3:f8c6efc8bf83 | 164 | OPEN = 0x01, |
embeddist | 3:f8c6efc8bf83 | 165 | LISTEN = 0x02, |
embeddist | 3:f8c6efc8bf83 | 166 | CONNECT = 0x04, |
embeddist | 3:f8c6efc8bf83 | 167 | DISCON = 0x08, |
embeddist | 3:f8c6efc8bf83 | 168 | CLOSE = 0x10, |
embeddist | 3:f8c6efc8bf83 | 169 | SEND = 0x20, |
embeddist | 3:f8c6efc8bf83 | 170 | SEND_MAC = 0x21, |
embeddist | 3:f8c6efc8bf83 | 171 | SEND_KEEP = 0x22, |
embeddist | 3:f8c6efc8bf83 | 172 | RECV = 0x40, |
embeddist | 3:f8c6efc8bf83 | 173 | |
embeddist | 3:f8c6efc8bf83 | 174 | }; |
embeddist | 3:f8c6efc8bf83 | 175 | |
embeddist | 3:f8c6efc8bf83 | 176 | enum Interrupt { |
embeddist | 3:f8c6efc8bf83 | 177 | INT_CON = 0x01, |
embeddist | 3:f8c6efc8bf83 | 178 | INT_DISCON = 0x02, |
embeddist | 3:f8c6efc8bf83 | 179 | INT_RECV = 0x04, |
embeddist | 3:f8c6efc8bf83 | 180 | INT_TIMEOUT = 0x08, |
embeddist | 3:f8c6efc8bf83 | 181 | INT_SEND_OK = 0x10, |
embeddist | 3:f8c6efc8bf83 | 182 | }; |
embeddist | 3:f8c6efc8bf83 | 183 | |
Soohwan Kim |
5:f432ae8f8708 | 184 | enum Status { |
Soohwan Kim |
5:f432ae8f8708 | 185 | SOCK_CLOSED = 0x00, |
Soohwan Kim |
5:f432ae8f8708 | 186 | SOCK_INIT = 0x13, |
Soohwan Kim |
5:f432ae8f8708 | 187 | SOCK_LISTEN = 0x14, |
Soohwan Kim |
5:f432ae8f8708 | 188 | SOCK_SYNSENT = 0x15, |
Soohwan Kim |
5:f432ae8f8708 | 189 | SOCK_ESTABLISHED = 0x17, |
Soohwan Kim |
5:f432ae8f8708 | 190 | SOCK_CLOSE_WAIT = 0x1c, |
Soohwan Kim |
5:f432ae8f8708 | 191 | SOCK_UDP = 0x22, |
Soohwan Kim |
5:f432ae8f8708 | 192 | }; |
Soohwan Kim |
5:f432ae8f8708 | 193 | |
Soohwan Kim |
4:4930f81bbe98 | 194 | |
Soohwan Kim |
4:4930f81bbe98 | 195 | uint16_t sock_any_port; |
Soohwan Kim |
4:4930f81bbe98 | 196 | |
Soohwan Kim |
0:6f28332c466f | 197 | /* |
Soohwan Kim |
0:6f28332c466f | 198 | * Constructor |
Soohwan Kim |
0:6f28332c466f | 199 | * |
Soohwan Kim |
0:6f28332c466f | 200 | * @param spi spi class |
Soohwan Kim |
0:6f28332c466f | 201 | * @param cs cs of the W5500 |
Soohwan Kim |
0:6f28332c466f | 202 | * @param reset reset pin of the W5500 |
Soohwan Kim |
0:6f28332c466f | 203 | */ |
Soohwan Kim |
4:4930f81bbe98 | 204 | WIZnet_Chip(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset); |
Soohwan Kim |
4:4930f81bbe98 | 205 | WIZnet_Chip(SPI* spi, PinName cs, PinName reset); |
Soohwan Kim |
0:6f28332c466f | 206 | |
Soohwan Kim |
0:6f28332c466f | 207 | /* |
Soohwan Kim |
4:4930f81bbe98 | 208 | * Set MAC Address to W5500 |
Soohwan Kim |
4:4930f81bbe98 | 209 | * |
Soohwan Kim |
4:4930f81bbe98 | 210 | * @return true if connected, false otherwise |
Soohwan Kim |
4:4930f81bbe98 | 211 | */ |
Soohwan Kim |
4:4930f81bbe98 | 212 | bool setmac(); |
Soohwan Kim |
4:4930f81bbe98 | 213 | |
Soohwan Kim |
4:4930f81bbe98 | 214 | /* |
Soohwan Kim |
4:4930f81bbe98 | 215 | * Set Network Informations (SrcIP, Netmask, Gataway) |
Soohwan Kim |
0:6f28332c466f | 216 | * |
Soohwan Kim |
0:6f28332c466f | 217 | * @return true if connected, false otherwise |
Soohwan Kim |
0:6f28332c466f | 218 | */ |
Soohwan Kim |
0:6f28332c466f | 219 | bool setip(); |
Soohwan Kim |
0:6f28332c466f | 220 | |
Soohwan Kim |
0:6f28332c466f | 221 | /* |
Soohwan Kim |
0:6f28332c466f | 222 | * Disconnect the connection |
Soohwan Kim |
0:6f28332c466f | 223 | * |
Soohwan Kim |
0:6f28332c466f | 224 | * @ returns true |
Soohwan Kim |
0:6f28332c466f | 225 | */ |
Soohwan Kim |
0:6f28332c466f | 226 | bool disconnect(); |
Soohwan Kim |
0:6f28332c466f | 227 | |
Soohwan Kim |
0:6f28332c466f | 228 | /* |
Soohwan Kim |
0:6f28332c466f | 229 | * Open a tcp connection with the specified host on the specified port |
Soohwan Kim |
0:6f28332c466f | 230 | * |
Soohwan Kim |
0:6f28332c466f | 231 | * @param host host (can be either an ip address or a name. If a name is provided, a dns request will be established) |
Soohwan Kim |
0:6f28332c466f | 232 | * @param port port |
Soohwan Kim |
0:6f28332c466f | 233 | * @ returns true if successful |
Soohwan Kim |
0:6f28332c466f | 234 | */ |
Soohwan Kim |
0:6f28332c466f | 235 | bool connect(int socket, const char * host, int port, int timeout_ms = 10*1000); |
Soohwan Kim |
0:6f28332c466f | 236 | |
Soohwan Kim |
0:6f28332c466f | 237 | /* |
Soohwan Kim |
0:6f28332c466f | 238 | * Set the protocol (UDP or TCP) |
Soohwan Kim |
0:6f28332c466f | 239 | * |
Soohwan Kim |
0:6f28332c466f | 240 | * @param p protocol |
Soohwan Kim |
0:6f28332c466f | 241 | * @ returns true if successful |
Soohwan Kim |
0:6f28332c466f | 242 | */ |
Soohwan Kim |
0:6f28332c466f | 243 | bool setProtocol(int socket, Protocol p); |
Soohwan Kim |
0:6f28332c466f | 244 | |
Soohwan Kim |
0:6f28332c466f | 245 | /* |
Soohwan Kim |
0:6f28332c466f | 246 | * Reset the W5500 |
Soohwan Kim |
0:6f28332c466f | 247 | */ |
Soohwan Kim |
0:6f28332c466f | 248 | void reset(); |
Soohwan Kim |
0:6f28332c466f | 249 | |
Soohwan Kim |
0:6f28332c466f | 250 | int wait_readable(int socket, int wait_time_ms, int req_size = 0); |
Soohwan Kim |
0:6f28332c466f | 251 | |
Soohwan Kim |
0:6f28332c466f | 252 | int wait_writeable(int socket, int wait_time_ms, int req_size = 0); |
Soohwan Kim |
0:6f28332c466f | 253 | |
Soohwan Kim |
0:6f28332c466f | 254 | /* |
Soohwan Kim |
8:4c02de1dbf3a | 255 | * Check if an ethernet link is pressent or not. |
Soohwan Kim |
8:4c02de1dbf3a | 256 | * |
Soohwan Kim |
8:4c02de1dbf3a | 257 | * @returns true if successful |
Soohwan Kim |
8:4c02de1dbf3a | 258 | */ |
Soohwan Kim |
8:4c02de1dbf3a | 259 | bool link(int wait_time_ms= 3*1000); |
Soohwan Kim |
8:4c02de1dbf3a | 260 | |
Soohwan Kim |
8:4c02de1dbf3a | 261 | /* |
Soohwan Kim |
8:4c02de1dbf3a | 262 | * Sets the speed and duplex parameters of an ethernet link. |
Soohwan Kim |
8:4c02de1dbf3a | 263 | * |
Soohwan Kim |
8:4c02de1dbf3a | 264 | * @returns true if successful |
Soohwan Kim |
8:4c02de1dbf3a | 265 | */ |
Soohwan Kim |
8:4c02de1dbf3a | 266 | void set_link(PHYMode phymode); |
Soohwan Kim |
8:4c02de1dbf3a | 267 | |
Soohwan Kim |
8:4c02de1dbf3a | 268 | /* |
Soohwan Kim |
0:6f28332c466f | 269 | * Check if a tcp link is active |
Soohwan Kim |
0:6f28332c466f | 270 | * |
Soohwan Kim |
0:6f28332c466f | 271 | * @returns true if successful |
Soohwan Kim |
0:6f28332c466f | 272 | */ |
Soohwan Kim |
0:6f28332c466f | 273 | bool is_connected(int socket); |
Soohwan Kim |
0:6f28332c466f | 274 | |
Soohwan Kim |
0:6f28332c466f | 275 | /* |
Soohwan Kim |
0:6f28332c466f | 276 | * Close a tcp connection |
Soohwan Kim |
0:6f28332c466f | 277 | * |
Soohwan Kim |
0:6f28332c466f | 278 | * @ returns true if successful |
Soohwan Kim |
0:6f28332c466f | 279 | */ |
Soohwan Kim |
0:6f28332c466f | 280 | bool close(int socket); |
Soohwan Kim |
0:6f28332c466f | 281 | |
Soohwan Kim |
0:6f28332c466f | 282 | /* |
Soohwan Kim |
0:6f28332c466f | 283 | * @param str string to be sent |
Soohwan Kim |
0:6f28332c466f | 284 | * @param len string length |
Soohwan Kim |
0:6f28332c466f | 285 | */ |
Soohwan Kim |
0:6f28332c466f | 286 | int send(int socket, const char * str, int len); |
Soohwan Kim |
0:6f28332c466f | 287 | |
Soohwan Kim |
0:6f28332c466f | 288 | int recv(int socket, char* buf, int len); |
Soohwan Kim |
0:6f28332c466f | 289 | |
Soohwan Kim |
0:6f28332c466f | 290 | /* |
Soohwan Kim |
0:6f28332c466f | 291 | * Return true if the module is using dhcp |
Soohwan Kim |
0:6f28332c466f | 292 | * |
Soohwan Kim |
0:6f28332c466f | 293 | * @returns true if the module is using dhcp |
Soohwan Kim |
0:6f28332c466f | 294 | */ |
Soohwan Kim |
0:6f28332c466f | 295 | bool isDHCP() { |
Soohwan Kim |
0:6f28332c466f | 296 | return dhcp; |
Soohwan Kim |
0:6f28332c466f | 297 | } |
Soohwan Kim |
0:6f28332c466f | 298 | |
Soohwan Kim |
0:6f28332c466f | 299 | bool gethostbyname(const char* host, uint32_t* ip); |
Soohwan Kim |
0:6f28332c466f | 300 | |
Soohwan Kim |
0:6f28332c466f | 301 | static WIZnet_Chip * getInstance() { |
Soohwan Kim |
0:6f28332c466f | 302 | return inst; |
Soohwan Kim |
0:6f28332c466f | 303 | }; |
Soohwan Kim |
0:6f28332c466f | 304 | |
Soohwan Kim |
0:6f28332c466f | 305 | int new_socket(); |
Soohwan Kim |
0:6f28332c466f | 306 | uint16_t new_port(); |
Soohwan Kim |
0:6f28332c466f | 307 | void scmd(int socket, Command cmd); |
Soohwan Kim |
0:6f28332c466f | 308 | |
Soohwan Kim |
0:6f28332c466f | 309 | template<typename T> |
Soohwan Kim |
0:6f28332c466f | 310 | void sreg(int socket, uint16_t addr, T data) { |
Soohwan Kim |
0:6f28332c466f | 311 | reg_wr<T>(addr, (0x0C + (socket << 5)), data); |
Soohwan Kim |
0:6f28332c466f | 312 | } |
Soohwan Kim |
0:6f28332c466f | 313 | |
Soohwan Kim |
0:6f28332c466f | 314 | template<typename T> |
Soohwan Kim |
0:6f28332c466f | 315 | T sreg(int socket, uint16_t addr) { |
Soohwan Kim |
0:6f28332c466f | 316 | return reg_rd<T>(addr, (0x08 + (socket << 5))); |
Soohwan Kim |
0:6f28332c466f | 317 | } |
Soohwan Kim |
0:6f28332c466f | 318 | |
Soohwan Kim |
0:6f28332c466f | 319 | template<typename T> |
Soohwan Kim |
0:6f28332c466f | 320 | void reg_wr(uint16_t addr, T data) { |
Soohwan Kim |
0:6f28332c466f | 321 | return reg_wr(addr, 0x04, data); |
Soohwan Kim |
0:6f28332c466f | 322 | } |
Soohwan Kim |
0:6f28332c466f | 323 | |
Soohwan Kim |
0:6f28332c466f | 324 | template<typename T> |
Soohwan Kim |
0:6f28332c466f | 325 | void reg_wr(uint16_t addr, uint8_t cb, T data) { |
Soohwan Kim |
0:6f28332c466f | 326 | uint8_t buf[sizeof(T)]; |
Soohwan Kim |
0:6f28332c466f | 327 | *reinterpret_cast<T*>(buf) = data; |
Soohwan Kim |
0:6f28332c466f | 328 | for(int i = 0; i < sizeof(buf)/2; i++) { // Little Endian to Big Endian |
Soohwan Kim |
0:6f28332c466f | 329 | uint8_t t = buf[i]; |
Soohwan Kim |
0:6f28332c466f | 330 | buf[i] = buf[sizeof(buf)-1-i]; |
Soohwan Kim |
0:6f28332c466f | 331 | buf[sizeof(buf)-1-i] = t; |
Soohwan Kim |
0:6f28332c466f | 332 | } |
Soohwan Kim |
0:6f28332c466f | 333 | spi_write(addr, cb, buf, sizeof(buf)); |
Soohwan Kim |
0:6f28332c466f | 334 | } |
Soohwan Kim |
0:6f28332c466f | 335 | |
Soohwan Kim |
0:6f28332c466f | 336 | template<typename T> |
Soohwan Kim |
0:6f28332c466f | 337 | T reg_rd(uint16_t addr) { |
Soohwan Kim |
0:6f28332c466f | 338 | return reg_rd<T>(addr, 0x00); |
Soohwan Kim |
0:6f28332c466f | 339 | } |
Soohwan Kim |
0:6f28332c466f | 340 | |
Soohwan Kim |
0:6f28332c466f | 341 | template<typename T> |
Soohwan Kim |
0:6f28332c466f | 342 | T reg_rd(uint16_t addr, uint8_t cb) { |
Soohwan Kim |
0:6f28332c466f | 343 | uint8_t buf[sizeof(T)]; |
Soohwan Kim |
0:6f28332c466f | 344 | spi_read(addr, cb, buf, sizeof(buf)); |
Soohwan Kim |
0:6f28332c466f | 345 | for(int i = 0; i < sizeof(buf)/2; i++) { // Big Endian to Little Endian |
Soohwan Kim |
0:6f28332c466f | 346 | uint8_t t = buf[i]; |
Soohwan Kim |
0:6f28332c466f | 347 | buf[i] = buf[sizeof(buf)-1-i]; |
Soohwan Kim |
0:6f28332c466f | 348 | buf[sizeof(buf)-1-i] = t; |
Soohwan Kim |
0:6f28332c466f | 349 | } |
Soohwan Kim |
0:6f28332c466f | 350 | return *reinterpret_cast<T*>(buf); |
Soohwan Kim |
0:6f28332c466f | 351 | } |
Soohwan Kim |
0:6f28332c466f | 352 | |
Soohwan Kim |
0:6f28332c466f | 353 | void reg_rd_mac(uint16_t addr, uint8_t* data) { |
Soohwan Kim |
0:6f28332c466f | 354 | spi_read(addr, 0x00, data, 6); |
Soohwan Kim |
0:6f28332c466f | 355 | } |
Soohwan Kim |
0:6f28332c466f | 356 | |
Soohwan Kim |
0:6f28332c466f | 357 | void reg_wr_ip(uint16_t addr, uint8_t cb, const char* ip) { |
Soohwan Kim |
0:6f28332c466f | 358 | uint8_t buf[4]; |
Soohwan Kim |
0:6f28332c466f | 359 | char* p = (char*)ip; |
Soohwan Kim |
0:6f28332c466f | 360 | for(int i = 0; i < 4; i++) { |
Soohwan Kim |
0:6f28332c466f | 361 | buf[i] = atoi(p); |
Soohwan Kim |
0:6f28332c466f | 362 | p = strchr(p, '.'); |
Soohwan Kim |
0:6f28332c466f | 363 | if (p == NULL) { |
Soohwan Kim |
0:6f28332c466f | 364 | break; |
Soohwan Kim |
0:6f28332c466f | 365 | } |
Soohwan Kim |
0:6f28332c466f | 366 | p++; |
Soohwan Kim |
0:6f28332c466f | 367 | } |
Soohwan Kim |
0:6f28332c466f | 368 | spi_write(addr, cb, buf, sizeof(buf)); |
Soohwan Kim |
0:6f28332c466f | 369 | } |
Soohwan Kim |
4:4930f81bbe98 | 370 | |
Soohwan Kim |
0:6f28332c466f | 371 | void sreg_ip(int socket, uint16_t addr, const char* ip) { |
Soohwan Kim |
0:6f28332c466f | 372 | reg_wr_ip(addr, (0x0C + (socket << 5)), ip); |
Soohwan Kim |
0:6f28332c466f | 373 | } |
Soohwan Kim |
4:4930f81bbe98 | 374 | |
Soohwan Kim |
4:4930f81bbe98 | 375 | void reg_rd_ip_byte(uint16_t addr, uint8_t* data) { |
Soohwan Kim |
4:4930f81bbe98 | 376 | spi_read(addr, 0x00, data, 4); |
Soohwan Kim |
4:4930f81bbe98 | 377 | } |
Soohwan Kim |
4:4930f81bbe98 | 378 | |
Soohwan Kim |
4:4930f81bbe98 | 379 | void reg_wr_ip_byte(uint16_t addr, uint8_t* data) { |
Soohwan Kim |
4:4930f81bbe98 | 380 | spi_write(addr, 0x04, data, 4); |
Soohwan Kim |
4:4930f81bbe98 | 381 | } |
Soohwan Kim |
4:4930f81bbe98 | 382 | |
Soohwan Kim |
4:4930f81bbe98 | 383 | ///////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 384 | // Common Register I/O function // |
Soohwan Kim |
4:4930f81bbe98 | 385 | ///////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 386 | /** |
Soohwan Kim |
4:4930f81bbe98 | 387 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 388 | * @brief Set Mode Register |
Soohwan Kim |
4:4930f81bbe98 | 389 | * @param (uint8_t)mr The value to be set. |
Soohwan Kim |
4:4930f81bbe98 | 390 | * @sa getMR() |
Soohwan Kim |
4:4930f81bbe98 | 391 | */ |
Soohwan Kim |
4:4930f81bbe98 | 392 | void setMR(uint8_t mr) { |
Soohwan Kim |
4:4930f81bbe98 | 393 | reg_wr<uint8_t>(MR,mr); |
Soohwan Kim |
4:4930f81bbe98 | 394 | } |
Soohwan Kim |
4:4930f81bbe98 | 395 | |
Soohwan Kim |
4:4930f81bbe98 | 396 | |
Soohwan Kim |
4:4930f81bbe98 | 397 | /** |
Soohwan Kim |
4:4930f81bbe98 | 398 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 399 | * @brief Get Mode Register |
Soohwan Kim |
4:4930f81bbe98 | 400 | * @return uint8_t. The value of Mode register. |
Soohwan Kim |
4:4930f81bbe98 | 401 | * @sa setMR() |
Soohwan Kim |
4:4930f81bbe98 | 402 | */ |
Soohwan Kim |
4:4930f81bbe98 | 403 | uint8_t getMR() { |
Soohwan Kim |
4:4930f81bbe98 | 404 | return reg_rd<uint8_t>(MR); |
Soohwan Kim |
4:4930f81bbe98 | 405 | } |
Soohwan Kim |
4:4930f81bbe98 | 406 | |
Soohwan Kim |
4:4930f81bbe98 | 407 | /** |
Soohwan Kim |
4:4930f81bbe98 | 408 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 409 | * @brief Set gateway IP address |
Soohwan Kim |
4:4930f81bbe98 | 410 | * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 411 | * @sa getGAR() |
Soohwan Kim |
4:4930f81bbe98 | 412 | */ |
Soohwan Kim |
4:4930f81bbe98 | 413 | void setGAR(uint8_t * gar) { |
Soohwan Kim |
4:4930f81bbe98 | 414 | reg_wr_ip_byte(GAR,gar); |
Soohwan Kim |
4:4930f81bbe98 | 415 | } |
Soohwan Kim |
4:4930f81bbe98 | 416 | |
Soohwan Kim |
4:4930f81bbe98 | 417 | /** |
Soohwan Kim |
4:4930f81bbe98 | 418 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 419 | * @brief Get gateway IP address |
Soohwan Kim |
4:4930f81bbe98 | 420 | * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 421 | * @sa setGAR() |
Soohwan Kim |
4:4930f81bbe98 | 422 | */ |
Soohwan Kim |
4:4930f81bbe98 | 423 | void getGAR(uint8_t * gar) { |
Soohwan Kim |
4:4930f81bbe98 | 424 | reg_rd_ip_byte(GAR,gar); |
Soohwan Kim |
4:4930f81bbe98 | 425 | } |
Soohwan Kim |
4:4930f81bbe98 | 426 | |
Soohwan Kim |
4:4930f81bbe98 | 427 | /** |
Soohwan Kim |
4:4930f81bbe98 | 428 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 429 | * @brief Set subnet mask address |
Soohwan Kim |
4:4930f81bbe98 | 430 | * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 431 | * @sa getSUBR() |
Soohwan Kim |
4:4930f81bbe98 | 432 | */ |
Soohwan Kim |
4:4930f81bbe98 | 433 | void setSUBR(uint8_t * subr) { |
Soohwan Kim |
4:4930f81bbe98 | 434 | reg_wr_ip_byte(SUBR, subr); |
Soohwan Kim |
4:4930f81bbe98 | 435 | } |
Soohwan Kim |
4:4930f81bbe98 | 436 | |
Soohwan Kim |
4:4930f81bbe98 | 437 | |
Soohwan Kim |
4:4930f81bbe98 | 438 | /** |
Soohwan Kim |
4:4930f81bbe98 | 439 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 440 | * @brief Get subnet mask address |
Soohwan Kim |
4:4930f81bbe98 | 441 | * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 442 | * @sa setSUBR() |
Soohwan Kim |
4:4930f81bbe98 | 443 | */ |
Soohwan Kim |
4:4930f81bbe98 | 444 | void getSUBR(uint8_t * subr) { |
Soohwan Kim |
4:4930f81bbe98 | 445 | reg_rd_ip_byte(SUBR, subr); |
Soohwan Kim |
4:4930f81bbe98 | 446 | } |
Soohwan Kim |
4:4930f81bbe98 | 447 | |
Soohwan Kim |
4:4930f81bbe98 | 448 | /** |
Soohwan Kim |
4:4930f81bbe98 | 449 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 450 | * @brief Set local MAC address |
Soohwan Kim |
4:4930f81bbe98 | 451 | * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 452 | * @sa getSHAR() |
Soohwan Kim |
4:4930f81bbe98 | 453 | */ |
Soohwan Kim |
4:4930f81bbe98 | 454 | void setSHAR(uint8_t * shar) { |
Soohwan Kim |
4:4930f81bbe98 | 455 | reg_wr_mac(SHAR, shar); |
Soohwan Kim |
4:4930f81bbe98 | 456 | } |
Soohwan Kim |
4:4930f81bbe98 | 457 | |
Soohwan Kim |
4:4930f81bbe98 | 458 | /** |
Soohwan Kim |
4:4930f81bbe98 | 459 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 460 | * @brief Get local MAC address |
Soohwan Kim |
4:4930f81bbe98 | 461 | * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 462 | * @sa setSHAR() |
Soohwan Kim |
4:4930f81bbe98 | 463 | */ |
Soohwan Kim |
4:4930f81bbe98 | 464 | void getSHAR(uint8_t * shar) { |
Soohwan Kim |
4:4930f81bbe98 | 465 | reg_rd_mac(SHAR, shar); |
Soohwan Kim |
4:4930f81bbe98 | 466 | } |
Soohwan Kim |
4:4930f81bbe98 | 467 | |
Soohwan Kim |
4:4930f81bbe98 | 468 | /** |
Soohwan Kim |
4:4930f81bbe98 | 469 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 470 | * @brief Set local IP address |
Soohwan Kim |
4:4930f81bbe98 | 471 | * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 472 | * @sa getSIPR() |
Soohwan Kim |
4:4930f81bbe98 | 473 | */ |
Soohwan Kim |
4:4930f81bbe98 | 474 | void setSIPR(uint8_t * sipr) { |
Soohwan Kim |
4:4930f81bbe98 | 475 | reg_wr_ip_byte(SIPR, sipr); |
Soohwan Kim |
4:4930f81bbe98 | 476 | } |
Soohwan Kim |
4:4930f81bbe98 | 477 | |
Soohwan Kim |
4:4930f81bbe98 | 478 | /** |
Soohwan Kim |
4:4930f81bbe98 | 479 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 480 | * @brief Get local IP address |
Soohwan Kim |
4:4930f81bbe98 | 481 | * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 482 | * @sa setSIPR() |
Soohwan Kim |
4:4930f81bbe98 | 483 | */ |
Soohwan Kim |
4:4930f81bbe98 | 484 | void getSIPR(uint8_t * sipr) { |
Soohwan Kim |
4:4930f81bbe98 | 485 | reg_rd_ip_byte(SIPR, sipr); |
Soohwan Kim |
4:4930f81bbe98 | 486 | } |
Soohwan Kim |
4:4930f81bbe98 | 487 | |
Soohwan Kim |
4:4930f81bbe98 | 488 | /** |
Soohwan Kim |
4:4930f81bbe98 | 489 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 490 | * @brief Set INTLEVEL register |
Soohwan Kim |
4:4930f81bbe98 | 491 | * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. |
Soohwan Kim |
4:4930f81bbe98 | 492 | * @sa getINTLEVEL() |
Soohwan Kim |
4:4930f81bbe98 | 493 | */ |
Soohwan Kim |
4:4930f81bbe98 | 494 | void setINTLEVEL(uint16_t intlevel) { |
Soohwan Kim |
4:4930f81bbe98 | 495 | reg_wr<uint16_t>(INTLEVEL, intlevel); |
Soohwan Kim |
4:4930f81bbe98 | 496 | } |
Soohwan Kim |
4:4930f81bbe98 | 497 | |
Soohwan Kim |
4:4930f81bbe98 | 498 | |
Soohwan Kim |
4:4930f81bbe98 | 499 | /** |
Soohwan Kim |
4:4930f81bbe98 | 500 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 501 | * @brief Get INTLEVEL register |
Soohwan Kim |
4:4930f81bbe98 | 502 | * @return uint16_t. Value of @ref INTLEVEL register. |
Soohwan Kim |
4:4930f81bbe98 | 503 | * @sa setINTLEVEL() |
Soohwan Kim |
4:4930f81bbe98 | 504 | */ |
Soohwan Kim |
4:4930f81bbe98 | 505 | uint16_t getINTLEVEL() { |
Soohwan Kim |
4:4930f81bbe98 | 506 | return reg_rd<uint16_t>(INTLEVEL); |
Soohwan Kim |
4:4930f81bbe98 | 507 | } |
Soohwan Kim |
4:4930f81bbe98 | 508 | |
Soohwan Kim |
4:4930f81bbe98 | 509 | /** |
Soohwan Kim |
4:4930f81bbe98 | 510 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 511 | * @brief Set @ref IR register |
Soohwan Kim |
4:4930f81bbe98 | 512 | * @param (uint8_t)ir Value to set @ref IR register. |
Soohwan Kim |
4:4930f81bbe98 | 513 | * @sa getIR() |
Soohwan Kim |
4:4930f81bbe98 | 514 | */ |
Soohwan Kim |
4:4930f81bbe98 | 515 | void setIR(uint8_t ir) { |
Soohwan Kim |
4:4930f81bbe98 | 516 | reg_wr<uint8_t>(IR, (ir & 0xF0)); |
Soohwan Kim |
4:4930f81bbe98 | 517 | } |
Soohwan Kim |
4:4930f81bbe98 | 518 | |
Soohwan Kim |
4:4930f81bbe98 | 519 | /** |
Soohwan Kim |
4:4930f81bbe98 | 520 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 521 | * @brief Get @ref IR register |
Soohwan Kim |
4:4930f81bbe98 | 522 | * @return uint8_t. Value of @ref IR register. |
Soohwan Kim |
4:4930f81bbe98 | 523 | * @sa setIR() |
Soohwan Kim |
4:4930f81bbe98 | 524 | */ |
Soohwan Kim |
4:4930f81bbe98 | 525 | uint8_t getIR() { |
Soohwan Kim |
4:4930f81bbe98 | 526 | return reg_rd<uint8_t>(IR & 0xF0); |
Soohwan Kim |
4:4930f81bbe98 | 527 | } |
Soohwan Kim |
4:4930f81bbe98 | 528 | |
Soohwan Kim |
4:4930f81bbe98 | 529 | /** |
Soohwan Kim |
4:4930f81bbe98 | 530 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 531 | * @brief Set @ref IMR register |
Soohwan Kim |
4:4930f81bbe98 | 532 | * @param (uint8_t)imr Value to set @ref IMR register. |
Soohwan Kim |
4:4930f81bbe98 | 533 | * @sa getIMR() |
Soohwan Kim |
4:4930f81bbe98 | 534 | */ |
Soohwan Kim |
4:4930f81bbe98 | 535 | void setIMR(uint8_t imr) { |
Soohwan Kim |
4:4930f81bbe98 | 536 | reg_wr<uint8_t>(IMR, imr); |
Soohwan Kim |
4:4930f81bbe98 | 537 | } |
Soohwan Kim |
4:4930f81bbe98 | 538 | |
Soohwan Kim |
4:4930f81bbe98 | 539 | /** |
Soohwan Kim |
4:4930f81bbe98 | 540 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 541 | * @brief Get @ref IMR register |
Soohwan Kim |
4:4930f81bbe98 | 542 | * @return uint8_t. Value of @ref IMR register. |
Soohwan Kim |
4:4930f81bbe98 | 543 | * @sa setIMR() |
Soohwan Kim |
4:4930f81bbe98 | 544 | */ |
Soohwan Kim |
4:4930f81bbe98 | 545 | uint8_t getIMR() { |
Soohwan Kim |
4:4930f81bbe98 | 546 | return reg_rd<uint8_t>(IMR); |
Soohwan Kim |
4:4930f81bbe98 | 547 | } |
Soohwan Kim |
4:4930f81bbe98 | 548 | |
Soohwan Kim |
4:4930f81bbe98 | 549 | |
Soohwan Kim |
4:4930f81bbe98 | 550 | /** |
Soohwan Kim |
4:4930f81bbe98 | 551 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 552 | * @brief Set @ref SIR register |
Soohwan Kim |
4:4930f81bbe98 | 553 | * @param (uint8_t)sir Value to set @ref SIR register. |
Soohwan Kim |
4:4930f81bbe98 | 554 | * @sa getSIR() |
Soohwan Kim |
4:4930f81bbe98 | 555 | */ |
Soohwan Kim |
4:4930f81bbe98 | 556 | void setSIR(uint8_t sir) { |
Soohwan Kim |
4:4930f81bbe98 | 557 | reg_wr<uint8_t>(SIR, sir); |
Soohwan Kim |
4:4930f81bbe98 | 558 | } |
Soohwan Kim |
4:4930f81bbe98 | 559 | |
Soohwan Kim |
4:4930f81bbe98 | 560 | /** |
Soohwan Kim |
4:4930f81bbe98 | 561 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 562 | * @brief Get @ref SIR register |
Soohwan Kim |
4:4930f81bbe98 | 563 | * @return uint8_t. Value of @ref SIR register. |
Soohwan Kim |
4:4930f81bbe98 | 564 | * @sa setSIR() |
Soohwan Kim |
4:4930f81bbe98 | 565 | */ |
Soohwan Kim |
4:4930f81bbe98 | 566 | uint8_t getSIR() { |
Soohwan Kim |
4:4930f81bbe98 | 567 | return reg_rd<uint8_t>(SIR); |
Soohwan Kim |
4:4930f81bbe98 | 568 | } |
Soohwan Kim |
4:4930f81bbe98 | 569 | /** |
Soohwan Kim |
4:4930f81bbe98 | 570 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 571 | * @brief Set @ref SIMR register |
Soohwan Kim |
4:4930f81bbe98 | 572 | * @param (uint8_t)simr Value to set @ref SIMR register. |
Soohwan Kim |
4:4930f81bbe98 | 573 | * @sa getSIMR() |
Soohwan Kim |
4:4930f81bbe98 | 574 | */ |
Soohwan Kim |
4:4930f81bbe98 | 575 | void setSIMR(uint8_t simr) { |
Soohwan Kim |
4:4930f81bbe98 | 576 | reg_wr<uint8_t>(SIMR, simr); |
Soohwan Kim |
4:4930f81bbe98 | 577 | } |
Soohwan Kim |
4:4930f81bbe98 | 578 | |
Soohwan Kim |
4:4930f81bbe98 | 579 | /** |
Soohwan Kim |
4:4930f81bbe98 | 580 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 581 | * @brief Get @ref SIMR register |
Soohwan Kim |
4:4930f81bbe98 | 582 | * @return uint8_t. Value of @ref SIMR register. |
Soohwan Kim |
4:4930f81bbe98 | 583 | * @sa setSIMR() |
Soohwan Kim |
4:4930f81bbe98 | 584 | */ |
Soohwan Kim |
4:4930f81bbe98 | 585 | uint8_t getSIMR() { |
Soohwan Kim |
4:4930f81bbe98 | 586 | return reg_rd<uint8_t>(SIMR); |
Soohwan Kim |
4:4930f81bbe98 | 587 | } |
Soohwan Kim |
4:4930f81bbe98 | 588 | |
Soohwan Kim |
4:4930f81bbe98 | 589 | /** |
Soohwan Kim |
4:4930f81bbe98 | 590 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 591 | * @brief Set @ref RTR register |
Soohwan Kim |
4:4930f81bbe98 | 592 | * @param (uint16_t)rtr Value to set @ref RTR register. |
Soohwan Kim |
4:4930f81bbe98 | 593 | * @sa getRTR() |
Soohwan Kim |
4:4930f81bbe98 | 594 | */ |
Soohwan Kim |
4:4930f81bbe98 | 595 | void setRTR(uint16_t rtr) { |
Soohwan Kim |
4:4930f81bbe98 | 596 | reg_wr<uint16_t>(RTR, rtr); |
Soohwan Kim |
4:4930f81bbe98 | 597 | } |
Soohwan Kim |
4:4930f81bbe98 | 598 | |
Soohwan Kim |
4:4930f81bbe98 | 599 | /** |
Soohwan Kim |
4:4930f81bbe98 | 600 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 601 | * @brief Get @ref RTR register |
Soohwan Kim |
4:4930f81bbe98 | 602 | * @return uint16_t. Value of @ref RTR register. |
Soohwan Kim |
4:4930f81bbe98 | 603 | * @sa setRTR() |
Soohwan Kim |
4:4930f81bbe98 | 604 | */ |
Soohwan Kim |
4:4930f81bbe98 | 605 | uint16_t getRTR() { |
Soohwan Kim |
4:4930f81bbe98 | 606 | return reg_rd<uint16_t>(RTR); |
Soohwan Kim |
4:4930f81bbe98 | 607 | } |
Soohwan Kim |
4:4930f81bbe98 | 608 | |
Soohwan Kim |
4:4930f81bbe98 | 609 | /** |
Soohwan Kim |
4:4930f81bbe98 | 610 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 611 | * @brief Set @ref RCR register |
Soohwan Kim |
4:4930f81bbe98 | 612 | * @param (uint8_t)rcr Value to set @ref RCR register. |
Soohwan Kim |
4:4930f81bbe98 | 613 | * @sa getRCR() |
Soohwan Kim |
4:4930f81bbe98 | 614 | */ |
Soohwan Kim |
4:4930f81bbe98 | 615 | void setRCR(uint8_t rcr) { |
Soohwan Kim |
4:4930f81bbe98 | 616 | reg_wr<uint8_t>(RCR, rcr); |
Soohwan Kim |
4:4930f81bbe98 | 617 | } |
Soohwan Kim |
4:4930f81bbe98 | 618 | |
Soohwan Kim |
4:4930f81bbe98 | 619 | /** |
Soohwan Kim |
4:4930f81bbe98 | 620 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 621 | * @brief Get @ref RCR register |
Soohwan Kim |
4:4930f81bbe98 | 622 | * @return uint8_t. Value of @ref RCR register. |
Soohwan Kim |
4:4930f81bbe98 | 623 | * @sa setRCR() |
Soohwan Kim |
4:4930f81bbe98 | 624 | */ |
Soohwan Kim |
4:4930f81bbe98 | 625 | uint8_t getRCR() { |
Soohwan Kim |
4:4930f81bbe98 | 626 | return reg_rd<uint8_t>(RCR); |
Soohwan Kim |
4:4930f81bbe98 | 627 | } |
Soohwan Kim |
4:4930f81bbe98 | 628 | |
Soohwan Kim |
4:4930f81bbe98 | 629 | //================================================== test done =========================================================== |
Soohwan Kim |
4:4930f81bbe98 | 630 | |
Soohwan Kim |
4:4930f81bbe98 | 631 | /** |
Soohwan Kim |
4:4930f81bbe98 | 632 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 633 | * @brief Set @ref PHYCFGR register |
Soohwan Kim |
4:4930f81bbe98 | 634 | * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. |
Soohwan Kim |
4:4930f81bbe98 | 635 | * @sa getPHYCFGR() |
Soohwan Kim |
4:4930f81bbe98 | 636 | */ |
Soohwan Kim |
4:4930f81bbe98 | 637 | void setPHYCFGR(uint8_t phycfgr) { |
Soohwan Kim |
4:4930f81bbe98 | 638 | reg_wr<uint8_t>(PHYCFGR, phycfgr); |
Soohwan Kim |
4:4930f81bbe98 | 639 | } |
Soohwan Kim |
4:4930f81bbe98 | 640 | |
Soohwan Kim |
4:4930f81bbe98 | 641 | /** |
Soohwan Kim |
4:4930f81bbe98 | 642 | * @ingroup Common_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 643 | * @brief Get @ref PHYCFGR register |
Soohwan Kim |
4:4930f81bbe98 | 644 | * @return uint8_t. Value of @ref PHYCFGR register. |
Soohwan Kim |
4:4930f81bbe98 | 645 | * @sa setPHYCFGR() |
Soohwan Kim |
4:4930f81bbe98 | 646 | */ |
Soohwan Kim |
4:4930f81bbe98 | 647 | uint8_t getPHYCFGR() { |
Soohwan Kim |
4:4930f81bbe98 | 648 | return reg_rd<uint8_t>(PHYCFGR); |
Soohwan Kim |
4:4930f81bbe98 | 649 | } |
Soohwan Kim |
4:4930f81bbe98 | 650 | |
Soohwan Kim |
4:4930f81bbe98 | 651 | |
Soohwan Kim |
4:4930f81bbe98 | 652 | ///////////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 653 | |
Soohwan Kim |
4:4930f81bbe98 | 654 | /////////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 655 | // Socket N register I/O function // |
Soohwan Kim |
4:4930f81bbe98 | 656 | /////////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 657 | /** |
Soohwan Kim |
4:4930f81bbe98 | 658 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 659 | * @brief Set @ref Sn_MR register |
Soohwan Kim |
4:4930f81bbe98 | 660 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 661 | * @param (uint8_t)mr Value to set @ref Sn_MR |
Soohwan Kim |
4:4930f81bbe98 | 662 | * @sa getSn_MR() |
Soohwan Kim |
4:4930f81bbe98 | 663 | */ |
Soohwan Kim |
4:4930f81bbe98 | 664 | void setSn_MR(uint8_t sn, uint8_t mr) { |
Soohwan Kim |
4:4930f81bbe98 | 665 | sreg<uint8_t>(sn, MR, mr); |
Soohwan Kim |
4:4930f81bbe98 | 666 | } |
Soohwan Kim |
4:4930f81bbe98 | 667 | |
Soohwan Kim |
4:4930f81bbe98 | 668 | /** |
Soohwan Kim |
4:4930f81bbe98 | 669 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 670 | * @brief Get @ref Sn_MR register |
Soohwan Kim |
4:4930f81bbe98 | 671 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 672 | * @return uint8_t. Value of @ref Sn_MR. |
Soohwan Kim |
4:4930f81bbe98 | 673 | * @sa setSn_MR() |
Soohwan Kim |
4:4930f81bbe98 | 674 | */ |
Soohwan Kim |
4:4930f81bbe98 | 675 | uint8_t getSn_MR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 676 | return sreg<uint8_t>(sn, Sn_MR); |
Soohwan Kim |
4:4930f81bbe98 | 677 | } |
Soohwan Kim |
4:4930f81bbe98 | 678 | |
Soohwan Kim |
4:4930f81bbe98 | 679 | /** |
Soohwan Kim |
4:4930f81bbe98 | 680 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 681 | * @brief Set @ref Sn_CR register |
Soohwan Kim |
4:4930f81bbe98 | 682 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 683 | * @param (uint8_t)cr Value to set @ref Sn_CR |
Soohwan Kim |
4:4930f81bbe98 | 684 | * @sa getSn_CR() |
Soohwan Kim |
4:4930f81bbe98 | 685 | */ |
Soohwan Kim |
4:4930f81bbe98 | 686 | void setSn_CR(uint8_t sn, uint8_t cr) { |
Soohwan Kim |
4:4930f81bbe98 | 687 | sreg<uint8_t>(sn, Sn_CR, cr); |
Soohwan Kim |
4:4930f81bbe98 | 688 | } |
Soohwan Kim |
4:4930f81bbe98 | 689 | |
Soohwan Kim |
4:4930f81bbe98 | 690 | /** |
Soohwan Kim |
4:4930f81bbe98 | 691 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 692 | * @brief Get @ref Sn_CR register |
Soohwan Kim |
4:4930f81bbe98 | 693 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 694 | * @return uint8_t. Value of @ref Sn_CR. |
Soohwan Kim |
4:4930f81bbe98 | 695 | * @sa setSn_CR() |
Soohwan Kim |
4:4930f81bbe98 | 696 | */ |
Soohwan Kim |
4:4930f81bbe98 | 697 | uint8_t getSn_CR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 698 | return sreg<uint8_t>(sn, Sn_CR); |
Soohwan Kim |
4:4930f81bbe98 | 699 | } |
Soohwan Kim |
4:4930f81bbe98 | 700 | |
Soohwan Kim |
4:4930f81bbe98 | 701 | /** |
Soohwan Kim |
4:4930f81bbe98 | 702 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 703 | * @brief Set @ref Sn_IR register |
Soohwan Kim |
4:4930f81bbe98 | 704 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 705 | * @param (uint8_t)ir Value to set @ref Sn_IR |
Soohwan Kim |
4:4930f81bbe98 | 706 | * @sa getSn_IR() |
Soohwan Kim |
4:4930f81bbe98 | 707 | */ |
Soohwan Kim |
4:4930f81bbe98 | 708 | void setSn_IR(uint8_t sn, uint8_t ir) { |
Soohwan Kim |
4:4930f81bbe98 | 709 | sreg<uint8_t>(sn, Sn_IR, (ir & 0x1F)); |
Soohwan Kim |
4:4930f81bbe98 | 710 | } |
Soohwan Kim |
4:4930f81bbe98 | 711 | |
Soohwan Kim |
4:4930f81bbe98 | 712 | /** |
Soohwan Kim |
4:4930f81bbe98 | 713 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 714 | * @brief Get @ref Sn_IR register |
Soohwan Kim |
4:4930f81bbe98 | 715 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 716 | * @return uint8_t. Value of @ref Sn_IR. |
Soohwan Kim |
4:4930f81bbe98 | 717 | * @sa setSn_IR() |
Soohwan Kim |
4:4930f81bbe98 | 718 | */ |
Soohwan Kim |
4:4930f81bbe98 | 719 | uint8_t getSn_IR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 720 | return (sreg<uint8_t>(sn, Sn_IR)) & 0x1F; |
Soohwan Kim |
4:4930f81bbe98 | 721 | } |
Soohwan Kim |
4:4930f81bbe98 | 722 | |
Soohwan Kim |
4:4930f81bbe98 | 723 | /** |
Soohwan Kim |
4:4930f81bbe98 | 724 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 725 | * @brief Set @ref Sn_IMR register |
Soohwan Kim |
4:4930f81bbe98 | 726 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 727 | * @param (uint8_t)imr Value to set @ref Sn_IMR |
Soohwan Kim |
4:4930f81bbe98 | 728 | * @sa getSn_IMR() |
Soohwan Kim |
4:4930f81bbe98 | 729 | */ |
Soohwan Kim |
4:4930f81bbe98 | 730 | void setSn_IMR(uint8_t sn, uint8_t imr) { |
Soohwan Kim |
4:4930f81bbe98 | 731 | sreg<uint8_t>(sn, Sn_IMR, (imr & 0x1F)); |
Soohwan Kim |
4:4930f81bbe98 | 732 | } |
Soohwan Kim |
4:4930f81bbe98 | 733 | |
Soohwan Kim |
4:4930f81bbe98 | 734 | /** |
Soohwan Kim |
4:4930f81bbe98 | 735 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 736 | * @brief Get @ref Sn_IMR register |
Soohwan Kim |
4:4930f81bbe98 | 737 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 738 | * @return uint8_t. Value of @ref Sn_IMR. |
Soohwan Kim |
4:4930f81bbe98 | 739 | * @sa setSn_IMR() |
Soohwan Kim |
4:4930f81bbe98 | 740 | */ |
Soohwan Kim |
4:4930f81bbe98 | 741 | uint8_t getSn_IMR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 742 | return (sreg<uint8_t>(sn, Sn_IMR)) & 0x1F; |
Soohwan Kim |
4:4930f81bbe98 | 743 | } |
Soohwan Kim |
4:4930f81bbe98 | 744 | |
Soohwan Kim |
4:4930f81bbe98 | 745 | /** |
Soohwan Kim |
4:4930f81bbe98 | 746 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 747 | * @brief Get @ref Sn_SR register |
Soohwan Kim |
4:4930f81bbe98 | 748 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 749 | * @return uint8_t. Value of @ref Sn_SR. |
Soohwan Kim |
4:4930f81bbe98 | 750 | */ |
Soohwan Kim |
4:4930f81bbe98 | 751 | uint8_t getSn_SR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 752 | return sreg<uint8_t>(sn, Sn_SR); |
Soohwan Kim |
4:4930f81bbe98 | 753 | } |
Soohwan Kim |
4:4930f81bbe98 | 754 | |
Soohwan Kim |
4:4930f81bbe98 | 755 | /** |
Soohwan Kim |
4:4930f81bbe98 | 756 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 757 | * @brief Set @ref Sn_PORT register |
Soohwan Kim |
4:4930f81bbe98 | 758 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 759 | * @param (uint16_t)port Value to set @ref Sn_PORT. |
Soohwan Kim |
4:4930f81bbe98 | 760 | * @sa getSn_PORT() |
Soohwan Kim |
4:4930f81bbe98 | 761 | */ |
Soohwan Kim |
4:4930f81bbe98 | 762 | void setSn_PORT(uint8_t sn, uint16_t port) { |
Soohwan Kim |
4:4930f81bbe98 | 763 | sreg<uint16_t>(sn, Sn_PORT, port ); |
Soohwan Kim |
4:4930f81bbe98 | 764 | } |
Soohwan Kim |
4:4930f81bbe98 | 765 | |
Soohwan Kim |
4:4930f81bbe98 | 766 | /** |
Soohwan Kim |
4:4930f81bbe98 | 767 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 768 | * @brief Get @ref Sn_PORT register |
Soohwan Kim |
4:4930f81bbe98 | 769 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 770 | * @return uint16_t. Value of @ref Sn_PORT. |
Soohwan Kim |
4:4930f81bbe98 | 771 | * @sa setSn_PORT() |
Soohwan Kim |
4:4930f81bbe98 | 772 | */ |
Soohwan Kim |
4:4930f81bbe98 | 773 | uint16_t getSn_PORT(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 774 | return sreg<uint16_t>(sn, Sn_PORT); |
Soohwan Kim |
4:4930f81bbe98 | 775 | } |
Soohwan Kim |
4:4930f81bbe98 | 776 | |
Soohwan Kim |
4:4930f81bbe98 | 777 | /** |
Soohwan Kim |
4:4930f81bbe98 | 778 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 779 | * @brief Set @ref Sn_DHAR register |
Soohwan Kim |
4:4930f81bbe98 | 780 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 781 | * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 782 | * @sa getSn_DHAR() |
Soohwan Kim |
4:4930f81bbe98 | 783 | */ |
Soohwan Kim |
4:4930f81bbe98 | 784 | void setSn_DHAR(uint8_t sn, uint8_t * dhar) { |
Soohwan Kim |
4:4930f81bbe98 | 785 | spi_write(Sn_DHAR, (0x0C + (sn << 5)), dhar, 6); |
Soohwan Kim |
4:4930f81bbe98 | 786 | } |
Soohwan Kim |
4:4930f81bbe98 | 787 | |
Soohwan Kim |
4:4930f81bbe98 | 788 | /** |
Soohwan Kim |
4:4930f81bbe98 | 789 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 790 | * @brief Get @ref Sn_MR register |
Soohwan Kim |
4:4930f81bbe98 | 791 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 792 | * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 793 | * @sa setSn_DHAR() |
Soohwan Kim |
4:4930f81bbe98 | 794 | */ |
Soohwan Kim |
4:4930f81bbe98 | 795 | void getSn_DHAR(uint8_t sn, uint8_t * dhar) { |
Soohwan Kim |
4:4930f81bbe98 | 796 | spi_read(Sn_DHAR, (0x08 + (sn << 5)), dhar, 6); |
Soohwan Kim |
4:4930f81bbe98 | 797 | } |
Soohwan Kim |
4:4930f81bbe98 | 798 | |
Soohwan Kim |
4:4930f81bbe98 | 799 | /** |
Soohwan Kim |
4:4930f81bbe98 | 800 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 801 | * @brief Set @ref Sn_DIPR register |
Soohwan Kim |
4:4930f81bbe98 | 802 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 803 | * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 804 | * @sa getSn_DIPR() |
Soohwan Kim |
4:4930f81bbe98 | 805 | */ |
Soohwan Kim |
4:4930f81bbe98 | 806 | void setSn_DIPR(uint8_t sn, uint8_t * dipr) { |
Soohwan Kim |
4:4930f81bbe98 | 807 | spi_write(Sn_DIPR, (0x0C + (sn << 5)), dipr, 4); |
Soohwan Kim |
4:4930f81bbe98 | 808 | } |
Soohwan Kim |
4:4930f81bbe98 | 809 | |
Soohwan Kim |
4:4930f81bbe98 | 810 | /** |
Soohwan Kim |
4:4930f81bbe98 | 811 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 812 | * @brief Get @ref Sn_DIPR register |
Soohwan Kim |
4:4930f81bbe98 | 813 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 814 | * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. |
Soohwan Kim |
4:4930f81bbe98 | 815 | * @sa SetSn_DIPR() |
Soohwan Kim |
4:4930f81bbe98 | 816 | */ |
Soohwan Kim |
4:4930f81bbe98 | 817 | void getSn_DIPR(uint8_t sn, uint8_t * dipr) { |
Soohwan Kim |
4:4930f81bbe98 | 818 | spi_read(Sn_DIPR, (0x08 + (sn << 5)), dipr, 4); |
Soohwan Kim |
4:4930f81bbe98 | 819 | } |
Soohwan Kim |
4:4930f81bbe98 | 820 | |
Soohwan Kim |
4:4930f81bbe98 | 821 | /** |
Soohwan Kim |
4:4930f81bbe98 | 822 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 823 | * @brief Set @ref Sn_DPORT register |
Soohwan Kim |
4:4930f81bbe98 | 824 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 825 | * @param (uint16_t)dport Value to set @ref Sn_DPORT |
Soohwan Kim |
4:4930f81bbe98 | 826 | * @sa getSn_DPORT() |
Soohwan Kim |
4:4930f81bbe98 | 827 | */ |
Soohwan Kim |
4:4930f81bbe98 | 828 | void setSn_DPORT(uint8_t sn, uint16_t dport) { |
Soohwan Kim |
4:4930f81bbe98 | 829 | sreg<uint16_t>(sn, Sn_DPORT, dport); |
Soohwan Kim |
4:4930f81bbe98 | 830 | } |
Soohwan Kim |
4:4930f81bbe98 | 831 | |
Soohwan Kim |
4:4930f81bbe98 | 832 | /** |
Soohwan Kim |
4:4930f81bbe98 | 833 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 834 | * @brief Get @ref Sn_DPORT register |
Soohwan Kim |
4:4930f81bbe98 | 835 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 836 | * @return uint16_t. Value of @ref Sn_DPORT. |
Soohwan Kim |
4:4930f81bbe98 | 837 | * @sa setSn_DPORT() |
Soohwan Kim |
4:4930f81bbe98 | 838 | */ |
Soohwan Kim |
4:4930f81bbe98 | 839 | uint16_t getSn_DPORT(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 840 | return sreg<uint16_t>(sn, Sn_DPORT); |
Soohwan Kim |
4:4930f81bbe98 | 841 | } |
Soohwan Kim |
4:4930f81bbe98 | 842 | |
Soohwan Kim |
4:4930f81bbe98 | 843 | |
Soohwan Kim |
4:4930f81bbe98 | 844 | /** |
Soohwan Kim |
4:4930f81bbe98 | 845 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 846 | * @brief Set @ref Sn_RXBUF_SIZE register |
Soohwan Kim |
4:4930f81bbe98 | 847 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 848 | * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE |
Soohwan Kim |
4:4930f81bbe98 | 849 | * @sa getSn_RXBUF_SIZE() |
Soohwan Kim |
4:4930f81bbe98 | 850 | */ |
Soohwan Kim |
4:4930f81bbe98 | 851 | void setSn_RXBUF_SIZE(uint8_t sn, uint8_t rxbufsize) { |
Soohwan Kim |
4:4930f81bbe98 | 852 | sreg<uint8_t>(sn, Sn_RXBUF_SIZE ,rxbufsize); |
Soohwan Kim |
4:4930f81bbe98 | 853 | } |
Soohwan Kim |
4:4930f81bbe98 | 854 | |
Soohwan Kim |
4:4930f81bbe98 | 855 | |
Soohwan Kim |
4:4930f81bbe98 | 856 | /** |
Soohwan Kim |
4:4930f81bbe98 | 857 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 858 | * @brief Get @ref Sn_RXBUF_SIZE register |
Soohwan Kim |
4:4930f81bbe98 | 859 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 860 | * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. |
Soohwan Kim |
4:4930f81bbe98 | 861 | * @sa setSn_RXBUF_SIZE() |
Soohwan Kim |
4:4930f81bbe98 | 862 | */ |
Soohwan Kim |
4:4930f81bbe98 | 863 | uint8_t getSn_RXBUF_SIZE(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 864 | return sreg<uint8_t>(sn, Sn_RXBUF_SIZE); |
Soohwan Kim |
4:4930f81bbe98 | 865 | } |
Soohwan Kim |
4:4930f81bbe98 | 866 | |
Soohwan Kim |
4:4930f81bbe98 | 867 | /** |
Soohwan Kim |
4:4930f81bbe98 | 868 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 869 | * @brief Set @ref Sn_TXBUF_SIZE register |
Soohwan Kim |
4:4930f81bbe98 | 870 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 871 | * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE |
Soohwan Kim |
4:4930f81bbe98 | 872 | * @sa getSn_TXBUF_SIZE() |
Soohwan Kim |
4:4930f81bbe98 | 873 | */ |
Soohwan Kim |
4:4930f81bbe98 | 874 | void setSn_TXBUF_SIZE(uint8_t sn, uint8_t txbufsize) { |
Soohwan Kim |
4:4930f81bbe98 | 875 | sreg<uint8_t>(sn, Sn_TXBUF_SIZE, txbufsize); |
Soohwan Kim |
4:4930f81bbe98 | 876 | } |
Soohwan Kim |
4:4930f81bbe98 | 877 | |
Soohwan Kim |
4:4930f81bbe98 | 878 | /** |
Soohwan Kim |
4:4930f81bbe98 | 879 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 880 | * @brief Get @ref Sn_TXBUF_SIZE register |
Soohwan Kim |
4:4930f81bbe98 | 881 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 882 | * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. |
Soohwan Kim |
4:4930f81bbe98 | 883 | * @sa setSn_TXBUF_SIZE() |
Soohwan Kim |
4:4930f81bbe98 | 884 | */ |
Soohwan Kim |
4:4930f81bbe98 | 885 | uint8_t getSn_TXBUF_SIZE(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 886 | return sreg<uint8_t>(sn, Sn_TXBUF_SIZE); |
Soohwan Kim |
4:4930f81bbe98 | 887 | } |
Soohwan Kim |
4:4930f81bbe98 | 888 | |
Soohwan Kim |
4:4930f81bbe98 | 889 | /** |
Soohwan Kim |
4:4930f81bbe98 | 890 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 891 | * @brief Get @ref Sn_TX_FSR register |
Soohwan Kim |
4:4930f81bbe98 | 892 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 893 | * @return uint16_t. Value of @ref Sn_TX_FSR. |
Soohwan Kim |
4:4930f81bbe98 | 894 | */ |
Soohwan Kim |
4:4930f81bbe98 | 895 | uint16_t getSn_TX_FSR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 896 | return sreg<uint16_t>(sn, Sn_TX_FSR); |
Soohwan Kim |
4:4930f81bbe98 | 897 | } |
Soohwan Kim |
4:4930f81bbe98 | 898 | |
Soohwan Kim |
4:4930f81bbe98 | 899 | |
Soohwan Kim |
4:4930f81bbe98 | 900 | /** |
Soohwan Kim |
4:4930f81bbe98 | 901 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 902 | * @brief Get @ref Sn_TX_RD register |
Soohwan Kim |
4:4930f81bbe98 | 903 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 904 | * @return uint16_t. Value of @ref Sn_TX_RD. |
Soohwan Kim |
4:4930f81bbe98 | 905 | */ |
Soohwan Kim |
4:4930f81bbe98 | 906 | uint16_t getSn_TX_RD(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 907 | return sreg<uint16_t>(sn, Sn_TX_RD); |
Soohwan Kim |
4:4930f81bbe98 | 908 | } |
Soohwan Kim |
4:4930f81bbe98 | 909 | |
Soohwan Kim |
4:4930f81bbe98 | 910 | /** |
Soohwan Kim |
4:4930f81bbe98 | 911 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 912 | * @brief Set @ref Sn_TX_WR register |
Soohwan Kim |
4:4930f81bbe98 | 913 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 914 | * @param (uint16_t)txwr Value to set @ref Sn_TX_WR |
Soohwan Kim |
4:4930f81bbe98 | 915 | * @sa GetSn_TX_WR() |
Soohwan Kim |
4:4930f81bbe98 | 916 | */ |
Soohwan Kim |
4:4930f81bbe98 | 917 | void setSn_TX_WR(uint8_t sn, uint16_t txwr) { |
Soohwan Kim |
4:4930f81bbe98 | 918 | sreg<uint16_t>(sn, Sn_TX_WR, txwr); |
Soohwan Kim |
4:4930f81bbe98 | 919 | } |
Soohwan Kim |
4:4930f81bbe98 | 920 | |
Soohwan Kim |
4:4930f81bbe98 | 921 | /** |
Soohwan Kim |
4:4930f81bbe98 | 922 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 923 | * @brief Get @ref Sn_TX_WR register |
Soohwan Kim |
4:4930f81bbe98 | 924 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 925 | * @return uint16_t. Value of @ref Sn_TX_WR. |
Soohwan Kim |
4:4930f81bbe98 | 926 | * @sa setSn_TX_WR() |
Soohwan Kim |
4:4930f81bbe98 | 927 | */ |
Soohwan Kim |
4:4930f81bbe98 | 928 | uint16_t getSn_TX_WR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 929 | return sreg<uint16_t>(sn, Sn_TX_WR); |
Soohwan Kim |
4:4930f81bbe98 | 930 | } |
Soohwan Kim |
4:4930f81bbe98 | 931 | |
Soohwan Kim |
4:4930f81bbe98 | 932 | |
Soohwan Kim |
4:4930f81bbe98 | 933 | /** |
Soohwan Kim |
4:4930f81bbe98 | 934 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 935 | * @brief Get @ref Sn_RX_RSR register |
Soohwan Kim |
4:4930f81bbe98 | 936 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 937 | * @return uint16_t. Value of @ref Sn_RX_RSR. |
Soohwan Kim |
4:4930f81bbe98 | 938 | */ |
Soohwan Kim |
4:4930f81bbe98 | 939 | uint16_t getSn_RX_RSR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 940 | return sreg<uint16_t>(sn, Sn_RX_RSR); |
Soohwan Kim |
4:4930f81bbe98 | 941 | } |
Soohwan Kim |
4:4930f81bbe98 | 942 | |
Soohwan Kim |
4:4930f81bbe98 | 943 | |
Soohwan Kim |
4:4930f81bbe98 | 944 | /** |
Soohwan Kim |
4:4930f81bbe98 | 945 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 946 | * @brief Set @ref Sn_RX_RD register |
Soohwan Kim |
4:4930f81bbe98 | 947 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 948 | * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD |
Soohwan Kim |
4:4930f81bbe98 | 949 | * @sa getSn_RX_RD() |
Soohwan Kim |
4:4930f81bbe98 | 950 | */ |
Soohwan Kim |
4:4930f81bbe98 | 951 | void setSn_RX_RD(uint8_t sn, uint16_t rxrd) { |
Soohwan Kim |
4:4930f81bbe98 | 952 | sreg<uint16_t>(sn, Sn_RX_RD, rxrd); |
Soohwan Kim |
4:4930f81bbe98 | 953 | } |
Soohwan Kim |
4:4930f81bbe98 | 954 | |
Soohwan Kim |
4:4930f81bbe98 | 955 | /** |
Soohwan Kim |
4:4930f81bbe98 | 956 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 957 | * @brief Get @ref Sn_RX_RD register |
Soohwan Kim |
4:4930f81bbe98 | 958 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 959 | * @regurn uint16_t. Value of @ref Sn_RX_RD. |
Soohwan Kim |
4:4930f81bbe98 | 960 | * @sa setSn_RX_RD() |
Soohwan Kim |
4:4930f81bbe98 | 961 | */ |
Soohwan Kim |
4:4930f81bbe98 | 962 | uint16_t getSn_RX_RD(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 963 | return sreg<uint16_t>(sn, Sn_RX_RD); |
Soohwan Kim |
4:4930f81bbe98 | 964 | } |
Soohwan Kim |
4:4930f81bbe98 | 965 | |
Soohwan Kim |
4:4930f81bbe98 | 966 | /** |
Soohwan Kim |
4:4930f81bbe98 | 967 | * @ingroup Socket_register_access_function |
Soohwan Kim |
4:4930f81bbe98 | 968 | * @brief Get @ref Sn_RX_WR register |
Soohwan Kim |
4:4930f81bbe98 | 969 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 970 | * @return uint16_t. Value of @ref Sn_RX_WR. |
Soohwan Kim |
4:4930f81bbe98 | 971 | */ |
Soohwan Kim |
4:4930f81bbe98 | 972 | uint16_t getSn_RX_WR(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 973 | return sreg<uint16_t>(sn, Sn_RX_WR); |
Soohwan Kim |
4:4930f81bbe98 | 974 | } |
Soohwan Kim |
4:4930f81bbe98 | 975 | |
Soohwan Kim |
4:4930f81bbe98 | 976 | |
Soohwan Kim |
4:4930f81bbe98 | 977 | ////////////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 978 | |
Soohwan Kim |
4:4930f81bbe98 | 979 | ///////////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 980 | // Sn_TXBUF & Sn_RXBUF IO function // |
Soohwan Kim |
4:4930f81bbe98 | 981 | ///////////////////////////////////// |
Soohwan Kim |
4:4930f81bbe98 | 982 | /** |
Soohwan Kim |
4:4930f81bbe98 | 983 | * @brief Gets the max buffer size of socket sn passed as parameter. |
Soohwan Kim |
4:4930f81bbe98 | 984 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 985 | * @return uint16_t. Value of Socket n RX max buffer size. |
Soohwan Kim |
4:4930f81bbe98 | 986 | */ |
Soohwan Kim |
4:4930f81bbe98 | 987 | uint16_t getSn_RxMAX(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 988 | return (getSn_RXBUF_SIZE(sn) << 10); |
Soohwan Kim |
4:4930f81bbe98 | 989 | } |
Soohwan Kim |
4:4930f81bbe98 | 990 | |
Soohwan Kim |
4:4930f81bbe98 | 991 | /** |
Soohwan Kim |
4:4930f81bbe98 | 992 | * @brief Gets the max buffer size of socket sn passed as parameters. |
Soohwan Kim |
4:4930f81bbe98 | 993 | * @param (uint8_t)sn Socket number. It should be <b>0 ~ 7</b>. |
Soohwan Kim |
4:4930f81bbe98 | 994 | * @return uint16_t. Value of Socket n TX max buffer size. |
Soohwan Kim |
4:4930f81bbe98 | 995 | */ |
Soohwan Kim |
4:4930f81bbe98 | 996 | //uint16_t getSn_TxMAX(uint8_t sn); |
Soohwan Kim |
4:4930f81bbe98 | 997 | uint16_t getSn_TxMAX(uint8_t sn) { |
Soohwan Kim |
4:4930f81bbe98 | 998 | return (getSn_TXBUF_SIZE(sn) << 10); |
Soohwan Kim |
4:4930f81bbe98 | 999 | } |
Soohwan Kim |
4:4930f81bbe98 | 1000 | |
Soohwan Kim |
0:6f28332c466f | 1001 | |
Soohwan Kim |
0:6f28332c466f | 1002 | protected: |
Soohwan Kim |
0:6f28332c466f | 1003 | uint8_t mac[6]; |
Soohwan Kim |
0:6f28332c466f | 1004 | uint32_t ip; |
Soohwan Kim |
0:6f28332c466f | 1005 | uint32_t netmask; |
Soohwan Kim |
0:6f28332c466f | 1006 | uint32_t gateway; |
Soohwan Kim |
0:6f28332c466f | 1007 | uint32_t dnsaddr; |
Soohwan Kim |
0:6f28332c466f | 1008 | bool dhcp; |
Soohwan Kim |
4:4930f81bbe98 | 1009 | |
Soohwan Kim |
4:4930f81bbe98 | 1010 | |
Soohwan Kim |
0:6f28332c466f | 1011 | |
Soohwan Kim |
0:6f28332c466f | 1012 | static WIZnet_Chip* inst; |
Soohwan Kim |
0:6f28332c466f | 1013 | |
Soohwan Kim |
0:6f28332c466f | 1014 | void reg_wr_mac(uint16_t addr, uint8_t* data) { |
Soohwan Kim |
0:6f28332c466f | 1015 | spi_write(addr, 0x04, data, 6); |
Soohwan Kim |
0:6f28332c466f | 1016 | } |
Soohwan Kim |
0:6f28332c466f | 1017 | |
Soohwan Kim |
0:6f28332c466f | 1018 | void spi_write(uint16_t addr, uint8_t cb, const uint8_t *buf, uint16_t len); |
Soohwan Kim |
0:6f28332c466f | 1019 | void spi_read(uint16_t addr, uint8_t cb, uint8_t *buf, uint16_t len); |
Soohwan Kim |
0:6f28332c466f | 1020 | SPI* spi; |
Soohwan Kim |
0:6f28332c466f | 1021 | DigitalOut cs; |
Soohwan Kim |
0:6f28332c466f | 1022 | DigitalOut reset_pin; |
Soohwan Kim |
0:6f28332c466f | 1023 | }; |
Soohwan Kim |
8:4c02de1dbf3a | 1024 | extern int ethernet_link(void); |
Soohwan Kim |
8:4c02de1dbf3a | 1025 | extern void ethernet_set_link(int speed, int duplex); |
Soohwan Kim |
0:6f28332c466f | 1026 | |
Soohwan Kim |
0:6f28332c466f | 1027 | extern uint32_t str_to_ip(const char* str); |
Soohwan Kim |
0:6f28332c466f | 1028 | extern void printfBytes(char* str, uint8_t* buf, int len); |
Soohwan Kim |
0:6f28332c466f | 1029 | extern void printHex(uint8_t* buf, int len); |
Soohwan Kim |
0:6f28332c466f | 1030 | extern void debug_hex(uint8_t* buf, int len); |