|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Shared contract for the esp-hosted port bring-up application. More...
#include <stddef.h>#include <stdint.h>#include "esp_hosted_header.h"#include "port_esp_hosted_host_spi.h"#include "ra8_esp_hosted_pins.h"Go to the source code of this file.
Data Structures | |
| union | c6_hosted_frame |
| One esp-hosted transaction buffer, addressable either way. More... | |
Typedefs | |
| typedef union c6_hosted_frame | c6_hosted_frame_t |
Enumerations | |
| enum | c6_hosted_cfg_t : uint32_t { k_c6_hosted_uart_baud = 115200U , k_c6_hosted_sck_hz = 5000000U , k_c6_hosted_edge_poll_ms = 2U , k_c6_hosted_heartbeat_ms = 2000U , k_c6_hosted_boot_wait_ms = 200U , k_c6_hosted_dma_align = 64U , k_c6_hosted_worker_stack = 4096U , k_c6_hosted_worker_prio = 8U } |
| Link and storage parameters this application chooses. More... | |
| enum | c6_hosted_fmt_t : uint16_t { k_c6_hosted_str_max = 256U , k_c6_hosted_dec_radix = 10U , k_c6_hosted_dec_digits = 10U , k_c6_hosted_hex_digits = 8U , k_c6_hosted_hex_bits = 4U , k_c6_hosted_hex_mask = 0x0FU , k_c6_hosted_hex_alpha = 10U , k_c6_hosted_hex_byte = 2U , k_c6_hosted_hex_csum = 4U } |
| Bounds for the console formatters in src/c6_hosted_console.c. More... | |
| enum | c6_hosted_link_t : uint16_t { k_c6_hosted_frame_bytes = (uint16_t)MAX_TRANSPORT_BUFFER_SIZE } |
| Frame geometry both ends of the link must agree on. More... | |
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) |
| Emit an unsigned 32-bit value in decimal. | |
| void | c6_hosted_put_i32 (int32_t value) |
| Emit a signed 32-bit value in decimal. | |
| 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) |
| Print one packed board pin as <label>=port<n>.pin<n>. | |
| void | c6_hosted_print_banner (uint32_t cpuclk_hz, uint32_t pclka_hz) |
| Print the port identity, the clocks and the SPI parameters. | |
| void | c6_hosted_print_pin_map (void) |
| Print the resolved pin map, bus pins and side-band alike. | |
| void | c6_hosted_report_sideband (void) |
| Sample both side-band lines through the vtable and report them. | |
| void | c6_hosted_on_event (void *ctx, const char *base, int32_t event_id, const void *data, size_t data_len) |
| Report an event the port delivered from the vendored core. | |
| uint32_t | c6_hosted_event_count (void) |
| Report how many events c6_hosted_on_event has seen. | |
| void | c6_hosted_run_transaction (void) |
| Clock one full-duplex transaction and report the verdict. | |
Shared contract for the esp-hosted port bring-up application.
The application is split into one module per concern, all driven by main.c:
Every parameter an application owns is stated once here. Pin identity is a board fact and lives in port/esp-hosted/inc/ra8_esp_hosted_pins.h; protocol sizes are read from the vendored esp-hosted headers, never restated. The frame type below is the one place the two meet: it is declared here because both the transaction buffers and the decode need it.
Definition in file c6_hosted.h.
| typedef union c6_hosted_frame c6_hosted_frame_t |
| enum c6_hosted_cfg_t : uint32_t |
Link and storage 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 transaction-buffer alignment and the worker stack are sized here as well as the link timing.
Definition at line 59 of file c6_hosted.h.
| enum c6_hosted_fmt_t : uint16_t |
Bounds for the console formatters in src/c6_hosted_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.
Definition at line 87 of file c6_hosted.h.
| enum c6_hosted_link_t : uint16_t |
Frame geometry both ends of the link must agree on.
Derived from the vendored transport header rather than restated, so an upstream change to the transaction size moves this application with it instead of leaving a stale literal behind.
| Enumerator | |
|---|---|
| k_c6_hosted_frame_bytes | Bytes clocked in one full-duplex transaction. |
Definition at line 118 of file c6_hosted.h.
| uint32_t c6_hosted_event_count | ( | void | ) |
Report how many events c6_hosted_on_event has seen.
| 0 | The co-processor has never announced anything. |
Definition at line 182 of file c6_hosted_report.c.
References s_c6_hosted_events.
Referenced by c6_hosted_heartbeat().
| void c6_hosted_on_event | ( | void * | ctx, |
| const char * | base, | ||
| int32_t | event_id, | ||
| const void * | data, | ||
| size_t | data_len ) |
Report an event the port delivered from the vendored core.
| [in] | ctx | Registered context; unused, the counter is file-scope. |
| [in] | base | Event namespace; never null per the port contract. |
| [in] | event_id | Identifier within that namespace. |
| [in] | data | Payload, or null; not decoded here. |
| [in] | data_len | Payload length in bytes. |
Definition at line 164 of file c6_hosted_report.c.
References c6_hosted_put_i32(), c6_hosted_put_u32(), c6_hosted_puts(), and s_c6_hosted_events.
Referenced by tx_application_define().
| void c6_hosted_print_banner | ( | uint32_t | cpuclk_hz, |
| uint32_t | pclka_hz ) |
Print the port identity, the clocks and the SPI parameters.
| [in] | cpuclk_hz | Live CPUCLK0 rate in hertz. |
| [in] | pclka_hz | Live PCLKA rate in hertz, the SCI baud-clock source. |
Definition at line 118 of file c6_hosted_report.c.
References c6_hosted_put_u32(), c6_hosted_puts(), k_c6_hosted_sck_hz, k_ra8_board_pmod1_sci_channel, and k_ra8_spi_mode_3.
Referenced by main().
| 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.
| [in] | label | Field name, printed verbatim; null prints nothing. |
| [in] | gpio_port | Opaque port handle – an index in pointer clothing, never dereferenced. |
| [in] | gpio_pin | Pin index, or negative when the signal is unwired. |
gpio_port and gpio_pin are the two halves of one macro pair. 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().
| void c6_hosted_print_pin | ( | const char * | label, |
| ra8_esp_hosted_pin_t | pin ) |
Print one packed board pin as <label>=port<n>.pin<n>.
| [in] | label | Field name, printed verbatim; null prints nothing. |
| [in] | pin | Packed pin from ra8_esp_hosted_pins.h, possibly the k_ra8_pin_none sentinel. |
pin came from the port's pin table, never from a literal. 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().
| void c6_hosted_print_pin_map | ( | void | ) |
Print the resolved pin map, bus pins and side-band alike.
Definition at line 136 of file c6_hosted_report.c.
References c6_hosted_print_gpio(), c6_hosted_print_pin(), c6_hosted_print_route(), c6_hosted_puts(), H_GPIO_DATA_READY_Pin, H_GPIO_DATA_READY_Port, H_GPIO_HANDSHAKE_Pin, H_GPIO_HANDSHAKE_Port, H_GPIO_PIN_RESET, H_GPIO_PORT_RESET, k_ra8_esp_hosted_pin_chip_select, k_ra8_esp_hosted_pin_cipo, k_ra8_esp_hosted_pin_copi, k_ra8_esp_hosted_pin_data_ready, k_ra8_esp_hosted_pin_handshake, and k_ra8_esp_hosted_pin_sck.
Referenced by main().
| void c6_hosted_put_hex | ( | uint32_t | value, |
| uint8_t | digits ) |
Emit a value as a fixed-width lower-case hexadecimal field.
| [in] | value | Value to print. |
| [in] | digits | Field width, 1..k_c6_hosted_hex_digits; an out-of-range width prints nothing rather than overrunning the output array. |
digits is within 1..k_c6_hosted_hex_digits. digits characters were emitted, or none on a bad width. digits (NASA Rule 2). 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().
| void c6_hosted_put_i32 | ( | int32_t | value | ) |
Emit a signed 32-bit value in decimal.
| [in] | value | Value to print, including INT32_MIN. |
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().
| void c6_hosted_put_u32 | ( | uint32_t | value | ) |
Emit an unsigned 32-bit value in decimal.
| [in] | value | Value to print; the whole 32-bit range is representable. |
Emit an unsigned 32-bit value in decimal.
Definition at line 45 of file c6_hosted_console.c.
References k_c6_hosted_dec_digits, k_c6_hosted_dec_radix, 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_route(), c6_hosted_print_rx_header(), c6_hosted_put_i32(), and c6_hosted_run_transaction().
| void c6_hosted_puts | ( | const char * | text | ) |
Write a NUL-terminated string to the board console.
| [in] | text | String to emit; null is ignored rather than dereferenced and the length is capped at k_c6_hosted_str_max. |
text is NUL-terminated within k_c6_hosted_str_max bytes. 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().
| void c6_hosted_report_sideband | ( | void | ) |
Sample both side-band lines through the vtable and report them.
Definition at line 152 of file c6_hosted_report.c.
References c6_hosted_read_sideband(), H_DR_VAL_ACTIVE, H_GPIO_DATA_READY_Pin, H_GPIO_DATA_READY_Port, H_GPIO_HANDSHAKE_Pin, H_GPIO_HANDSHAKE_Port, and H_HS_VAL_ACTIVE.
Referenced by c6_hosted_heartbeat(), and c6_hosted_worker_entry().
| void c6_hosted_run_transaction | ( | void | ) |
Clock one full-duplex transaction and report the verdict.
Definition at line 373 of file c6_hosted_frame.c.
References c6_hosted_build_idle_frame(), c6_hosted_classify(), c6_hosted_print_rx_header(), c6_hosted_put_i32(), c6_hosted_put_u32(), c6_hosted_puts(), c6_hosted_rx_checksum(), c6_hosted_verdict_text(), g_h, k_c6_hosted_frame_bytes, k_c6_hosted_verdict_idle, k_c6_hosted_verdict_pass, s_c6_hosted_rx, and s_c6_hosted_tx.
Referenced by c6_hosted_worker_entry().