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

Shared contract for the ra8_c6link facade bring-up application. More...

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

Go to the source code of this file.

Enumerations

enum  c6_wifi_cfg_t : uint32_t {
  k_c6_wifi_uart_baud = 115200U ,
  k_c6_wifi_sck_hz = 5000000U ,
  k_c6_wifi_edge_poll_ms = 2U ,
  k_c6_wifi_boot_wait_ms = 200U ,
  k_c6_wifi_heartbeat_ms = 5000U ,
  k_c6_wifi_worker_stack = 8192U ,
  k_c6_wifi_worker_prio = 8U ,
  k_c6_wifi_arena_bytes = 4096U
}
 Link, thread and pacing parameters this application chooses. More...
enum  c6_wifi_fmt_t : uint16_t {
  k_c6_wifi_str_max = 256U ,
  k_c6_wifi_dec_radix = 10U ,
  k_c6_wifi_dec_digits = 10U ,
  k_c6_wifi_hex_digits = 8U ,
  k_c6_wifi_hex_bits = 4U ,
  k_c6_wifi_hex_mask = 0x0FU ,
  k_c6_wifi_hex_alpha = 10U ,
  k_c6_wifi_hex_byte = 2U ,
  k_c6_wifi_text_max = 32U
}
 Bounds for the console formatters in src/c6_wifi_console.c. More...

Functions

void c6_wifi_puts (const char *text)
 Write a NUL-terminated string to the board console.
void c6_wifi_put_u32 (uint32_t value)
 Emit an unsigned 32-bit value in decimal.
void c6_wifi_put_i32 (int32_t value)
 Emit a signed 32-bit value in decimal.
void c6_wifi_put_hex (uint32_t value, uint8_t digits)
 Emit a value as a fixed-width lower-case hexadecimal field.
void c6_wifi_put_text (const char *text, size_t len)
 Emit a NUL-terminated co-processor string as printable text.
void c6_wifi_put_mac (const ra8_c6link_mac_t *mac)
 Emit an IEEE 802 address as six colon-separated hexadecimal octets.
void c6_wifi_print_banner (uint32_t cpuclk_hz, uint32_t pclka_hz)
 Print the banner: identity, clocks and link parameters.
void c6_wifi_print_stats (const char *label, const ra8_c6link_stats_t *stats)
 Print what one facade poll did, as one console line.

Detailed Description

Shared contract for the ra8_c6link facade bring-up application.

Tag
[Ring 6 / APP] {World: S}

c6_fw_version proved one esp-hosted RPC round-trip by hand-building the request inside the application. This application proves the same wire through libs/ra8_c6link, the facade every consumer is meant to use, and then goes one step further: it brings the co-processor's Wi-Fi station up and reads back its MAC address. That is the first thing #492's NetX Duo glue will do, and it is the part of the control plane a host test cannot settle – whether the Req_WifiInit configuration this host transmits is one the co-processor's own build accepts.

Two modules, both driven by main.c:

  • src/c6_wifi_console.c – bounded console formatters, so the image links no newlib printf.
  • main.c – bring-up, the four phases, and the verdict.

Everything protocol-shaped lives in the facade. This file holds only what an application genuinely owns: pacing, buffer bounds and formatter widths.

Since
0.1.0

Definition in file c6_wifi.h.

Enumeration Type Documentation

◆ c6_wifi_cfg_t

enum c6_wifi_cfg_t : uint32_t

Link, thread and pacing parameters this application chooses.

Only values an application owns live here. NASA Power of 10 Rule 3 forbids allocation after initialisation and this image has no heap, so the worker stack and the decode arena are sized here alongside the link timing.

Invariant
k_c6_wifi_sck_hz is the bit rate c6_fw_version completed an RPC round-trip at on 2026-07-28, so this application changes one variable at a time relative to that run.
k_c6_wifi_arena_bytes is at least k_ra8_c6link_arena_min, which ra8_c6link_open enforces.
Example:
cfg.sck_hz = (uint32_t)k_c6_wifi_sck_hz;
@ k_c6_wifi_sck_hz
SPI bit rate; the rate the RPC round-trip ran at on silicon.
Definition c6_wifi.h:60
See also
ra8_esp_hosted_port_cfg_t
Since
0.1.0
Enumerator
k_c6_wifi_uart_baud 

Console rate, 8N1, over the J-Link OB VCOM.

k_c6_wifi_sck_hz 

SPI bit rate; the rate the RPC round-trip ran at on silicon.

k_c6_wifi_edge_poll_ms 

Poll period for a side-band pin with no ICU channel.

k_c6_wifi_boot_wait_ms 

Settling delay before the first transaction.

k_c6_wifi_heartbeat_ms 

Heartbeat gap after the verdict, in milliseconds and therefore in ThreadX ticks.

k_c6_wifi_worker_stack 

Worker-thread stack, in bytes.

The protobuf decoder recurses through nested messages.

k_c6_wifi_worker_prio 

Worker priority and preemption threshold.

k_c6_wifi_arena_bytes 

Decode arena handed to the facade.

Double the enforced minimum, because an AP record carries nested country and HE sub-messages.

