Rename W6300 public API: drop wiz prefix, snake_case, verb-first functions, namespace w6300
This commit is contained in:
165
w6300/w6300.cpp
165
w6300/w6300.cpp
@@ -9,6 +9,7 @@
|
||||
#include "w6300.h"
|
||||
#include "qspi.pio.h"
|
||||
|
||||
namespace w6300 {
|
||||
namespace {
|
||||
|
||||
#define PIO_PROGRAM_NAME wizchip_pio_spi_quad_write_read
|
||||
@@ -226,7 +227,7 @@ void wizchip_pio_write(uint8_t opcode, uint16_t addr, uint8_t* buf, uint16_t len
|
||||
|
||||
constexpr int _WIZCHIP_ = 6300;
|
||||
constexpr uint8_t _WIZCHIP_QSPI_MODE_ = 0x02 << 6;
|
||||
constexpr int _WIZCHIP_SOCK_NUM_ = WIZCHIP_SOCK_NUM;
|
||||
constexpr int _SOCK_COUNT_ = SOCK_COUNT;
|
||||
|
||||
constexpr uint16_t _PHY_IO_MODE_PHYCR_ = 0x0000;
|
||||
constexpr uint16_t _PHY_IO_MODE_MII_ = 0x0010;
|
||||
@@ -904,7 +905,7 @@ static ipconf_mode ipmode_;
|
||||
|
||||
static constexpr char WIZCHIP_ID[] = "W6300";
|
||||
|
||||
int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) {
|
||||
int8_t ctl_chip(chip_ctl cwtype, void* arg) {
|
||||
uint8_t tmp = *(uint8_t*)arg;
|
||||
uint8_t* ptmp[2] = {0, 0};
|
||||
switch (cwtype) {
|
||||
@@ -922,25 +923,25 @@ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) {
|
||||
*(uint8_t*)arg = getSYSR() >> 5;
|
||||
break;
|
||||
case CW_RESET_WIZCHIP:
|
||||
wizchip_sw_reset();
|
||||
soft_reset();
|
||||
break;
|
||||
case CW_INIT_WIZCHIP:
|
||||
if (arg) {
|
||||
ptmp[0] = (uint8_t*)arg;
|
||||
ptmp[1] = ptmp[0] + WIZCHIP_SOCK_NUM;
|
||||
ptmp[1] = ptmp[0] + SOCK_COUNT;
|
||||
}
|
||||
return wizchip_init(ptmp[0], ptmp[1]);
|
||||
return init_buffers(ptmp[0], ptmp[1]);
|
||||
case CW_CLR_INTERRUPT:
|
||||
wizchip_clrinterrupt(*((intr_kind*)arg));
|
||||
clear_interrupt(*((intr_kind*)arg));
|
||||
break;
|
||||
case CW_GET_INTERRUPT:
|
||||
*((intr_kind*)arg) = wizchip_getinterrupt();
|
||||
*((intr_kind*)arg) = get_interrupt();
|
||||
break;
|
||||
case CW_SET_INTRMASK:
|
||||
wizchip_setinterruptmask(*((intr_kind*)arg));
|
||||
set_interrupt_mask(*((intr_kind*)arg));
|
||||
break;
|
||||
case CW_GET_INTRMASK:
|
||||
*((intr_kind*)arg) = wizchip_getinterruptmask();
|
||||
*((intr_kind*)arg) = get_interrupt_mask();
|
||||
break;
|
||||
case CW_SET_INTRTIME:
|
||||
setINTPTMR(*(uint16_t*)arg);
|
||||
@@ -955,26 +956,26 @@ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) {
|
||||
*(uint16_t*)arg = getVER();
|
||||
break;
|
||||
case CW_RESET_PHY:
|
||||
wizphy_reset();
|
||||
reset_phy();
|
||||
break;
|
||||
case CW_SET_PHYCONF:
|
||||
wizphy_setphyconf((wiz_PhyConf*)arg);
|
||||
set_phy_conf((phy_conf*)arg);
|
||||
break;
|
||||
case CW_GET_PHYCONF:
|
||||
wizphy_getphyconf((wiz_PhyConf*)arg);
|
||||
get_phy_conf((phy_conf*)arg);
|
||||
break;
|
||||
case CW_GET_PHYSTATUS:
|
||||
break;
|
||||
case CW_SET_PHYPOWMODE:
|
||||
wizphy_setphypmode(*(uint8_t*)arg);
|
||||
set_phy_power_mode(*(uint8_t*)arg);
|
||||
break;
|
||||
case CW_GET_PHYPOWMODE:
|
||||
tmp = wizphy_getphypmode();
|
||||
tmp = get_phy_power_mode();
|
||||
if ((int8_t)tmp == -1) return -1;
|
||||
*(uint8_t*)arg = tmp;
|
||||
break;
|
||||
case CW_GET_PHYLINK:
|
||||
tmp = wizphy_getphylink();
|
||||
tmp = get_phy_link();
|
||||
if ((int8_t)tmp == -1) return -1;
|
||||
*(uint8_t*)arg = tmp;
|
||||
break;
|
||||
@@ -984,14 +985,14 @@ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) {
|
||||
int8_t ctl_net(net_ctl cntype, void* arg) {
|
||||
switch (cntype) {
|
||||
case CN_SET_NETINFO: wizchip_setnetinfo((wiz_NetInfo*)arg); break;
|
||||
case CN_GET_NETINFO: wizchip_getnetinfo((wiz_NetInfo*)arg); break;
|
||||
case CN_SET_NETMODE: wizchip_setnetmode(*(netmode_type*)arg); break;
|
||||
case CN_GET_NETMODE: *(netmode_type*)arg = wizchip_getnetmode(); break;
|
||||
case CN_SET_TIMEOUT: wizchip_settimeout((wiz_NetTimeout*)arg); break;
|
||||
case CN_GET_TIMEOUT: wizchip_gettimeout((wiz_NetTimeout*)arg); break;
|
||||
case CN_SET_NETINFO: set_net_info((net_info*)arg); break;
|
||||
case CN_GET_NETINFO: get_net_info((net_info*)arg); break;
|
||||
case CN_SET_NETMODE: set_net_mode(*(netmode_type*)arg); break;
|
||||
case CN_GET_NETMODE: *(netmode_type*)arg = get_net_mode(); break;
|
||||
case CN_SET_TIMEOUT: set_timeout((net_timeout*)arg); break;
|
||||
case CN_GET_TIMEOUT: get_timeout((net_timeout*)arg); break;
|
||||
case CN_SET_PREFER: setSLPSR(*(uint8_t*)arg); break;
|
||||
case CN_GET_PREFER: *(uint8_t*)arg = getSLPSR(); break;
|
||||
default: return -1;
|
||||
@@ -999,19 +1000,19 @@ int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t ctlnetservice(ctlnetservice_type cnstype, void* arg) {
|
||||
int8_t ctl_net_service(net_service_ctl cnstype, void* arg) {
|
||||
switch (cnstype) {
|
||||
case CNS_ARP: return wizchip_arp((wiz_ARP*)arg);
|
||||
case CNS_PING: return wizchip_ping((wiz_PING*)arg);
|
||||
case CNS_DAD: return wizchip_dad((uint8_t*)arg);
|
||||
case CNS_SLAAC: return wizchip_slaac((wiz_Prefix*)arg);
|
||||
case CNS_UNSOL_NA: return wizchip_unsolicited();
|
||||
case CNS_GET_PREFIX: return wizchip_getprefix((wiz_Prefix*)arg);
|
||||
case CNS_ARP: return send_arp((arp_request*)arg);
|
||||
case CNS_PING: return send_ping((ping_request*)arg);
|
||||
case CNS_DAD: return send_dad((uint8_t*)arg);
|
||||
case CNS_SLAAC: return send_slaac((prefix*)arg);
|
||||
case CNS_UNSOL_NA: return send_unsolicited();
|
||||
case CNS_GET_PREFIX: return get_prefix((prefix*)arg);
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void wizchip_sw_reset() {
|
||||
void soft_reset() {
|
||||
uint8_t gw[4], sn[4], sip[4], mac[6];
|
||||
uint8_t gw6[16], sn6[16], lla[16], gua[16];
|
||||
uint8_t islock = getSYSR();
|
||||
@@ -1030,71 +1031,71 @@ void wizchip_sw_reset() {
|
||||
if (islock & SYSR_NETL) NETLOCK();
|
||||
}
|
||||
|
||||
int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) {
|
||||
wizchip_sw_reset();
|
||||
int8_t init_buffers(uint8_t* txsize, uint8_t* rxsize) {
|
||||
soft_reset();
|
||||
if (txsize) {
|
||||
int8_t tmp = 0;
|
||||
for (int i = 0; i < WIZCHIP_SOCK_NUM; i++) {
|
||||
for (int i = 0; i < SOCK_COUNT; i++) {
|
||||
tmp += txsize[i];
|
||||
if (tmp > 32) return -1;
|
||||
}
|
||||
for (int i = 0; i < WIZCHIP_SOCK_NUM; i++) setSn_TXBUF_SIZE(i, txsize[i]);
|
||||
for (int i = 0; i < SOCK_COUNT; i++) setSn_TXBUF_SIZE(i, txsize[i]);
|
||||
}
|
||||
if (rxsize) {
|
||||
int8_t tmp = 0;
|
||||
for (int i = 0; i < WIZCHIP_SOCK_NUM; i++) {
|
||||
for (int i = 0; i < SOCK_COUNT; i++) {
|
||||
tmp += rxsize[i];
|
||||
if (tmp > 32) return -1;
|
||||
}
|
||||
for (int i = 0; i < WIZCHIP_SOCK_NUM; i++) setSn_RXBUF_SIZE(i, rxsize[i]);
|
||||
for (int i = 0; i < SOCK_COUNT; i++) setSn_RXBUF_SIZE(i, rxsize[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wizchip_clrinterrupt(intr_kind intr) {
|
||||
void clear_interrupt(intr_kind intr) {
|
||||
setIRCLR((uint8_t)intr);
|
||||
uint8_t sir = (uint8_t)((uint16_t)intr >> 8);
|
||||
for (int i = 0; i < WIZCHIP_SOCK_NUM; i++)
|
||||
for (int i = 0; i < SOCK_COUNT; i++)
|
||||
if (sir & (1 << i)) setSn_IRCLR(i, 0xFF);
|
||||
setSLIRCLR((uint8_t)((uint32_t)intr >> 16));
|
||||
}
|
||||
|
||||
intr_kind wizchip_getinterrupt() {
|
||||
intr_kind get_interrupt() {
|
||||
uint32_t ret = getSIR();
|
||||
ret = (ret << 8) + getIR();
|
||||
ret = (((uint32_t)getSLIR()) << 16) | ret;
|
||||
return (intr_kind)ret;
|
||||
}
|
||||
|
||||
void wizchip_setinterruptmask(intr_kind intr) {
|
||||
void set_interrupt_mask(intr_kind intr) {
|
||||
setIMR((uint8_t)intr);
|
||||
setSIMR((uint8_t)((uint16_t)intr >> 8));
|
||||
setSLIMR((uint8_t)((uint32_t)intr >> 16));
|
||||
}
|
||||
|
||||
intr_kind wizchip_getinterruptmask() {
|
||||
intr_kind get_interrupt_mask() {
|
||||
uint32_t ret = getSIMR();
|
||||
ret = (ret << 8) + getIMR();
|
||||
ret = (((uint32_t)getSLIMR()) << 16) | ret;
|
||||
return (intr_kind)ret;
|
||||
}
|
||||
|
||||
int8_t wizphy_getphylink() {
|
||||
int8_t get_phy_link() {
|
||||
if (wiz_mdio_read(PHYRAR_BMSR) & BMSR_LINK_STATUS) return PHY_LINK_ON;
|
||||
return PHY_LINK_OFF;
|
||||
}
|
||||
|
||||
int8_t wizphy_getphypmode() {
|
||||
int8_t get_phy_power_mode() {
|
||||
if (wiz_mdio_read(PHYRAR_BMCR) & BMCR_PWDN) return PHY_POWER_DOWN;
|
||||
return PHY_POWER_NORM;
|
||||
}
|
||||
|
||||
void wizphy_reset() {
|
||||
void reset_phy() {
|
||||
wiz_mdio_write(PHYRAR_BMCR, wiz_mdio_read(PHYRAR_BMCR) | BMCR_RST);
|
||||
while (wiz_mdio_read(PHYRAR_BMCR) & BMCR_RST);
|
||||
}
|
||||
|
||||
void wizphy_setphyconf(wiz_PhyConf* phyconf) {
|
||||
void set_phy_conf(phy_conf* phyconf) {
|
||||
uint16_t tmp = wiz_mdio_read(PHYRAR_BMCR);
|
||||
if (phyconf->mode == PHY_MODE_TE) {
|
||||
setPHYCR1(getPHYCR1() | PHYCR1_TE);
|
||||
@@ -1112,28 +1113,28 @@ void wizphy_setphyconf(wiz_PhyConf* phyconf) {
|
||||
}
|
||||
}
|
||||
|
||||
void wizphy_getphyconf(wiz_PhyConf* phyconf) {
|
||||
void get_phy_conf(phy_conf* phyconf) {
|
||||
uint16_t tmp = wiz_mdio_read(PHYRAR_BMCR);
|
||||
phyconf->mode = (getPHYCR1() & PHYCR1_TE) ? PHY_MODE_TE : ((tmp & BMCR_ANE) ? PHY_MODE_AUTONEGO : PHY_MODE_MANUAL);
|
||||
phyconf->duplex = (tmp & BMCR_DPX) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF;
|
||||
phyconf->speed = (tmp & BMCR_SPD) ? PHY_SPEED_100 : PHY_SPEED_10;
|
||||
}
|
||||
|
||||
void wizphy_getphystat(wiz_PhyConf* phyconf) {
|
||||
void get_phy_status(phy_conf* phyconf) {
|
||||
uint8_t tmp = getPHYSR();
|
||||
phyconf->mode = (getPHYCR1() & PHYCR1_TE) ? PHY_MODE_TE : ((tmp & (1 << 5)) ? PHY_MODE_MANUAL : PHY_MODE_AUTONEGO);
|
||||
phyconf->speed = (tmp & PHYSR_SPD) ? PHY_SPEED_10 : PHY_SPEED_100;
|
||||
phyconf->duplex = (tmp & PHYSR_DPX) ? PHY_DUPLEX_HALF : PHY_DUPLEX_FULL;
|
||||
}
|
||||
|
||||
void wizphy_setphypmode(uint8_t pmode) {
|
||||
void set_phy_power_mode(uint8_t pmode) {
|
||||
uint16_t tmp = wiz_mdio_read(PHYRAR_BMCR);
|
||||
if (pmode == PHY_POWER_DOWN) tmp |= BMCR_PWDN;
|
||||
else tmp &= ~BMCR_PWDN;
|
||||
wiz_mdio_write(PHYRAR_BMCR, tmp);
|
||||
}
|
||||
|
||||
void wizchip_setnetinfo(wiz_NetInfo* p) {
|
||||
void set_net_info(net_info* p) {
|
||||
setSHAR(p->mac); setGAR(p->gw); setSUBR(p->sn); setSIPR(p->ip);
|
||||
setGA6R(p->gw6); setSUB6R(p->sn6); setLLAR(p->lla); setGUAR(p->gua);
|
||||
memcpy(dns_, p->dns, 4);
|
||||
@@ -1141,7 +1142,7 @@ void wizchip_setnetinfo(wiz_NetInfo* p) {
|
||||
ipmode_ = p->ipmode;
|
||||
}
|
||||
|
||||
void wizchip_getnetinfo(wiz_NetInfo* p) {
|
||||
void get_net_info(net_info* p) {
|
||||
getSHAR(p->mac); getGAR(p->gw); getSUBR(p->sn); getSIPR(p->ip);
|
||||
getGA6R(p->gw6); getSUB6R(p->sn6); getLLAR(p->lla); getGUAR(p->gua);
|
||||
memcpy(p->dns, dns_, 4);
|
||||
@@ -1149,7 +1150,7 @@ void wizchip_getnetinfo(wiz_NetInfo* p) {
|
||||
p->ipmode = ipmode_;
|
||||
}
|
||||
|
||||
void wizchip_setnetmode(netmode_type netmode) {
|
||||
void set_net_mode(netmode_type netmode) {
|
||||
uint32_t tmp = (uint32_t)netmode;
|
||||
setNETMR((uint8_t)tmp);
|
||||
setNETMR2((uint8_t)(tmp >> 8));
|
||||
@@ -1157,7 +1158,7 @@ void wizchip_setnetmode(netmode_type netmode) {
|
||||
setNET6MR((uint8_t)(tmp >> 24));
|
||||
}
|
||||
|
||||
netmode_type wizchip_getnetmode() {
|
||||
netmode_type get_net_mode() {
|
||||
uint32_t ret = getNETMR();
|
||||
ret = (ret << 8) + getNETMR2();
|
||||
ret = (ret << 16) + getNET4MR();
|
||||
@@ -1165,17 +1166,17 @@ netmode_type wizchip_getnetmode() {
|
||||
return (netmode_type)ret;
|
||||
}
|
||||
|
||||
void wizchip_settimeout(wiz_NetTimeout* t) {
|
||||
void set_timeout(net_timeout* t) {
|
||||
setRCR(t->s_retry_cnt); setRTR(t->s_time_100us);
|
||||
setSLRCR(t->sl_retry_cnt); setSLRTR(t->sl_time_100us);
|
||||
}
|
||||
|
||||
void wizchip_gettimeout(wiz_NetTimeout* t) {
|
||||
void get_timeout(net_timeout* t) {
|
||||
t->s_retry_cnt = getRCR(); t->s_time_100us = getRTR();
|
||||
t->sl_retry_cnt = getSLRCR(); t->sl_time_100us = getSLRTR();
|
||||
}
|
||||
|
||||
int8_t wizchip_arp(wiz_ARP* arp) {
|
||||
int8_t send_arp(arp_request* arp) {
|
||||
uint8_t tmp;
|
||||
if (arp->destinfo.len == 16) { setSLDIP6R(arp->destinfo.ip); setSLCR(SLCR_ARP6); }
|
||||
else { setSLDIP4R(arp->destinfo.ip); setSLCR(SLCR_ARP4); }
|
||||
@@ -1186,7 +1187,7 @@ int8_t wizchip_arp(wiz_ARP* arp) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t wizchip_ping(wiz_PING* ping) {
|
||||
int8_t send_ping(ping_request* ping) {
|
||||
uint8_t tmp;
|
||||
setPINGIDR(ping->id); setPINGSEQR(ping->seq);
|
||||
if (ping->destinfo.len == 16) { setSLDIP6R(ping->destinfo.ip); setSLCR(SLCR_PING6); }
|
||||
@@ -1198,7 +1199,7 @@ int8_t wizchip_ping(wiz_PING* ping) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t wizchip_dad(uint8_t* ipv6) {
|
||||
int8_t send_dad(uint8_t* ipv6) {
|
||||
uint8_t tmp;
|
||||
setSLDIP6R(ipv6); setSLCR(SLCR_NS);
|
||||
while (getSLCR());
|
||||
@@ -1208,7 +1209,7 @@ int8_t wizchip_dad(uint8_t* ipv6) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t wizchip_slaac(wiz_Prefix* prefix) {
|
||||
int8_t send_slaac(prefix* prefix) {
|
||||
uint8_t tmp;
|
||||
setSLCR(SLCR_RS);
|
||||
while (getSLCR());
|
||||
@@ -1223,7 +1224,7 @@ int8_t wizchip_slaac(wiz_Prefix* prefix) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t wizchip_unsolicited() {
|
||||
int8_t send_unsolicited() {
|
||||
uint8_t tmp;
|
||||
setSLCR(SLCR_UNA);
|
||||
while (getSLCR());
|
||||
@@ -1233,7 +1234,7 @@ int8_t wizchip_unsolicited() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t wizchip_getprefix(wiz_Prefix* prefix) {
|
||||
int8_t get_prefix(prefix* prefix) {
|
||||
if (getSLIR() & SLIR_RA) {
|
||||
prefix->len = getPLR(); prefix->flag = getPFR();
|
||||
prefix->valid_lifetime = getVLTR(); prefix->preferred_lifetime = getPLTR();
|
||||
@@ -1247,10 +1248,10 @@ constexpr uint16_t SOCK_ANY_PORT_NUM = 0xC000;
|
||||
static uint16_t sock_any_port = SOCK_ANY_PORT_NUM;
|
||||
static uint16_t sock_io_mode = 0;
|
||||
static uint16_t sock_is_sending = 0;
|
||||
static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,};
|
||||
uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,};
|
||||
static uint16_t sock_remained_size[_SOCK_COUNT_] = {0,};
|
||||
uint8_t sock_pack_info[_SOCK_COUNT_] = {0,};
|
||||
|
||||
#define CHECK_SOCKNUM() do { if(sn >= _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; } while(0)
|
||||
#define CHECK_SOCKNUM() do { if(sn >= _SOCK_COUNT_) return SOCKERR_SOCKNUM; } while(0)
|
||||
#define CHECK_SOCKMODE(mode) do { if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; } while(0)
|
||||
#define CHECK_TCPMODE() do { if((getSn_MR(sn) & 0x03) != 0x01) return SOCKERR_SOCKMODE; } while(0)
|
||||
#define CHECK_UDPMODE() do { if((getSn_MR(sn) & 0x03) != 0x02) return SOCKERR_SOCKMODE; } while(0)
|
||||
@@ -1641,7 +1642,7 @@ int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16
|
||||
return (int32_t)pack_len;
|
||||
}
|
||||
|
||||
int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) {
|
||||
int8_t ctl_socket(uint8_t sn, sock_ctl cstype, void* arg) {
|
||||
uint8_t tmp = 0;
|
||||
CHECK_SOCKNUM();
|
||||
tmp = *((uint8_t*)arg);
|
||||
@@ -1687,7 +1688,7 @@ int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) {
|
||||
return SOCK_OK;
|
||||
}
|
||||
|
||||
int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
int8_t set_sockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
CHECK_SOCKNUM();
|
||||
switch (sotype) {
|
||||
case SO_TTL:
|
||||
@@ -1700,7 +1701,7 @@ int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
setSn_MSSR(sn, *(uint16_t*)arg);
|
||||
break;
|
||||
case SO_DESTIP:
|
||||
if (((wiz_IPAddress *)arg)->len == 16) setSn_DIP6R(sn, ((wiz_IPAddress*)arg)->ip);
|
||||
if (((ip_address *)arg)->len == 16) setSn_DIP6R(sn, ((ip_address*)arg)->ip);
|
||||
else setSn_DIPR(sn, (uint8_t*)arg);
|
||||
break;
|
||||
case SO_DESTPORT:
|
||||
@@ -1727,7 +1728,7 @@ int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
return SOCK_OK;
|
||||
}
|
||||
|
||||
int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
int8_t get_sockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
CHECK_SOCKNUM();
|
||||
switch (sotype) {
|
||||
case SO_FLAG:
|
||||
@@ -1745,11 +1746,11 @@ int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
case SO_DESTIP:
|
||||
CHECK_TCPMODE();
|
||||
if (getSn_ESR(sn) & TCPSOCK_MODE) {
|
||||
getSn_DIP6R(sn, ((wiz_IPAddress*)arg)->ip);
|
||||
((wiz_IPAddress*)arg)->len = 16;
|
||||
getSn_DIP6R(sn, ((ip_address*)arg)->ip);
|
||||
((ip_address*)arg)->len = 16;
|
||||
} else {
|
||||
getSn_DIPR(sn, ((wiz_IPAddress*)arg)->ip);
|
||||
((wiz_IPAddress*)arg)->len = 4;
|
||||
getSn_DIPR(sn, ((ip_address*)arg)->ip);
|
||||
((ip_address*)arg)->len = 4;
|
||||
}
|
||||
break;
|
||||
case SO_DESTPORT:
|
||||
@@ -1791,7 +1792,7 @@ int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) {
|
||||
return SOCK_OK;
|
||||
}
|
||||
|
||||
int16_t peeksockmsg(uint8_t sn, uint8_t* submsg, uint16_t subsize) {
|
||||
int16_t peek_socket_msg(uint8_t sn, uint8_t* submsg, uint16_t subsize) {
|
||||
uint32_t rx_ptr = 0;
|
||||
uint16_t i = 0, sub_idx = 0;
|
||||
if ((getSn_RX_RSR(sn) > 0) && (subsize > 0)) {
|
||||
@@ -1810,7 +1811,7 @@ int16_t peeksockmsg(uint8_t sn, uint8_t* submsg, uint16_t subsize) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wizchip_reset() {
|
||||
void reset() {
|
||||
gpio_init(PIN_RST);
|
||||
gpio_set_dir(PIN_RST, GPIO_OUT);
|
||||
gpio_put(PIN_RST, 0);
|
||||
@@ -1819,26 +1820,28 @@ void wizchip_reset() {
|
||||
sleep_ms(100);
|
||||
}
|
||||
|
||||
void wizchip_spi_initialize() {
|
||||
void init_spi() {
|
||||
wizchip_pio_init();
|
||||
}
|
||||
|
||||
void wizchip_cris_initialize() {
|
||||
void init_critical_section() {
|
||||
critical_section_init(&g_cris_sec);
|
||||
}
|
||||
|
||||
void wizchip_initialize() {
|
||||
void init() {
|
||||
wizchip_pio_frame_end();
|
||||
uint8_t memsize[2][8] = {{4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4}};
|
||||
ctlwizchip(CW_INIT_WIZCHIP, (void *)memsize);
|
||||
ctl_chip(CW_INIT_WIZCHIP, (void *)memsize);
|
||||
}
|
||||
|
||||
bool wizchip_check() {
|
||||
bool check() {
|
||||
return getCIDR() == 0x6300;
|
||||
}
|
||||
|
||||
void network_initialize(wiz_NetInfo net_info) {
|
||||
void init_net(net_info net_info) {
|
||||
uint8_t syslock = SYS_NET_LOCK;
|
||||
ctlwizchip(CW_SYS_UNLOCK, &syslock);
|
||||
ctlnetwork(CN_SET_NETINFO, (void *)&net_info);
|
||||
ctl_chip(CW_SYS_UNLOCK, &syslock);
|
||||
ctl_net(CN_SET_NETINFO, (void *)&net_info);
|
||||
}
|
||||
|
||||
} // namespace w6300
|
||||
|
||||
Reference in New Issue
Block a user