31#include "esp_hosted_power_save.h"
55static const char*
const s_tag =
"eh_gpio";
73typedef enum : uint32_t {
92typedef enum : uint32_t {
112typedef enum : uint32_t {
132typedef enum : uint8_t {
138 "input mode selector must match the vendored spelling");
140 "output mode selector must match the vendored spelling");
142 "pull-up selector must match the vendored spelling");
144 "pull-down selector must match the vendored spelling");
146 "HANDSHAKE edge selector must be a legal ICU sense");
148 "DATA_READY edge selector must be a legal ICU sense");
216 if (out_pin ==
nullptr) {
219 const uintptr_t port_idx = (uintptr_t)gpio_port;
224 *out_pin =
RA8_PIN((uint16_t)port_idx, (uint16_t)gpio_num);
373 void (*handler)(
void*),
484 void (*gpio_isr_handler)(
void* arg),
491 if (gpio_isr_handler ==
nullptr) {
502 const uint8_t sense = (uint8_t)intr_type;
732 ra8_log_warn(
s_tag,
"pin hold unavailable: no per-pin retention control in ra8_hal");
768 return (
int)HOSTED_WAKEUP_UNDEFINED;
771 return (
int)HOSTED_WAKEUP_DEEP_SLEEP;
773 return (
int)HOSTED_WAKEUP_NORMAL_REBOOT;
const ra8_pin_interface_t g_ra8_gpio_pin_interface
esp-hosted port header: transport selection, side-band pin map, link polarity.
#define H_DR_INTR_EDGE
Interrupt sense the port programs for the DATA_READY input.
#define H_HS_INTR_EDGE
Interrupt sense the port programs for the HANDSHAKE input.
#define H_RESET_VAL_INACTIVE
Level that releases the co-processor from reset.
esp-hosted port header: RTOS handle types, return codes and budgets.
#define H_GPIO_PULL_DOWN
Select the internal pull-down when configuring a pin.
#define H_GPIO_MODE_DEF_INPUT
Configure a side-band pin as a digital input.
#define H_GPIO_MODE_DEF_OUTPUT
Configure a side-band pin as a push-pull digital output.
#define RET_FAIL
Operation failed for an unspecified reason.
#define RET_INVALID
A parameter was out of contract (null handle, bad size).
#define RET_OK
Operation completed.
#define H_GPIO_PULL_UP
Select the internal pull-up when configuring a pin.
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
ra8_board_eth_pin_t pin
Pin.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_esp_hosted_gpio_read_t
Values _h_read_gpio returns for a successful read.
@ k_ra8_esp_hosted_gpio_read_high
Pin read high.
@ k_ra8_esp_hosted_gpio_read_low
Pin read low.
static const ra8_pin_interface_t * s_pin_if
The pin driver every level read and write goes through.
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.
static int internal_wakeup_reason(void)
_h_get_host_wakeup_or_reboot_reason: why the host last started.
static int internal_write_gpio(void *gpio_port, uint32_t gpio_num, uint32_t value)
_h_write_gpio: drive a side-band output.
static int internal_hold_gpio(void *gpio_port, uint32_t gpio_num, uint32_t hold_value)
_h_hold_gpio: freeze a pin's state across deep sleep.
static int internal_config_gpio(void *gpio_port, uint32_t gpio_num, uint32_t mode)
_h_config_gpio: put a side-band pin in a plain digital mode.
static uint8_t internal_irq_alloc(void)
Take the first free interrupt row.
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.
static ra8_err_t internal_attach_hardware(ra8_port_pin_t pin, uint8_t irq_num, uint8_t sense, void(*handler)(void *), void *arg)
Attach a pin to a real ICU external-interrupt channel.
ra8_err_t priv_ra8_esp_hosted_gpio_bind(hosted_osi_funcs_t *out)
Populate the eight GPIO slots of the OS-abstraction vtable.
static void internal_isr_trampoline(void *ctx)
ICU handler shim that calls the vendored side-band callback.
const ra8_pin_interface_t * priv_ra8_esp_hosted_gpio_pin_interface(void)
Report the pin driver currently installed in the slice.
ra8_esp_hosted_gpio_mode_t
Pin directions _h_config_gpio accepts.
@ k_ra8_esp_hosted_gpio_mode_input
Digital input.
@ k_ra8_esp_hosted_gpio_mode_output
Push-pull digital output.
struct ra8_esp_hosted_gpio_irq_row ra8_esp_hosted_gpio_irq_row_t
ra8_esp_hosted_gpio_pull_t
Pull selectors _h_pull_gpio accepts.
@ k_ra8_esp_hosted_gpio_pull_up
Internal pull-up.
@ k_ra8_esp_hosted_gpio_pull_down
Internal pull-down (no silicon).
static ra8_esp_hosted_gpio_irq_row_t s_irq_rows[k_ra8_esp_hosted_gpio_row_max]
Pins currently attached to an ICU external-interrupt channel.
static int internal_config_gpio_as_interrupt(void *gpio_port, uint32_t gpio_num, uint32_t intr_type, void(*gpio_isr_handler)(void *arg), void *arg)
_h_config_gpio_as_interrupt: watch a side-band pin for an edge.
ra8_esp_hosted_gpio_sentinel_t
The "signal is not wired" pin value as it arrives at a slot.
@ k_ra8_esp_hosted_gpio_pin_unwired
-1 widened to 32 bits.
static int internal_read_gpio(void *gpio_port, uint32_t gpio_num)
_h_read_gpio: sample the raw logic level of a side-band pin.
static int internal_teardown_gpio_interrupt(void *gpio_port, uint32_t gpio_num)
_h_teardown_gpio_interrupt: stop watching a side-band pin.
static uint8_t internal_irq_find(ra8_port_pin_t pin)
Find the interrupt row watching a pin.
static int internal_pull_gpio(void *gpio_port, uint32_t gpio_num, uint32_t pull_value, uint32_t enable)
_h_pull_gpio: enable or disable an internal pull on a pin.
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.
Module-private surface of the esp-hosted side-band GPIO slice.
@ k_ra8_esp_hosted_gpio_row_max
Rows in the polled edge table; also the registration ceiling.
@ k_ra8_esp_hosted_gpio_irq_priority
NVIC priority given to a hardware side-band edge.
THE single point of change for the RA8 <-> ESP32-C6 harness map.
@ k_ra8_esp_hosted_irq_none
No ICU channel routes this pin.
uint8_t ra8_esp_hosted_pin_irq_num(ra8_port_pin_t pin)
Report the ICU external-interrupt channel that serves a pin.
Interrupt Control Unit (ICU) register layout for the Renesas RA8D2.
@ k_ra8_icu_fclksel_pclkb
00: sample every PCLKB cycle.
ra8_icu_irqmd_t
IRQCRi.IRQMD[1:0] detection sense values (HUM 14.2.12 p 535).
@ k_ra8_icu_irqmd_low
11: low-level sensitive.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_warn(tag, message)
RA8 log warn.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
Abstract pin-driver interface for dependency injection.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_pin_none
Sentinel: no pin selected.
@ k_ra8_port_max
Highest valid port index.
#define RA8_PIN(port, pin)
Build a ra8_port_pin_t from explicit port / pin indices.
ra8_level_t
Digital output / input level.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
@ k_ra8_pin_max
Highest valid pin index.
ra8_pin_pull_t
Pull-up/pull-down selection (where supported).
@ k_ra8_pull_none
No internal pull.
@ k_ra8_pull_up
Internal pull-up.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_gpio_input_init(ra8_port_pin_t pin, ra8_pin_pull_t pull)
Configure a pin as a digital input.
ra8_err_t ra8_gpio_detach_irq(ra8_port_pin_t pin, uint8_t irq_num)
Tear down a previously attached external IRQ.
ra8_err_t ra8_gpio_release(ra8_port_pin_t pin)
Release a GPIO pin claim.
ra8_err_t ra8_gpio_attach_irq(ra8_port_pin_t pin, uint8_t irq_num, const ra8_gpio_irq_cfg_t *cfg, ra8_isr_handler_t handler, void *ctx)
Wire a pin as an external IRQ input and install a handler.
Reset cause introspection + software reset trigger.
ra8_err_t ra8_reset_get_cause(ra8_reset_cause_t *out)
Decode the latched RSTSRn flags into a single primary cause.
ra8_reset_cause_t
Decoded reset-cause taxonomy.
@ k_ra8_reset_cause_deep_sw_standby
RSTSR0.DPSRSTF.
@ k_ra8_reset_cause_unknown
No flag latched.
One pin served by a real ICU external-interrupt channel.
ra8_port_pin_t pin
Packed pin the channel watches.
uint8_t irq_num
ICU external-interrupt channel, 0..15.
bool used
True while the row is occupied.
void(* handler)(void *arg)
Vendored callback to invoke.
void * arg
Opaque argument for handler.
Configuration descriptor for ra8_gpio_attach_irq.
ra8_err_t(* output_init)(void *ctx, ra8_port_pin_t pin, ra8_level_t init_level)
Configure a pin as an output at an initial level.
void * ctx
Opaque context handed to every call.
ra8_err_t(* write)(void *ctx, ra8_port_pin_t pin, ra8_level_t level)
Drive a pin.
ra8_err_t(* read)(void *ctx, ra8_port_pin_t pin, ra8_level_t *out_level)
Read a pin.