ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
nx_ether_driver_c6.h File Reference

NetX Duo network driver shim that bridges onto the ESP32-C6 link. More...

#include <stdint.h>
#include "nx_api.h"
#include "ra8_c6link.h"
Include dependency graph for nx_ether_driver_c6.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void nx_ether_driver_c6 (NX_IP_DRIVER *driver_req)
 NetX Duo link driver entry point for the ESP32-C6 Wi-Fi station.
void nx_ether_driver_c6_bind (ra8_c6link_t *link)
 Bind an open C6 link handle to the driver and arm its mutex.
void nx_ether_driver_c6_set_mac (const uint8_t mac[6])
 Tell the driver the station MAC address to stamp on outgoing frames.
void nx_ether_driver_c6_rx (void *ctx, const uint8_t *frame, uint16_t len)
 Receive callback the application registers with ra8_c6link_open.

Detailed Description

NetX Duo network driver shim that bridges onto the ESP32-C6 link.

Tag
[Ring 4 / PAL] {World: NS}

The twin of nx_ether_driver_ra8_eth for the wireless path: where that driver hands NetX-supplied frames to the on-chip Ethernet MAC, this one hands them to the ESP32-C6 over the ra8_c6link facade – ra8_c6link_eth_send for transmit and the facade's 802.3 receive callback for receive. Above it NetX Duo neither knows nor cares that the wire is a Wi-Fi station rather than a copper port: the interface is Ethernet II framing either way.

How the pieces fit
The C6 link is a single-threaded, polled SPI transport – ra8_c6link_poll clocks transactions and ra8_c6link_eth_send pumps its own – so both must never touch the wire at once. This driver serialises them behind one ThreadX mutex: transmit takes it around ra8_c6link_eth_send, and a dedicated RX poll worker takes it around ra8_c6link_poll. Received frames arrive inside that poll, on the worker thread, through nx_ether_driver_c6_rx, which the application registers as the link's receive callback at ra8_c6link_open.
The order the application must follow
  1. open the link with rx_cb = nx_ether_driver_c6_rx and bring the Wi-Fi station all the way to associated (ra8_c6link_wifi_start / ra8_c6link_wifi_join / wait for k_ra8_c6link_event_sta_connected);
  2. nx_ether_driver_c6_bind the open handle to this driver;
  3. nx_ether_driver_c6_set_mac the station address read back from the C6;
  4. nx_ip_create naming nx_ether_driver_c6 as the link driver, which fires NX_LINK_INITIALIZE and spawns the RX worker.
See also
nx_ether_driver_ra8_eth.h The on-chip twin this mirrors
ra8_c6link.h The link this sits on
Since
0.1.0

Definition in file nx_ether_driver_c6.h.

Function Documentation

◆ nx_ether_driver_c6()

void nx_ether_driver_c6 ( NX_IP_DRIVER * driver_req)

NetX Duo link driver entry point for the ESP32-C6 Wi-Fi station.

Pass this symbol as the driver argument to nx_ip_create. NetX Duo calls it for every link command – INITIALIZE, ENABLE, PACKET_SEND, GET_STATUS and the rest – and it dispatches each to the matching handler. The transmit path builds the 14-byte Ethernet header from the destination MAC NetX resolved, the station MAC set by nx_ether_driver_c6_set_mac and the EtherType implied by the command, then forwards the whole frame to ra8_c6link_eth_send.

Parameters
[in,out]driver_reqNetX Duo driver request block; NetX never passes null, but a null is tolerated as a no-op.
Returns
Nothing; the outcome is written to driver_req->nx_ip_driver_status.
Precondition
nx_ether_driver_c6_bind has run with an open, associated link.
The caller is NetX Duo's IP thread (the dispatch is not re-entrant).
Postcondition
driver_req->nx_ip_driver_status is set to NX_SUCCESS or an error.
Any packet carried by a send command is released exactly once.
Note
Not thread-safe against itself; NetX serialises link commands on the IP thread. Wire access is serialised against the RX worker by a mutex.
Since
0.1.0

Definition at line 770 of file nx_ether_driver_c6.c.

References internal_handle_get_status(), internal_handle_init(), internal_handle_send(), internal_set_link_state(), and s_open.

Referenced by internal_c6_cam_net_create(), priv_net_create_ip(), and priv_net_create_ip().

