ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_board_ek_ra8d2.c File Reference

Board-support implementation for the EK-RA8D2 v1. More...

#include "ra8_board_ek_ra8d2.h"
#include <stddef.h>
#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_elc_regs.h"
#include "ra8_err.h"
#include "ra8_gpio_constants.h"
#include "ra8_icu.h"
#include "ra8_icu_regs.h"
#include "ra8_isr.h"
#include "ra8_pfs_regs.h"
#include "ra8_port_constants.h"
#include "ra8_port_utils.h"
#include "ra8_time.h"
Include dependency graph for ra8_board_ek_ra8d2.c:

Go to the source code of this file.

Enumerations

enum  ra8_board_xspi_reset_timing_t : uint32_t {
  k_ra8_board_xspi_reset_low_ms = 1U ,
  k_ra8_board_xspi_reset_high_ms = 15U
}
 Hardware reset pulse + post-reset settle times for IS25LX512M-JHLE. More...

Functions

ra8_err_t ra8_board_get_info (ra8_board_info_t *out)
 Copy the three board-identity strings into out.
ra8_err_t ra8_board_led_pin (ra8_board_led_id_t led, ra8_port_pin_t *out_pin)
 Translate a board LED id into its underlying ra8_port_pin_t.
ra8_err_t ra8_board_led_init (ra8_board_led_id_t led)
 Configure led as a digital output, initial level low (off).
ra8_err_t ra8_board_led_on (ra8_board_led_id_t led)
 Drive led HIGH (light it).
ra8_err_t ra8_board_led_off (ra8_board_led_id_t led)
 Drive led LOW (extinguish it).
ra8_err_t ra8_board_led_toggle (ra8_board_led_id_t led)
 Toggle led's output state.
ra8_err_t ra8_board_sw_pin (ra8_board_sw_id_t sw, ra8_port_pin_t *out_pin)
 Translate a board switch id into its underlying ra8_port_pin_t.
ra8_err_t ra8_board_sw_init (ra8_board_sw_id_t sw)
 Configure a switch pin as an input with internal pull-up.
ra8_err_t ra8_board_sw_read (ra8_board_sw_id_t sw, ra8_board_sw_state_t *out_pressed)
 Sample the current state of sw.
ra8_err_t ra8_board_sw_attach_irq (ra8_board_sw_id_t sw, ra8_board_sw_irq_cb_t cb, void *ctx)
 Wire sw to the ICU and register a falling-edge callback.
static bool internal_glcdc_signal_starts_with (const char *s, const char *prefix)
 Check whether a NUL-terminated string starts with prefix.
static bool internal_glcdc_signal_is_color_data (const char *signal)
 Check whether a signal name is a GLCDC R/G/B data line.
static bool internal_glcdc_signal_is_output (const char *signal)
 Test whether a J1 signal name corresponds to a GLCDC output.
static void internal_glcdc_force_pin_output (ra8_port_pin_t pin)
 Force a PFS register to PSEL=glcdc, PMR=1, PDR=1 in one write.
ra8_err_t ra8_board_glcdc_init (ra8_board_glcdc_fmt_t fmt)
 Program every J1 pin for fmt to its GLCDC alternate function.
ra8_err_t ra8_board_lcd_panel_power_on (void)
 Implementation of ra8_board_lcd_panel_power_on.
ra8_err_t ra8_board_backlight_set (bool on)
 Turn the J1 panel backlight (BLEN, P514) on or off.
ra8_err_t ra8_board_xspi_pins_init (void)
 Route the 12 OCTA bus pins to the xSPI peripheral and pulse RESET_L.
ra8_err_t ra8_board_sdhi_pins_init (void)
 Route the eight SDHI0 bus pins to the SDHI peripheral function.
ra8_err_t ra8_board_arduino_pin_init (ra8_board_arduino_pin_t pin, ra8_board_arduino_mode_t mode)
 Configure an Arduino header pin in GPIO mode.
ra8_err_t ra8_board_arduino_gpio_write (ra8_board_arduino_pin_t pin, ra8_level_t level)
 Drive a previously-initialized Arduino GPIO pin.
ra8_err_t ra8_board_arduino_gpio_read (ra8_board_arduino_pin_t pin, ra8_level_t *out_level)
 Sample a previously-initialized Arduino GPIO pin.

Variables

const char *const k_ra8_board_name = "EK-RA8D2 v1"
 Human-readable strings identifying this BSP target.
const char *const k_ra8_board_doc_rev = "R20UT5523EG0101 Rev 1.01"
 "R20UT5523EG0101 Rev 1.01".
const char *const k_ra8_board_mcu = "R7KA8D2KFLCAC"
 "R7KA8D2KFLCAC".
static const ra8_port_pin_t s_led_pins [k_ra8_board_led_count]
 Lookup table from ra8_board_led_id_t to ra8_port_pin_t.
