ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_net_pal.h
Go to the documentation of this file.
1
69
70#pragma once
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
76#include <stdint.h>
77
78#include "ra8_err.h"
79
80/* =============================================================================
81 * Constants
82 * =============================================================================
83 */
84
99
108
109/* =============================================================================
110 * Types
111 * =============================================================================
112 */
113
123/* The bytes field is read by ra8_net_pal_set_mac_addr / get_mac_addr
124 * which cppcheck does not see if the test build excludes them. */
128
139typedef void (*ra8_net_pal_event_fn_t)(void* ctx, uint32_t event_mask);
140
153
154/* =============================================================================
155 * Lifecycle
156 * =============================================================================
157 */
158
185[[nodiscard]] ra8_err_t ra8_net_pal_init(const ra8_net_pal_mac_t* mac);
186
208[[nodiscard]] ra8_err_t ra8_net_pal_deinit(void);
209
210/* =============================================================================
211 * MAC address
212 * =============================================================================
213 */
214
239
259
260/* =============================================================================
261 * Frame I/O
262 * =============================================================================
263 */
264
294[[nodiscard]] ra8_err_t ra8_net_pal_send_frame(const uint8_t* frame, uint16_t len);
295
326[[nodiscard]] ra8_err_t ra8_net_pal_recv_frame(uint8_t* out_buf, uint16_t* inout_len);
327
328/* =============================================================================
329 * Link state
330 * =============================================================================
331 */
332
353
354/* =============================================================================
355 * Async event handler
356 * =============================================================================
357 */
358
383
384#ifdef __cplusplus
385}
386#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
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.
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.
void(* ra8_net_pal_event_fn_t)(void *ctx, uint32_t event_mask)
Async event callback shape (link change, RX ready, error).
ra8_err_t ra8_net_pal_get_mac_addr(ra8_net_pal_mac_t *out_mac)
Read the currently programmed MAC address.
ra8_net_pal_link_state_t
Possible link-up states surfaced to the stack.
@ k_ra8_net_pal_link_up
Link up at any speed/duplex.
@ k_ra8_net_pal_link_down
Cable unplugged or PHY not up.
ra8_err_t ra8_net_pal_set_event_handler(ra8_net_pal_event_fn_t fn, void *ctx)
Attach 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.
ra8_net_pal_limits_t
maximums / sizes baked into the PAL contract.
Definition ra8_net_pal.h:94
@ k_ra8_net_pal_frame_max
MTU + header + FCS.
Definition ra8_net_pal.h:97
@ k_ra8_net_pal_mtu
Standard payload size.
Definition ra8_net_pal.h:96
@ k_ra8_net_pal_mac_addr_len
48-bit Ethernet MAC.
Definition ra8_net_pal.h:95
ra8_net_pal_event_t
Bits passed to ra8_net_pal_event_fn_t.
@ k_ra8_net_pal_event_tx_done
TX descriptor freed.
@ k_ra8_net_pal_event_link_up
Link came up.
@ k_ra8_net_pal_event_error
MAC reported a fault.
@ k_ra8_net_pal_event_none
RA8 net pal event none.
@ k_ra8_net_pal_event_link_down
Link went down.
@ k_ra8_net_pal_event_rx_ready
RX descriptor has data.
ra8_err_t ra8_net_pal_init(const ra8_net_pal_mac_t *mac)
Initialise the network PAL.
48-bit MAC address container.
uint8_t bytes[k_ra8_net_pal_mac_addr_len]
Bytes.