|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Multi-function Pin Controller (MPC) facade. More...
Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_mpc_route_peripheral (ra8_port_t port, ra8_pin_t pin, ra8_mpc_psel_t psel) |
| Route a pin to a peripheral function. | |
| ra8_err_t | ra8_mpc_set_gpio (ra8_port_t port, ra8_pin_t pin, ra8_mpc_dir_t dir) |
| Reset a pin to plain GPIO with a chosen direction. | |
| ra8_err_t | ra8_mpc_set_analog (ra8_port_t port, ra8_pin_t pin) |
| Put a pin in analog-input mode (ASEL = 1). | |
| ra8_err_t | ra8_mpc_set_irq (ra8_port_t port, ra8_pin_t pin) |
| Mark a pin as an external IRQ input (ISEL = 1). | |
| ra8_err_t | ra8_mpc_set_pull (ra8_port_t port, ra8_pin_t pin, ra8_mpc_pull_t pull) |
| Enable or disable the internal pull-up on a pin. | |
| ra8_err_t | ra8_mpc_set_open_drain (ra8_port_t port, ra8_pin_t pin, bool enable) |
| Enable or disable N-channel open-drain on a pin. | |
| ra8_err_t | ra8_mpc_read_pfs (ra8_port_t port, ra8_pin_t pin, uint32_t *out_val) |
| Read the raw 32-bit PmnPFS register for diagnostic use. | |
Multi-function Pin Controller (MPC) facade.
Ring 3 / HAL substrate. Wraps the RA8D2 PmnPFS register array (HUM Ch 20 "I/O Ports", p 837) behind a small set of operation-named helpers:
Drivers never touch PmnPFS directly. The substrate handles the PWPR unlock / lock sequence, the "write zero first" reset, and the pin-validator registration so two drivers cannot claim the same pin without being told about it.
Single-threaded init context only.
Definition in file ra8_mpc.h.
| enum ra8_mpc_dir_t : uint8_t |
Pin direction for ra8_mpc_set_gpio.
| Enumerator | |
|---|---|
| k_ra8_mpc_dir_input | Input direction (PDR = 0). |
| k_ra8_mpc_dir_output | Output direction (PDR = 1). |
| enum ra8_mpc_psel_t : uint8_t |
Peripheral function select values for the PMR/PSEL path.
Values come from HUM Ch 20 table "Pin function select" (section 20.2.x), cross-verified against FSP ra/fsp/src/bsp/mcu/ra8d2/bsp_override.h (RA8D2-specific ioport_peripheral_t enum). The 5-bit PSEL field accepts values 0x00..0x1F; only the codes the firmware currently routes are listed – extend as new drivers come online.
| enum ra8_mpc_pull_t : uint8_t |
Pull-up enable for ra8_mpc_set_pull.
| Enumerator | |
|---|---|
| k_ra8_mpc_pull_off | RA8 mpc pull off. |
| k_ra8_mpc_pull_up | RA8 mpc pull up. |
|
nodiscard |
Read the raw 32-bit PmnPFS register for diagnostic use.
| [in] | port | Port index. |
| [in] | pin | Pin index. |
| [out] | out_val | On success, the current PmnPFS value. |
| k_ra8_ok | Value returned. |
| k_ra8_err_null_ptr | out_val was NULL. |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
Definition at line 212 of file ra8_mpc.c.
References internal_check(), k_ra8_err_gpio_invalid_pin, k_ra8_ok, pin, RA8_CHECK_NULL_PTR, ra8_pfs_pmn(), and s_tag.
|
nodiscard |
Route a pin to a peripheral function.
Unlocks PWPR, writes the pin's PmnPFS register with PMR = 1 and PSEL = psel, then re-locks PWPR. Any stale direction / pull / open-drain bits are cleared in the same write so the caller sees a clean slate.
| [in] | port | Port index 0..k_ra8_port_max. |
| [in] | pin | Pin index 0..k_ra8_pin_max. |
| [in] | psel | Peripheral function from ra8_mpc_psel_t. |
| k_ra8_ok | Pin routed. |
| k_ra8_err_gpio_invalid_port | port index out of range. |
| k_ra8_err_gpio_invalid_pin | pin index out of range. |
Definition at line 122 of file ra8_mpc.c.
References internal_check(), k_ra8_err_gpio_invalid_pin, k_ra8_ok, k_ra8_pfs_bit_psel0, k_ra8_pfs_mask_pmr, k_ra8_pfs_mask_psel, pin, ra8_log_info_val, ra8_pfs_pmn(), ra8_pfs_pwpr_lock(), ra8_pfs_pwpr_unlock(), and s_tag.
|
nodiscard |
Put a pin in analog-input mode (ASEL = 1).
| [in] | port | Port index. |
| [in] | pin | Pin index. |
| k_ra8_ok | Analog input configured. |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
Definition at line 167 of file ra8_mpc.c.
References internal_check(), internal_reset_pfs(), k_ra8_ok, k_ra8_pfs_mask_asel, and pin.
|
nodiscard |
Reset a pin to plain GPIO with a chosen direction.
| [in] | port | Port index 0..k_ra8_port_max. |
| [in] | pin | Pin index 0..k_ra8_pin_max. |
| [in] | dir | Input or output. |
| k_ra8_ok | Pin reset to GPIO. |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
Definition at line 156 of file ra8_mpc.c.
References internal_check(), internal_reset_pfs(), k_ra8_mpc_dir_output, k_ra8_ok, k_ra8_pfs_mask_pdr, and pin.
|
nodiscard |
Mark a pin as an external IRQ input (ISEL = 1).
Does NOT program the ICU IELSR entry – that's ra8_isr's job. This helper just flips the pin's PFS so the edge detector is active.
| [in] | port | Port index. |
| [in] | pin | Pin index. |
| k_ra8_ok | Pin ISEL set. |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
Definition at line 177 of file ra8_mpc.c.
References internal_check(), internal_reset_pfs(), k_ra8_ok, k_ra8_pfs_mask_isel, and pin.
|
nodiscard |
Enable or disable N-channel open-drain on a pin.
| [in] | port | Port index. |
| [in] | pin | Pin index. |
| [in] | enable | true for open-drain, false for CMOS. |
| k_ra8_ok | NCODR updated. |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
Definition at line 198 of file ra8_mpc.c.
References internal_check(), internal_update_pfs(), k_ra8_ok, k_ra8_pfs_mask_ncodr, and pin.
Referenced by combo_pfs_or_halt(), i3c_demo_pfs_or_halt(), and internal_io_expander_route_pins().
|
nodiscard |
Enable or disable the internal pull-up on a pin.
| [in] | port | Port index. |
| [in] | pin | Pin index. |
| [in] | pull | Off or on. |
| k_ra8_ok | Pull updated. |
| k_ra8_err_gpio_invalid_port | Port out of range. |
| k_ra8_err_gpio_invalid_pin | Pin out of range. |
Definition at line 187 of file ra8_mpc.c.
References internal_check(), internal_update_pfs(), k_ra8_mpc_pull_up, k_ra8_ok, k_ra8_pfs_mask_pcr, and pin.