static const ra8_port_pin_t s_sw_pins [k_ra8_board_sw_count]
 Lookup table from ra8_board_sw_id_t to ra8_port_pin_t.
static const uint8_t s_sw_irq_nums [k_ra8_board_sw_count]
 Lookup table from ra8_board_sw_id_t to ICU IRQ channel.
const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb888_pins []
 RGB888-mode pin table for J1 (UM Table 33 p 42).
const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb666_pins []
 RGB666-mode pin table for J1 (UM Table 33 p 42).
const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb565_pins []
 RGB565-mode pin table for J1 (UM Table 33 p 42).
const uint32_t g_ra8_board_glcdc_rgb888_pin_count
 Number of entries in each per-format pin table.
const uint32_t g_ra8_board_glcdc_rgb666_pin_count
const uint32_t g_ra8_board_glcdc_rgb565_pin_count
static const ra8_port_pin_t s_xspi_octa_pins []
 Lookup table for the 12 OCTA bus pins routed to PSEL=0x1C.
static const ra8_port_pin_t s_sdhi_bus_pins []
 Lookup table for the eight SDHI0 bus pins routed to PSEL=0x15.

Detailed Description

Board-support implementation for the EK-RA8D2 v1.

Tag
[Ring 5 / BSP] {World: S}

Translates board-coordinate APIs ("LED1", "Arduino D13") into HAL calls. The BSP itself never touches MCU registers; ra8_gpio_* / ra8_pfs_route_peripheral / ra8_icu_configure_irq_pin / ra8_ssie_* carry every register write.

Source-of-truth for the pin tables is docs/reference/ek-ra8d2-v1-users-manual.pdf (R20UT5523EG0101 Rev 1.01, October 2025). Each pin entry's comment cites the table and page in that document.

Since
0.1.0

Definition in file ra8_board_ek_ra8d2.c.

Enumeration Type Documentation

◆ ra8_board_xspi_reset_timing_t

Hardware reset pulse + post-reset settle times for IS25LX512M-JHLE.

IS25LX512M datasheet specifies:

  • tRLRH (RESET_L low pulse width): min 100 ns (Ch 9.2 "Hardware Reset")
  • tRHSL (RESET_L high to first chip-select): min 100 us (Ch 9.2)
  • tPUW (power-up window before first command): up to 10 ms (Ch 14 "Power-up / Power-down Timing")

From cold boot we must honour tPUW, not just the much shorter reset recovery. The previous 1 ms / 1 ms pulse was compliant with tRLRH/tRHSL but not necessarily with tPUW: the controller could clock RDID before the IS25LX internal regulator was stable, the device would silently NAK, and CMDCMP would never assert – LevelX format then bailed at ra8_xspi_flash_read_id. Post-release settle is now 15 ms, comfortably clearing tPUW from a true cold boot. The pre-release low pulse stays at 1 ms (still 10000x the 100 ns minimum tRLRH, just generous).

Enumerator
k_ra8_board_xspi_reset_low_ms 

Hold RESET_L low for >= tRLRH.

k_ra8_board_xspi_reset_high_ms 

Wait >= tPUW before first CS.

Definition at line 691 of file ra8_board_ek_ra8d2.c.

Function Documentation

◆ internal_glcdc_force_pin_output()

void internal_glcdc_force_pin_output ( ra8_port_pin_t pin)
static

Force a PFS register to PSEL=glcdc, PMR=1, PDR=1 in one write.

ra8_pfs_route_peripheral writes PSEL + PMR but leaves PDR cleared, which keeps the pin in input direction. GLCDC needs its outputs in output direction; this helper does the combined write directly under PWPR unlock so the chip drives the line.

Parameters
[in]pinJ1 pin already validated to be a GLCDC output.
Precondition
Caller has confirmed the pin is a GLCDC output via internal_glcdc_signal_is_output.
IOPORT module is powered (true at reset).
Postcondition
PFS = (psel_glcdc << 24) | PMR | PDR for the target pin.
PWPR is left in its locked state.
Note
Single-threaded init context only.
Since
0.1.0

< PFS psel shift.

< PFS pmr bit.

< PFS pdr bit.

Definition at line 531 of file ra8_board_ek_ra8d2.c.

References k_ra8_psel_glcdc, pin, RA8_INTERNAL, ra8_pfs_pmn(), ra8_pfs_pwpr_lock(), ra8_pfs_pwpr_unlock(), RA8_PIN_PIN, and RA8_PIN_PORT.

Referenced by ra8_board_glcdc_init().

◆ internal_glcdc_signal_is_color_data()

bool internal_glcdc_signal_is_color_data ( const char * signal)
static

Check whether a signal name is a GLCDC R/G/B data line.

Matches the pattern [RGB][0-9] (e.g. "R0", "G7", "B3"). The digit check rules out "BLEN" (starts with B but second char is 'L', not a digit).