Definition at line 58 of file c6_wifi.h.

◆ c6_wifi_fmt_t

enum c6_wifi_fmt_t : uint16_t

Bounds for the console formatters in src/c6_wifi_console.c.

The image links no newlib printf, so the serialisers do their own digit extraction; every loop they run is bounded by a value from this enumeration, which is what satisfies NASA Power of 10 Rule 2.

Invariant
k_c6_wifi_dec_digits holds the widest 32-bit decimal value.
k_c6_wifi_hex_digits holds the widest 32-bit hex value.
Example:
@ k_c6_wifi_hex_byte
Hex digits printed for a byte-wide field.
Definition c6_wifi.h:98
void c6_wifi_put_hex(uint32_t value, uint8_t digits)
Emit a value as a fixed-width lower-case hexadecimal field.
See also
c6_wifi_put_u32
Since
0.1.0
Enumerator
k_c6_wifi_str_max 

Longest string the console helper emits.

k_c6_wifi_dec_radix 

Decimal radix.

k_c6_wifi_dec_digits 

Digits in the widest 32-bit decimal value.

k_c6_wifi_hex_digits 

Digits in the widest 32-bit hex value.

k_c6_wifi_hex_bits 

Bits per hexadecimal digit.

k_c6_wifi_hex_mask 

Nibble mask.

k_c6_wifi_hex_alpha 

First nibble value spelled with a letter.

k_c6_wifi_hex_byte 

Hex digits printed for a byte-wide field.

k_c6_wifi_text_max 

Longest co-processor-supplied string echoed to the console; anything longer is truncated rather than trusted.

Definition at line 90 of file c6_wifi.h.

Function Documentation

◆ c6_wifi_print_banner()

void c6_wifi_print_banner ( uint32_t cpuclk_hz,
uint32_t pclka_hz )

Print the banner: identity, clocks and link parameters.

Parameters
[in]cpuclk_hzLive CPUCLK0 rate in hertz.
[in]pclka_hzLive PCLKA rate in hertz, the SCI baud-clock source.
Returns
Nothing.
Precondition
The console is up.
Both rates were read from the CGC rather than assumed.
Postcondition
Three banner lines were emitted.
No application state is modified.
Note
The SPI mode is the co-processor's: the C6 image in coprocessor/esp32c6/ is built with CONFIG_ESP_SPI_MODE=3 and the port opens the bus to match.
See also
c6_wifi_print_stats
Since
0.1.0

Definition at line 140 of file c6_wifi_console.c.

References c6_wifi_put_u32(), c6_wifi_puts(), k_c6_wifi_sck_hz, k_ra8_board_pmod1_sci_channel, k_ra8_c6link_frame_bytes, and k_ra8_c6link_max_payload.

Referenced by main().

◆ c6_wifi_print_stats()

void c6_wifi_print_stats ( const char * label,
const ra8_c6link_stats_t * stats )

Print what one facade poll did, as one console line.

Parameters
[in]labelField name printed before the counters; null prints nothing at all rather than being dereferenced.
[in]statsCounters filled in by ra8_c6link_poll; null prints nothing.
Returns
Nothing.
Precondition
The console is up.
stats came from a completed poll.
Postcondition
Exactly one line was emitted, or none on a null argument.
No application state is modified.
Note
Every counter is printed, including the zero ones: a zero bad_checksum beside a non-zero transfers is itself the evidence that the link is clean.
See also
ra8_c6link_stats
Since
0.1.0

Definition at line 159 of file c6_wifi_console.c.

References ra8_c6link_stats::bad_checksum, c6_wifi_put_u32(), c6_wifi_puts(), ra8_c6link_stats::data, ra8_c6link_stats::eth_in, ra8_c6link_stats::events, ra8_c6link_stats::hs_timeouts, ra8_c6link_stats::idle, ra8_c6link_stats::malformed, ra8_c6link_stats::rpc_in, ra8_c6link_stats::transfers, ra8_c6link_stats::undecodable, and ra8_c6link_stats::unrouted.

Referenced by c6_wifi_phase_station().

◆ c6_wifi_put_hex()

void c6_wifi_put_hex ( uint32_t value,
uint8_t digits )

Emit a value as a fixed-width lower-case hexadecimal field.

Parameters
[in]valueValue to print.
[in]digitsField width, 1..k_c6_wifi_hex_digits; an out-of-range width prints nothing rather than overrunning the output array.
Returns
Nothing.
Precondition
The console is up.
digits is within 1..k_c6_wifi_hex_digits.
Postcondition
Exactly digits characters were emitted, or none on a bad width.
No application state is modified.
Note
The loop is bounded by the range-checked digits (NASA Rule 2).
See also
c6_wifi_put_u32
Since
0.1.0

Definition at line 94 of file c6_wifi_console.c.

References k_c6_wifi_hex_alpha, k_c6_wifi_hex_bits, k_c6_wifi_hex_digits, k_c6_wifi_hex_mask, and ra8_board_uart_console_write().

Referenced by c6_wifi_phase_identity(), and c6_wifi_put_mac().

◆ c6_wifi_put_i32()

