|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Module-private surface of the esp-hosted side-band GPIO slice. More...
#include <stdint.h>#include "esp_hosted_os_abstraction.h"#include "ra8_attributes.h"#include "ra8_err.h"#include "ra8_pin_interface.h"#include "ra8_port_constants.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_esp_hosted_gpio_limits_t : uint8_t { k_ra8_esp_hosted_gpio_row_max = 4U , k_ra8_esp_hosted_gpio_poll_ms_default = 2U , k_ra8_esp_hosted_gpio_irq_priority = 6U } |
| Fixed bounds of the side-band GPIO slice. More... | |
Functions | |
| ra8_err_t | priv_ra8_esp_hosted_gpio_bind (hosted_osi_funcs_t *out) |
| Populate the eight GPIO slots of the OS-abstraction vtable. | |
| bool | priv_ra8_esp_hosted_gpio_decode_pin (const void *gpio_port, uint32_t gpio_num, ra8_port_pin_t *out_pin) |
| Decode the vendored (void* port, uint32_t pin) pair into a pin. | |
| void | priv_ra8_esp_hosted_gpio_set_pin_interface (const ra8_pin_interface_t *iface) |
| Replace the pin driver the slice reads and writes levels through. | |
| const ra8_pin_interface_t * | priv_ra8_esp_hosted_gpio_pin_interface (void) |
| Report the pin driver currently installed in the slice. | |
| ra8_err_t | priv_ra8_esp_hosted_gpio_set_edge_poll_ms (uint16_t period_ms) |
| Set the sampling period the software edge detector runs at. | |
| ra8_err_t | priv_ra8_esp_hosted_gpio_edge_register (ra8_port_pin_t pin, uint8_t sense, void(*handler)(void *), void *arg) |
| Take a pin under software edge detection. | |
| ra8_err_t | priv_ra8_esp_hosted_gpio_edge_unregister (ra8_port_pin_t pin) |
| Drop a pin from software edge detection. | |
| uint8_t | priv_ra8_esp_hosted_gpio_edge_count (void) |
| Report how many pins are under software edge detection. | |
| void | priv_ra8_esp_hosted_gpio_edge_poll_once (void) |
| Sample every polled row once and dispatch the edges seen. | |
| bool | priv_ra8_esp_hosted_gpio_edge_seen (uint8_t prev_level, uint8_t now_level, uint8_t sense) |
| Decide whether two consecutive samples show the configured edge. | |
Module-private surface of the esp-hosted side-band GPIO slice.
The vendored esp-hosted core reaches every side-band pin through eight slots of hosted_osi_funcs_t. ra8_esp_hosted_gpio.c fills those slots; ra8_esp_hosted_gpio_edge.c owns the software edge detector the slots fall back on. This header is the seam between those two translation units and the tests, and nothing outside port/esp-hosted/ may include it.
Definition in file ra8_esp_hosted_gpio_internal.h.
| enum ra8_esp_hosted_gpio_limits_t : uint8_t |
Fixed bounds of the side-band GPIO slice.
The link uses four side-band nets at most – chip select, HANDSHAKE, DATA_READY and the co-processor reset – and only the ones configured as interrupts take a table row, so four rows can never be exhausted by the vendored driver. The bound is stated anyway because a registration that cannot be recorded must fail loudly rather than be silently dropped.
| Enumerator | |
|---|---|
| k_ra8_esp_hosted_gpio_row_max | Rows in the polled edge table; also the registration ceiling. |
| k_ra8_esp_hosted_gpio_poll_ms_default | Sampling period used until priv_ra8_esp_hosted_gpio_set_edge_poll_ms runs. |
| k_ra8_esp_hosted_gpio_irq_priority | NVIC priority given to a hardware side-band edge. |
Definition at line 64 of file ra8_esp_hosted_gpio_internal.h.
|
nodiscard |
Populate the eight GPIO slots of the OS-abstraction vtable.
Writes _h_config_gpio, _h_config_gpio_as_interrupt, _h_teardown_gpio_interrupt, _h_read_gpio, _h_write_gpio, _h_pull_gpio, _h_hold_gpio and _h_get_host_wakeup_or_reboot_reason into out. No other slot is touched, so the RTOS and transport slices may fill theirs before or after this call in any order.
| [out] | out | Vtable to populate; must be non-null. Only the eight GPIO rows are written. |
| k_ra8_ok | The eight rows are populated. |
| k_ra8_err_null_ptr | out was null. |
out points at storage that out-lives the vendored core. out are non-null. out is modified.Definition at line 776 of file ra8_esp_hosted_gpio.c.
References internal_config_gpio(), internal_config_gpio_as_interrupt(), internal_hold_gpio(), internal_pull_gpio(), internal_read_gpio(), internal_teardown_gpio_interrupt(), internal_wakeup_reason(), internal_write_gpio(), k_ra8_err_invalid_state, k_ra8_ok, RA8_CHECK_NULL_PTR, RA8_PRIV, and s_tag.
Referenced by priv_ra8_esp_hosted_osi_bind_all().
|
nodiscard |
Decode the vendored (void* port, uint32_t pin) pair into a pin.
Exact inverse of RA8_ESP_HOSTED_GPIO_PORT / RA8_ESP_HOSTED_GPIO_PIN in port_esp_hosted_host_config.h: the port half is an index carried inside a pointer, so port 0 arrives as a null pointer and must NOT be null-checked – the decoded index is range-checked instead. The pin half arrives as uint32_t, so the vendored -1 "not wired" spelling arrives as 0xFFFFFFFF; that value is rejected explicitly rather than only by the range test, because it is a distinct fact about the harness.
| [in] | gpio_port | Port index in pointer clothing. Never dereferenced. |
| [in] | gpio_num | Pin index within the port, or 0xFFFFFFFF for a signal this harness does not wire. |
| [out] | out_pin | Receives the packed RA8_PIN(port, pin) value. Untouched on any rejection. |
| true | *out_pin holds the packed pin. |
| false | out_pin was null, the signal is unwired, or an index was out of range. |
out_pin is writable when non-null. gpio_port was produced by RA8_ESP_HOSTED_GPIO_PORT. Definition at line 212 of file ra8_esp_hosted_gpio.c.
References k_ra8_esp_hosted_gpio_pin_unwired, k_ra8_pin_max, k_ra8_port_max, RA8_PIN, and RA8_PRIV.
Referenced by internal_config_gpio(), internal_config_gpio_as_interrupt(), internal_hold_gpio(), internal_pull_gpio(), internal_read_gpio(), internal_teardown_gpio_interrupt(), and internal_write_gpio().
|
nodiscard |
Report how many pins are under software edge detection.
Reads the table occupancy. Exists so the port and the tests can assert the detector's state – in particular that teardown emptied it – without reaching into the module's storage.
| 0 | No pin is polled; the periodic timer is not running. |
Definition at line 381 of file ra8_esp_hosted_gpio_edge.c.
References k_ra8_esp_hosted_gpio_edge_one_row, k_ra8_esp_hosted_gpio_row_max, RA8_PRIV, and s_rows.
Referenced by priv_ra8_esp_hosted_gpio_edge_unregister().
| void priv_ra8_esp_hosted_gpio_edge_poll_once | ( | void | ) |
Sample every polled row once and dispatch the edges seen.
The body of the periodic timer, exposed so tests drive it directly rather than waiting on a kernel tick. For each occupied row it reads the pin through the injected pin interface, asks priv_ra8_esp_hosted_gpio_edge_seen whether the configured edge occurred, stores the new level and, when it did, calls the row's handler. A read that fails leaves the stored level untouched so a transient failure cannot manufacture an edge on the next pass.
Definition at line 467 of file ra8_esp_hosted_gpio_edge.c.
References ra8_esp_hosted_gpio_edge_row::arg, ra8_esp_hosted_gpio_edge_row::handler, internal_sample(), k_ra8_esp_hosted_gpio_edge_low, k_ra8_esp_hosted_gpio_row_max, ra8_esp_hosted_gpio_edge_row::last_level, ra8_esp_hosted_gpio_edge_row::pin, priv_ra8_esp_hosted_gpio_edge_seen(), RA8_PRIV, s_rows, ra8_esp_hosted_gpio_edge_row::sense, and ra8_esp_hosted_gpio_edge_row::used.
Referenced by internal_timer_expiry().
|
nodiscard |
Take a pin under software edge detection.
Configures the pin as an input, records the level it starts at so the first sample cannot report a phantom edge, and arms the shared periodic timer if this is the first row. The row stores the vendored callback and its argument verbatim, so a polled pin and an ICU-served pin deliver identical calls.
| [in] | pin | Packed pin to watch; must be a legal RA8 pin. |
| [in] | sense | Edge selector using the ra8_icu_irqmd_t encoding: 0 falling, 1 rising, 2 both, 3 low level. |
| [in] | handler | Callback invoked on a detected edge; must be non-null and must not block. |
| [in] | arg | Opaque argument handed back to handler. |
| k_ra8_ok | The pin is being sampled. |
| k_ra8_err_null_ptr | handler was null. |
| k_ra8_err_invalid_arg | sense was outside 0..3. |
| k_ra8_err_exists | The pin already has a row. |
| k_ra8_err_no_mem | The table is full. |
| k_ra8_err_rtos_error | The periodic timer would not arm. |
| k_ra8_err_gpio_conflict | The pin is owned by another module. |
handler tolerates being called from timer context. Definition at line 405 of file ra8_esp_hosted_gpio_edge.c.
References internal_find(), internal_sample(), internal_timer_arm(), k_ra8_err_exists, k_ra8_err_invalid_arg, k_ra8_err_no_mem, k_ra8_err_null_ptr, k_ra8_esp_hosted_gpio_edge_low, k_ra8_esp_hosted_gpio_row_max, k_ra8_icu_irqmd_low, k_ra8_ok, k_ra8_pull_none, pin, ra8_gpio_input_init(), ra8_gpio_release(), ra8_log_error_val, RA8_PRIV, s_rows, and s_tag.
Referenced by internal_config_gpio_as_interrupt().
|
nodiscard |
Decide whether two consecutive samples show the configured edge.
The whole decision logic of the software edge detector, kept pure so it can be driven exhaustively without hardware. Edge senses compare the two samples; the low-level sense is not an edge at all and reports on the current sample alone, which matches what the ICU does with k_ra8_icu_irqmd_low.
| [in] | prev_level | Level recorded by the previous sample: 0 or 1. |
| [in] | now_level | Level just read: 0 or 1. |
| [in] | sense | Selector using the ra8_icu_irqmd_t encoding: 0 falling, 1 rising, 2 both, 3 low level. |
| true | The handler should run. |
| false | No event, or sense was outside 0..3. |
prev_level and now_level are 0 or 1. sense uses the ICU encoding, not the vendored polarity flags. Definition at line 182 of file ra8_esp_hosted_gpio_edge.c.
References k_ra8_esp_hosted_gpio_edge_high, k_ra8_esp_hosted_gpio_edge_low, k_ra8_icu_irqmd_both, k_ra8_icu_irqmd_low, and k_ra8_icu_irqmd_rising.
Referenced by priv_ra8_esp_hosted_gpio_edge_poll_once().
|
nodiscard |
Drop a pin from software edge detection.
Frees the row, releases the pin claim and, when the last row goes, deletes the shared periodic timer so a torn-down port leaves no kernel object running.
| [in] | pin | Packed pin previously passed to priv_ra8_esp_hosted_gpio_edge_register. |
| k_ra8_ok | The row was freed. |
| k_ra8_err_not_found | The pin had no row. |
| k_ra8_err_rtos_error | The timer would not stop. |
Definition at line 453 of file ra8_esp_hosted_gpio_edge.c.
References internal_find(), internal_timer_disarm(), k_ra8_err_not_found, k_ra8_esp_hosted_gpio_row_max, k_ra8_ok, pin, priv_ra8_esp_hosted_gpio_edge_count(), ra8_gpio_release(), RA8_PRIV, and s_rows.
Referenced by internal_teardown_gpio_interrupt().
|
nodiscard |
Report the pin driver currently installed in the slice.
Exists so the edge detector, which lives in its own translation unit, can sample levels through exactly the interface the slots write through. It never returns null: an unset seam reads back as the production instance.
| non-null | Always; the production instance when nothing was injected. |
Definition at line 233 of file ra8_esp_hosted_gpio.c.
References g_ra8_gpio_pin_interface, RA8_PRIV, and s_pin_if.
Referenced by internal_config_gpio(), internal_read_gpio(), internal_sample(), and internal_write_gpio().
|
nodiscard |
Set the sampling period the software edge detector runs at.
Applies to the single periodic ThreadX timer shared by every polled row. Changing it while rows are registered re-arms the timer, so the new period takes effect from the next expiry. The port passes ra8_esp_hosted_port_cfg_t::edge_poll_ms here during bring-up.
| [in] | period_ms | Sampling period in milliseconds; must be non-zero, because ThreadX rejects a zero-tick timer. |
| k_ra8_ok | The period was accepted. |
| k_ra8_err_invalid_arg | period_ms was zero. |
| k_ra8_err_rtos_error | The timer could not be re-armed. |
period_ms is small enough that an edge cannot be missed; the C6 holds DATA_READY asserted until the frame is taken, so any period shorter than a transaction is safe. period_ms. Definition at line 392 of file ra8_esp_hosted_gpio_edge.c.
References internal_timer_arm(), internal_timer_disarm(), k_ra8_err_invalid_arg, k_ra8_ok, RA8_PRIV, s_poll_ms, and s_timer_live.
Referenced by internal_bring_up().
| void priv_ra8_esp_hosted_gpio_set_pin_interface | ( | const ra8_pin_interface_t * | iface | ) |
Replace the pin driver the slice reads and writes levels through.
Dependency-injection seam. Production leaves it at g_ra8_gpio_pin_interface; host tests point it at a recorder so pin levels can be driven without hardware. The interface covers output_init, write, read and toggle only, so input configuration, pin release and interrupt attachment still call the HAL directly – those have no row in ra8_pin_interface_t.
| [in] | iface | Replacement interface, or null to restore the production instance. Must out-live every later slot call. |
iface, when non-null, has non-null write and read rows. iface. Definition at line 228 of file ra8_esp_hosted_gpio.c.