Parameters
[in]signalNUL-terminated signal name from the pin table.
Returns
true iff the first two characters form [RGB][0-9].
Return values
trueSignal is a colour-data line.
falseSignal is not a colour-data line.
Precondition
signal is non-null and at least 2 characters (incl. NUL).
Signal names follow EK-RA8D2 UM Table 33 conventions.
Postcondition
No side effects; pure inspection.
Return value is one of {true, false}.
Note
Init-time helper; single-threaded.
Since
0.1.0

Definition at line 457 of file ra8_board_ek_ra8d2.c.

References RA8_INTERNAL.

Referenced by internal_glcdc_signal_is_output().

◆ internal_glcdc_signal_is_output()

bool internal_glcdc_signal_is_output ( const char * signal)
static

Test whether a J1 signal name corresponds to a GLCDC output.

Returns true for TCONx / CLK / R[0-9]* / G[0-9]* / B[0-9]*; false for BLEN / RST / SDA1 / SCL1 / INT / EXTCLK. Used by ra8_board_glcdc_init to filter the J1 connector pin table down to the pins that actually carry GLCDC peripheral signals.

Parameters
[in]signalHuman-readable signal name from the pin table.
Returns
true for GLCDC peripheral outputs.
Return values
trueSignal is a GLCDC peripheral output.
falseSignal is GPIO/I2C/clock-input.
Precondition
signal is non-null and NUL-terminated.
Signal names follow EK-RA8D2 UM Table 33 conventions.
Postcondition
No side effects; pure inspection.
Return value is one of {true, false}.
Note
Single-threaded init-time helper.
Since
0.1.0

Definition at line 501 of file ra8_board_ek_ra8d2.c.

References internal_glcdc_signal_is_color_data(), internal_glcdc_signal_starts_with(), and RA8_INTERNAL.

Referenced by ra8_board_glcdc_init().

◆ internal_glcdc_signal_starts_with()

bool internal_glcdc_signal_starts_with ( const char * s,
const char * prefix )
static

Check whether a NUL-terminated string starts with prefix.

Bounded to the longest prefix this BSP needs ("TCON", 4 chars). Implemented inline instead of strncmp to keep the BSP free of <string.h> and to avoid compound boolean decisions that would require MC/DC vectors.

Parameters
[in]sNUL-terminated subject string.
[in]prefixNUL-terminated prefix (<= 4 chars).
Returns
true iff every prefix character matches the matching position in s.
Return values
truePrefix matches.
falseAt least one character differs.
Precondition
s and prefix are both non-null and NUL-terminated.
prefix is at most 4 characters long (compile-time invariant).
Postcondition
No side effects; pure inspection.
Return value is one of {true, false}.
Note
Init-time helper; single-threaded.
Since
0.1.0

Definition at line 423 of file ra8_board_ek_ra8d2.c.

References RA8_INTERNAL.

Referenced by internal_glcdc_signal_is_output().

◆ ra8_board_arduino_gpio_read()

ra8_err_t ra8_board_arduino_gpio_read ( ra8_board_arduino_pin_t pin,
ra8_level_t * out_level )
nodiscard

Sample a previously-initialized Arduino GPIO pin.

Since
0.1.0

Definition at line 803 of file ra8_board_ek_ra8d2.c.

References k_ra8_err_invalid_arg, pin, and ra8_gpio_read().

◆ ra8_board_arduino_gpio_write()

ra8_err_t ra8_board_arduino_gpio_write ( ra8_board_arduino_pin_t pin,
ra8_level_t level )
nodiscard

Drive a previously-initialized Arduino GPIO pin.

Since
0.1.0

Definition at line 798 of file ra8_board_ek_ra8d2.c.

References pin, and ra8_gpio_write().

◆ ra8_board_arduino_pin_init()

ra8_err_t ra8_board_arduino_pin_init ( ra8_board_arduino_pin_t pin,
ra8_board_arduino_mode_t mode )
nodiscard

Configure an Arduino header pin in GPIO mode.

Return values
k_ra8_ok/ k_ra8_err_invalid_arg / k_ra8_err_gpio_conflict
Precondition
HAL pin validator initialized.
SW4-4 ON (Arduino vs Octo-SPI selection).
Since
0.1.0

Definition at line 784 of file ra8_board_ek_ra8d2.c.

References k_ra8_board_arduino_mode_input, k_ra8_board_arduino_mode_input_pullup, k_ra8_board_arduino_mode_output, k_ra8_err_invalid_arg, k_ra8_level_low, k_ra8_pull_none, k_ra8_pull_up, pin, ra8_gpio_input_init(), and ra8_gpio_output_init().

◆ ra8_board_backlight_set()

ra8_err_t ra8_board_backlight_set ( bool on)
nodiscard

Turn the J1 panel backlight (BLEN, P514) on or off.

