|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Pin Function Select (PFS) register layout for the Renesas RA8D2. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_bit_constants.h"#include "ra8_port_constants.h"Go to the source code of this file.
Functions | |
| 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. | |
| static volatile uint8_t * | ra8_pfs_pwpr (void) |
| Get pointer to the PWPR register (non-secure write-protect). | |
| static volatile uint8_t * | ra8_pfs_pwprs (void) |
| Get pointer to the PWPRS register (Secure write-protect). | |
| static void | ra8_pfs_pwpr_unlock (void) |
| Unlock PFS writes. | |
| static void | ra8_pfs_pwpr_lock (void) |
| Re-lock PFS writes. | |
Pin Function Select (PFS) register layout for the Renesas RA8D2.
Every GPIO pin on an RA8D2 has a 32-bit PmnPFS register inside the PFS block at 0x40400800. The register controls direction, output level, pull-up, open-drain, drive strength, IRQ/analog enable and (most importantly) which peripheral function is routed to the pin.
Pins are addressed by a flat (port * 16) + pin index; each entry is 4 bytes. The whole PFS array covers 15 ports x 16 pins x 4 bytes = 960 bytes.
| Bits | Name | RW | Purpose |
|---|---|---|---|
| 0 | PODR | RW | Port output data |
| 1 | PIDR | R | Port input data |
| 2 | PDR | RW | Port direction (0 = in, 1 = out) |
| 4 | PCR | RW | Pull-up control |
| 6 | NCODR | RW | N-channel open-drain |
| 11:10 | DSCR | RW | Drive strength |
| 13:12 | EOFR | RW | Event on falling / rising trigger control |
| 14 | ISEL | RW | IRQ input enable |
| 15 | ASEL | RW | Analog input enable |
| 16 | PMR | RW | Peripheral mode (0 = GPIO, 1 = peripheral) |
| 28:24 | PSEL | RW | Peripheral function select (0..31) |
PmnPFS writes are gated by the PWPR (Write Protect Register). The sequence is:
Skipping the unlock makes the write silently go nowhere.
Definition in file ra8_pfs_regs.h.
| enum ra8_pfs_addr_t : uintptr_t |
| Enumerator | |
|---|---|
| k_ra8_pfs_base_addr | PFS array base. |
| k_ra8_pmisc_base_addr | PMISC: contains PWPR and PWPRS. |
Definition at line 66 of file ra8_pfs_regs.h.
| enum ra8_pfs_bit_t : uint8_t |
Bit positions inside the 32-bit PmnPFS register.
Definition at line 93 of file ra8_pfs_regs.h.
| enum ra8_pfs_dscr_t : uint8_t |
PmnPFS.DSCR[1:0] port drive-capability encodings.
HUM Ch 20.2.6 "PmnPFS" p 845: the DSCR field selects the output pad drive strength. The default after reset is k_ra8_pfs_dscr_low. High-speed peripheral outputs (RGMII transmit data/clock/control, parallel display) need a stronger setting – HUM Ch 20.2.6 explicitly lists DSCR = 01b (middle) for RGMII/3.3 V and 11b (high) for RGMII/2.5 V; any other value for an RGMII pin leaves the electrical characteristics unguaranteed.
| Enumerator | |
|---|---|
| k_ra8_pfs_dscr_low | 00b: Low drive (reset default). |
| k_ra8_pfs_dscr_middle | 01b: Middle drive. |
| k_ra8_pfs_dscr_high_speed_high | 10b: High-speed high drive. |
| k_ra8_pfs_dscr_high | 11b: High drive. |
Definition at line 144 of file ra8_pfs_regs.h.
| enum ra8_pfs_mask_t : uint32_t |
Full-width masks for PmnPFS fields.
Definition at line 113 of file ra8_pfs_regs.h.
| enum ra8_pmisc_off_t : uint16_t |
Definition at line 71 of file ra8_pfs_regs.h.
| enum ra8_pwpr_bit_t : uint8_t |
Bit positions inside the 8-bit PWPR register.
| Enumerator | |
|---|---|
| k_ra8_pwpr_bit_pfswe | 1 = PFS writes allowed, 0 = PFS writes blocked. |
| k_ra8_pwpr_bit_b0wi | 1 = PFSWE write blocked, 0 = PFSWE writable. |
Definition at line 183 of file ra8_pfs_regs.h.
|
inlinestatic |
Get pointer to the PmnPFS register for a single pin.
| [in] | port | Port index (0..k_ra8_port_max). |
| [in] | pin | Pin index within the port (0..k_ra8_pin_max). |
Definition at line 160 of file ra8_pfs_regs.h.
References k_ra8_pfs_base_addr, k_ra8_pin_count, k_ra8_pin_max, k_ra8_port_max, and pin.
Referenced by internal_capture_xspi_pin_state(), internal_glcdc_force_pin_output(), internal_reset_pfs(), internal_update_pfs(), ra8_gpio_input_init(), ra8_gpio_output_init(), ra8_mpc_read_pfs(), ra8_mpc_route_peripheral(), ra8_pfs_route_peripheral(), and ra8_pfs_set_drive_strength().
|
inlinestatic |
Get pointer to the PWPR register (non-secure write-protect).
Definition at line 190 of file ra8_pfs_regs.h.
References k_ra8_pmisc_base_addr, and k_ra8_pmisc_off_pwpr.
Referenced by ra8_pfs_pwpr_lock(), and ra8_pfs_pwpr_unlock().
|
inlinestatic |
Re-lock PFS writes.
Clears PFSWE, then sets B0WI so subsequent accidental writes to PFSWE are silently dropped.
Definition at line 268 of file ra8_pfs_regs.h.
References k_ra8_pwpr_bit_b0wi, ra8_pfs_pwpr(), and ra8_pfs_pwprs().
Referenced by internal_glcdc_force_pin_output(), internal_reset_pfs(), internal_update_pfs(), ra8_gpio_input_init(), ra8_gpio_output_init(), ra8_mpc_route_peripheral(), ra8_pfs_route_peripheral(), and ra8_pfs_set_drive_strength().
|
inlinestatic |
Unlock PFS writes.
Sequence from HUM section 20.2.6 (PWPR) and 20.2.7 (PWPRS):
Must be called once before a burst of PmnPFS writes, then balanced with ra8_pfs_pwpr_lock().
Definition at line 241 of file ra8_pfs_regs.h.
References k_ra8_pwpr_bit_pfswe, ra8_pfs_pwpr(), and ra8_pfs_pwprs().
Referenced by internal_glcdc_force_pin_output(), internal_reset_pfs(), internal_update_pfs(), ra8_gpio_input_init(), ra8_gpio_output_init(), ra8_mpc_route_peripheral(), ra8_pfs_route_peripheral(), and ra8_pfs_set_drive_strength().
|
inlinestatic |
Get pointer to the PWPRS register (Secure write-protect).
On RA8D2 the Cortex-M85 boots in the Secure world. Until the SAU partition is programmed, PFS writes gated only by PWPR are silently dropped because PWPR controls the non-secure path. Secure code must unlock PWPRS as well; both registers share the same bit layout (B0WI / PFSWE) per HUM Ch 20.2.6 / 20.2.7.
Definition at line 208 of file ra8_pfs_regs.h.
References k_ra8_pmisc_base_addr, and k_ra8_pmisc_off_pwprs.
Referenced by ra8_pfs_pwpr_lock(), and ra8_pfs_pwpr_unlock().