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

Bounded console formatters for the esp-hosted port bring-up app. More...

#include <stddef.h>
#include <stdint.h>
#include "c6_hosted.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_esp_hosted_pins.h"
Include dependency graph for c6_hosted_console.c:

Go to the source code of this file.

Functions

void c6_hosted_puts (const char *text)
 Write a NUL-terminated string to the board console.
void c6_hosted_put_u32 (uint32_t value)
 Implementation of c6_hosted_put_u32() – reversed division loop.
void c6_hosted_put_i32 (int32_t value)
 Implementation of c6_hosted_put_i32() – two's-complement magnitude.
void c6_hosted_put_hex (uint32_t value, uint8_t digits)
 Emit a value as a fixed-width lower-case hexadecimal field.
void c6_hosted_print_gpio (const char *label, const void *gpio_port, int32_t gpio_pin)
 Print an H_GPIO_*_Port / H_GPIO_*_Pin pair as one field.
void c6_hosted_print_pin (const char *label, ra8_esp_hosted_pin_t pin)
 Implementation of c6_hosted_print_pin() – unpacks, then delegates.

Detailed Description

Bounded console formatters for the esp-hosted port bring-up app.

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

Four tiny serialisers – string, unsigned decimal, signed decimal and hexadecimal – plus the two printers that turn a pin identity into a console field. They exist so the application can narrate itself without dragging newlib's printf (and its heap and reentrancy machinery) into a bare-metal image with no heap at all.

Every loop here is bounded by a constant from c6_hosted.h, which is what satisfies NASA Power of 10 Rule 2. Neither pin printer writes an EK-RA8D2 pin number: both decode whatever the port's pin table and the H_GPIO_* macro pairs resolve to at run time.

Since
0.1.0

Definition in file c6_hosted_console.c.

Function Documentation

◆ c6_hosted_print_gpio()

void c6_hosted_print_gpio ( const char * label,
const void * gpio_port,
int32_t gpio_pin )

Print an H_GPIO_*_Port / H_GPIO_*_Pin pair as one field.

Parameters
[in]labelField name, printed verbatim; null prints nothing.
[in]gpio_portOpaque port handle – an index in pointer clothing, never dereferenced.
[in]gpio_pinPin index, or negative when the signal is unwired.
Returns
Nothing.
Precondition
The console is up.
gpio_port and gpio_pin are the two halves of one macro pair.
Postcondition
One field was emitted, =unwired for a negative pin.
No application state is modified.
Note
This is the encoding the vendored driver itself consumes, so printing it shows what the driver will act on.
See also
c6_hosted_print_pin
Since
0.1.0

Definition at line 90 of file c6_hosted_console.c.

References c6_hosted_put_i32(), c6_hosted_put_u32(), and c6_hosted_puts().

Referenced by c6_hosted_print_pin(), and c6_hosted_print_pin_map().

◆ c6_hosted_print_pin()

void c6_hosted_print_pin ( const char * label,
ra8_esp_hosted_pin_t pin )

Implementation of c6_hosted_print_pin() – unpacks, then delegates.

Print one packed board pin as <label>=port<n>.pin<n>.

Definition at line 104 of file c6_hosted_console.c.

References c6_hosted_print_gpio(), k_ra8_pin_none, pin, RA8_PIN_PIN, and RA8_PIN_PORT.

Referenced by c6_hosted_print_pin_map(), and c6_hosted_print_route().

◆ c6_hosted_put_hex()

void c6_hosted_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_hosted_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_hosted_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_hosted_put_u32
Since
0.1.0

Definition at line 74 of file c6_hosted_console.c.

References k_c6_hosted_hex_alpha, k_c6_hosted_hex_bits, k_c6_hosted_hex_digits, k_c6_hosted_hex_mask, and ra8_board_uart_console_write().

Referenced by c6_hosted_print_rx_header().

◆ c6_hosted_put_i32()

void c6_hosted_put_i32 ( int32_t value)

Implementation of c6_hosted_put_i32() – two's-complement magnitude.

Emit a signed 32-bit value in decimal.

Definition at line 64 of file c6_hosted_console.c.

References c6_hosted_put_u32(), and c6_hosted_puts().

Referenced by c6_hosted_on_event(), c6_hosted_print_gpio(), c6_hosted_read_sideband(), and c6_hosted_run_transaction().

◆ c6_hosted_put_u32()

void c6_hosted_put_u32 ( uint32_t value)

◆ c6_hosted_puts()

void c6_hosted_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_hosted_str_max.
Returns
Nothing.
Precondition
ra8_board_uart_console_init has succeeded.
text is NUL-terminated within k_c6_hosted_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_hosted_put_u32
Since
0.1.0

Definition at line 32 of file c6_hosted_console.c.

References k_c6_hosted_str_max, and ra8_board_uart_console_write().

Referenced by c6_hosted_heartbeat(), c6_hosted_on_event(), c6_hosted_print_banner(), c6_hosted_print_gpio(), c6_hosted_print_pin_map(), c6_hosted_print_route(), c6_hosted_print_rx_header(), c6_hosted_put_i32(), c6_hosted_read_sideband(), c6_hosted_run_transaction(), c6_hosted_worker_entry(), main(), and tx_application_define().