Drives the active-high k_ra8_board_lcd_blen output high (on == true) or low (on == false). BLEN is configured as a GPIO output by ra8_board_lcd_panel_power_on, so this is a level change only – no re-init. Intended for an application idle-dim / auto-off policy: the LED backlight is the single largest load on a battery-powered backlit TFT, so blanking it while the reader sits idle on a static page is the highest-value power saving available. Brightness (PWM) control is a separate capability (BLEN is not routed to a GPT output on this board); this is on/off only.

Parameters
[in]ontrue to light the backlight, false to blank it.
Returns
ra8_err_t Error code.
Return values
k_ra8_okBacklight level updated.
k_ra8_err_invalid_argBLEN pin invalid (should not occur).
k_ra8_err_gpio_*Underlying ra8_gpio_write propagated error.
Precondition
ra8_board_lcd_panel_power_on has run (BLEN is a GPIO output).
IOPORT module is powered (true at reset).
Postcondition
P514 (BLEN) is driven to the level selected by on.
No other pin or panel state is changed.
Note
Not thread-safe; call from the single input/render context.
See also
ra8_board_lcd_panel_power_on
Since
0.1.0

Definition at line 627 of file ra8_board_ek_ra8d2.c.

References k_ra8_level_high, k_ra8_level_low, k_ra8_pin_lcd_blen, and ra8_gpio_write().

Referenced by sh_run().

◆ ra8_board_get_info()

ra8_err_t ra8_board_get_info ( ra8_board_info_t * out)
nodiscard

Copy the three board-identity strings into out.

Parameters
[out]outDestination struct, must be non-NULL.
Return values
k_ra8_okFilled.
k_ra8_err_invalid_argout == NULL.
Precondition
out is writable.
Postcondition
On success out->name / doc_rev / mcu point at the global k_ra8_board_* strings.
Since
0.1.0

Definition at line 50 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_glcdc_init()

ra8_err_t ra8_board_glcdc_init ( ra8_board_glcdc_fmt_t fmt)
nodiscard

Program every J1 pin for fmt to its GLCDC alternate function.

Walks the right table above and calls ra8_pfs_route_peripheral for each entry. Does NOT bring the GLCDC peripheral itself up – call ra8_glcdc_init after this returns.

Return values
k_ra8_okAll pins routed.
k_ra8_err_invalid_argfmt out of range.
k_ra8_err_gpio_conflictAt least one pin already owned.
Precondition
IOPORT module powered (true at reset).
Postcondition
Every J1 pin for the chosen format is in GLCDC mode.
Since
0.1.0

Definition at line 550 of file ra8_board_ek_ra8d2.c.

References g_ra8_board_glcdc_rgb565_pin_count, g_ra8_board_glcdc_rgb565_pins, g_ra8_board_glcdc_rgb666_pin_count, g_ra8_board_glcdc_rgb666_pins, g_ra8_board_glcdc_rgb888_pin_count, g_ra8_board_glcdc_rgb888_pins, internal_glcdc_force_pin_output(), internal_glcdc_signal_is_output(), k_ra8_board_glcdc_fmt_rgb565, k_ra8_board_glcdc_fmt_rgb666, k_ra8_board_glcdc_fmt_rgb888, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_psel_glcdc, pin, and ra8_pfs_route_peripheral().

Referenced by internal_lcd_bringup_panel(), and internal_lcd_bringup_panel().

◆ ra8_board_lcd_panel_power_on()

ra8_err_t ra8_board_lcd_panel_power_on ( void )
nodiscard

Implementation of ra8_board_lcd_panel_power_on.

Pulse the J1 panel's RESET_L line and assert BLEN backlight.

See header for caller-facing contract. Body drives RESET_L low for 50 ms, releases it high for another 50 ms to let the panel's internal POR finish, then asserts BLEN.

Returns
Error code from the underlying GPIO operations.
Return values
k_ra8_okPanel out of reset, backlight on.
k_ra8_err_gpio_*Underlying GPIO call failed.
Precondition
IOPORT module powered (true at reset).
ra8_time_init has been called.
Postcondition
P606 RESET_L is high; P514 BLEN is high.
Returns within ~100 ms.
Note
Single-threaded init context; blocks on ra8_delay_ms.
Since
0.1.0

< Reset pulse ms.

Definition at line 608 of file ra8_board_ek_ra8d2.c.

References k_ra8_level_high, k_ra8_level_low, k_ra8_ok, k_ra8_pin_lcd_blen, k_ra8_pin_lcd_reset_l, ra8_delay_ms(), ra8_gpio_output_init(), and ra8_gpio_write().

Referenced by internal_lcd_bringup_panel(), and internal_lcd_bringup_panel().

◆ ra8_board_led_init()

ra8_err_t ra8_board_led_init ( ra8_board_led_id_t led)
nodiscard

Configure led as a digital output, initial level low (off).

