|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Runtime pin-ownership bitmap implementation. More...
#include "ra8_pin_validator.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_bit_constants.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_log.h"#include "ra8_port_constants.h"Go to the source code of this file.
Functions | |
| static ra8_err_t | internal_flat_index (ra8_port_pin_t pin, uint16_t *out_index) |
| ra8_err_t | ra8_pin_validator_claim (ra8_port_pin_t pin, const char *owner) |
| Implementation of ra8_pin_validator_claim(). | |
| ra8_err_t | ra8_pin_validator_release (ra8_port_pin_t pin) |
| Implementation of ra8_pin_validator_release(). | |
| bool | ra8_pin_validator_is_claimed (ra8_port_pin_t pin) |
| Implementation of ra8_pin_validator_is_claimed(). | |
| void | ra8_pin_validator_reset (void) |
| Implementation of ra8_pin_validator_reset(). | |
Variables | |
| static const char * | s_tag = "PINVAL" |
| static uint8_t | s_claimed [((uint16_t) k_ra8_port_count *(uint16_t) k_ra8_pin_count)/(uint16_t) k_ra8_bits_per_byte] |
| Bitmap of claimed pins (1 bit per port/pin). | |
| static const char * | s_owner [(uint16_t) k_ra8_port_count *(uint16_t) k_ra8_pin_count] |
| Owner tag for each claimed pin, indexed by flat (port, pin) index. | |
Runtime pin-ownership bitmap implementation.
Implements the API defined in ra8_pin_validator.h. Uses a fixed 30-byte bitmap (15 ports x 16 pins x 1 bit) and a parallel owner-tag array so that diagnostics can report which driver currently owns a given pin.
Definition in file ra8_pin_validator.c.
|
static |
Definition at line 53 of file ra8_pin_validator.c.
References k_ra8_err_gpio_invalid_pin, k_ra8_err_gpio_invalid_port, k_ra8_ok, k_ra8_pin_count, k_ra8_port_count, pin, RA8_INTERNAL, RA8_PIN_PIN, and RA8_PIN_PORT.
Referenced by ra8_pin_validator_claim(), ra8_pin_validator_is_claimed(), and ra8_pin_validator_release().
|
nodiscard |
Implementation of ra8_pin_validator_claim().
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 | ) |
Implementation of ra8_pin_validator_is_claimed().
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 |
Implementation of ra8_pin_validator_release().
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 | ) |
Implementation of ra8_pin_validator_reset().
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().
|
static |
Bitmap of claimed pins (1 bit per port/pin).
Index = (port * k_ra8_pin_count) + pin, then split into byte = index / k_ra8_bits_per_byte, bit = index % k_ra8_bits_per_byte.
Definition at line 39 of file ra8_pin_validator.c.
Referenced by ra8_pin_validator_claim(), ra8_pin_validator_is_claimed(), ra8_pin_validator_release(), and ra8_pin_validator_reset().
|
static |
Owner tag for each claimed pin, indexed by flat (port, pin) index.
NULL means "not claimed". Claim stores the caller-provided string literal pointer; the validator never copies the bytes.
Definition at line 50 of file ra8_pin_validator.c.
Referenced by ra8_pin_validator_claim(), ra8_pin_validator_release(), and ra8_pin_validator_reset().
|
static |
Definition at line 26 of file ra8_pin_validator.c.