Rename screaming case symbols to snake_case in w6300 public API

This commit is contained in:
Ian Gulliver
2026-04-07 07:09:11 +09:00
parent 843a286631
commit 3c320cf466
2 changed files with 37 additions and 37 deletions

View File

@@ -260,7 +260,7 @@ constexpr uint8_t PACK_COMPLETED = static_cast<uint8_t>(pack_info::completed);
constexpr uint8_t PACK_IPv6 = static_cast<uint8_t>(pack_info::ipv6);
enum sockint_kind { SIK_CONNECTED = 1, SIK_DISCONNECTED = 2, SIK_RECEIVED = 4, SIK_TIMEOUT = 8, SIK_SENT = 16, SIK_ALL = 0x1F };
enum sockint_kind { sik_connected = 1, sik_disconnected = 2, sik_received = 4, sik_timeout = 8, sik_sent = 16, sik_all = 0x1F };
constexpr uint8_t TCPSOCK_MODE = static_cast<uint8_t>(tcp_sock_info::mode);
@@ -959,19 +959,19 @@ int8_t init_buffers(std::span<const uint8_t> txsize, std::span<const uint8_t> rx
soft_reset();
if (!txsize.empty()) {
int8_t tmp = 0;
for (int i = 0; i < SOCK_COUNT; i++) {
for (int i = 0; i < sock_count; i++) {
tmp += txsize[i];
if (tmp > 32) return -1;
}
for (int i = 0; i < SOCK_COUNT; i++) set_sn_txbuf_size(i, txsize[i]);
for (int i = 0; i < sock_count; i++) set_sn_txbuf_size(i, txsize[i]);
}
if (!rxsize.empty()) {
int8_t tmp = 0;
for (int i = 0; i < SOCK_COUNT; i++) {
for (int i = 0; i < sock_count; i++) {
tmp += rxsize[i];
if (tmp > 32) return -1;
}
for (int i = 0; i < SOCK_COUNT; i++) set_sn_rxbuf_size(i, rxsize[i]);
for (int i = 0; i < sock_count; i++) set_sn_rxbuf_size(i, rxsize[i]);
}
return 0;
}
@@ -979,7 +979,7 @@ int8_t init_buffers(std::span<const uint8_t> txsize, std::span<const uint8_t> rx
void clear_interrupt(intr_kind intr) {
set_irclr((uint8_t)intr);
uint8_t sir = (uint8_t)((uint16_t)intr >> 8);
for (int i = 0; i < SOCK_COUNT; i++)
for (int i = 0; i < sock_count; i++)
if (sir & (1 << i)) set_sn_irclr(i, 0xFF);
set_slirclr((uint8_t)((uint32_t)intr >> 16));
}
@@ -1179,11 +1179,11 @@ constexpr uint16_t SOCK_ANY_PORT_NUM = 0xC000;
static uint16_t sock_any_port = SOCK_ANY_PORT_NUM;
static uint16_t sock_io_mode_bits = 0;
static uint16_t sock_is_sending = 0;
static uint16_t sock_remained_size[SOCK_COUNT] = {0,};
uint8_t sock_pack_info[SOCK_COUNT] = {0,};
static uint16_t sock_remained_size[sock_count] = {0,};
uint8_t sock_pack_info[sock_count] = {0,};
#define FAIL(e) return std::unexpected(sock_error::e)
#define CHECK_SOCKNUM() do { if(sn >= SOCK_COUNT) FAIL(sock_num); } while(0)
#define CHECK_SOCKNUM() do { if(sn >= sock_count) FAIL(sock_num); } while(0)
#define CHECK_SOCKMODE(mode) do { if((get_sn_mr(sn) & 0x0F) != mode) 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)
@@ -1649,7 +1649,7 @@ void init_net(const net_info& info) {
std::expected<void, sock_error> set_socket_io_mode(socket_id sid, sock_io_mode mode) {
uint8_t sn = static_cast<uint8_t>(sid);
if (sn >= SOCK_COUNT) FAIL(sock_num);
if (sn >= sock_count) FAIL(sock_num);
if (mode == sock_io_mode::nonblock) sock_io_mode_bits |= (1 << sn);
else if (mode == sock_io_mode::block) sock_io_mode_bits &= ~(1 << sn);
else FAIL(arg);
@@ -1671,8 +1671,8 @@ uint16_t get_socket_max_rx(socket_id sid) {
std::expected<void, sock_error> clear_socket_interrupt(socket_id sid, uint8_t flags) {
uint8_t sn = static_cast<uint8_t>(sid);
if (sn >= SOCK_COUNT) FAIL(sock_num);
if (flags > SIK_ALL) FAIL(arg);
if (sn >= sock_count) FAIL(sock_num);
if (flags > sik_all) FAIL(arg);
set_sn_ir(sn, flags);
return {};
}
@@ -1683,8 +1683,8 @@ uint8_t get_socket_interrupt(socket_id sid) {
std::expected<void, sock_error> set_socket_interrupt_mask(socket_id sid, uint8_t mask) {
uint8_t sn = static_cast<uint8_t>(sid);
if (sn >= SOCK_COUNT) FAIL(sock_num);
if (mask > SIK_ALL) FAIL(arg);
if (sn >= sock_count) FAIL(sock_num);
if (mask > sik_all) FAIL(arg);
set_sn_imr(sn, mask);
return {};
}
@@ -1695,7 +1695,7 @@ uint8_t get_socket_interrupt_mask(socket_id sid) {
std::expected<void, sock_error> set_socket_prefer(socket_id sid, srcv6_prefer pref) {
uint8_t sn = static_cast<uint8_t>(sid);
if (sn >= SOCK_COUNT) FAIL(sock_num);
if (sn >= sock_count) FAIL(sock_num);
uint8_t v = static_cast<uint8_t>(pref);
if ((v & 0x03) == 0x01) FAIL(arg);
set_sn_psr(sn, v);

View File

@@ -7,7 +7,7 @@
namespace w6300 {
constexpr int SOCK_COUNT = 8;
constexpr int sock_count = 8;
enum class socket_id : uint8_t {};
enum class port_num : uint16_t {};
@@ -100,15 +100,15 @@ enum class sock_io_mode : uint8_t {
};
enum intr_kind : uint32_t {
IK_PPPOE_TERMINATED = (1 << 0), IK_DEST_UNREACH = (1 << 1), IK_IP_CONFLICT = (1 << 2),
IK_DEST_UNREACH6 = (1 << 4), IK_WOL = (1 << 7), IK_NET_ALL = 0x97,
IK_SOCK_0 = (1 << 8), IK_SOCK_1 = (1 << 9), IK_SOCK_2 = (1 << 10), IK_SOCK_3 = (1 << 11),
IK_SOCK_4 = (1 << 12), IK_SOCK_5 = (1 << 13), IK_SOCK_6 = (1 << 14), IK_SOCK_7 = (1 << 15),
IK_SOCK_ALL = (0xFF << 8),
IK_SOCKL_TOUT = (1 << 16), IK_SOCKL_ARP4 = (1 << 17), IK_SOCKL_PING4 = (1 << 18),
IK_SOCKL_ARP6 = (1 << 19), IK_SOCKL_PING6 = (1 << 20), IK_SOCKL_NS = (1 << 21),
IK_SOCKL_RS = (1 << 22), IK_SOCKL_RA = (1 << 23), IK_SOCKL_ALL = (0xFF << 16),
IK_INT_ALL = 0x00FFFF97
ik_pppoe_terminated = (1 << 0), ik_dest_unreach = (1 << 1), ik_ip_conflict = (1 << 2),
ik_dest_unreach6 = (1 << 4), ik_wol = (1 << 7), ik_net_all = 0x97,
ik_sock_0 = (1 << 8), ik_sock_1 = (1 << 9), ik_sock_2 = (1 << 10), ik_sock_3 = (1 << 11),
ik_sock_4 = (1 << 12), ik_sock_5 = (1 << 13), ik_sock_6 = (1 << 14), ik_sock_7 = (1 << 15),
ik_sock_all = (0xFF << 8),
ik_sockl_tout = (1 << 16), ik_sockl_arp4 = (1 << 17), ik_sockl_ping4 = (1 << 18),
ik_sockl_arp6 = (1 << 19), ik_sockl_ping6 = (1 << 20), ik_sockl_ns = (1 << 21),
ik_sockl_rs = (1 << 22), ik_sockl_ra = (1 << 23), ik_sockl_all = (0xFF << 16),
ik_int_all = 0x00FFFF97
};
struct phy_conf {
@@ -119,12 +119,12 @@ struct phy_conf {
};
enum ipconf_mode : uint8_t {
NETINFO_NONE = 0x00, NETINFO_STATIC_V4 = 0x01, NETINFO_STATIC_V6 = 0x02,
NETINFO_STATIC_ALL = 0x03, NETINFO_SLAAC_V6 = 0x04,
NETINFO_DHCP_V4 = 0x10, NETINFO_DHCP_V6 = 0x20, NETINFO_DHCP_ALL = 0x30
ipconf_none = 0x00, ipconf_static_v4 = 0x01, ipconf_static_v6 = 0x02,
ipconf_static_all = 0x03, ipconf_slaac_v6 = 0x04,
ipconf_dhcp_v4 = 0x10, ipconf_dhcp_v6 = 0x20, ipconf_dhcp_all = 0x30
};
enum dhcp_mode : uint8_t { NETINFO_STATIC = 1, NETINFO_DHCP };
enum dhcp_mode : uint8_t { dhcp_static = 1, dhcp_dynamic };
struct net_info {
std::array<uint8_t, 6> mac;
@@ -142,14 +142,14 @@ struct net_info {
};
enum netmode_type : uint32_t {
NM_IPB_V4 = (1 << 0), NM_IPB_V6 = (1 << 1), NM_WOL = (1 << 2),
NM_PB6_MULTI = (1 << 4), NM_PB6_ALLNODE = (1 << 5), NM_MR_MASK = 0x37,
NM_PPPoE = (1 << 8), NM_DHA_SELECT = (1 << 15), NM_MR2_MASK = (0x09 << 8),
NM_PB4_ALL = (1 << 16), NM_TRSTB_V4 = (1 << 17), NM_PARP_V4 = (1 << 18),
NM_UNRB_V4 = (1 << 19), NM_NET4_MASK = (0x0F << 16),
NM_PB6_ALL = (1 << 24), NM_TRSTB_V6 = (1 << 25), NM_PARP_V6 = (1 << 26),
NM_UNRB_V6 = (1 << 27), NM_NET6_MASK = (0x0F << 24),
NM_MASK_ALL = 0x0F0F0937
nm_ipb_v4 = (1 << 0), nm_ipb_v6 = (1 << 1), nm_wol = (1 << 2),
nm_pb6_multi = (1 << 4), nm_pb6_allnode = (1 << 5), nm_mr_mask = 0x37,
nm_pppoe = (1 << 8), nm_dha_select = (1 << 15), nm_mr2_mask = (0x09 << 8),
nm_pb4_all = (1 << 16), nm_trstb_v4 = (1 << 17), nm_parp_v4 = (1 << 18),
nm_unrb_v4 = (1 << 19), nm_net4_mask = (0x0F << 16),
nm_pb6_all = (1 << 24), nm_trstb_v6 = (1 << 25), nm_parp_v6 = (1 << 26),
nm_unrb_v6 = (1 << 27), nm_net6_mask = (0x0F << 24),
nm_mask_all = 0x0F0F0937
};
struct net_timeout {