Return values
k_ra8_okPin claimed and driven low.
k_ra8_err_invalid_argled >= k_ra8_board_led_count.
k_ra8_err_gpio_conflictPin already owned.
Precondition
HAL pin validator initialized (single-threaded boot context).
Postcondition
LED is off and pin is configured as a digital output.
Since
0.1.0

Definition at line 91 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_led_off()

ra8_err_t ra8_board_led_off ( ra8_board_led_id_t led)
nodiscard

Drive led LOW (extinguish it).

Return values
k_ra8_ok/ k_ra8_err_invalid_arg
Precondition
ra8_board_led_init(led) succeeded.
Postcondition
LED pin output latch == 0.

Definition at line 111 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_led_on()

ra8_err_t ra8_board_led_on ( ra8_board_led_id_t led)
nodiscard

Drive led HIGH (light it).

Return values
k_ra8_ok/ k_ra8_err_invalid_arg
Precondition
ra8_board_led_init(led) succeeded.
Postcondition
LED pin output latch == 1.

Definition at line 101 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_led_pin()

ra8_err_t ra8_board_led_pin ( ra8_board_led_id_t led,
ra8_port_pin_t * out_pin )
nodiscard

Translate a board LED id into its underlying ra8_port_pin_t.

Parameters
[in]ledLED identifier.
[out]out_pinDestination pin id.
Return values
k_ra8_ok/ k_ra8_err_invalid_arg
Since
0.1.0

Definition at line 79 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_led_init(), ra8_board_led_off(), ra8_board_led_on(), and ra8_board_led_toggle().

◆ ra8_board_led_toggle()

ra8_err_t ra8_board_led_toggle ( ra8_board_led_id_t led)
nodiscard

Toggle led's output state.

Return values
k_ra8_ok/ k_ra8_err_invalid_arg
Precondition
ra8_board_led_init(led) succeeded.
Postcondition
LED pin output latch is inverted from its prior value.

Definition at line 121 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_sdhi_pins_init()

ra8_err_t ra8_board_sdhi_pins_init ( void )
nodiscard

Route the eight SDHI0 bus pins to the SDHI peripheral function.

Walks the ra8_board_sdhi_pin_t bus order (CMD / CLK / DAT0..3 / WP / CD on port 4 pins 0..7) and calls ra8_pfs_route_peripheral for each under PSEL = k_ra8_psel_sdhi (chip HUM Ch 20.6 "Multiplexed Pin Function Selector"). It does NOT bring the SDHI block or the card up – call ra8_sdcard_init / ra8_sdhi_init after this returns. Returns on the first failing pin so the caller can panic-halt before SD bring-up.

See the

Warning
on ra8_board_sdhi_pin_t: EK-RA8D2 v1 has no on-board micro-SD socket, so this routing is only meaningful with an external SDHI break-out wired to port 4.
Returns
ra8_err_t Error code.
Return values
k_ra8_okAll eight SDHI0 pins routed.
k_ra8_err_invalid_argPFS programming rejected an entry.
k_ra8_err_gpio_conflictAt least one pin already owned.
Precondition
IOPORT module powered (reset default).
Single-threaded init context (no other consumer owns port-4 pins).
Postcondition
On success port-4 pins 0..7 are in the SDHI alternate function.
On failure the affected pins are left in their prior state.
Note
Not thread-safe; call once during board bring-up before SDHI init.
Since
0.1.0

Definition at line 763 of file ra8_board_ek_ra8d2.c.

References k_ra8_ok, k_ra8_psel_sdhi, ra8_pfs_route_peripheral(), and s_sdhi_bus_pins.

Referenced by main(), sdhi_card_setup_or_halt(), and sdhi_demo_setup_or_halt().

◆ ra8_board_sw_attach_irq()

ra8_err_t ra8_board_sw_attach_irq ( ra8_board_sw_id_t sw,
ra8_board_sw_irq_cb_t cb,
void * ctx )
nodiscard

Wire sw to the ICU and register a falling-edge callback.

Buttons are active-low so a falling edge corresponds to a press. The HAL takes care of the PFS routing, IRQCR programming, and NVIC enable; this veneer just hides the specific channel number (UM Table 25) from the caller.

Return values
k_ra8_ok/ k_ra8_err_invalid_arg / k_ra8_err_gpio_conflict
Precondition
ra8_icu_init() has been called once during boot.
Postcondition
Pressing sw invokes cb(ctx) from the ICU ISR context.

Definition at line 196 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_sw_init()

ra8_err_t ra8_board_sw_init ( ra8_board_sw_id_t sw)
nodiscard

Configure a switch pin as an input with internal pull-up.

Return values
k_ra8_ok/ k_ra8_err_invalid_arg / k_ra8_err_gpio_conflict
Precondition
HAL pin validator initialized.
Postcondition
Pin is digital input, pull-up enabled.
Since
0.1.0

Definition at line 165 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_sw_pin()

ra8_err_t ra8_board_sw_pin ( ra8_board_sw_id_t sw,
ra8_port_pin_t * out_pin )
nodiscard

