Remove leading underscores and mixed case from w6300 internal symbols
This commit is contained in:
@@ -352,9 +352,9 @@ constexpr uint32_t REG_SLHOPR = (0x420F << 8) + CREG_BLOCK;
|
|||||||
constexpr uint32_t REG_SN_MR(uint8_t n) { return (0x0000 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_MR(uint8_t n) { return (0x0000 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_PSR(uint8_t n) { return (0x0004 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_PSR(uint8_t n) { return (0x0004 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_CR(uint8_t n) { return (0x0010 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_CR(uint8_t n) { return (0x0010 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t _SnREG_IR(uint8_t n) { return (0x0020 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_IR(uint8_t n) { return (0x0020 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t _SnREG_IMR(uint8_t n) { return (0x0024 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_IMR(uint8_t n) { return (0x0024 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t _SnREG_IRCLR(uint8_t n) { return (0x0028 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_IRCLR(uint8_t n) { return (0x0028 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_SR(uint8_t n) { return (0x0030 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_SR(uint8_t n) { return (0x0030 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_ESR(uint8_t n) { return (0x0031 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_ESR(uint8_t n) { return (0x0031 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_PNR(uint8_t n) { return (0x0100 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_PNR(uint8_t n) { return (0x0100 << 8) + SREG_BLOCK(n); }
|
||||||
@@ -371,8 +371,8 @@ constexpr uint32_t REG_SN_DIP4R(uint8_t n) { return REG_SN_DIPR(n); }
|
|||||||
constexpr uint32_t REG_SN_DIP6R(uint8_t n) { return (0x0130 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_DIP6R(uint8_t n) { return (0x0130 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_DPORTR(uint8_t n) { return (0x0140 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_DPORTR(uint8_t n) { return (0x0140 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_MR2(uint8_t n) { return (0x0144 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_MR2(uint8_t n) { return (0x0144 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t _SnREG_RTR(uint8_t n) { return (0x0180 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_RTR(uint8_t n) { return (0x0180 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t _SnREG_RCR(uint8_t n) { return (0x0184 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_RCR(uint8_t n) { return (0x0184 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_KPALVTR(uint8_t n) { return (0x0188 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_KPALVTR(uint8_t n) { return (0x0188 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_TX_BSR(uint8_t n) { return (0x0200 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_TX_BSR(uint8_t n) { return (0x0200 << 8) + SREG_BLOCK(n); }
|
||||||
constexpr uint32_t REG_SN_TX_FSR(uint8_t n) { return (0x0204 << 8) + SREG_BLOCK(n); }
|
constexpr uint32_t REG_SN_TX_FSR(uint8_t n) { return (0x0204 << 8) + SREG_BLOCK(n); }
|
||||||
@@ -448,10 +448,10 @@ constexpr uint8_t PHYCR0_10H = 0x07;
|
|||||||
constexpr uint8_t PHYCR1_PWDN = 1 << 5;
|
constexpr uint8_t PHYCR1_PWDN = 1 << 5;
|
||||||
constexpr uint8_t PHYCR1_TE = 1 << 3;
|
constexpr uint8_t PHYCR1_TE = 1 << 3;
|
||||||
constexpr uint8_t PHYCR1_RST = 1 << 0;
|
constexpr uint8_t PHYCR1_RST = 1 << 0;
|
||||||
constexpr uint8_t NETxMR_UNRB = 1 << 3;
|
constexpr uint8_t NETX_MR_UNRB = 1 << 3;
|
||||||
constexpr uint8_t NETxMR_PARP = 1 << 2;
|
constexpr uint8_t NETX_MR_PARP = 1 << 2;
|
||||||
constexpr uint8_t NETxMR_RSTB = 1 << 1;
|
constexpr uint8_t NETX_MR_RSTB = 1 << 1;
|
||||||
constexpr uint8_t NETxMR_PB = 1 << 0;
|
constexpr uint8_t NETX_MR_PB = 1 << 0;
|
||||||
constexpr uint8_t NETMR_ANB = 1 << 5;
|
constexpr uint8_t NETMR_ANB = 1 << 5;
|
||||||
constexpr uint8_t NETMR_M6B = 1 << 4;
|
constexpr uint8_t NETMR_M6B = 1 << 4;
|
||||||
constexpr uint8_t NETMR_WOL = 1 << 2;
|
constexpr uint8_t NETMR_WOL = 1 << 2;
|
||||||
@@ -460,51 +460,51 @@ constexpr uint8_t NETMR_IP4B = 1 << 0;
|
|||||||
constexpr uint8_t NETMR2_DHAS = 1 << 7;
|
constexpr uint8_t NETMR2_DHAS = 1 << 7;
|
||||||
constexpr uint8_t NETMR2_DHAS_ARP = 1 << 7;
|
constexpr uint8_t NETMR2_DHAS_ARP = 1 << 7;
|
||||||
constexpr uint8_t NETMR2_DHAS_ETH = 0 << 7;
|
constexpr uint8_t NETMR2_DHAS_ETH = 0 << 7;
|
||||||
constexpr uint8_t NETMR2_PPPoE = 1 << 0;
|
constexpr uint8_t NETMR2_PPPOE = 1 << 0;
|
||||||
constexpr uint8_t ICMP6BLKR_PING6 = 1 << 4;
|
constexpr uint8_t ICMP6BLKR_PING6 = 1 << 4;
|
||||||
constexpr uint8_t ICMP6BLKR_MLD = 1 << 3;
|
constexpr uint8_t ICMP6BLKR_MLD = 1 << 3;
|
||||||
constexpr uint8_t ICMP6BLKR_RA = 1 << 2;
|
constexpr uint8_t ICMP6BLKR_RA = 1 << 2;
|
||||||
constexpr uint8_t ICMP6BLKR_NA = 1 << 1;
|
constexpr uint8_t ICMP6BLKR_NA = 1 << 1;
|
||||||
constexpr uint8_t ICMP6BLKR_NS = 1 << 0;
|
constexpr uint8_t ICMP6BLKR_NS = 1 << 0;
|
||||||
constexpr uint8_t Sn_MR_MULTI = 1 << 7;
|
constexpr uint8_t SN_MR_MULTI = 1 << 7;
|
||||||
constexpr uint8_t Sn_MR_MF = 1 << 7;
|
constexpr uint8_t SN_MR_MF = 1 << 7;
|
||||||
constexpr uint8_t Sn_MR_BRDB = 1 << 6;
|
constexpr uint8_t SN_MR_BRDB = 1 << 6;
|
||||||
constexpr uint8_t Sn_MR_FPSH = 1 << 6;
|
constexpr uint8_t SN_MR_FPSH = 1 << 6;
|
||||||
constexpr uint8_t Sn_MR_ND = 1 << 5;
|
constexpr uint8_t SN_MR_ND = 1 << 5;
|
||||||
constexpr uint8_t Sn_MR_MC = 1 << 5;
|
constexpr uint8_t SN_MR_MC = 1 << 5;
|
||||||
constexpr uint8_t Sn_MR_SMB = 1 << 5;
|
constexpr uint8_t SN_MR_SMB = 1 << 5;
|
||||||
constexpr uint8_t Sn_MR_MMB = 1 << 5;
|
constexpr uint8_t SN_MR_MMB = 1 << 5;
|
||||||
constexpr uint8_t Sn_MR_MMB4 = Sn_MR_MMB;
|
constexpr uint8_t SN_MR_MMB4 = SN_MR_MMB;
|
||||||
constexpr uint8_t Sn_MR_UNIB = 1 << 4;
|
constexpr uint8_t SN_MR_UNIB = 1 << 4;
|
||||||
constexpr uint8_t Sn_MR_MMB6 = 1 << 4;
|
constexpr uint8_t SN_MR_MMB6 = 1 << 4;
|
||||||
constexpr uint8_t Sn_MR_CLOSE = 0x00;
|
constexpr uint8_t SN_MR_CLOSE = 0x00;
|
||||||
constexpr uint8_t Sn_MR_TCP = 0x01;
|
constexpr uint8_t SN_MR_TCP = 0x01;
|
||||||
constexpr uint8_t Sn_MR_TCP4 = Sn_MR_TCP;
|
constexpr uint8_t SN_MR_TCP4 = SN_MR_TCP;
|
||||||
constexpr uint8_t Sn_MR_UDP = 0x02;
|
constexpr uint8_t SN_MR_UDP = 0x02;
|
||||||
constexpr uint8_t Sn_MR_UDP4 = Sn_MR_UDP;
|
constexpr uint8_t SN_MR_UDP4 = SN_MR_UDP;
|
||||||
constexpr uint8_t Sn_MR_IPRAW = 0x03;
|
constexpr uint8_t SN_MR_IPRAW = 0x03;
|
||||||
constexpr uint8_t Sn_MR_IPRAW4 = Sn_MR_IPRAW;
|
constexpr uint8_t SN_MR_IPRAW4 = SN_MR_IPRAW;
|
||||||
constexpr uint8_t Sn_MR_MACRAW = 0x07;
|
constexpr uint8_t SN_MR_MACRAW = 0x07;
|
||||||
constexpr uint8_t Sn_MR_TCP6 = 0x09;
|
constexpr uint8_t SN_MR_TCP6 = 0x09;
|
||||||
constexpr uint8_t Sn_MR_UDP6 = 0x0A;
|
constexpr uint8_t SN_MR_UDP6 = 0x0A;
|
||||||
constexpr uint8_t Sn_MR_IPRAW6 = 0x0B;
|
constexpr uint8_t SN_MR_IPRAW6 = 0x0B;
|
||||||
constexpr uint8_t Sn_MR_TCPD = 0x0D;
|
constexpr uint8_t SN_MR_TCPD = 0x0D;
|
||||||
constexpr uint8_t Sn_MR_UDPD = 0x0E;
|
constexpr uint8_t SN_MR_UDPD = 0x0E;
|
||||||
constexpr uint8_t Sn_CR_OPEN = 0x01;
|
constexpr uint8_t SN_CR_OPEN = 0x01;
|
||||||
constexpr uint8_t Sn_CR_LISTEN = 0x02;
|
constexpr uint8_t SN_CR_LISTEN = 0x02;
|
||||||
constexpr uint8_t Sn_CR_CONNECT = 0x04;
|
constexpr uint8_t SN_CR_CONNECT = 0x04;
|
||||||
constexpr uint8_t Sn_CR_CONNECT6 = 0x84;
|
constexpr uint8_t SN_CR_CONNECT6 = 0x84;
|
||||||
constexpr uint8_t Sn_CR_DISCON = 0x08;
|
constexpr uint8_t SN_CR_DISCON = 0x08;
|
||||||
constexpr uint8_t Sn_CR_CLOSE = 0x10;
|
constexpr uint8_t SN_CR_CLOSE = 0x10;
|
||||||
constexpr uint8_t Sn_CR_SEND = 0x20;
|
constexpr uint8_t SN_CR_SEND = 0x20;
|
||||||
constexpr uint8_t Sn_CR_SEND6 = 0xA0;
|
constexpr uint8_t SN_CR_SEND6 = 0xA0;
|
||||||
constexpr uint8_t Sn_CR_SEND_KEEP = 0x22;
|
constexpr uint8_t SN_CR_SEND_KEEP = 0x22;
|
||||||
constexpr uint8_t Sn_CR_RECV = 0x40;
|
constexpr uint8_t SN_CR_RECV = 0x40;
|
||||||
constexpr uint8_t SnREG_IRSENDOK = 0x10;
|
constexpr uint8_t SN_IR_SENDOK = 0x10;
|
||||||
constexpr uint8_t SnREG_IRTIMEOUT = 0x08;
|
constexpr uint8_t SN_IR_TIMEOUT = 0x08;
|
||||||
constexpr uint8_t SnREG_IRRECV = 0x04;
|
constexpr uint8_t SN_IR_RECV = 0x04;
|
||||||
constexpr uint8_t SnREG_IRDISCON = 0x02;
|
constexpr uint8_t SN_IR_DISCON = 0x02;
|
||||||
constexpr uint8_t SnREG_IRCON = 0x01;
|
constexpr uint8_t SN_IR_CON = 0x01;
|
||||||
constexpr uint8_t SOCK_CLOSED = 0x00;
|
constexpr uint8_t SOCK_CLOSED = 0x00;
|
||||||
constexpr uint8_t SOCK_INIT = 0x13;
|
constexpr uint8_t SOCK_INIT = 0x13;
|
||||||
constexpr uint8_t SOCK_LISTEN = 0x14;
|
constexpr uint8_t SOCK_LISTEN = 0x14;
|
||||||
@@ -520,19 +520,19 @@ constexpr uint8_t SOCK_IPRAW4 = 0x32;
|
|||||||
constexpr uint8_t SOCK_IPRAW = SOCK_IPRAW4;
|
constexpr uint8_t SOCK_IPRAW = SOCK_IPRAW4;
|
||||||
constexpr uint8_t SOCK_IPRAW6 = 0x33;
|
constexpr uint8_t SOCK_IPRAW6 = 0x33;
|
||||||
constexpr uint8_t SOCK_MACRAW = 0x42;
|
constexpr uint8_t SOCK_MACRAW = 0x42;
|
||||||
constexpr uint8_t Sn_ESR_TCPM = 1 << 2;
|
constexpr uint8_t SN_ESR_TCPM = 1 << 2;
|
||||||
constexpr uint8_t Sn_ESR_TCPM_IPV4 = 0 << 2;
|
constexpr uint8_t SN_ESR_TCPM_IPV4 = 0 << 2;
|
||||||
constexpr uint8_t Sn_ESR_TCPM_IPV6 = 1 << 2;
|
constexpr uint8_t SN_ESR_TCPM_IPV6 = 1 << 2;
|
||||||
constexpr uint8_t Sn_ESR_TCPOP = 1 << 1;
|
constexpr uint8_t SN_ESR_TCPOP = 1 << 1;
|
||||||
constexpr uint8_t Sn_ESR_TCPOP_SVR = 0 << 1;
|
constexpr uint8_t SN_ESR_TCPOP_SVR = 0 << 1;
|
||||||
constexpr uint8_t Sn_ESR_TCPOP_CLT = 1 << 1;
|
constexpr uint8_t SN_ESR_TCPOP_CLT = 1 << 1;
|
||||||
constexpr uint8_t Sn_ESR_IP6T = 1 << 0;
|
constexpr uint8_t SN_ESR_IP6T = 1 << 0;
|
||||||
constexpr uint8_t Sn_ESR_IP6T_LLA = 0 << 0;
|
constexpr uint8_t SN_ESR_IP6T_LLA = 0 << 0;
|
||||||
constexpr uint8_t Sn_ESR_IP6T_GUA = 1 << 0;
|
constexpr uint8_t SN_ESR_IP6T_GUA = 1 << 0;
|
||||||
constexpr uint8_t Sn_MR2_DHAM = 1 << 1;
|
constexpr uint8_t SN_MR2_DHAM = 1 << 1;
|
||||||
constexpr uint8_t Sn_MR2_DHAM_AUTO = 0 << 1;
|
constexpr uint8_t SN_MR2_DHAM_AUTO = 0 << 1;
|
||||||
constexpr uint8_t Sn_MR2_DHAM_MANUAL = 1 << 1;
|
constexpr uint8_t SN_MR2_DHAM_MANUAL = 1 << 1;
|
||||||
constexpr uint8_t Sn_MR2_FARP = 1 << 0;
|
constexpr uint8_t SN_MR2_FARP = 1 << 0;
|
||||||
constexpr uint8_t PHYRAR_BMCR = 0x00;
|
constexpr uint8_t PHYRAR_BMCR = 0x00;
|
||||||
constexpr uint8_t PHYRAR_BMSR = 0x01;
|
constexpr uint8_t PHYRAR_BMSR = 0x01;
|
||||||
constexpr uint16_t BMCR_RST = 1 << 15;
|
constexpr uint16_t BMCR_RST = 1 << 15;
|
||||||
@@ -560,10 +560,10 @@ constexpr uint16_t BMSR_EXT_CAPA = 1 << 0;
|
|||||||
void cris_enter();
|
void cris_enter();
|
||||||
void cris_exit();
|
void cris_exit();
|
||||||
|
|
||||||
uint8_t reg_read(uint32_t AddrSel);
|
uint8_t reg_read(uint32_t addr_sel);
|
||||||
void reg_write(uint32_t AddrSel, uint8_t wb);
|
void reg_write(uint32_t addr_sel, uint8_t wb);
|
||||||
void reg_read_buf(uint32_t AddrSel, uint8_t* pBuf, datasize_t len);
|
void reg_read_buf(uint32_t addr_sel, uint8_t* buf, datasize_t len);
|
||||||
void reg_write_buf(uint32_t AddrSel, uint8_t* pBuf, datasize_t len);
|
void reg_write_buf(uint32_t addr_sel, uint8_t* buf, datasize_t len);
|
||||||
uint16_t get_sn_tx_fsr(uint8_t sn);
|
uint16_t get_sn_tx_fsr(uint8_t sn);
|
||||||
uint16_t get_sn_rx_rsr(uint8_t sn);
|
uint16_t get_sn_rx_rsr(uint8_t sn);
|
||||||
|
|
||||||
@@ -733,10 +733,10 @@ inline void set_sn_psr(uint8_t sn, uint8_t v) { reg_write(REG_SN_PSR(sn), v); }
|
|||||||
inline uint8_t get_sn_psr(uint8_t sn) { return reg_read(REG_SN_PSR(sn)); }
|
inline uint8_t get_sn_psr(uint8_t sn) { return reg_read(REG_SN_PSR(sn)); }
|
||||||
inline void set_sn_cr(uint8_t sn, uint8_t v) { reg_write(REG_SN_CR(sn), v); }
|
inline void set_sn_cr(uint8_t sn, uint8_t v) { reg_write(REG_SN_CR(sn), v); }
|
||||||
inline uint8_t get_sn_cr(uint8_t sn) { return reg_read(REG_SN_CR(sn)); }
|
inline uint8_t get_sn_cr(uint8_t sn) { return reg_read(REG_SN_CR(sn)); }
|
||||||
inline uint8_t get_sn_ir(uint8_t sn) { return reg_read(_SnREG_IR(sn)); }
|
inline uint8_t get_sn_ir(uint8_t sn) { return reg_read(REG_SN_IR(sn)); }
|
||||||
inline void set_sn_imr(uint8_t sn, uint8_t v) { reg_write(_SnREG_IMR(sn), v); }
|
inline void set_sn_imr(uint8_t sn, uint8_t v) { reg_write(REG_SN_IMR(sn), v); }
|
||||||
inline uint8_t get_sn_imr(uint8_t sn) { return reg_read(_SnREG_IMR(sn)); }
|
inline uint8_t get_sn_imr(uint8_t sn) { return reg_read(REG_SN_IMR(sn)); }
|
||||||
inline void set_sn_irclr(uint8_t sn, uint8_t v) { reg_write(_SnREG_IRCLR(sn), v); }
|
inline void set_sn_irclr(uint8_t sn, uint8_t v) { reg_write(REG_SN_IRCLR(sn), v); }
|
||||||
inline void set_sn_ir(uint8_t sn, uint8_t v) { set_sn_irclr(sn, v); }
|
inline void set_sn_ir(uint8_t sn, uint8_t v) { set_sn_irclr(sn, v); }
|
||||||
inline uint8_t get_sn_sr(uint8_t sn) { return reg_read(REG_SN_SR(sn)); }
|
inline uint8_t get_sn_sr(uint8_t sn) { return reg_read(REG_SN_SR(sn)); }
|
||||||
inline uint8_t get_sn_esr(uint8_t sn) { return reg_read(REG_SN_ESR(sn)); }
|
inline uint8_t get_sn_esr(uint8_t sn) { return reg_read(REG_SN_ESR(sn)); }
|
||||||
@@ -787,12 +787,12 @@ inline void set_sn_dport(uint8_t sn, uint16_t v) { set_sn_dportr(sn, v); }
|
|||||||
inline void set_sn_mr2(uint8_t sn, uint8_t v) { reg_write(REG_SN_MR2(sn), v); }
|
inline void set_sn_mr2(uint8_t sn, uint8_t v) { reg_write(REG_SN_MR2(sn), v); }
|
||||||
inline uint8_t get_sn_mr2(uint8_t sn) { return reg_read(REG_SN_MR2(sn)); }
|
inline uint8_t get_sn_mr2(uint8_t sn) { return reg_read(REG_SN_MR2(sn)); }
|
||||||
inline void set_sn_rtr(uint8_t sn, uint16_t v) {
|
inline void set_sn_rtr(uint8_t sn, uint16_t v) {
|
||||||
reg_write(_SnREG_RTR(sn), (uint8_t)(v >> 8));
|
reg_write(REG_SN_RTR(sn), (uint8_t)(v >> 8));
|
||||||
reg_write(offset_inc(_SnREG_RTR(sn), 1), (uint8_t)v);
|
reg_write(offset_inc(REG_SN_RTR(sn), 1), (uint8_t)v);
|
||||||
}
|
}
|
||||||
inline uint16_t get_sn_rtr(uint8_t sn) { return (((uint16_t)reg_read(_SnREG_RTR(sn))) << 8) + reg_read(offset_inc(_SnREG_RTR(sn), 1)); }
|
inline uint16_t get_sn_rtr(uint8_t sn) { return (((uint16_t)reg_read(REG_SN_RTR(sn))) << 8) + reg_read(offset_inc(REG_SN_RTR(sn), 1)); }
|
||||||
inline void set_sn_rcr(uint8_t sn, uint8_t v) { reg_write(_SnREG_RCR(sn), v); }
|
inline void set_sn_rcr(uint8_t sn, uint8_t v) { reg_write(REG_SN_RCR(sn), v); }
|
||||||
inline uint8_t get_sn_rcr(uint8_t sn) { return reg_read(_SnREG_RCR(sn)); }
|
inline uint8_t get_sn_rcr(uint8_t sn) { return reg_read(REG_SN_RCR(sn)); }
|
||||||
inline void set_sn_kpalvtr(uint8_t sn, uint8_t v) { reg_write(REG_SN_KPALVTR(sn), v); }
|
inline void set_sn_kpalvtr(uint8_t sn, uint8_t v) { reg_write(REG_SN_KPALVTR(sn), v); }
|
||||||
inline uint8_t get_sn_kpalvtr(uint8_t sn) { return reg_read(REG_SN_KPALVTR(sn)); }
|
inline uint8_t get_sn_kpalvtr(uint8_t sn) { return reg_read(REG_SN_KPALVTR(sn)); }
|
||||||
inline void set_sn_tx_bsr(uint8_t sn, uint8_t v) { reg_write(REG_SN_TX_BSR(sn), v); }
|
inline void set_sn_tx_bsr(uint8_t sn, uint8_t v) { reg_write(REG_SN_TX_BSR(sn), v); }
|
||||||
@@ -837,36 +837,36 @@ static uint16_t make_addr(uint32_t addr) {
|
|||||||
return static_cast<uint16_t>((addr & 0x00FFFF00) >> 8);
|
return static_cast<uint16_t>((addr & 0x00FFFF00) >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reg_write(uint32_t AddrSel, uint8_t wb) {
|
void reg_write(uint32_t addr_sel, uint8_t wb) {
|
||||||
cris_enter();
|
cris_enter();
|
||||||
pio_frame_start();
|
pio_frame_start();
|
||||||
pio_write(make_opcode(AddrSel, SPI_WRITE), make_addr(AddrSel), &wb, 1);
|
pio_write(make_opcode(addr_sel, SPI_WRITE), make_addr(addr_sel), &wb, 1);
|
||||||
pio_frame_end();
|
pio_frame_end();
|
||||||
cris_exit();
|
cris_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t reg_read(uint32_t AddrSel) {
|
uint8_t reg_read(uint32_t addr_sel) {
|
||||||
uint8_t ret[2] = {0};
|
uint8_t ret[2] = {0};
|
||||||
cris_enter();
|
cris_enter();
|
||||||
pio_frame_start();
|
pio_frame_start();
|
||||||
pio_read(make_opcode(AddrSel, SPI_READ), make_addr(AddrSel), ret, 1);
|
pio_read(make_opcode(addr_sel, SPI_READ), make_addr(addr_sel), ret, 1);
|
||||||
pio_frame_end();
|
pio_frame_end();
|
||||||
cris_exit();
|
cris_exit();
|
||||||
return ret[0];
|
return ret[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void reg_write_buf(uint32_t AddrSel, uint8_t* pBuf, datasize_t len) {
|
void reg_write_buf(uint32_t addr_sel, uint8_t* buf, datasize_t len) {
|
||||||
cris_enter();
|
cris_enter();
|
||||||
pio_frame_start();
|
pio_frame_start();
|
||||||
pio_write(make_opcode(AddrSel, SPI_WRITE), make_addr(AddrSel), pBuf, len);
|
pio_write(make_opcode(addr_sel, SPI_WRITE), make_addr(addr_sel), buf, len);
|
||||||
pio_frame_end();
|
pio_frame_end();
|
||||||
cris_exit();
|
cris_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reg_read_buf(uint32_t AddrSel, uint8_t* pBuf, datasize_t len) {
|
void reg_read_buf(uint32_t addr_sel, uint8_t* buf, datasize_t len) {
|
||||||
cris_enter();
|
cris_enter();
|
||||||
pio_frame_start();
|
pio_frame_start();
|
||||||
pio_read(make_opcode(AddrSel, SPI_READ), make_addr(AddrSel), pBuf, len);
|
pio_read(make_opcode(addr_sel, SPI_READ), make_addr(addr_sel), buf, len);
|
||||||
pio_frame_end();
|
pio_frame_end();
|
||||||
cris_exit();
|
cris_exit();
|
||||||
}
|
}
|
||||||
@@ -1188,7 +1188,7 @@ uint8_t sock_pack_info[sock_count] = {0,};
|
|||||||
#define CHECK_TCPMODE() do { if((get_sn_mr(sn) & 0x03) != 0x01) FAIL(sock_mode); } while(0)
|
#define CHECK_TCPMODE() do { if((get_sn_mr(sn) & 0x03) != 0x01) FAIL(sock_mode); } while(0)
|
||||||
#define CHECK_UDPMODE() do { if((get_sn_mr(sn) & 0x03) != 0x02) FAIL(sock_mode); } while(0)
|
#define CHECK_UDPMODE() do { if((get_sn_mr(sn) & 0x03) != 0x02) FAIL(sock_mode); } while(0)
|
||||||
#define CHECK_IPMODE() do { if((get_sn_mr(sn) & 0x07) != 0x03) FAIL(sock_mode); } while(0)
|
#define CHECK_IPMODE() do { if((get_sn_mr(sn) & 0x07) != 0x03) FAIL(sock_mode); } while(0)
|
||||||
#define CHECK_DGRAMMODE() do { if(get_sn_mr(sn) == Sn_MR_CLOSED) FAIL(sock_mode); if((get_sn_mr(sn) & 0x03) == 0x01) FAIL(sock_mode); } while(0)
|
#define CHECK_DGRAMMODE() do { if(get_sn_mr(sn) == SN_MR_CLOSED) FAIL(sock_mode); if((get_sn_mr(sn) & 0x03) == 0x01) FAIL(sock_mode); } while(0)
|
||||||
#define CHECK_SOCKINIT() do { if((get_sn_sr(sn) != SOCK_INIT)) FAIL(sock_init); } while(0)
|
#define CHECK_SOCKINIT() do { if((get_sn_sr(sn) != SOCK_INIT)) FAIL(sock_init); } while(0)
|
||||||
#define CHECK_SOCKDATA() do { if(len == 0) FAIL(data_len); } while(0)
|
#define CHECK_SOCKDATA() do { if(len == 0) FAIL(data_len); } while(0)
|
||||||
#define CHECK_IPZERO(addr, addrlen) do { uint16_t ipzero=0; for(uint8_t i=0; i<addrlen; i++) ipzero += (uint16_t)addr[i]; if(ipzero == 0) FAIL(ip_invalid); } while(0)
|
#define CHECK_IPZERO(addr, addrlen) do { uint16_t ipzero=0; for(uint8_t i=0; i<addrlen; i++) ipzero += (uint16_t)addr[i]; if(ipzero == 0) FAIL(ip_invalid); } while(0)
|
||||||
@@ -1201,26 +1201,26 @@ std::expected<socket_id, sock_error> open_socket(socket_id sid, protocol proto,
|
|||||||
uint8_t taddr[16];
|
uint8_t taddr[16];
|
||||||
CHECK_SOCKNUM();
|
CHECK_SOCKNUM();
|
||||||
switch (pr & 0x0F) {
|
switch (pr & 0x0F) {
|
||||||
case Sn_MR_TCP4:
|
case SN_MR_TCP4:
|
||||||
get_sipr(taddr);
|
get_sipr(taddr);
|
||||||
CHECK_IPZERO(taddr, 4);
|
CHECK_IPZERO(taddr, 4);
|
||||||
break;
|
break;
|
||||||
case Sn_MR_TCP6:
|
case SN_MR_TCP6:
|
||||||
get_llar(taddr);
|
get_llar(taddr);
|
||||||
CHECK_IPZERO(taddr, 16);
|
CHECK_IPZERO(taddr, 16);
|
||||||
break;
|
break;
|
||||||
case Sn_MR_TCPD:
|
case SN_MR_TCPD:
|
||||||
get_sipr(taddr);
|
get_sipr(taddr);
|
||||||
CHECK_IPZERO(taddr, 4);
|
CHECK_IPZERO(taddr, 4);
|
||||||
get_llar(taddr);
|
get_llar(taddr);
|
||||||
CHECK_IPZERO(taddr, 16);
|
CHECK_IPZERO(taddr, 16);
|
||||||
break;
|
break;
|
||||||
case Sn_MR_UDP:
|
case SN_MR_UDP:
|
||||||
case Sn_MR_UDP6:
|
case SN_MR_UDP6:
|
||||||
case Sn_MR_UDPD:
|
case SN_MR_UDPD:
|
||||||
case Sn_MR_MACRAW:
|
case SN_MR_MACRAW:
|
||||||
case Sn_MR_IPRAW4:
|
case SN_MR_IPRAW4:
|
||||||
case Sn_MR_IPRAW6:
|
case SN_MR_IPRAW6:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FAIL(sock_mode);
|
FAIL(sock_mode);
|
||||||
@@ -1229,16 +1229,16 @@ std::expected<socket_id, sock_error> open_socket(socket_id sid, protocol proto,
|
|||||||
|
|
||||||
if (fl != 0) {
|
if (fl != 0) {
|
||||||
switch (pr) {
|
switch (pr) {
|
||||||
case Sn_MR_MACRAW:
|
case SN_MR_MACRAW:
|
||||||
if ((fl & (Sn_MR2_DHAM | Sn_MR2_FARP)) != 0) FAIL(sock_flag);
|
if ((fl & (SN_MR2_DHAM | SN_MR2_FARP)) != 0) FAIL(sock_flag);
|
||||||
break;
|
break;
|
||||||
case Sn_MR_TCP4:
|
case SN_MR_TCP4:
|
||||||
case Sn_MR_TCP6:
|
case SN_MR_TCP6:
|
||||||
case Sn_MR_TCPD:
|
case SN_MR_TCPD:
|
||||||
if ((fl & (Sn_MR_MULTI | Sn_MR_UNIB)) != 0) FAIL(sock_flag);
|
if ((fl & (SN_MR_MULTI | SN_MR_UNIB)) != 0) FAIL(sock_flag);
|
||||||
break;
|
break;
|
||||||
case Sn_MR_IPRAW4:
|
case SN_MR_IPRAW4:
|
||||||
case Sn_MR_IPRAW6:
|
case SN_MR_IPRAW6:
|
||||||
if (fl != 0) FAIL(sock_flag);
|
if (fl != 0) FAIL(sock_flag);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1253,7 +1253,7 @@ std::expected<socket_id, sock_error> open_socket(socket_id sid, protocol proto,
|
|||||||
if (sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM;
|
if (sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM;
|
||||||
}
|
}
|
||||||
set_sn_portr(sn, p);
|
set_sn_portr(sn, p);
|
||||||
set_sn_cr(sn, Sn_CR_OPEN);
|
set_sn_cr(sn, SN_CR_OPEN);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
sock_io_mode_bits &= ~(1 << sn);
|
sock_io_mode_bits &= ~(1 << sn);
|
||||||
sock_io_mode_bits |= ((fl & (static_cast<uint8_t>(sock_flag::io_nonblock) >> 3)) << sn);
|
sock_io_mode_bits |= ((fl & (static_cast<uint8_t>(sock_flag::io_nonblock) >> 3)) << sn);
|
||||||
@@ -1267,7 +1267,7 @@ std::expected<socket_id, sock_error> open_socket(socket_id sid, protocol proto,
|
|||||||
std::expected<void, sock_error> close(socket_id sid) {
|
std::expected<void, sock_error> close(socket_id sid) {
|
||||||
uint8_t sn = static_cast<uint8_t>(sid);
|
uint8_t sn = static_cast<uint8_t>(sid);
|
||||||
CHECK_SOCKNUM();
|
CHECK_SOCKNUM();
|
||||||
set_sn_cr(sn, Sn_CR_CLOSE);
|
set_sn_cr(sn, SN_CR_CLOSE);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
set_sn_ir(sn, 0xFF);
|
set_sn_ir(sn, 0xFF);
|
||||||
sock_io_mode_bits &= ~(1 << sn);
|
sock_io_mode_bits &= ~(1 << sn);
|
||||||
@@ -1283,7 +1283,7 @@ std::expected<void, sock_error> listen(socket_id sid) {
|
|||||||
CHECK_SOCKNUM();
|
CHECK_SOCKNUM();
|
||||||
CHECK_TCPMODE();
|
CHECK_TCPMODE();
|
||||||
CHECK_SOCKINIT();
|
CHECK_SOCKINIT();
|
||||||
set_sn_cr(sn, Sn_CR_LISTEN);
|
set_sn_cr(sn, SN_CR_LISTEN);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
while (get_sn_sr(sn) != SOCK_LISTEN) {
|
while (get_sn_sr(sn) != SOCK_LISTEN) {
|
||||||
close(sid);
|
close(sid);
|
||||||
@@ -1306,20 +1306,20 @@ std::expected<void, sock_error> connect(socket_id sid, const ip_address& addr, p
|
|||||||
if (addrlen == 16) {
|
if (addrlen == 16) {
|
||||||
if (get_sn_mr(sn) & 0x08) {
|
if (get_sn_mr(sn) & 0x08) {
|
||||||
set_sn_dip6r(sn, const_cast<uint8_t*>(addr.ip.data()));
|
set_sn_dip6r(sn, const_cast<uint8_t*>(addr.ip.data()));
|
||||||
set_sn_cr(sn, Sn_CR_CONNECT6);
|
set_sn_cr(sn, SN_CR_CONNECT6);
|
||||||
} else {
|
} else {
|
||||||
FAIL(sock_mode);
|
FAIL(sock_mode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (get_sn_mr(sn) == Sn_MR_TCP6) FAIL(sock_mode);
|
if (get_sn_mr(sn) == SN_MR_TCP6) FAIL(sock_mode);
|
||||||
set_sn_dipr(sn, const_cast<uint8_t*>(addr.ip.data()));
|
set_sn_dipr(sn, const_cast<uint8_t*>(addr.ip.data()));
|
||||||
set_sn_cr(sn, Sn_CR_CONNECT);
|
set_sn_cr(sn, SN_CR_CONNECT);
|
||||||
}
|
}
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
|
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
|
||||||
while (get_sn_sr(sn) != SOCK_ESTABLISHED) {
|
while (get_sn_sr(sn) != SOCK_ESTABLISHED) {
|
||||||
if (get_sn_ir(sn) & SnREG_IRTIMEOUT) {
|
if (get_sn_ir(sn) & SN_IR_TIMEOUT) {
|
||||||
set_sn_ir(sn, SnREG_IRTIMEOUT);
|
set_sn_ir(sn, SN_IR_TIMEOUT);
|
||||||
FAIL(timeout);
|
FAIL(timeout);
|
||||||
}
|
}
|
||||||
if (get_sn_sr(sn) == SOCK_CLOSED) FAIL(sock_closed);
|
if (get_sn_sr(sn) == SOCK_CLOSED) FAIL(sock_closed);
|
||||||
@@ -1332,12 +1332,12 @@ std::expected<void, sock_error> disconnect(socket_id sid) {
|
|||||||
CHECK_SOCKNUM();
|
CHECK_SOCKNUM();
|
||||||
CHECK_TCPMODE();
|
CHECK_TCPMODE();
|
||||||
if (get_sn_sr(sn) != SOCK_CLOSED) {
|
if (get_sn_sr(sn) != SOCK_CLOSED) {
|
||||||
set_sn_cr(sn, Sn_CR_DISCON);
|
set_sn_cr(sn, SN_CR_DISCON);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
sock_is_sending &= ~(1 << sn);
|
sock_is_sending &= ~(1 << sn);
|
||||||
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
|
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
|
||||||
while (get_sn_sr(sn) != SOCK_CLOSED) {
|
while (get_sn_sr(sn) != SOCK_CLOSED) {
|
||||||
if (get_sn_ir(sn) & SnREG_IRTIMEOUT) {
|
if (get_sn_ir(sn) & SN_IR_TIMEOUT) {
|
||||||
close(sid);
|
close(sid);
|
||||||
FAIL(timeout);
|
FAIL(timeout);
|
||||||
}
|
}
|
||||||
@@ -1366,17 +1366,17 @@ std::expected<uint16_t, sock_error> send(socket_id sid, std::span<const uint8_t>
|
|||||||
}
|
}
|
||||||
send_data(sn, const_cast<uint8_t*>(buf.data()), len);
|
send_data(sn, const_cast<uint8_t*>(buf.data()), len);
|
||||||
if (sock_is_sending & (1 << sn)) {
|
if (sock_is_sending & (1 << sn)) {
|
||||||
while (!(get_sn_ir(sn) & SnREG_IRSENDOK)) {
|
while (!(get_sn_ir(sn) & SN_IR_SENDOK)) {
|
||||||
tmp = get_sn_sr(sn);
|
tmp = get_sn_sr(sn);
|
||||||
if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) {
|
if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) {
|
||||||
if ((tmp == SOCK_CLOSED) || (get_sn_ir(sn) & SnREG_IRTIMEOUT)) close(sid);
|
if ((tmp == SOCK_CLOSED) || (get_sn_ir(sn) & SN_IR_TIMEOUT)) close(sid);
|
||||||
FAIL(sock_status);
|
FAIL(sock_status);
|
||||||
}
|
}
|
||||||
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
|
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
|
||||||
}
|
}
|
||||||
set_sn_ir(sn, SnREG_IRSENDOK);
|
set_sn_ir(sn, SN_IR_SENDOK);
|
||||||
}
|
}
|
||||||
set_sn_cr(sn, Sn_CR_SEND);
|
set_sn_cr(sn, SN_CR_SEND);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
sock_is_sending |= (1 << sn);
|
sock_is_sending |= (1 << sn);
|
||||||
return len;
|
return len;
|
||||||
@@ -1389,7 +1389,7 @@ std::expected<uint16_t, sock_error> recv(socket_id sid, std::span<uint8_t> buf)
|
|||||||
uint16_t recvsize = 0;
|
uint16_t recvsize = 0;
|
||||||
|
|
||||||
CHECK_SOCKNUM();
|
CHECK_SOCKNUM();
|
||||||
CHECK_SOCKMODE(Sn_MR_TCP);
|
CHECK_SOCKMODE(SN_MR_TCP);
|
||||||
CHECK_SOCKDATA();
|
CHECK_SOCKDATA();
|
||||||
|
|
||||||
recvsize = get_sn_rx_max(sn);
|
recvsize = get_sn_rx_max(sn);
|
||||||
@@ -1416,7 +1416,7 @@ std::expected<uint16_t, sock_error> recv(socket_id sid, std::span<uint8_t> buf)
|
|||||||
|
|
||||||
if (recvsize < len) len = recvsize;
|
if (recvsize < len) len = recvsize;
|
||||||
recv_data(sn, buf.data(), len);
|
recv_data(sn, buf.data(), len);
|
||||||
set_sn_cr(sn, Sn_CR_RECV);
|
set_sn_cr(sn, SN_CR_RECV);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@@ -1427,32 +1427,32 @@ std::expected<uint16_t, sock_error> sendto(socket_id sid, std::span<const uint8_
|
|||||||
uint16_t len = buf.size();
|
uint16_t len = buf.size();
|
||||||
uint8_t addrlen = addr.len;
|
uint8_t addrlen = addr.len;
|
||||||
uint8_t tmp = 0;
|
uint8_t tmp = 0;
|
||||||
uint8_t tcmd = Sn_CR_SEND;
|
uint8_t tcmd = SN_CR_SEND;
|
||||||
uint16_t freesize = 0;
|
uint16_t freesize = 0;
|
||||||
|
|
||||||
CHECK_SOCKNUM();
|
CHECK_SOCKNUM();
|
||||||
switch (get_sn_mr(sn) & 0x0F) {
|
switch (get_sn_mr(sn) & 0x0F) {
|
||||||
case Sn_MR_UDP:
|
case SN_MR_UDP:
|
||||||
case Sn_MR_MACRAW:
|
case SN_MR_MACRAW:
|
||||||
case Sn_MR_IPRAW:
|
case SN_MR_IPRAW:
|
||||||
case Sn_MR_IPRAW6:
|
case SN_MR_IPRAW6:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FAIL(sock_mode);
|
FAIL(sock_mode);
|
||||||
}
|
}
|
||||||
tmp = get_sn_mr(sn);
|
tmp = get_sn_mr(sn);
|
||||||
if (tmp != Sn_MR_MACRAW) {
|
if (tmp != SN_MR_MACRAW) {
|
||||||
if (addrlen == 16) {
|
if (addrlen == 16) {
|
||||||
if (tmp & 0x08) {
|
if (tmp & 0x08) {
|
||||||
set_sn_dip6r(sn, const_cast<uint8_t*>(addr.ip.data()));
|
set_sn_dip6r(sn, const_cast<uint8_t*>(addr.ip.data()));
|
||||||
tcmd = Sn_CR_SEND6;
|
tcmd = SN_CR_SEND6;
|
||||||
} else {
|
} else {
|
||||||
FAIL(sock_mode);
|
FAIL(sock_mode);
|
||||||
}
|
}
|
||||||
} else if (addrlen == 4) {
|
} else if (addrlen == 4) {
|
||||||
if (tmp == Sn_MR_UDP6 || tmp == Sn_MR_IPRAW6) FAIL(sock_mode);
|
if (tmp == SN_MR_UDP6 || tmp == SN_MR_IPRAW6) FAIL(sock_mode);
|
||||||
set_sn_dipr(sn, const_cast<uint8_t*>(addr.ip.data()));
|
set_sn_dipr(sn, const_cast<uint8_t*>(addr.ip.data()));
|
||||||
tcmd = Sn_CR_SEND;
|
tcmd = SN_CR_SEND;
|
||||||
} else {
|
} else {
|
||||||
FAIL(ip_invalid);
|
FAIL(ip_invalid);
|
||||||
}
|
}
|
||||||
@@ -1478,11 +1478,11 @@ std::expected<uint16_t, sock_error> sendto(socket_id sid, std::span<const uint8_
|
|||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
while (1) {
|
while (1) {
|
||||||
tmp = get_sn_ir(sn);
|
tmp = get_sn_ir(sn);
|
||||||
if (tmp & SnREG_IRSENDOK) {
|
if (tmp & SN_IR_SENDOK) {
|
||||||
set_sn_ir(sn, SnREG_IRSENDOK);
|
set_sn_ir(sn, SN_IR_SENDOK);
|
||||||
break;
|
break;
|
||||||
} else if (tmp & SnREG_IRTIMEOUT) {
|
} else if (tmp & SN_IR_TIMEOUT) {
|
||||||
set_sn_ir(sn, SnREG_IRTIMEOUT);
|
set_sn_ir(sn, SN_IR_TIMEOUT);
|
||||||
FAIL(timeout);
|
FAIL(timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1500,10 +1500,10 @@ std::expected<uint16_t, sock_error> recvfrom(socket_id sid, std::span<uint8_t> b
|
|||||||
CHECK_SOCKDATA();
|
CHECK_SOCKDATA();
|
||||||
|
|
||||||
switch ((mr = get_sn_mr(sn)) & 0x0F) {
|
switch ((mr = get_sn_mr(sn)) & 0x0F) {
|
||||||
case Sn_MR_UDP:
|
case SN_MR_UDP:
|
||||||
case Sn_MR_IPRAW:
|
case SN_MR_IPRAW:
|
||||||
case Sn_MR_IPRAW6:
|
case SN_MR_IPRAW6:
|
||||||
case Sn_MR_MACRAW:
|
case SN_MR_MACRAW:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FAIL(sock_mode);
|
FAIL(sock_mode);
|
||||||
@@ -1522,23 +1522,23 @@ std::expected<uint16_t, sock_error> recvfrom(socket_id sid, std::span<uint8_t> b
|
|||||||
}
|
}
|
||||||
|
|
||||||
recv_data(sn, head, 2);
|
recv_data(sn, head, 2);
|
||||||
set_sn_cr(sn, Sn_CR_RECV);
|
set_sn_cr(sn, SN_CR_RECV);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
pack_len = head[0] & 0x07;
|
pack_len = head[0] & 0x07;
|
||||||
pack_len = (pack_len << 8) + head[1];
|
pack_len = (pack_len << 8) + head[1];
|
||||||
|
|
||||||
switch (mr & 0x07) {
|
switch (mr & 0x07) {
|
||||||
case Sn_MR_UDP4:
|
case SN_MR_UDP4:
|
||||||
case Sn_MR_UDP6:
|
case SN_MR_UDP6:
|
||||||
case Sn_MR_UDPD:
|
case SN_MR_UDPD:
|
||||||
sock_pack_info[sn] = head[0] & 0xF8;
|
sock_pack_info[sn] = head[0] & 0xF8;
|
||||||
if (sock_pack_info[sn] & PACK_IPv6) addr.len = 16;
|
if (sock_pack_info[sn] & PACK_IPv6) addr.len = 16;
|
||||||
else addr.len = 4;
|
else addr.len = 4;
|
||||||
recv_data(sn, addr.ip.data(), addr.len);
|
recv_data(sn, addr.ip.data(), addr.len);
|
||||||
set_sn_cr(sn, Sn_CR_RECV);
|
set_sn_cr(sn, SN_CR_RECV);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
break;
|
break;
|
||||||
case Sn_MR_MACRAW:
|
case SN_MR_MACRAW:
|
||||||
if (sock_remained_size[sn] == 0) {
|
if (sock_remained_size[sn] == 0) {
|
||||||
sock_remained_size[sn] = head[0];
|
sock_remained_size[sn] = head[0];
|
||||||
sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[1] - 2;
|
sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[1] - 2;
|
||||||
@@ -1552,14 +1552,14 @@ std::expected<uint16_t, sock_error> recvfrom(socket_id sid, std::span<uint8_t> b
|
|||||||
else pack_len = sock_remained_size[sn];
|
else pack_len = sock_remained_size[sn];
|
||||||
recv_data(sn, buf.data(), pack_len);
|
recv_data(sn, buf.data(), pack_len);
|
||||||
break;
|
break;
|
||||||
case Sn_MR_IPRAW6:
|
case SN_MR_IPRAW6:
|
||||||
case Sn_MR_IPRAW4:
|
case SN_MR_IPRAW4:
|
||||||
if (sock_remained_size[sn] == 0) {
|
if (sock_remained_size[sn] == 0) {
|
||||||
sock_pack_info[sn] = head[0] & 0xF8;
|
sock_pack_info[sn] = head[0] & 0xF8;
|
||||||
if (sock_pack_info[sn] & PACK_IPv6) addr.len = 16;
|
if (sock_pack_info[sn] & PACK_IPv6) addr.len = 16;
|
||||||
else addr.len = 4;
|
else addr.len = 4;
|
||||||
recv_data(sn, addr.ip.data(), addr.len);
|
recv_data(sn, addr.ip.data(), addr.len);
|
||||||
set_sn_cr(sn, Sn_CR_RECV);
|
set_sn_cr(sn, SN_CR_RECV);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1574,14 +1574,14 @@ std::expected<uint16_t, sock_error> recvfrom(socket_id sid, std::span<uint8_t> b
|
|||||||
if ((get_sn_mr(sn) & 0x03) == 0x02) {
|
if ((get_sn_mr(sn) & 0x03) == 0x02) {
|
||||||
recv_data(sn, head, 2);
|
recv_data(sn, head, 2);
|
||||||
port = static_cast<port_num>((((uint16_t)head[0]) << 8) + head[1]);
|
port = static_cast<port_num>((((uint16_t)head[0]) << 8) + head[1]);
|
||||||
set_sn_cr(sn, Sn_CR_RECV);
|
set_sn_cr(sn, SN_CR_RECV);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len < sock_remained_size[sn]) pack_len = len;
|
if (len < sock_remained_size[sn]) pack_len = len;
|
||||||
else pack_len = sock_remained_size[sn];
|
else pack_len = sock_remained_size[sn];
|
||||||
recv_data(sn, buf.data(), pack_len);
|
recv_data(sn, buf.data(), pack_len);
|
||||||
set_sn_cr(sn, Sn_CR_RECV);
|
set_sn_cr(sn, SN_CR_RECV);
|
||||||
while (get_sn_cr(sn));
|
while (get_sn_cr(sn));
|
||||||
|
|
||||||
sock_remained_size[sn] -= pack_len;
|
sock_remained_size[sn] -= pack_len;
|
||||||
@@ -1765,10 +1765,10 @@ std::expected<void, sock_error> send_keepalive(socket_id sid) {
|
|||||||
uint8_t sn = static_cast<uint8_t>(sid);
|
uint8_t sn = static_cast<uint8_t>(sid);
|
||||||
if ((get_sn_mr(sn) & 0x03) != 0x01) FAIL(sock_mode);
|
if ((get_sn_mr(sn) & 0x03) != 0x01) FAIL(sock_mode);
|
||||||
if (get_sn_kpalvtr(sn) != 0) FAIL(sock_opt);
|
if (get_sn_kpalvtr(sn) != 0) FAIL(sock_opt);
|
||||||
set_sn_cr(sn, Sn_CR_SEND_KEEP);
|
set_sn_cr(sn, SN_CR_SEND_KEEP);
|
||||||
while (get_sn_cr(sn) != 0) {
|
while (get_sn_cr(sn) != 0) {
|
||||||
if (get_sn_ir(sn) & SnREG_IRTIMEOUT) {
|
if (get_sn_ir(sn) & SN_IR_TIMEOUT) {
|
||||||
set_sn_ir(sn, SnREG_IRTIMEOUT);
|
set_sn_ir(sn, SN_IR_TIMEOUT);
|
||||||
FAIL(timeout);
|
FAIL(timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user