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