Translate a board switch id into its underlying ra8_port_pin_t.

Since
0.1.0

Definition at line 153 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_sw_init(), and ra8_board_sw_read().

◆ ra8_board_sw_read()

ra8_err_t ra8_board_sw_read ( ra8_board_sw_id_t sw,
ra8_board_sw_state_t * out_pressed )
nodiscard

Sample the current state of sw.

The buttons are wired active-low (press shorts the pin to GND); this function inverts the level so callers receive a positive "pressed = true" semantic.

Parameters
[in]swSwitch id.
[out]out_pressedSet to k_ra8_board_sw_pressed if held.
Return values
k_ra8_okRead complete.
k_ra8_err_invalid_argsw out of range or out_pressed NULL.
Precondition
ra8_board_sw_init(sw) succeeded.
Postcondition
*out_pressed is one of {released, pressed}.
Since
0.1.0

Definition at line 175 of file ra8_board_ek_ra8d2.c.

◆ ra8_board_xspi_pins_init()

ra8_err_t ra8_board_xspi_pins_init ( void )
nodiscard

Route the 12 OCTA bus pins to the xSPI peripheral and pulse RESET_L.

Configures CS / CK / DQS / DQ0..DQ7 under PSEL=k_ra8_psel_qspi (0x1C) per EK-RA8D2 UM Table 29 (p 35), then drives the active-low RESET strap as a GPIO output: low for >= tRLRH, high for >= tRHSL before the first xSPI command. Must run BEFORE any ra8_xspi_* call.

Returns
ra8_err_t Error code.
Return values
k_ra8_okAll pins routed and reset strap pulsed.
k_ra8_err_invalid_argPFS programming rejected an entry.
Precondition
IOPORT MSTP cleared (ra8_pfs_init has run).
Single-threaded init context.
Postcondition
12 OCTA pins are under PSEL=0x1C.
RESET_L is high; the IS25LX512M is ready for its first command.
Note
Not thread-safe; init context only.
Since
0.1.0

Definition at line 696 of file ra8_board_ek_ra8d2.c.

References k_ra8_board_xspi_reset, k_ra8_board_xspi_reset_high_ms, k_ra8_board_xspi_reset_low_ms, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, k_ra8_psel_qspi, ra8_delay_ms(), ra8_gpio_output_init(), ra8_gpio_write(), ra8_pfs_route_peripheral(), and s_xspi_octa_pins.

Referenced by demo_run(), flash_journal_setup_or_halt(), internal_bus_init_once(), ospirw_ospi_provision(), and selftest_ospi_provision().

Variable Documentation

◆ g_ra8_board_glcdc_rgb565_pin_count

const uint32_t g_ra8_board_glcdc_rgb565_pin_count
Initial value:
=
const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb565_pins[]
RGB565-mode pin table for J1 (UM Table 33 p 42).

Definition at line 396 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_glcdc_init().

◆ g_ra8_board_glcdc_rgb565_pins

const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb565_pins[]
Initial value:
= {
{.signal = "BLEN", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_5) << 8) | (uint16_t)(k_ra8_pin_14))) },
{.signal = "SDA1", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_5) << 8) | (uint16_t)(k_ra8_pin_11))) },
{.signal = "INT", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_1) << 8) | (uint16_t)(k_ra8_pin_11))) },
{.signal = "SCL1", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_5) << 8) | (uint16_t)(k_ra8_pin_12))) },
{.signal = "RST", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_6) << 8) | (uint16_t)(k_ra8_pin_6))) },
{.signal = "TCON0", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_8) << 8) | (uint16_t)(k_ra8_pin_6))) },
{.signal = "CLK", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_5) << 8) | (uint16_t)(k_ra8_pin_15))) },
{.signal = "TCON2", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_8) << 8) | (uint16_t)(k_ra8_pin_7))) },
{.signal = "TCON1", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_8) << 8) | (uint16_t)(k_ra8_pin_5))) },
{.signal = "EXTCLK", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_7) << 8) | (uint16_t)(k_ra8_pin_10))) },
{.signal = "TCON3", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_5) << 8) | (uint16_t)(k_ra8_pin_13))) },
{.signal = "B4", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_15))) },
{.signal = "B3", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_14))) },
{.signal = "B6", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_2))) },
{.signal = "B5", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_3))) },
{.signal = "G2", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_11))) },
{.signal = "B7", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_10))) },
{.signal = "G4", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_13))) },
{.signal = "G3", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_12))) },
{.signal = "G6", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_2) << 8) | (uint16_t)(k_ra8_pin_7))) },
{.signal = "G5", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_9) << 8) | (uint16_t)(k_ra8_pin_4))) },
{.signal = "R3", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_11) << 8) | (uint16_t)(k_ra8_pin_6))) },
{.signal = "G7", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_11) << 8) | (uint16_t)(k_ra8_pin_7))) },
{.signal = "R5", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_11) << 8) | (uint16_t)(k_ra8_pin_1))) },
{.signal = "R4", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_11) << 8) | (uint16_t)(k_ra8_pin_5))) },
{.signal = "R7", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_11) << 8) | (uint16_t)(k_ra8_pin_3))) },
{.signal = "R6", .pin = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_11) << 8) | (uint16_t)(k_ra8_pin_4))) },
}
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_port_9
RA8 port 9.
@ k_ra8_port_7
RA8 port 7.
@ k_ra8_port_11
RA8 port 11.
@ k_ra8_port_2
RA8 port 2.
@ k_ra8_port_6
RA8 port 6.
@ k_ra8_port_5
RA8 port 5.
@ k_ra8_port_8
RA8 port 8.
@ k_ra8_port_1
RA8 port 1.
@ k_ra8_pin_4
RA8 pin 4.
@ k_ra8_pin_6
RA8 pin 6.
@ k_ra8_pin_11
RA8 pin 11.
@ k_ra8_pin_7
RA8 pin 7.
@ k_ra8_pin_10
RA8 pin 10.
@ k_ra8_pin_1
RA8 pin 1.
@ k_ra8_pin_2
RA8 pin 2.
@ k_ra8_pin_13
RA8 pin 13.
@ k_ra8_pin_12
RA8 pin 12.
@ k_ra8_pin_5
RA8 pin 5.
@ k_ra8_pin_14
RA8 pin 14.
@ k_ra8_pin_3
RA8 pin 3.
@ k_ra8_pin_15
RA8 pin 15.