◆ nx_ether_driver_c6_bind()

void nx_ether_driver_c6_bind ( ra8_c6link_t * link)

Bind an open C6 link handle to the driver and arm its mutex.

The driver reaches the co-processor only through this handle. Call it once, after the link is open and the station is associated, and before nx_ip_create. It also creates the ThreadX mutex that serialises transmit against the RX poll worker, so it must run after the ThreadX kernel is up.

Parameters
[in]linkOpen, associated C6 link handle; must be non-null and must outlive every NetX operation on this interface.
Returns
Nothing.
Precondition
The ThreadX kernel is running (tx_application_define has returned).
link is open and its receive callback is nx_ether_driver_c6_rx.
Postcondition
The driver forwards transmit and receive through link.
The transmit/receive serialisation mutex exists.
Note
Idempotent for the mutex: a second bind re-points the handle but does not recreate the mutex.
Since
0.1.0

Definition at line 198 of file nx_ether_driver_c6.c.

References s_c6_link, s_c6_mtx, s_c6_mtx_made, tx_mutex_create, and TX_SUCCESS.

Referenced by c6_cam_net_up(), c6_join_net_up(), and wifi_hal_ip_bind().

◆ nx_ether_driver_c6_rx()

void nx_ether_driver_c6_rx ( void * ctx,
const uint8_t * frame,
uint16_t len )

Receive callback the application registers with ra8_c6link_open.

The facade invokes this for every 802.3 frame the co-processor forwards from the associated AP, synchronously inside ra8_c6link_poll (or inside a transmit pump). It allocates an NX_PACKET from the IP's default pool, copies the frame in, and hands it to NetX Duo's deferred receive path, keyed by EtherType. Before the interface is up (NX_LINK_INITIALIZE has not run) it drops the frame, which is correct: no data frames flow before association and IP bring-up.

Parameters
[in]ctxUnused context pointer from the link configuration.
[in]frameWhole Ethernet II frame including the 14-byte header; must be non-null when len is non-zero.
[in]lenFrame length in octets.
Returns
Nothing; a frame that cannot be delivered is dropped and counted.
Precondition
The driver has been bound and, for delivery, NX_LINK_INITIALIZE ran.
len is at least the 14-byte Ethernet header for delivery.
Postcondition
A well-formed frame is queued to NetX or dropped with the drop count incremented; the packet pool is never leaked.
Runt or pre-initialise frames leave NetX state untouched.
Note
Runs on the RX worker (or the transmit caller) with the wire mutex held; it performs no further wire access, only NetX packet operations.
Since
0.1.0

Definition at line 351 of file nx_ether_driver_c6.c.

References internal_dispatch_to_netx(), internal_rx_acceptable(), k_nx_c6_max_frame, k_nx_c6_rx_align, memcpy(), s_nx_c6_diag, s_rx_iface, s_rx_ip, and s_rx_staging.

Referenced by c6_join_open_link(), internal_c6_cam_open_link(), and wifi_hal_make_cfg().

◆ nx_ether_driver_c6_set_mac()

void nx_ether_driver_c6_set_mac ( const uint8_t mac[6])

Tell the driver the station MAC address to stamp on outgoing frames.

NetX Duo learns the interface MAC from nx_ip_interface_physical_address_set, but nx_ip_create fires NX_LINK_INITIALIZE before the application can call that, so the driver would otherwise stamp a zero source MAC on the first frames. Read the station address with ra8_c6link_wifi_mac and hand it here before nx_ip_create so INITIALIZE has the real value.

Parameters
[in]macSix-octet station MAC; must be non-null.
Returns
Nothing.
Precondition
mac points at k_ra8_c6link_mac_bytes readable octets.
Called before nx_ip_create for deterministic INITIALIZE framing.
Postcondition
The driver stamps mac as the source MAC on every transmitted frame.
A later NX_LINK_INITIALIZE prefers this value over the interface.
Note
Not thread-safe; call it during single-threaded bring-up.
Since
0.1.0

Definition at line 189 of file nx_ether_driver_c6.c.

References k_nx_c6_mac_len, memcpy(), s_local_mac, and s_mac_user_set.

Referenced by c6_cam_net_up(), c6_join_net_up(), and wifi_hal_ip_bind().