|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Library-private surface of the esp-hosted port bring-up. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_err.h"#include "ra8_esp_hosted_port.h"Go to the source code of this file.
Functions | |
| ra8_err_t | priv_ra8_esp_hosted_port_cfg_check (const ra8_esp_hosted_port_cfg_t *cfg) |
| Check a port configuration against its documented contract. | |
| ra8_err_t | priv_ra8_esp_hosted_port_pins_check (void) |
| Check the compiled-in pin map for self-consistency. | |
| ra8_err_t | priv_ra8_esp_hosted_port_pins_check_values (uint16_t chip_select, uint16_t handshake, uint16_t data_ready) |
| Check three candidate pin assignments for self-consistency. | |
| ra8_err_t | priv_ra8_esp_hosted_port_first_error (ra8_err_t first, ra8_err_t next) |
| Keep the first error of a teardown sequence, discarding later ones. | |
Library-private surface of the esp-hosted port bring-up.
ra8_esp_hosted_port.c sequences the slices – RTOS pools, the vtable, the SPI channel, the side-band pins – and unwinds them in the opposite order. The two decisions that are worth testing on their own, configuration validation and pin-map validation, are promoted out of static here so a host test can drive every rejection path without a board.
Nothing outside port/esp-hosted/ and tests/ may include this.
Definition in file ra8_esp_hosted_port_internal.h.
|
nodiscard |
Check a port configuration against its documented contract.
Every field has a reason it cannot be zero: a zero peripheral clock makes the bit-rate divider undefined, a zero bit rate asks the SCI for a rate it cannot produce, a zero poll period arms a ThreadX timer with a zero tick count – which ThreadX rejects – and an out-of-range SCI channel indexes past the peripheral. Rejecting them here, before any hardware is touched, is what lets initialisation fail without having claimed a pin.
| [in] | cfg | Configuration to validate. May be null. |
| k_ra8_ok | Every field is within contract. |
| k_ra8_err_null_ptr | cfg was null. |
| k_ra8_err_invalid_arg | A field was zero or out of range. |
Check a port configuration against its documented contract.
Definition at line 95 of file ra8_esp_hosted_port.c.
References ra8_esp_hosted_port_cfg::edge_poll_ms, k_ra8_err_invalid_arg, k_ra8_esp_hosted_port_sci_channels, k_ra8_ok, ra8_esp_hosted_port_cfg::pclk_hz, RA8_CHECK_NULL_PTR, s_esp_hosted_tag, ra8_esp_hosted_port_cfg::sci_channel, and ra8_esp_hosted_port_cfg::sck_hz.
Referenced by ra8_esp_hosted_port_init().
Keep the first error of a teardown sequence, discarding later ones.
The unwind path runs every release step regardless of what the previous one reported, because a teardown that stops at the first error strands exactly the resource it was meant to release. It therefore needs the "first error wins" fold in one place: given what has been reported so far and what the next step reported, the earlier failure survives and a clean step never overwrites a failure.
| [in] | first | What the sequence has reported so far. |
| [in] | next | What the step just run reported. |
| k_ra8_ok | Both arguments were k_ra8_ok. |
| first | first was already an error, whatever next was. |
| next | first was k_ra8_ok and next was not. |
Keep the first error of a teardown sequence, discarding later ones.
Definition at line 258 of file ra8_esp_hosted_port.c.
References k_ra8_ok.
Referenced by internal_unwind().
|
nodiscard |
Check the compiled-in pin map for self-consistency.
The pin map in ra8_esp_hosted_pins.h is the one file the owner edits when the harness changes, so it is exactly where a copy-and-paste mistake would land. Two properties are worth proving before anything claims a pin: the chip select and the two side-band nets must be three distinct pins, and each must decode to a legal port and pin index. A duplicated assignment would otherwise show up as an unexplained pin-claim conflict deep in bring-up.
The reset pin is deliberately exempt from the distinctness check: it is legitimately k_ra8_pin_none, the harness having no reset wire.
| k_ra8_ok | The map is self-consistent. |
| k_ra8_err_invalid_arg | Two signals share a pin, or a pin decodes to an out-of-range port or pin index. |
Check the compiled-in pin map for self-consistency.
Definition at line 170 of file ra8_esp_hosted_port.c.
References k_ra8_esp_hosted_pin_chip_select, k_ra8_esp_hosted_pin_data_ready, k_ra8_esp_hosted_pin_handshake, and priv_ra8_esp_hosted_port_pins_check_values().
Referenced by ra8_esp_hosted_port_init().
|
nodiscard |
Check three candidate pin assignments for self-consistency.
The body of priv_ra8_esp_hosted_port_pins_check, taking its inputs as parameters so every rejection path can be reached. The shipped map is a set of compile-time constants and therefore exercises exactly one path; without this seam the other paths would be unreachable from a test, which is the same as being unverified.
| [in] | chip_select | Packed chip-select pin code. |
| [in] | handshake | Packed HANDSHAKE pin code. |
| [in] | data_ready | Packed DATA_READY pin code. |
| k_ra8_ok | The three are distinct and each decodes legally. |
| k_ra8_err_invalid_arg | Two share a pin, or one decodes to an out-of-range port or pin index. |
Check three candidate pin assignments for self-consistency.
Definition at line 148 of file ra8_esp_hosted_port.c.
References internal_pin_in_range(), k_ra8_err_invalid_arg, and k_ra8_ok.
Referenced by priv_ra8_esp_hosted_port_pins_check().