RGB565-mode pin table for J1 (UM Table 33 p 42).

RGB565 uses 5+6+5 = 16 active data lines. R6/R7 + G6/G7 are NC, and DATA31..DATA38 (R0..R7 lines) are NC. Same control pins as RGB888.

Definition at line 362 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_glcdc_init().

◆ g_ra8_board_glcdc_rgb666_pin_count

const uint32_t g_ra8_board_glcdc_rgb666_pin_count
Initial value:
=
const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb666_pins[]
RGB666-mode pin table for J1 (UM Table 33 p 42).

Definition at line 394 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_glcdc_init().

◆ g_ra8_board_glcdc_rgb666_pins

const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb666_pins[]

RGB666-mode pin table for J1 (UM Table 33 p 42).

In RGB666 the lowest two bits of each colour channel (R0, R1, G0, G1, B0, B1) are not driven (board ties them off internally), so the table omits the DATA0..DATA3 + DATA8..DATA9 + DATA16..DATA17 lines and drops DATA22..DATA23 (R6/R7) which are NC in RGB666.

Definition at line 321 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_glcdc_init().

◆ g_ra8_board_glcdc_rgb888_pin_count

const uint32_t g_ra8_board_glcdc_rgb888_pin_count
Initial value:
=
const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb888_pins[]
Pin tables for J1 in each pixel format (UM Table 33 p 42).

Number of entries in each per-format pin table.

Definition at line 392 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_glcdc_init().

◆ g_ra8_board_glcdc_rgb888_pins

const ra8_board_glcdc_pin_t g_ra8_board_glcdc_rgb888_pins[]

RGB888-mode pin table for J1 (UM Table 33 p 42).

Pin tables for J1 in each pixel format (UM Table 33 p 42).

Common control + data lines routed when J1 is driven in 24-bit RGB888 mode. Order matches the UM table (J1-1..J1-38).

Definition at line 239 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_glcdc_init().

◆ k_ra8_board_doc_rev

const char* const k_ra8_board_doc_rev = "R20UT5523EG0101 Rev 1.01"

"R20UT5523EG0101 Rev 1.01".

"R01UH1064EJ (chip HUM)".

Definition at line 47 of file ra8_board_ek_ra8d2.c.

◆ k_ra8_board_mcu

const char* const k_ra8_board_mcu = "R7KA8D2KFLCAC"

"R7KA8D2KFLCAC".

"R7KA8P1KFLCAC".

Definition at line 48 of file ra8_board_ek_ra8d2.c.

◆ k_ra8_board_name

const char* const k_ra8_board_name = "EK-RA8D2 v1"

Human-readable strings identifying this BSP target.

Returned by ra8_board_get_info() so applications can log / verify the board they were built for. All three are ASCII string literals with permanent storage duration. "EK-RA8D2 v1".

Definition at line 46 of file ra8_board_ek_ra8d2.c.

◆ s_led_pins

const ra8_port_pin_t s_led_pins[k_ra8_board_led_count]
static
Initial value:
= {
[k_ra8_board_led1] = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_6) << 8) | (uint16_t)(k_ra8_pin_0))) ,
[k_ra8_board_led2] = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_3) << 8) | (uint16_t)(k_ra8_pin_3))) ,
[k_ra8_board_led3] = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_10) << 8) | (uint16_t)(k_ra8_pin_7))) ,
}
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
@ k_ra8_board_led3
LED3, RED, PA07 (jumper E28).
@ k_ra8_port_3
RA8 port 3.
@ k_ra8_port_10
RA8 port 10.
@ k_ra8_pin_0
RA8 pin 0.