void c6_wifi_put_i32 ( int32_t value)

Emit a signed 32-bit value in decimal.

Parameters
[in]valueValue to print, including INT32_MIN.
Returns
Nothing.
Precondition
The console is up.
The caller accepts a leading minus sign on negative values.
Postcondition
One optional sign plus the decimal magnitude were emitted.
No application state is modified.
Note
The magnitude is formed in unsigned arithmetic, so INT32_MIN does not overflow on negation.
See also
c6_wifi_put_u32
Since
0.1.0

Emit a signed 32-bit value in decimal.

Definition at line 84 of file c6_wifi_console.c.

References c6_wifi_put_u32(), and c6_wifi_puts().

Referenced by c6_wifi_on_event(), and c6_wifi_report_fault().

◆ c6_wifi_put_mac()

void c6_wifi_put_mac ( const ra8_c6link_mac_t * mac)

Emit an IEEE 802 address as six colon-separated hexadecimal octets.

Parameters
[in]macAddress to print; null prints nothing.
Returns
Nothing.
Precondition
The console is up.
mac was filled by ra8_c6link_wifi_mac or is the zero address.
Postcondition
Seventeen characters were emitted, or none on a null argument.
No application state is modified.
Note
The loop is bounded by k_ra8_c6link_mac_bytes (NASA Rule 2).
See also
ra8_c6link_wifi_mac
Since
0.1.0

Definition at line 127 of file c6_wifi_console.c.

References c6_wifi_put_hex(), c6_wifi_puts(), k_c6_wifi_hex_byte, k_ra8_c6link_mac_bytes, and ra8_c6link_mac::octet.

Referenced by c6_wifi_phase_station().

◆ c6_wifi_put_text()

void c6_wifi_put_text ( const char * text,
size_t len )

Emit a NUL-terminated co-processor string as printable text.

The co-processor supplies the bytes, so nothing about them is trusted: the string is truncated to k_c6_wifi_text_max and every byte outside printable ASCII is replaced with a full stop. A protocol field is evidence, and evidence that can reprogram a terminal is not evidence.

Parameters
[in]textBytes to emit; null prints nothing.
[in]lenNumber of bytes available at text.
Returns
Nothing.
Precondition
The console is up.
len bytes are readable at text.
Postcondition
At most k_c6_wifi_text_max characters were emitted.
No application state is modified.
Note
The loop is bounded by k_c6_wifi_text_max (NASA Rule 2).
See also
c6_wifi_puts
Since
0.1.0

Emit a NUL-terminated co-processor string as printable text.

Definition at line 111 of file c6_wifi_console.c.

References k_c6_wifi_ascii_high, k_c6_wifi_ascii_low, k_c6_wifi_ascii_sub, k_c6_wifi_text_max, and ra8_board_uart_console_write().

Referenced by c6_wifi_on_event(), and c6_wifi_phase_identity().

◆ c6_wifi_put_u32()

void c6_wifi_put_u32 ( uint32_t value)

Emit an unsigned 32-bit value in decimal.

Parameters
[in]valueValue to print; the whole 32-bit range is representable.
Returns
Nothing.
Precondition
The console is up.
The caller wants no padding; zero prints as a single digit.
Postcondition
Between one and k_c6_wifi_dec_digits characters were emitted.
No application state is modified.
Note
Not thread-safe, for the same reason as c6_wifi_puts.
See also
c6_wifi_put_i32
Since
0.1.0

Emit an unsigned 32-bit value in decimal.

Definition at line 65 of file c6_wifi_console.c.

References k_c6_wifi_dec_digits, k_c6_wifi_dec_radix, and ra8_board_uart_console_write().

Referenced by c6_wifi_heartbeat(), c6_wifi_on_event(), c6_wifi_phase_identity(), c6_wifi_print_banner(), c6_wifi_print_stats(), c6_wifi_put_i32(), c6_wifi_report_fault(), and c6_wifi_worker_entry().

◆ c6_wifi_puts()

void c6_wifi_puts ( const char * text)

Write a NUL-terminated string to the board console.

Parameters
[in]textString to emit; null is ignored rather than dereferenced and the length is capped at k_c6_wifi_str_max.
Returns
Nothing.
Precondition
ra8_board_uart_console_init has succeeded.
text is NUL-terminated within k_c6_wifi_str_max bytes.
Postcondition
The bytes are queued on the console transmitter.
No application state is modified.
Note
Not thread-safe; only pre-kernel bring-up and the single worker thread call it, and those never overlap.
See also
c6_wifi_put_u32
Since
0.1.0

Definition at line 52 of file c6_wifi_console.c.

References k_c6_wifi_str_max, and ra8_board_uart_console_write().

Referenced by c6_wifi_heartbeat(), c6_wifi_on_event(), c6_wifi_phase_identity(), c6_wifi_phase_ready(), c6_wifi_phase_station(), c6_wifi_print_banner(), c6_wifi_print_stats(), c6_wifi_put_i32(), c6_wifi_put_mac(), c6_wifi_report_fault(), c6_wifi_worker_entry(), main(), and tx_application_define().