|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Runtime Pin-Ownership Validator. More...
Go to the source code of this file.
Functions | |
| 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. | |
| bool | ra8_pin_validator_is_claimed (ra8_port_pin_t pin) |
| Test whether a pin is currently claimed. | |
| void | ra8_pin_validator_reset (void) |
| Reset the validator (release every pin). | |
Runtime Pin-Ownership Validator.
Centralised bookkeeping that prevents two drivers from accidentally claiming the same physical pin. Every driver that touches IOPORT or PFS (Pin Function Select) must call ra8_pin_validator_claim() before configuring the pin. The call returns k_ra8_err_gpio_conflict if anyone else already owns the pin.
The bitmap is guarded by an IRQ-masked critical section. Safe to call from any context (init, task body, ISR).
Definition in file ra8_pin_validator.h.
|
nodiscard |
Claim a pin for a driver.
| [in] | pin | Packed port/pin identifier. |
| [in] | owner | Short owner tag (e.g. "SCI0", "LED1"). Must point to a static string; the validator stores the pointer, not the contents. |
| k_ra8_ok | Pin successfully claimed. |
| k_ra8_err_gpio_invalid_port | Port out of range (0..14). |
| k_ra8_err_gpio_invalid_pin | Pin out of range within the port. |
| k_ra8_err_gpio_conflict | Pin already claimed by another owner. |
Claim a pin for a driver.
Marks the pin's bit in s_claimed and stores the owner pointer in s_owner.
| [in] | pin | Packed port/pin identifier. |
| [in] | owner | String literal naming the claimer; must be non-NULL. |
| k_ra8_ok | Pin successfully claimed. |
| k_ra8_err_null_ptr | owner was NULL. |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
| k_ra8_err_gpio_conflict | Pin already owned. |
Definition at line 94 of file ra8_pin_validator.c.
References internal_flat_index(), k_ra8_bits_per_byte, k_ra8_err_gpio_conflict, k_ra8_ok, owner, pin, RA8_CHECK_NULL_PTR, ra8_log_error, s_claimed, s_owner, and s_tag.
Referenced by internal_claim(), and ra8_pfs_route_peripheral().
| bool ra8_pin_validator_is_claimed | ( | ra8_port_pin_t | pin | ) |
Test whether a pin is currently claimed.
Reads the bitmap maintained by claim/release. Out-of-range identifiers report false rather than an error.
| [in] | pin | Packed port/pin identifier. |
| true | The pin is currently owned by some driver. |
| false | The pin is free OR the identifier is out of range. |
Test whether a pin is currently claimed.
Out-of-range identifiers quietly report false.
| [in] | pin | Packed port/pin identifier. |
| true | Pin is owned. |
| false | Pin is free OR identifier is invalid. |
Definition at line 174 of file ra8_pin_validator.c.
References internal_flat_index(), k_ra8_bits_per_byte, k_ra8_ok, pin, and s_claimed.
|
nodiscard |
Release a pin previously claimed by a driver.
| [in] | pin | Packed port/pin identifier. |
Release a pin previously claimed by a driver.
Clears the pin's bit in s_claimed and zeroes its owner.
| [in] | pin | Packed port/pin identifier. |
| k_ra8_ok | Pin released (or was already free). |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
Definition at line 138 of file ra8_pin_validator.c.
References internal_flat_index(), k_ra8_bits_per_byte, k_ra8_ok, pin, s_claimed, and s_owner.
Referenced by ra8_gpio_attach_irq(), ra8_gpio_detach_irq(), ra8_gpio_input_init(), ra8_gpio_output_init(), ra8_gpio_release(), and ra8_pfs_route_peripheral().
| void ra8_pin_validator_reset | ( | void | ) |
Reset the validator (release every pin).
Called exactly once during ra8_infrastructure_init(). Clears the claim bitmap and parallel owner-tag array.
Reset the validator (release every pin).
Zeroes the claim bitmap and the owner array.
Definition at line 201 of file ra8_pin_validator.c.
References k_ra8_pin_count, k_ra8_port_count, s_claimed, and s_owner.
Referenced by ra8_infrastructure_init().