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

Bounded console formatters for the C6 Wi-Fi join application. More...

#include <stddef.h>
#include <stdint.h>
#include "c6_join.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_c6link.h"
Include dependency graph for c6_join_console.c:

Go to the source code of this file.

Functions

void c6_join_puts (const char *text)
 Write a NUL-terminated string to the board console.
void c6_join_put_u32 (uint32_t value)
 Implementation of c6_join_put_u32() – reversed division loop.
void c6_join_put_hex (uint32_t value, uint8_t digits)
 Emit a value as a fixed-width lower-case hexadecimal field.
void c6_join_put_ip (uint32_t ip)
 Implementation of c6_join_put_ip() – four octets, dot-separated.
void c6_join_put_mac (const ra8_c6link_mac_t *mac)
 Emit an IEEE 802 address as six colon-separated hexadecimal octets.
void c6_join_print_banner (uint32_t cpuclk_hz, uint32_t pclka_hz)
 Print the banner: identity, clocks and link parameters.

Detailed Description

Bounded console formatters for the C6 Wi-Fi join application.

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

Small serialisers – string, unsigned decimal, hexadecimal, IPv4 dotted quad and MAC address – plus the banner. They exist so the application can narrate itself without dragging newlib's printf (and its heap) into a bare-metal image that has no heap at all. Every loop here is bounded by a constant from c6_join.h (NASA Power of 10 Rule 2).

Since
0.1.0

Definition in file c6_join_console.c.

Function Documentation

◆ c6_join_print_banner()

void c6_join_print_banner ( uint32_t cpuclk_hz,
uint32_t pclka_hz )

Print the banner: identity, clocks and link parameters.

Emits the application identity followed by measured CPU and peripheral clocks and immutable C6 transport geometry.

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 build (CONFIG_ESP_SPI_MODE=3).
See also
c6_join_puts
Since
0.1.0

Definition at line 104 of file c6_join_console.c.

References c6_join_put_u32(), c6_join_puts(), k_c6_join_sck_hz, k_ra8_board_pmod1_sci_channel, k_ra8_c6link_frame_bytes, and k_ra8_c6link_max_payload.

Referenced by main().

◆ c6_join_put_hex()

void c6_join_put_hex ( uint32_t value,
uint8_t digits )

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

Extracts one nibble per requested digit from most to least significant position and emits a fixed local character buffer.

Parameters
[in]valueValue to print.
[in]digitsField width, 1..k_c6_join_hex_digits; an out-of-range width prints nothing rather than overrunning the array.
Returns
Nothing.
Precondition
The console is up.
digits is within 1..k_c6_join_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_join_put_u32
Since
0.1.0

Definition at line 58 of file c6_join_console.c.

References k_c6_join_hex_alpha, k_c6_join_hex_bits, k_c6_join_hex_digits, k_c6_join_hex_mask, and ra8_board_uart_console_write().

Referenced by c6_join_phase_ready(), and c6_join_put_mac().

◆ c6_join_put_ip()

void c6_join_put_ip ( uint32_t ip)

Implementation of c6_join_put_ip() – four octets, dot-separated.

Emit a packed IPv4 address as a dotted quad.

Definition at line 75 of file c6_join_console.c.

References c6_join_put_u32(), c6_join_puts(), k_c6_join_ip_mask, k_c6_join_ip_octets, k_c6_join_ip_shift_0, k_c6_join_ip_shift_1, k_c6_join_ip_shift_2, and k_c6_join_ip_shift_3.

Referenced by c6_join_phase_ip().

◆ c6_join_put_mac()

void c6_join_put_mac ( const ra8_c6link_mac_t * mac)

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

Walks the fixed address extent in wire order, printing two hex digits per octet and a colon between adjacent 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 91 of file c6_join_console.c.

References c6_join_put_hex(), c6_join_puts(), k_c6_join_hex_byte, k_ra8_c6link_mac_bytes, and ra8_c6link_mac::octet.

Referenced by c6_join_phase_associate().

◆ c6_join_put_u32()

void c6_join_put_u32 ( uint32_t value)

Implementation of c6_join_put_u32() – reversed division loop.

Emit an unsigned 32-bit value in decimal.

Definition at line 40 of file c6_join_console.c.

References k_c6_join_dec_digits, k_c6_join_dec_radix, and ra8_board_uart_console_write().

Referenced by c6_join_phase_associate(), c6_join_phase_ready(), c6_join_print_banner(), c6_join_put_ip(), and c6_join_worker_entry().

◆ c6_join_puts()

void c6_join_puts ( const char * text)

Write a NUL-terminated string to the board console.

Measures at most the fixed string bound and forwards the resulting byte extent to the initialized board-console transmitter.

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

Definition at line 27 of file c6_join_console.c.

References k_c6_join_str_max, and ra8_board_uart_console_write().

Referenced by c6_join_heartbeat(), c6_join_phase_associate(), c6_join_phase_ip(), c6_join_phase_ready(), c6_join_print_banner(), c6_join_put_ip(), c6_join_put_mac(), c6_join_report_fault(), c6_join_worker_entry(), main(), and tx_application_define().