Rename W6300 public API: drop wiz prefix, snake_case, verb-first functions, namespace w6300
This commit is contained in:
123
w6300/w6300.h
123
w6300/w6300.h
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
constexpr int WIZCHIP_SOCK_NUM = 8;
|
||||
namespace w6300 {
|
||||
|
||||
enum ctlwizchip_type {
|
||||
constexpr int SOCK_COUNT = 8;
|
||||
|
||||
enum chip_ctl {
|
||||
CW_SYS_LOCK, CW_SYS_UNLOCK, CW_GET_SYSLOCK,
|
||||
CW_RESET_WIZCHIP, CW_INIT_WIZCHIP,
|
||||
CW_GET_INTERRUPT, CW_CLR_INTERRUPT, CW_SET_INTRMASK, CW_GET_INTRMASK,
|
||||
@@ -13,12 +15,12 @@ enum ctlwizchip_type {
|
||||
CW_SET_PHYPOWMODE, CW_GET_PHYPOWMODE, CW_GET_PHYLINK
|
||||
};
|
||||
|
||||
enum ctlnetwork_type {
|
||||
enum net_ctl {
|
||||
CN_SET_NETINFO, CN_GET_NETINFO, CN_SET_NETMODE, CN_GET_NETMODE,
|
||||
CN_SET_TIMEOUT, CN_GET_TIMEOUT, CN_SET_PREFER, CN_GET_PREFER,
|
||||
};
|
||||
|
||||
enum ctlnetservice_type {
|
||||
enum net_service_ctl {
|
||||
CNS_ARP, CNS_PING, CNS_DAD, CNS_SLAAC, CNS_UNSOL_NA, CNS_GET_PREFIX
|
||||
};
|
||||
|
||||
@@ -52,7 +54,7 @@ constexpr uint8_t PHY_LINK_ON = 1;
|
||||
constexpr uint8_t PHY_POWER_NORM = 0;
|
||||
constexpr uint8_t PHY_POWER_DOWN = 1;
|
||||
|
||||
struct wiz_PhyConf {
|
||||
struct phy_conf {
|
||||
uint8_t by;
|
||||
uint8_t mode;
|
||||
uint8_t speed;
|
||||
@@ -67,7 +69,7 @@ enum ipconf_mode : uint8_t {
|
||||
|
||||
enum dhcp_mode : uint8_t { NETINFO_STATIC = 1, NETINFO_DHCP };
|
||||
|
||||
struct wiz_NetInfo {
|
||||
struct net_info {
|
||||
uint8_t mac[6];
|
||||
uint8_t ip[4];
|
||||
uint8_t sn[4];
|
||||
@@ -93,19 +95,19 @@ enum netmode_type : uint32_t {
|
||||
NM_MASK_ALL = 0x0F0F0937
|
||||
};
|
||||
|
||||
struct wiz_NetTimeout {
|
||||
struct net_timeout {
|
||||
uint8_t s_retry_cnt;
|
||||
uint16_t s_time_100us;
|
||||
uint8_t sl_retry_cnt;
|
||||
uint16_t sl_time_100us;
|
||||
};
|
||||
|
||||
struct wiz_IPAddress {
|
||||
struct ip_address {
|
||||
uint8_t ip[16];
|
||||
uint8_t len;
|
||||
};
|
||||
|
||||
struct wiz_Prefix {
|
||||
struct prefix {
|
||||
uint8_t len;
|
||||
uint8_t flag;
|
||||
uint32_t valid_lifetime;
|
||||
@@ -113,58 +115,57 @@ struct wiz_Prefix {
|
||||
uint8_t prefix[16];
|
||||
};
|
||||
|
||||
struct wiz_ARP {
|
||||
wiz_IPAddress destinfo;
|
||||
struct arp_request {
|
||||
ip_address destinfo;
|
||||
uint8_t dha[6];
|
||||
};
|
||||
|
||||
struct wiz_PING {
|
||||
struct ping_request {
|
||||
uint16_t id;
|
||||
uint16_t seq;
|
||||
wiz_IPAddress destinfo;
|
||||
ip_address destinfo;
|
||||
};
|
||||
|
||||
int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
|
||||
int8_t ctlnetwork(ctlnetwork_type cntype, void* arg);
|
||||
int8_t ctlnetservice(ctlnetservice_type cnstype, void* arg);
|
||||
int8_t ctl_chip(chip_ctl type, void* arg);
|
||||
int8_t ctl_net(net_ctl type, void* arg);
|
||||
int8_t ctl_net_service(net_service_ctl type, void* arg);
|
||||
|
||||
void wizchip_sw_reset();
|
||||
int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize);
|
||||
void wizchip_clrinterrupt(intr_kind intr);
|
||||
intr_kind wizchip_getinterrupt();
|
||||
void wizchip_setinterruptmask(intr_kind intr);
|
||||
intr_kind wizchip_getinterruptmask();
|
||||
void soft_reset();
|
||||
int8_t init_buffers(uint8_t* txsize, uint8_t* rxsize);
|
||||
void clear_interrupt(intr_kind intr);
|
||||
intr_kind get_interrupt();
|
||||
void set_interrupt_mask(intr_kind intr);
|
||||
intr_kind get_interrupt_mask();
|
||||
|
||||
int8_t wizphy_getphylink();
|
||||
int8_t wizphy_getphypmode();
|
||||
void wizphy_reset();
|
||||
void wizphy_setphyconf(wiz_PhyConf* phyconf);
|
||||
void wizphy_getphyconf(wiz_PhyConf* phyconf);
|
||||
void wizphy_getphystat(wiz_PhyConf* phyconf);
|
||||
void wizphy_setphypmode(uint8_t pmode);
|
||||
int8_t get_phy_link();
|
||||
int8_t get_phy_power_mode();
|
||||
void reset_phy();
|
||||
void set_phy_conf(phy_conf* conf);
|
||||
void get_phy_conf(phy_conf* conf);
|
||||
void get_phy_status(phy_conf* conf);
|
||||
void set_phy_power_mode(uint8_t pmode);
|
||||
|
||||
void wizchip_setnetinfo(wiz_NetInfo* pnetinfo);
|
||||
void wizchip_getnetinfo(wiz_NetInfo* pnetinfo);
|
||||
void wizchip_setnetmode(netmode_type netmode);
|
||||
netmode_type wizchip_getnetmode();
|
||||
void wizchip_settimeout(wiz_NetTimeout* nettime);
|
||||
void wizchip_gettimeout(wiz_NetTimeout* nettime);
|
||||
void set_net_info(net_info* info);
|
||||
void get_net_info(net_info* info);
|
||||
void set_net_mode(netmode_type mode);
|
||||
netmode_type get_net_mode();
|
||||
void set_timeout(net_timeout* timeout);
|
||||
void get_timeout(net_timeout* timeout);
|
||||
|
||||
int8_t wizchip_arp(wiz_ARP* arp);
|
||||
int8_t wizchip_ping(wiz_PING* ping);
|
||||
int8_t wizchip_dad(uint8_t* ipv6);
|
||||
int8_t wizchip_slaac(wiz_Prefix* prefix);
|
||||
int8_t wizchip_unsolicited();
|
||||
int8_t wizchip_getprefix(wiz_Prefix* prefix);
|
||||
int8_t send_arp(arp_request* arp);
|
||||
int8_t send_ping(ping_request* ping);
|
||||
int8_t send_dad(uint8_t* ipv6);
|
||||
int8_t send_slaac(prefix* pfx);
|
||||
int8_t send_unsolicited();
|
||||
int8_t get_prefix(prefix* pfx);
|
||||
|
||||
void wizchip_spi_initialize();
|
||||
void wizchip_cris_initialize();
|
||||
void wizchip_reset();
|
||||
void wizchip_initialize();
|
||||
bool wizchip_check();
|
||||
void network_initialize(wiz_NetInfo net_info);
|
||||
void init_spi();
|
||||
void init_critical_section();
|
||||
void reset();
|
||||
void init();
|
||||
bool check();
|
||||
void init_net(net_info info);
|
||||
|
||||
using SOCKET = uint8_t;
|
||||
using iodata_t = uint8_t;
|
||||
using datasize_t = int16_t;
|
||||
|
||||
@@ -225,19 +226,19 @@ int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
|
||||
int8_t close(uint8_t sn);
|
||||
int8_t listen(uint8_t sn);
|
||||
int8_t disconnect(uint8_t sn);
|
||||
int32_t send(uint8_t sn, uint8_t * buf, uint16_t len);
|
||||
int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len);
|
||||
int32_t send(uint8_t sn, uint8_t* buf, uint16_t len);
|
||||
int32_t recv(uint8_t sn, uint8_t* buf, uint16_t len);
|
||||
|
||||
typedef enum {
|
||||
enum sockint_kind {
|
||||
SIK_CONNECTED = (1 << 0),
|
||||
SIK_DISCONNECTED = (1 << 1),
|
||||
SIK_RECEIVED = (1 << 2),
|
||||
SIK_TIMEOUT = (1 << 3),
|
||||
SIK_SENT = (1 << 4),
|
||||
SIK_ALL = 0x1F
|
||||
} sockint_kind;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
enum sock_ctl {
|
||||
CS_SET_IOMODE,
|
||||
CS_GET_IOMODE,
|
||||
CS_GET_MAXTXBUF,
|
||||
@@ -248,9 +249,9 @@ typedef enum {
|
||||
CS_GET_PREFER,
|
||||
CS_SET_INTMASK,
|
||||
CS_GET_INTMASK
|
||||
} ctlsock_type;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
enum sockopt_type {
|
||||
SO_FLAG,
|
||||
SO_TTL,
|
||||
SO_TOS,
|
||||
@@ -266,13 +267,15 @@ typedef enum {
|
||||
SO_MODE,
|
||||
SO_REMAINSIZE,
|
||||
SO_PACKINFO
|
||||
} sockopt_type;
|
||||
};
|
||||
|
||||
int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg);
|
||||
int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg);
|
||||
int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg);
|
||||
int16_t peeksockmsg(uint8_t sn, uint8_t* submsg, uint16_t subsize);
|
||||
int8_t ctl_socket(uint8_t sn, sock_ctl type, void* arg);
|
||||
int8_t set_sockopt(uint8_t sn, sockopt_type type, void* arg);
|
||||
int8_t get_sockopt(uint8_t sn, sockopt_type type, void* arg);
|
||||
int16_t peek_socket_msg(uint8_t sn, uint8_t* submsg, uint16_t subsize);
|
||||
|
||||
int8_t connect(uint8_t sn, uint8_t* addr, uint16_t port, uint8_t addrlen);
|
||||
int32_t sendto(uint8_t sn, uint8_t* buf, uint16_t len, uint8_t* addr, uint16_t port, uint8_t addrlen);
|
||||
int32_t recvfrom(uint8_t sn, uint8_t* buf, uint16_t len, uint8_t* addr, uint16_t* port, uint8_t* addrlen);
|
||||
|
||||
} // namespace w6300
|
||||
|
||||
Reference in New Issue
Block a user