Lookup table from ra8_board_led_id_t to ra8_port_pin_t.

Index by ra8_board_led_id_t (LED1=0, LED2=1, LED3=2). Entries come straight from EK-RA8D2 UM Table 24 p 31.

Definition at line 73 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_led_pin().

◆ s_sdhi_bus_pins

const ra8_port_pin_t s_sdhi_bus_pins[]
static
Initial value:

Lookup table for the eight SDHI0 bus pins routed to PSEL=0x15.

Bus order: CMD, CLK, DAT0..DAT3, WP, CD. The pin enums are uint16_t encodings of (port << 8) | pin – compatible with the ra8_port_pin_t value space. Source: chip HUM Ch 20.6 "Multiplexed Pin Function Selector" SDHI pin group (the EK-RA8D2 v1 board has no on-board micro-SD socket – see the

Warning
on ra8_board_sdhi_pin_t).

The ra8_port_pin_t enum only enumerates the convenience k_ra8_pin_led* aliases; raw RA8_PIN()-derived values are valid data-space members but trigger the EnumCastOutOfRange checker, so the cast cluster is wrapped in a lint-suppression region matching the board-pin convention used throughout this BSP.

Definition at line 752 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_sdhi_pins_init().

◆ s_sw_irq_nums

const uint8_t s_sw_irq_nums[k_ra8_board_sw_count]
static
Initial value:
= {
}
@ k_ra8_board_sw1
SW1, P009, IRQ13-DS (jumper E31).
@ k_ra8_board_sw2
SW2, P008, IRQ12-DS (jumper E32).
@ k_ra8_board_sw2_irq
SW2 -> IRQ12-DS.
@ k_ra8_board_sw1_irq
SW1 -> IRQ13-DS.

Lookup table from ra8_board_sw_id_t to ICU IRQ channel.

Definition at line 148 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_sw_attach_irq().

◆ s_sw_pins

const ra8_port_pin_t s_sw_pins[k_ra8_board_sw_count]
static
Initial value:
= {
[k_ra8_board_sw1] = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_0) << 8) | (uint16_t)(k_ra8_pin_9))) ,
[k_ra8_board_sw2] = (ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_0) << 8) | (uint16_t)(k_ra8_pin_8))) ,
}
@ k_ra8_port_0
RA8 port 0.
@ k_ra8_pin_9
RA8 pin 9.
@ k_ra8_pin_8
RA8 pin 8.

Lookup table from ra8_board_sw_id_t to ra8_port_pin_t.

SW1 -> P009, SW2 -> P008. Per UM Table 25 p 32.

Definition at line 142 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_sw_pin().

◆ s_xspi_octa_pins

const ra8_port_pin_t s_xspi_octa_pins[]
static
Initial value:
= {
}
@ k_ra8_board_xspi_dq2
OSPI_FLASH_DQ2, P103.
@ k_ra8_board_xspi_dq7
OSPI_FLASH_DQ7, P804.
@ k_ra8_board_xspi_dq6
OSPI_FLASH_DQ6, P802.
@ k_ra8_board_xspi_dq1
OSPI_FLASH_DQ1, P803.
@ k_ra8_board_xspi_dq5
OSPI_FLASH_DQ5, P800.
@ k_ra8_board_xspi_dq3
OSPI_FLASH_DQ3, P101.
@ k_ra8_board_xspi_dq0
OSPI_FLASH_DQ0, P100.
@ k_ra8_board_xspi_clk
OSPI_FLASH_C, P808.
@ k_ra8_board_xspi_dqs
OSPI_FLASH_DQS, P801.
@ k_ra8_board_xspi_dq4
OSPI_FLASH_DQ4, P102.
@ k_ra8_board_xspi_cs
OSPI_FLASH_S_L, P104.

Lookup table for the 12 OCTA bus pins routed to PSEL=0x1C.

Order: CS, CK, DQS, DQ0..DQ7. The pin enums are uint16_t encodings of (port << 8) | pin – compatible with ra8_port_pin_t value space. The RESET_L pin is intentionally NOT in this table: it is driven by the GPIO subsystem (active-low strap, not a peripheral function). Source: EK-RA8D2 UM Table 29 "Octo-SPI Flash Assignments" p 35.

The ra8_port_pin_t enum only enumerates the convenience k_ra8_pin_led* aliases; raw RA8_PIN()-derived values are valid data-space members but trigger the EnumCastOutOfRange checker, so the cast cluster is wrapped in a lint-suppression region matching the board-pin convention used throughout this BSP.

Definition at line 657 of file ra8_board_ek_ra8d2.c.

Referenced by ra8_board_xspi_pins_init().