44typedef enum : uint8_t {
49static const char*
s_tag =
"GPIO";
101 if (pfs ==
nullptr) {
110 const uint32_t new_val =
133 if (pfs ==
nullptr) {
141 uint32_t new_val = 0U;
166 if (port_regs ==
nullptr) {
173 const uint32_t bit_mask = (uint32_t)(1UL << (uint32_t)bit);
175 port_regs->
PCNTR3 = bit_mask;
194 if (port_regs ==
nullptr) {
199 const uint32_t pcntr1_val = port_regs->
PCNTR1;
201 const uint32_t bit_mask = (uint32_t)(1UL << (uint32_t)bit);
202 if ((podr & bit_mask) != 0U) {
205 port_regs->
PCNTR3 = bit_mask;
223 if (port_regs ==
nullptr) {
227 const uint32_t pidr = port_regs->
PCNTR2;
228 const uint32_t bit_mask = (uint32_t)(1UL << (uint32_t)bit);
258 if (pfs ==
nullptr) {
299 if (pfs ==
nullptr) {
308 const uint32_t dscr_field =
ra8_err_t ra8_gpio_read(ra8_port_pin_t pin, ra8_level_t *out_level)
Read a previously-configured input.
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_pfs_set_drive_strength(ra8_port_pin_t pin, ra8_pfs_dscr_t dscr)
Set the output drive strength (PmnPFS.DSCR) of an already-routed pin.
ra8_err_t ra8_gpio_toggle(ra8_port_pin_t pin)
Toggle a previously-configured output.
ra8_err_t ra8_gpio_output_init(ra8_port_pin_t pin, ra8_level_t init_level)
Configure a pin as a digital output and drive it to an initial level.
static ra8_err_t internal_pin_if_toggle(void *ctx, ra8_port_pin_t pin)
Internal helper.
static ra8_err_t internal_claim(ra8_port_pin_t pin, ra8_port_t *out_port, ra8_pin_t *out_pin)
Claim the pin in the validator and return the port / pin indices if the claim succeeded.
ra8_gpio_irq_limits_t
Local limits for IRQ attach API.
@ k_ra8_gpio_irq_num_max
External IRQ pins 0..15.
@ k_ra8_gpio_irq_event_base
ELC event for IRQ0.
ra8_err_t ra8_gpio_write(ra8_port_pin_t pin, ra8_level_t level)
Drive a previously-configured output to the given level.
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.
static ra8_err_t internal_pin_if_output_init(void *ctx, ra8_port_pin_t pin, ra8_level_t level)
Internal helper.
static ra8_elc_event_t internal_event_for_irq(uint8_t irq_num)
Internal helper.
static ra8_err_t internal_pin_if_read(void *ctx, ra8_port_pin_t pin, ra8_level_t *out)
Internal helper.
static ra8_err_t internal_pin_if_write(void *ctx, ra8_port_pin_t pin, ra8_level_t level)
Internal helper.
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.
ra8_err_t ra8_pfs_route_peripheral(ra8_port_pin_t pin, ra8_psel_t psel, const char *owner)
Route a pin to a non-IRQ peripheral function via PFS.PSEL.
const ra8_pin_interface_t g_ra8_gpio_pin_interface
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#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.
ra8_elc_event_t
Partial list of ELC events (populate as drivers need them).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_unmapped
Peripheral register block is not mapped in this MCU variant.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_gpio_invalid_pin
GPIO pin index out of range within its port (valid: 0..15).
@ k_ra8_err_gpio_invalid_port
GPIO port index out of range for this MCU.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
PSEL codes for peripheral pin routing on the RA8D2.
ra8_psel_t
Peripheral-function select codes (written to PSEL[4:0]).
Interrupt Control Unit driver (IRQ pins, NMI).
ra8_err_t ra8_icu_configure_irq_pin(uint8_t irq_num, const ra8_icu_irq_cfg_t *cfg)
Programme one IRQCRi register.
ra8_icu_fclksel_t
IRQCRi.FCLKSEL[1:0] digital filter sampling clock (HUM 14.2.12 p 535).
ra8_icu_irqmd_t
IRQCRi.IRQMD[1:0] detection sense values (HUM 14.2.12 p 535).
NVIC + ICU IELSR allocator.
void(* ra8_isr_handler_t)(void *ctx)
Driver-supplied callback invoked on interrupt entry.
ra8_err_t ra8_isr_register(ra8_elc_event_t event, ra8_isr_handler_t handler, void *ctx, uint8_t priority, uint16_t *out_slot)
Allocate an IELSR slot for an ELC event + handler.
ra8_err_t ra8_isr_unregister(ra8_elc_event_t event)
Release a previously-allocated IELSR slot.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
Pin Function Select (PFS) register layout for the Renesas RA8D2.
@ k_ra8_pfs_mask_dscr
bits 11..10.
@ k_ra8_pfs_mask_pmr
RA8 PFS mask pmr.
@ k_ra8_pfs_mask_podr
RA8 PFS mask podr.
@ k_ra8_pfs_mask_pdr
RA8 PFS mask pdr.
@ k_ra8_pfs_mask_pcr
RA8 PFS mask pcr.
@ k_ra8_pfs_bit_psel0
Peripheral select bit 0.
@ k_ra8_pfs_bit_dscr0
Drive strength (low bit).
static void ra8_pfs_pwpr_lock(void)
Re-lock PFS writes.
ra8_pfs_dscr_t
PmnPFS.DSCR[1:0] port drive-capability encodings.
static void ra8_pfs_pwpr_unlock(void)
Unlock PFS writes.
static volatile uint32_t * ra8_pfs_pmn(ra8_port_t port, ra8_pin_t pin)
Get pointer to the PmnPFS register for a single pin.
Abstract pin-driver interface for dependency injection.
Runtime Pin-Ownership Validator.
ra8_err_t ra8_pin_validator_claim(ra8_port_pin_t pin, const char *owner)
Claim a pin for a driver.
ra8_err_t ra8_pin_validator_release(ra8_port_pin_t pin)
Release a pin previously claimed by a driver.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
ra8_port_t
Port indices for the RA8D2 IOPORT module.
@ k_ra8_port_max
Highest valid port index.
@ k_ra8_port_0
RA8 port 0.
ra8_level_t
Digital output / input level.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
ra8_pin_t
Pin indices within an IOPORT port (0..15).
@ k_ra8_pin_max
Highest valid pin index.
#define RA8_PIN_PORT(p)
Extract the port index from a packed ra8_port_pin_t.
ra8_pin_pull_t
Pull-up/pull-down selection (where supported).
@ k_ra8_pull_up
Internal pull-up.
#define RA8_PIN_PIN(p)
Extract the pin index from a packed ra8_port_pin_t.
IOPORT (GPIO) register layout for the Renesas RA8D2.
@ k_ra8_pcntr_high_half_shift
PODR/EIDR/PORR/EORR half.
static volatile r_port_regs_t * ra8_port(ra8_port_t port)
Get the PORT register window for a given port index.
High-level GPIO helpers on top of the PORT + PFS register layer.
Per-port IOPORT register window.
volatile uint32_t PCNTR2
PCNTR2 – { EIDR[31:16], PIDR[15:0] } (read-only).
volatile uint32_t PCNTR3
PCNTR3 – { PORR[31:16], POSR[15:0] } (write-only).
volatile uint32_t PCNTR1
PCNTR1 – { PODR[31:16], PDR[15:0] }.
Configuration descriptor for ra8_gpio_attach_irq.
ra8_icu_irqmd_t sense
Edge / level detection mode.
ra8_icu_fclksel_t filter_div
Digital filter clock divider.
uint8_t priority
NVIC priority 0..15.
ra8_pin_pull_t pull
Input pull setting.
bool filter_en
True -> enable digital filter.
One external-IRQ-pin configuration descriptor.