53 for (uint16_t i = 0U; i < len; ++i) {
79 for (uint16_t i = 0U; i < len; ++i) {
84static const char*
s_tag =
"NETPAL";
91typedef enum : uint16_t {
184 if (eth_mask != 0U) {
271 if (mac !=
nullptr) {
426 if ((
s_state.event_fn !=
nullptr)) {
476 const uint16_t n = slot->
len;
491 *out_state =
s_state.link_state;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_no_data
No application data available (e.g.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Ethernet Switch Module (ESWM) + frame TX/RX driver.
void ra8_eth_attach_handler(ra8_eth_event_fn_t fn, void *ctx)
Replace the shared Ethernet event callback.
ra8_err_t ra8_eth_deinit(void)
Tear down the ESWM block.
ra8_err_t ra8_eth_init(void)
Initialise the ESWM block (MSTP enable + reset regs).
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
#define ra8_log_info(tag, message)
RA8 log info.
ra8_err_t ra8_net_pal_link_status(ra8_net_pal_link_state_t *out_state)
Read the current link state.
ra8_err_t ra8_net_pal_send_frame(const uint8_t *frame, uint16_t len)
Hand a complete ethernet frame to the MAC for transmit.
ra8_err_t ra8_net_pal_deinit(void)
Tear down the network PAL singleton.
ra8_err_t ra8_net_pal_recv_frame(uint8_t *out_buf, uint16_t *inout_len)
Pull the next received ethernet frame, if any, into a buffer.
static void internal_ring_reset(void)
Reset the software ring to empty.
static uint32_t internal_translate_event(uint32_t eth_mask)
Translate ra8_eth status bits into PAL event bits.
static void internal_copy_bytes(uint8_t *dst, const uint8_t *src, uint16_t len)
Copy len bytes byte-by-byte (string.h-free implementation).
ra8_err_t ra8_net_pal_get_mac_addr(ra8_net_pal_mac_t *out_mac)
Read the currently programmed MAC address.
ra8_err_t ra8_net_pal_set_event_handler(ra8_net_pal_event_fn_t fn, void *ctx)
Install a single event handler for link / RX / TX events.
ra8_err_t ra8_net_pal_set_mac_addr(const ra8_net_pal_mac_t *mac)
Programme the PAL MAC address.
static void internal_eth_event(void *ctx, uint32_t status_mask)
ra8_eth event handler – translate + forward to the PAL callback.
@ k_ra8_net_pal_ring_slots
Number of in-flight frames.
static void internal_zero_bytes(uint8_t *dst, uint16_t len)
Zero len bytes (project-local replacement for memset).
ra8_err_t ra8_net_pal_init(const ra8_net_pal_mac_t *mac)
Bring up the network PAL singleton.
Network Platform Abstraction Layer for the RA8D2 ESWM block.
void(* ra8_net_pal_event_fn_t)(void *ctx, uint32_t event_mask)
Async event callback shape (link change, RX ready, error).
ra8_net_pal_link_state_t
Possible link-up states surfaced to the stack.
@ k_ra8_net_pal_link_down
Cable unplugged or PHY not up.
@ k_ra8_net_pal_frame_max
MTU + header + FCS.
@ k_ra8_net_pal_mac_addr_len
48-bit Ethernet MAC.
@ k_ra8_net_pal_event_tx_done
TX descriptor freed.
@ k_ra8_net_pal_event_error
MAC reported a fault.
@ k_ra8_net_pal_event_none
RA8 net pal event none.
48-bit MAC address container.
uint8_t bytes[k_ra8_net_pal_mac_addr_len]
Bytes.
One ring slot holding a single frame plus its byte length.
uint16_t len
0 == slot empty.
uint8_t data[k_ra8_net_pal_frame_max]
Up to 1518 bytes.
ra8_net_pal_mac_t mac
Stored MAC address.
uint16_t tail
Next slot to push (send).
uint16_t head
Next slot to pop (recv).
ra8_net_pal_link_state_t link_state
Last observed link state.
void * event_ctx
Callback context.
ra8_net_pal_event_fn_t event_fn
Async event callback.
uint16_t count
In-flight frame count.
ra8_net_pal_slot_t ring[k_ra8_net_pal_ring_slots]
RX/TX ring.
bool initialized
True after ra8_net_pal_init.