#pragma once #include #include #include #include namespace w6300 { constexpr int sock_count = 8; enum class socket_id : uint8_t {}; enum class sock_error : int16_t { busy = 0, sock_num = -1, sock_closed = -4, sock_mode = -5, arg = -10, timeout = -13, data_len = -14, fatal_packlen = -1001, }; enum class protocol : uint8_t { macraw = 0x07, }; enum class sock_flag : uint8_t { none = 0, }; 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 }; void init_spi(); void reset(); void init(); bool check(); void clear_interrupt(intr_kind intr); void set_interrupt_mask(intr_kind intr); std::expected open_socket(socket_id sn, protocol proto, sock_flag flag); std::expected send(socket_id sn, std::span buf); std::expected recv(socket_id sn, std::span buf); uint16_t get_socket_recv_buf(socket_id sn); } // namespace w6300