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

I/O-expander, USB, camera, external-memory, MIPI-DSI, UART console, and Ethernet portion of the EK-RA8D2 v1 board-support layer. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_board_ek_ra8d2_connectors.h"
#include "ra8_err.h"
#include "ra8_port_constants.h"
Include dependency graph for ra8_board_ek_ra8d2_peripherals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_board_clock_rates_t
 Clock rates published by the standard EK-RA8D2 bring-up. More...

Enumerations

enum  ra8_board_usbhs_pin_t : uint16_t {
  k_ra8_board_usbhs_pin_vbus ,
  k_ra8_board_usbhs_pin_pwr
}
 USBHS host/device routing per UM Table 28 p 34. More...
enum  ra8_board_usbfs_pin_t : uint16_t {
  k_ra8_board_usbfs_pin_dp ,
  k_ra8_board_usbfs_pin_dm ,
  k_ra8_board_usbfs_pin_vbus ,
  k_ra8_board_usbfs_pin_vbusen
}
 USB-FS (J11) board-routed port pins, UM Table 22 p 30. More...
enum  ra8_board_i3c0_pin_t : uint16_t {
  k_ra8_board_i3c0_pin_scl ,
  k_ra8_board_i3c0_pin_sda
}
 IIC_B / I3C channel-0 board pins (SCL0 / SDA0), UM Table 20 p 28. More...
enum  ra8_board_touch_wiring_t : uint32_t {
  k_ra8_board_touch_i3c_channel = 0U ,
  k_ra8_board_touch_target_7b = 0x5DU ,
  k_ra8_board_touch_bus_hz = 400000U
}
 Where the on-board GoodIX GT911 capacitive-touch controller sits. More...
enum  ra8_board_camera_pin_t : uint16_t {
  k_ra8_board_cam_d0 ,
  k_ra8_board_cam_d1 ,
  k_ra8_board_cam_d2 ,
  k_ra8_board_cam_d3 ,
  k_ra8_board_cam_d4 ,
  k_ra8_board_cam_d5 ,
  k_ra8_board_cam_d6 ,
  k_ra8_board_cam_d7 ,
  k_ra8_board_cam_vsync ,
  k_ra8_board_cam_hsync ,
  k_ra8_board_cam_pclk ,
  k_ra8_board_cam_xclk ,
  k_ra8_board_cam_rst ,
  k_ra8_board_cam_int ,
  k_ra8_board_cam_i2c_sda ,
  k_ra8_board_cam_i2c_scl
}
 Pins routed to the parallel-camera connector J35 (DVP mode). More...
enum  ra8_board_camera_bus_t : uint8_t { k_ra8_board_camera_i2c_channel = 1U }
 RIIC controller channel wired to the J35 camera SCCB bus. More...
enum  ra8_board_extmem_base_t : uintptr_t {
  k_ra8_board_xspi_flash_base = 0x80000000UL ,
  k_ra8_board_sdram_base
}
 Memory-mapped base addresses for off-chip XSPI / SDRAM. More...
enum  ra8_board_extmem_size_t : uint32_t {
  k_ra8_board_xspi_flash_size = 0x04000000UL ,
  k_ra8_board_sdram_size = 0x04000000UL
}
 Sizes of the off-chip memories, in bytes. More...
enum  ra8_board_xspi_pin_t : uint16_t {
  k_ra8_board_xspi_cs ,
  k_ra8_board_xspi_clk ,
  k_ra8_board_xspi_dqs ,
  k_ra8_board_xspi_reset ,
  k_ra8_board_xspi_dq0 ,
  k_ra8_board_xspi_dq1 ,
  k_ra8_board_xspi_dq2 ,
  k_ra8_board_xspi_dq3 ,
  k_ra8_board_xspi_dq4 ,
  k_ra8_board_xspi_dq5 ,
  k_ra8_board_xspi_dq6 ,
  k_ra8_board_xspi_dq7
}
 Pins routed to the on-board IS25LX512M Octo-SPI flash. More...
enum  ra8_board_mipi_dsi_pin_t : uint16_t {
  k_ra8_board_mipi_dsi_te ,
  k_ra8_board_mipi_dsi_reset_n ,
  k_ra8_board_mipi_dsi_backlight ,
  k_ra8_board_mipi_dsi_touch_int ,
  k_ra8_board_mipi_dsi_i2c_sda ,
  k_ra8_board_mipi_dsi_i2c_scl
}
 MIPI-DSI display-connector control pins (J32). More...
enum  ra8_board_uart_t : uint8_t { k_ra8_board_uart_console = 0U }
 Identifiers for board-routed UART consoles. More...
enum  ra8_board_uart_sci_channel_t : uint8_t { k_ra8_board_uart_console_sci_channel }
 SCI channel that backs k_ra8_board_uart_console. More...
enum  ra8_board_uart_console_pin_t : uint16_t {
  k_ra8_board_uart_console_pin_txd ,
  k_ra8_board_uart_console_pin_rxd ,
  k_ra8_board_uart_console_pin_rts ,
  k_ra8_board_uart_console_pin_cts
}
 Pin assignments for the J-Link OB VCOM bridge (UM Table 13 p 24). More...
enum  ra8_board_eth_pin_t : uint16_t {
  k_ra8_board_eth_pin_mdint ,
  k_ra8_board_eth_pin_mdc ,
  k_ra8_board_eth_pin_mdio ,
  k_ra8_board_eth_pin_txd0 ,
  k_ra8_board_eth_pin_txd1 ,
  k_ra8_board_eth_pin_txd2 ,
  k_ra8_board_eth_pin_txd3 ,
  k_ra8_board_eth_pin_tx_ctl ,
  k_ra8_board_eth_pin_tx_clk ,
  k_ra8_board_eth_pin_rxd0 ,
  k_ra8_board_eth_pin_rxd1 ,
  k_ra8_board_eth_pin_rxd2 ,
  k_ra8_board_eth_pin_rxd3 ,
  k_ra8_board_eth_pin_rx_ctl ,
  k_ra8_board_eth_pin_rx_clk ,
  k_ra8_board_eth_pin_rstn
}
 Pin assignments for the on-board MaxLinear PEF7071 (GPY111) PHY. More...
enum  ra8_board_eth_index_t : uint8_t {
  k_ra8_board_eth_etha_port = 1U ,
  k_ra8_board_eth_rmac_port = 1U ,
  k_ra8_board_eth_phy_addr = 0U
}
 ETHA / RMAC port and PHY MDIO address for the on-board PHY. More...

Functions

ra8_err_t ra8_board_clocks_init (ra8_board_clock_rates_t *out_rates)
 Initialize the standard EK-RA8D2 clock tree and return its rates.
ra8_err_t ra8_board_io_expander_apply_project_sw4_defaults (void)
 Program the U15 I/O expander to apply the project's SW4 layout.
ra8_err_t ra8_board_io_expander_apply_sw4 (uint8_t output_byte)
 Program an exact U15 SW4 override byte in one bring-up sequence.
ra8_err_t ra8_board_io_expander_apply_sw4_mask (uint8_t output_byte, uint8_t output_mask)
 Override selected SW4 positions while releasing every other position.
ra8_err_t ra8_board_io_expander_set_octospi_active (void)
 Program the U15 I/O expander to request the Octo-SPI SW4 layout.
ra8_err_t ra8_board_io_expander_set_usbhs_device_mode (void)
 Drive the U15 PI4IOE5V6408 I/O expander to select USB-HS device mode.
ra8_err_t ra8_board_io_expander_set_usbhs_host_mode (void)
 Drive the U15 I/O expander to select USB-HS HOST mode.
ra8_err_t ra8_board_usbhs_device_init (void)
 Bring the chip USBHS module up in device mode (HS PHY).
ra8_err_t ra8_board_usbhs_host_init (void)
 Bring the chip USBHS module up in host mode.
ra8_err_t ra8_board_camera_xclk_start (uint32_t frequency_hz)
 Start the J35 camera sensor input clock (XCLK) on P501/GTIOC12A.
ra8_err_t ra8_board_camera_select_parallel (void)
 Drive only SW4-6 ON through U15, selecting J35 parallel DVP.
ra8_err_t ra8_board_camera_route_parallel_pins (void)
 Route J35 D[7:0], VSYNC, HSYNC and PCLK to the CEU peripheral.
ra8_err_t ra8_board_camera_reset (void)
 Pulse the J35 camera reset input and leave the sensor released.
ra8_err_t ra8_board_camera_sccb_read_reg (void *ctx, uint8_t address, uint16_t reg, uint8_t *out_value)
 Read one 16-bit-addressed SCCB register on the J35 camera bus.
ra8_err_t ra8_board_camera_sccb_write_reg (void *ctx, uint8_t address, uint16_t reg, uint8_t value)
 Write one 16-bit-addressed SCCB register on the J35 camera bus.
void ra8_board_camera_delay_ms (void *ctx, uint32_t milliseconds)
 Millisecond delay adapter for transport-independent camera drivers.
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_mipi_dsi_init (void)
 Bring the MIPI-DSI link up (PHY + DSI controller).
ra8_err_t ra8_board_uart_console_init (uint32_t baud)
 Configure SCI8 + PD02/PD03 as the debug-console UART.
ra8_err_t ra8_board_uart_console_write (const uint8_t *data, size_t len)
 Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_read (uint8_t *out, size_t cap, size_t *out_len)
 Polled non-blocking read from the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_flush (void)
 Block until every byte queued on the J-Link OB VCOM console has finished clocking out on the wire.
ra8_err_t ra8_board_ethernet_init (void)
 Bring up the on-board RGMII Ethernet PHY and RMAC1/ETHA1.

Detailed Description

I/O-expander, USB, camera, external-memory, MIPI-DSI, UART console, and Ethernet portion of the EK-RA8D2 v1 board-support layer.

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

Sub-header of ra8_board_ek_ra8d2.h (the thin umbrella). Carries the U15 PI4IOE5V6408 I/O-expander SW4 override functions (Section 6c), the USB-HS / USB-FS routing (Section 7), the parallel-camera connector J35 (Section 8), the Octo-SPI flash + SDRAM external memory (Section 9), the MIPI-DSI graphics expansion port J32 (Section 10), the J-Link OB VCOM serial bridge (Section 11), and the on-board RGMII Ethernet PHY (Section 12).

Every declaration here was moved VERBATIM out of ra8_board_ek_ra8d2.h; no contract, Doxygen block, or HUM/UM citation has changed. The enum that backs the SW4-layout output bytes (ra8_board_pi4ioe_project_t) lives in ra8_board_ek_ra8d2_connectors.h, pulled in below so the I/O-expander functions resolve their referenced constants. Consumers keep including ra8_board_ek_ra8d2.h; this file is pulled in by that umbrella and should not be included directly.

Authoritative source: docs/reference/ek-ra8d2-v1-users-manual.pdf (Rev 1.01, R20UT5523EG0101, October 2025).

Since
0.1.0

Definition in file ra8_board_ek_ra8d2_peripherals.h.

Enumeration Type Documentation

◆ ra8_board_camera_bus_t

enum ra8_board_camera_bus_t : uint8_t

RIIC controller channel wired to the J35 camera SCCB bus.

Enumerator
k_ra8_board_camera_i2c_channel 

RIIC1 serves J35 SCCB.

Definition at line 454 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_camera_pin_t

enum ra8_board_camera_pin_t : uint16_t

Pins routed to the parallel-camera connector J35 (DVP mode).

UM Table 35 ("Camera Expansion Port Assignments in Parallel mode, SW4-6 ON"). Goes into the chip CEU peripheral. P405/P406 are shared with the audio CODEC – see ra8_board_audio_pin_t and jumper J41. P902/PB02/PB03/PB04 are also shared with the parallel graphics expansion port, so DVP camera and parallel TFT are mutually exclusive.

Enumerator
k_ra8_board_cam_d0 

CAM D0, P400.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_d1 

CAM D1, P902.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_d2 

CAM D2, P405 (J41).

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_d3 

CAM D3, P406 (J41).

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_d4 

CAM D4, P700.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_d5 

CAM D5, P701.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_d6 

CAM D6, P702.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_d7 

CAM D7, P703.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_vsync 

CAM VSYNC, PB02.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_hsync 

CAM HSYNC, PB03.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_pclk 

CAM PCLK, PB04.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_xclk 

CAM XCLK, P501.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_rst 

CAM RST, P709.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_int 

CAM INT (IRQ-14), P010.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_i2c_sda 

CAM I2C SDA (SDA1), P511.

EK-RA8D2 UM Table 35 p 48.

k_ra8_board_cam_i2c_scl 

CAM I2C SCL (SCL1), P512.

EK-RA8D2 UM Table 35 p 48.

Definition at line 402 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_eth_index_t

enum ra8_board_eth_index_t : uint8_t

ETHA / RMAC port and PHY MDIO address for the on-board PHY.

Per UM 6.1 ("Ethernet interface") and the canonical FSP example project ethernet_ek_ra8d2_ep (ra8_cfg.txt: "Channel: 1" for both g_ether0 and g_rmac_phy0). The on-board PHY (MaxLinear PEF7071VV16- LLHU, UM Table 27 p 34) is the only device on the MDIO bus and powers up at MDIO address 0; the RA8D2 has two ETHA / RMAC instances, of which port 1 (not port 0) is the one wired to the RJ45 J33 on the EK-RA8D2. Earlier revisions of this header pointed at port 0 – that was wrong; the chip-side MDIO controller never saw a reply because the MDC / MDIO pads on RMAC0 are not routed to the board's PHY.

Enumerator
k_ra8_board_eth_etha_port 

ETHA1 (k_ra8_etha_port_1).

UM 6.1.

k_ra8_board_eth_rmac_port 

RMAC1 (k_ra8_rmac_port_1).

UM 6.1.

k_ra8_board_eth_phy_addr 

MDIO addr of the on-board PHY (HW strap on PEF7071, UM Table 27 p 34).

Definition at line 952 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_eth_pin_t

enum ra8_board_eth_pin_t : uint16_t

Pin assignments for the on-board MaxLinear PEF7071 (GPY111) PHY.

Per UM Table 26 ("Ethernet Port Assignments") p 33. The PHY is wired to the RA8D2 ETHERC0 / RMAC0 in RGMII mode (UM 6.1: "RGMII Ethernet Physical Layer Transceiver"). The 25 MHz reference clock is sourced from a discrete oscillator (ECS-250-10-37B-CTN-TR, UM Table 27 p 34) connected directly to the PHY – the MCU does not drive REFCLK. Ethernet data rails are gated by trace-cut links E18..E24, E33, E34, E36..E38 (all closed by default).

Enumerator
k_ra8_board_eth_pin_mdint 

MDINT, P107.

UM Table 26 p 33.

k_ra8_board_eth_pin_mdc 

MDC, P415.

UM Table 26 p 33.

k_ra8_board_eth_pin_mdio 

MDIO, P414.

UM Table 26 p 33.

k_ra8_board_eth_pin_txd0 

TXD0, P307 (E21).

UM Table 26 p 33.

k_ra8_board_eth_pin_txd1 

TXD1, P306 (E20).

UM Table 26 p 33.

k_ra8_board_eth_pin_txd2 

TXD2, P305 (E19).

UM Table 26 p 33.

k_ra8_board_eth_pin_txd3 

TXD3, P304 (E18).

UM Table 26 p 33.

k_ra8_board_eth_pin_tx_ctl 

TX_CTL, P310 (E22).

UM Table 26 p 33.

k_ra8_board_eth_pin_tx_clk 

TX_CLK, P309 (E23).

UM Table 26 p 33.

k_ra8_board_eth_pin_rxd0 

RXD0, P906 (E36).

UM Table 26 p 33.

k_ra8_board_eth_pin_rxd1 

RXD1, P907 (E34).

UM Table 26 p 33.

k_ra8_board_eth_pin_rxd2 

RXD2, P908 (E33).

UM Table 26 p 33.

k_ra8_board_eth_pin_rxd3 

RXD3, P909 (E24).

UM Table 26 p 33.

k_ra8_board_eth_pin_rx_ctl 

RX_CTL, P206 (E38).

UM Table 26 p 33.

k_ra8_board_eth_pin_rx_clk 

RX_CLK, P905 (E37).

UM Table 26 p 33.

k_ra8_board_eth_pin_rstn 

RSTN, P708.

UM Table 26 p 33.

Definition at line 902 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_extmem_base_t

enum ra8_board_extmem_base_t : uintptr_t

Memory-mapped base addresses for off-chip XSPI / SDRAM.

Per UM Section 6.3 (Octo-SPI flash, IS25LX512M-JHLE 64 MB on the Octo-SPI peripheral) and Section 6.4 (IS42S32160F-6BLI 64 MB SDRAM on the SDRAMC bus). Bases are documented in the chip Hardware User's Manual memory map; the board UM only specifies the parts and their pin connections.

Enumerator
k_ra8_board_xspi_flash_base 

64 MB IS25LX512M (chip HUM memory map).

k_ra8_board_sdram_base 

64 MB IS42S32160F (per linker scripts + ra8_sdramc.c).

Definition at line 595 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_extmem_size_t

enum ra8_board_extmem_size_t : uint32_t

Sizes of the off-chip memories, in bytes.

Enumerator
k_ra8_board_xspi_flash_size 

64 MiB.

UM Section 6.3 p 35.

k_ra8_board_sdram_size 

64 MiB.

UM Section 6.4 p 36.

Definition at line 602 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_i3c0_pin_t

enum ra8_board_i3c0_pin_t : uint16_t

IIC_B / I3C channel-0 board pins (SCL0 / SDA0), UM Table 20 p 28.

The I3C ch0 I2C-compatibility bus is routed to P400 (SCL0) and P401 (SDA0) when SW4-5 selects I3C mode (UM Table 20 p 28 + Section 5.5.3 p 32). These two pads double as SDHI0 CMD/CLK under the default I2C-mode routing, so use these names only when the board is jumpered for the I3C bus.

Enumerator
k_ra8_board_i3c0_pin_scl 

P400 SCL0.

UM Table 20 p 28.

k_ra8_board_i3c0_pin_sda 

P401 SDA0.

UM Table 20 p 28.

Definition at line 252 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_mipi_dsi_pin_t

enum ra8_board_mipi_dsi_pin_t : uint16_t

MIPI-DSI display-connector control pins (J32).

UM Table 34 ("MIPI Graphics Expansion Port Assignments"). The high-speed DSI clock + 2 data lanes (MIPI_DSI_CL_P/N, MIPI_DSI_DL0_P/N, MIPI_DSI_DL1_P/N) are dedicated MIPI-PHY balls and are not exposed as general-purpose port pins; only the low-speed control side (TE / reset / backlight / I2C touch / touch INT) is BSP-addressable.

Enumerator
k_ra8_board_mipi_dsi_te 

DSI tearing-effect, P411.

UM Table 34 p 45.

k_ra8_board_mipi_dsi_reset_n 

DSI DISP_RST, P606.

UM Table 34 p 45.

k_ra8_board_mipi_dsi_backlight 

DSI DISP_BLEN, P514.

UM Table 34 p 45.

k_ra8_board_mipi_dsi_touch_int 

DSI DISP_INT (IRQ-19), P111.

UM Table 34 p 45.

k_ra8_board_mipi_dsi_i2c_sda 

DSI I2C SDA1, P511.

UM Table 34 p 45.

k_ra8_board_mipi_dsi_i2c_scl 

DSI I2C SCL1, P512.

UM Table 34 p 45.

Definition at line 696 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_touch_wiring_t

enum ra8_board_touch_wiring_t : uint32_t

Where the on-board GoodIX GT911 capacitive-touch controller sits.

The Parallel Graphics Expansion Board's ER-TFT070-6 carries one GT911, on one bus, at one address. These three values are that wiring, stated once: the I3C block's I2C-compatibility channel it hangs off, its 7-bit target address, and the fast-mode rate the panel's touch bus is specified for. Eight applications used to declare their own copy of each under their own prefix, and all eight also hardcoded a source clock instead of asking CGC – see ra8_board_touch_open, which is the supported way to consume these.

The SOURCE CLOCK is deliberately absent. It is not a board fact: PCLKA is whatever the application's CGC tree settled on, so the bit-rate divider must be solved against ra8_cgc_get_clock_hz at run time, never against a constant.

Invariant
k_ra8_board_touch_i3c_channel indexes an I3C I2C-compat channel the chip implements.
See also
ra8_board_touch_open Brings this bus up and opens the driver.
ra8_board_i3c0_pin_t The SCL0 / SDA0 pads this channel drives.
Since
0.1.0
Enumerator
k_ra8_board_touch_i3c_channel 

IIC_B / I3C channel 0 carries the GT911.

k_ra8_board_touch_target_7b 

GT911 default 7-bit target address.

k_ra8_board_touch_bus_hz 

Fast-mode I2C rate for the touch bus.

Definition at line 285 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_uart_console_pin_t

Pin assignments for the J-Link OB VCOM bridge (UM Table 13 p 24).

PD02 / PD03 are always wired to the debug MCU's CDC bridge. PD04 / PD05 are the optional RTS / CTS lines (links E17 / E9, both closed by default). Chip-coordinate names: P1302 / P1303 / P1304 / P1305 (port 13, pins 2..5).

Enumerator
k_ra8_board_uart_console_pin_txd 

PD02 TXD.

UM Table 13 p 24.

k_ra8_board_uart_console_pin_rxd 

PD03 RXD.

UM Table 13 p 24.

k_ra8_board_uart_console_pin_rts 

PD04 RTS (link E17).

UM Table 13 p 24.

k_ra8_board_uart_console_pin_cts 

PD05 CTS (link E9).

UM Table 13 p 24.

Definition at line 770 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_uart_sci_channel_t

SCI channel that backs k_ra8_board_uart_console.

Exposed as an enum (not a macro) so test code and applications can reference the channel without re-encoding the magic number. The value comes from PD02/PD03's Multiplexed Pin Function Selector row in the chip HUM I/O Ports chapter (TXD8/RXD8 alternate).

Enumerator
k_ra8_board_uart_console_sci_channel 

PD02/PD03 -> SCI8 (verified on real EK-RA8D2 v1 silicon).

Definition at line 756 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_uart_t

enum ra8_board_uart_t : uint8_t

Identifiers for board-routed UART consoles.

The EK-RA8D2 v1 carries the J-Link OB debug MCU's USB-CDC virtual-COM bridge on chip pins PD02 (TXD) / PD03 (RXD) per UM Table 13 p 24. Hardware-flow-control lines PD04 (RTS) and PD05 (CTS) are present on the same connector but are gated by trace-cut links E17 / E9 and are not used by the basic console wiring.

On the RA8D2 PD02/PD03 are the SCI8 TXD8/RXD8 alternate functions (chip HUM "Multiplexed Pin Function Selector"); the BSP forwards to SCI channel 8 via ra8_sci_init / ra8_sci_write_polling / ra8_sci_getc_polling.

Enumerator
k_ra8_board_uart_console 

J-Link OB VCOM bridge: PD02 TXD / PD03 RXD on SCI8.

EK-RA8D2 UM Table 13 p 24.

Definition at line 742 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_usbfs_pin_t

enum ra8_board_usbfs_pin_t : uint16_t

USB-FS (J11) board-routed port pins, UM Table 22 p 30.

The full-speed peripheral on J11 (USB Type-C) exposes four board-routed pins: the D+/D- differential pair, the VBUS sense input, and the MCU-driven VBUS-enable GPIO. Route D+/D-/VBUS to the USBFS peripheral function (k_ra8_psel_usb_fs) and drive VBUSEN as a GPIO output (LOW = device role, HIGH = supply 5 V VBUS for host role).

These are the single source of truth for the EK-RA8D2 USB-FS pinout: applications reference these names instead of re-encoding the port/pin pair, so the board fact lives in exactly one place.

Enumerator
k_ra8_board_usbfs_pin_dp 

P8_14 D+.

UM Table 22 p 30.

k_ra8_board_usbfs_pin_dm 

P8_15 D-.

UM Table 22 p 30.

k_ra8_board_usbfs_pin_vbus 

P4_07 VBUS sense.

UM Table 22 p 30.

k_ra8_board_usbfs_pin_vbusen 

P5_00 VBUSEN GPIO.

UM Table 22 p 30.

Definition at line 232 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_usbhs_pin_t

enum ra8_board_usbhs_pin_t : uint16_t

USBHS host/device routing per UM Table 28 p 34.

USBHS (J7, USB Type-C). The HS PHY DM/DP differential pair (USBH_P/USBH_N) is internal to the chip and not a board-routed port pin. VBUS sense (USBHS_cVBUS_CON) and CC pins are PHY-side. Only the bus signals listed below are exposed to user firmware.

USB-FS (J11, USB Type-C, UM Table 22 p 30) is the host/dev port for the full-speed peripheral and follows the same arrangement.

Enumerator
k_ra8_board_usbhs_pin_vbus 

P4_08 USBHS_VBUS sense.

UM Table 28 p 34.

k_ra8_board_usbhs_pin_pwr 

PD07 J7 host-power switch (HIGH = U18 drives 5 V VBUS).

UM 6.2.

Definition at line 207 of file ra8_board_ek_ra8d2_peripherals.h.

◆ ra8_board_xspi_pin_t

enum ra8_board_xspi_pin_t : uint16_t

Pins routed to the on-board IS25LX512M Octo-SPI flash.

UM Table 29 ("Octo-SPI Flash Assignments"). Selection is gated by SW4-3 (Octo-SPI vs Arduino/Pmod1). The chip-select strobe is OSPI_FLASH_S_L, mapped to P104.

Enumerator
k_ra8_board_xspi_cs 

OSPI_FLASH_S_L, P104.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_clk 

OSPI_FLASH_C, P808.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dqs 

OSPI_FLASH_DQS, P801.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_reset 

OSPI_FLASH_RESET_L, P106.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq0 

OSPI_FLASH_DQ0, P100.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq1 

OSPI_FLASH_DQ1, P803.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq2 

OSPI_FLASH_DQ2, P103.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq3 

OSPI_FLASH_DQ3, P101.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq4 

OSPI_FLASH_DQ4, P102.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq5 

OSPI_FLASH_DQ5, P800.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq6 

OSPI_FLASH_DQ6, P802.

EK-RA8D2 UM Table 29 p 35.

k_ra8_board_xspi_dq7 

OSPI_FLASH_DQ7, P804.

EK-RA8D2 UM Table 29 p 35.

Definition at line 616 of file ra8_board_ek_ra8d2_peripherals.h.

Function Documentation

◆ ra8_board_camera_delay_ms()

void ra8_board_camera_delay_ms ( void * ctx,
uint32_t milliseconds )

Millisecond delay adapter for transport-independent camera drivers.

Ignores ctx and delegates the bounded delay to ra8_delay_ms.

Parameters
[in]ctxUnused transport context; may be nullptr.
[in]millisecondsDelay duration.
Precondition
The SysTick timebase is initialized.
milliseconds is acceptable to the platform delay service.
Postcondition
At least the requested delay interval has elapsed.
No camera or transport state is modified directly.
Note
Blocking and not suitable for interrupt context.
Since
0.1.0

Definition at line 179 of file ra8_board_ek_ra8d2_camera.c.

References ra8_delay_ms().

Referenced by cam_sensor_bind(), internal_c6_cam_sensor_bind(), and sensor_bind().

◆ ra8_board_camera_reset()

ra8_err_t ra8_board_camera_reset ( void )
nodiscard

Pulse the J35 camera reset input and leave the sensor released.

Claims P709 as an output, holds reset low, then releases it high.

Returns
ra8_err_t Error code.
Return values
k_ra8_okP709 was driven low, then high.
otherForwarded GPIO initialization/write error.
Precondition
The IOPORT module is powered.
P709 is available for the camera reset function.
Postcondition
CAM_RST is high after two 20 ms settle intervals.
On success the reset pin remains claimed as a GPIO output.
Note
Not thread-safe; call from camera initialization context.
Since
0.1.0

Definition at line 128 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_reset_high_ms, k_camera_reset_low_ms, k_ra8_board_cam_rst, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, ra8_delay_ms(), ra8_gpio_output_init(), and ra8_gpio_write().

Referenced by c6_cam_camera_init(), cam_run(), and internal_bring_up_sensor().

◆ ra8_board_camera_route_parallel_pins()

ra8_err_t ra8_board_camera_route_parallel_pins ( void )
nodiscard

Route J35 D[7:0], VSYNC, HSYNC and PCLK to the CEU peripheral.

Claims and muxes the eleven parallel-camera pads in board order.

Returns
Error code.
Return values
k_ra8_okEvery parallel-camera pin was routed.
otherFirst propagated PFS routing error.
Precondition
SW4-6 selects the parallel-camera path.
The eleven J35 CEU pins are not claimed by another peripheral.
Postcondition
On success every listed pin uses the CEU peripheral function.
On failure no later pin in the routing list is touched.
Note
Init-context only; partial routing may remain after an error.
Since
0.1.0

Definition at line 113 of file ra8_board_ek_ra8d2_camera.c.

References k_ra8_ok, k_ra8_psel_ceu, ra8_pfs_route_peripheral(), and s_camera_parallel_pins.

Referenced by c6_cam_camera_init(), cam_prepare_capture(), and internal_bring_up_capture_pipeline().

◆ ra8_board_camera_sccb_read_reg()

ra8_err_t ra8_board_camera_sccb_read_reg ( void * ctx,
uint8_t address,
uint16_t reg,
uint8_t * out_value )
nodiscard

Read one 16-bit-addressed SCCB register on the J35 camera bus.

Signature intentionally matches the transport callback used by ra8_ov5640; the BSP remains independent of that optional sensor library.

Parameters
[in]ctxUnused transport context; may be nullptr.
[in]address7-bit SCCB target address.
[in]reg16-bit sensor register address.
[out]out_valueRegister value on success.
Returns
ra8_err_t Forwarded RIIC result.
Return values
k_ra8_okOne register byte was read.
k_ra8_err_null_ptrout_value was nullptr.
otherPropagated RIIC transfer error.
Precondition
RIIC1 is initialized for the J35 SCCB bus.
The sensor is clocked and released from reset.
Postcondition
On success out_value contains the addressed register byte.
The RIIC bus is idle after the completed transfer.
Note
Not thread-safe with respect to RIIC1.
Since
0.1.0

Definition at line 146 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_high_byte_shift, k_camera_reg_address_bytes, k_ra8_board_camera_i2c_channel, RA8_CHECK_NULL_PTR, and ra8_i2c_transfer().

Referenced by cam_sensor_bind(), internal_c6_cam_sensor_bind(), and sensor_sccb_read().

◆ ra8_board_camera_sccb_write_reg()

ra8_err_t ra8_board_camera_sccb_write_reg ( void * ctx,
uint8_t address,
uint16_t reg,
uint8_t value )
nodiscard

Write one 16-bit-addressed SCCB register on the J35 camera bus.

Parameters
[in]ctxUnused transport context; may be nullptr.
[in]address7-bit SCCB target address.
[in]reg16-bit sensor register address.
[in]valueRegister value to write.
Returns
ra8_err_t Forwarded RIIC result.
Return values
k_ra8_okThe complete address and value payload was written.
otherPropagated RIIC write error.
Precondition
RIIC1 is initialized for the J35 SCCB bus.
The sensor is clocked and released from reset.
Postcondition
On success the target accepted the addressed register byte.
The RIIC bus is idle after the completed transfer.
Note
Not thread-safe with respect to RIIC1.
Since
0.1.0

Definition at line 163 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_high_byte_shift, k_camera_write_bytes, k_ra8_board_camera_i2c_channel, and ra8_i2c_write().

Referenced by cam_sensor_bind(), internal_c6_cam_sensor_bind(), and sensor_sccb_write().

◆ ra8_board_camera_select_parallel()

ra8_err_t ra8_board_camera_select_parallel ( void )
nodiscard

Drive only SW4-6 ON through U15, selecting J35 parallel DVP.

Applies a masked U15 override without changing unrelated switches.

Returns
Error code.
Return values
k_ra8_okU15 selected the parallel-camera path.
otherPropagated expander or RIIC error.
Precondition
Board I/O-expander services and RIIC1 are available.
The Camera Expansion Board is connected at J35.
Postcondition
On success SW4-6 is overridden to its ON state.
Other U15 SW4 override bits retain their prior values.
Note
Init-context only; this changes shared physical routing.
Since
0.1.0

Definition at line 106 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_sw46_mask, k_camera_sw46_output, and ra8_board_io_expander_apply_sw4_mask().

Referenced by c6_cam_camera_init(), cam_bringup(), and internal_bring_up_sensor().

◆ ra8_board_camera_xclk_start()

ra8_err_t ra8_board_camera_xclk_start ( uint32_t frequency_hz)
nodiscard

Start the J35 camera sensor input clock (XCLK) on P501/GTIOC12A.

Configures GPT12 saw-PWM from PCLKD and routes its A output to P501.

Parameters
[in]frequency_hzRequested non-zero camera input-clock frequency.
Returns
Error code.
Return values
k_ra8_okGPT12 is running and P501 is routed.
k_ra8_err_invalid_argThe requested divisor is not representable.
otherPropagated clock, GPT, or pin-routing error.
Precondition
CGC and module-stop services are initialized.
P501 is available for the camera clock function.
Postcondition
On success GPT12 runs continuously at the nearest integer divisor.
On success P501 uses the high-speed GPT peripheral drive setting.
Note
Init-context only; this claims shared board resources.
Since
0.1.0

Definition at line 59 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_gpt_period_max, k_camera_xclk_gpt_channel, k_ra8_board_cam_xclk, k_ra8_clock_id_pclkd, k_ra8_err_invalid_arg, k_ra8_gpt_disable_none, k_ra8_gpt_mode_saw_pwm, k_ra8_gpt_pin_a, k_ra8_gpt_pol_active_high, k_ra8_gpt_ps_div_1, k_ra8_gpt_stop_low, k_ra8_ok, k_ra8_pfs_dscr_high_speed_high, k_ra8_psel_gpt0, ra8_cgc_get_clock_hz(), ra8_gpt_init(), ra8_gpt_pwm_pin_configure(), ra8_pfs_route_peripheral(), and ra8_pfs_set_drive_strength().

Referenced by c6_cam_camera_init(), cam_bringup(), and internal_bring_up_sensor().

◆ ra8_board_clocks_init()

ra8_err_t ra8_board_clocks_init ( ra8_board_clock_rates_t * out_rates)
nodiscard

Initialize the standard EK-RA8D2 clock tree and return its rates.

Keeps chip-specific CGC selection inside the board-composition layer while exposing the fixed rates needed by application-owned timebases and peripheral configurations.

Parameters
[out]out_ratesInitialized CPUCLK0 and PCLKA rates.
Returns
Error code from the board clock bring-up.
Return values
k_ra8_okClock initialization succeeded and out_rates is valid.
k_ra8_err_invalid_argout_rates is null.
otherPropagated clock-generator initialization error.
Precondition
Called from single-threaded board initialization.
Postcondition
On success, the standard PLL1 clock tree is active.
On failure, out_rates is unchanged when nonnull.
Note
Not thread-safe; call once during board initialization.
Since
0.1.0

Initialize the standard EK-RA8D2 clock tree and return its rates.

Delegates the register-level transition to the CGC HAL, then returns the board-qualified CPUCLK0 and PCLKA constants without exposing a concrete clock driver to application code.

Parameters
[out]out_ratesInitialized board clock rates.
Returns
Board clock initialization status.
Return values
k_ra8_okClock initialization and rate publication succeeded.
k_ra8_err_invalid_argout_rates is null.
otherPropagated clock-generator initialization error.
Precondition
Called from the single-threaded board boot path.
Postcondition
On success, PLL1 supplies the standard EK-RA8D2 clock tree.
On failure, out_rates is unchanged when nonnull.
Note
Not thread-safe; call once during board initialization.
Since
0.1.0

Definition at line 58 of file ra8_board_ek_ra8d2_comms.c.

References k_ra8_cpuclk0_hz, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_pclka_hz, and ra8_cgc_init().

Referenced by internal_c6_cam_setup_or_halt(), internal_setup_or_halt(), and pdm_demo_clocks_or_halt().

◆ ra8_board_ethernet_init()

ra8_err_t ra8_board_ethernet_init ( void )

Bring up the on-board RGMII Ethernet PHY and RMAC1/ETHA1.

Hardware-resets the PEF7071/GPY111 through RSTN (P708), leaving that signal as a GPIO output driven high. The other 15 Ethernet signals are routed to their RGMII alternate functions before the ESWM clocks, power, module-stop gates, and COMA buffer pool are brought up. ETHA1 then walks RESET to CONFIG, the external media mux selects RGMII, and RMAC1 starts with its internal xMII profile at MII, 100 Mbps, full duplex.

After RMAC1 programming, ETHA1 enters OPERATION and this function soft-resets the PHY, applies the RGMII receive skew, advertises the supported 10/100 modes, and restarts PHY auto-negotiation internally.

Returns
ra8_err_t Result from the first failing Ethernet bring-up stage.
Return values
k_ra8_okBring-up completed and PHY auto-negotiation restarted.
k_ra8_err_gpio_conflictRSTN or an alternate-function pin is owned.
k_ra8_err_invalid_stateAn Ethernet module-stop reference is saturated.
k_ra8_err_hw_timeoutA clock, module-stop, ETHA, COMA, or MDIO wait timed out.
Precondition
IOPORT module powered (reset default).
ra8_mstp_init() has run.
Postcondition
Fifteen Ethernet pins use the RGMII alternate; RSTN remains GPIO-high.
RMAC1 and ETHA1 are operational and PHY auto-negotiation is running.
Note
Not thread-safe; call once during board bring-up.
Since
0.1.0

Definition at line 626 of file ra8_board_ek_ra8d2_ethernet.c.

References internal_eth_etha_to_operation(), internal_eth_phy_chip_init(), internal_eth_phy_hw_reset(), internal_eth_rmac_program(), internal_eth_route_alt_pins(), k_ra8_board_eth_rmac_port, k_ra8_ok, priv_ra8_board_eth_eswm_bring_up(), priv_ra8_board_eth_etha_to_config(), and ra8_eth_rgmii_select().

Referenced by demo_setup_or_halt(), eop_run_once(), and internal_demo_setup_or_halt().

◆ ra8_board_io_expander_apply_project_sw4_defaults()

ra8_err_t ra8_board_io_expander_apply_project_sw4_defaults ( void )
nodiscard

Program the U15 I/O expander to apply the project's SW4 layout.

Equivalent to ra8_board_io_expander_set_usbhs_device_mode but writes k_ra8_board_pi4ioe_output_project_default (0xF2) to the expander's output register instead of 0xFF. After the write the board is forced into "Pmod1 UART, Octo-SPI inactive, Arduino + mikroBUS active, I2C on mikroBUS, USBHS Device" regardless of the physical DIP positions.

Returns
ra8_err_t Error code.
Return values
k_ra8_okAll three U15 register writes succeeded.
k_ra8_err_gpio_conflictP512/P511 already owned by another driver.
k_ra8_err_hw_init_failedRIIC1 initialization failed.
k_ra8_err_nackU15 didn't ACK the register write.
Precondition
IOPORT module powered (reset default).
ra8_mstp_init has run.
Postcondition
P512/P511 are routed to SCL1/SDA1; RIIC1 is initialized at 100 kHz; U15.P0..P7 are configured as outputs driven to k_ra8_board_pi4ioe_output_project_default.
Note
Not thread-safe; call once from the boot context before any Pmod / Arduino / mikroBUS init that depends on SW4 routing.
Since
0.1.0

Program the U15 I/O expander to apply the project's SW4 layout.

Writes k_ra8_board_pi4ioe_output_project_default (0xF2) to the expander's output register, which forces SW4-1 ON + SW4-2 OFF (Pmod1 UART) + SW4-3 ON (Octo-SPI inactive) + SW4-4 ON (Arduino/mikroBUS active) + SW4-5 OFF (I2C), regardless of the physical DIP positions. See the header for the full per-bit table.

Returns
ra8_err_t Error code.
Return values
k_ra8_okAll bring-up steps completed; SW4 layout latched.
k_ra8_err_gpio_conflictP512/P511 already owned.
k_ra8_err_hw_init_failedRIIC1 initialization failed.
k_ra8_err_nackU15 didn't ACK one of the register writes.
Precondition
IOPORT module powered (reset default).
ra8_mstp_init has run.
Postcondition
On success U15 outputs are 0xF2; the project's expected SW4 layout is active.
P512/P511 are routed to SCL1/SDA1 and RIIC1 is brought up at 100 kHz, ready for subsequent in-tree I2C work.
Note
Not thread-safe; call once early in main() before any code that depends on Pmod1 / Arduino / mikroBUS routing.
Since
0.1.0

Definition at line 814 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_apply_mask(), k_ra8_board_pi4ioe_iodir_all_outputs, and k_ra8_board_pi4ioe_output_project_default.

Referenced by combo_setup_or_halt(), internal_setup_or_halt(), and riic_target_setup_or_halt().

◆ ra8_board_io_expander_apply_sw4()

ra8_err_t ra8_board_io_expander_apply_sw4 ( uint8_t output_byte)
nodiscard

Program an exact U15 SW4 override byte in one bring-up sequence.

Writes the requested output latch before enabling U15's outputs, avoiding an intermediate board-mux layout. Bit n = 1 requests SW4-(n+1) OFF and bit n = 0 requests it ON.

Parameters
[in]output_byteExact byte for U15's output register.
Returns
ra8_err_t Error code.
Return values
k_ra8_okU15 is driving output_byte.
k_ra8_err_gpio_conflictRIIC1 pins are already owned.
k_ra8_err_hw_init_failedRIIC1 initialization failed.
k_ra8_err_nackU15 did not acknowledge a register write.
Precondition
IOPORT is powered and ra8_mstp_init has run.
Postcondition
RIIC1 is initialized at 100 kHz and U15 drives output_byte.
Note
Not thread-safe; call once from boot context.
Since
0.1.0

Definition at line 820 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_apply_mask(), and k_ra8_board_pi4ioe_iodir_all_outputs.

◆ ra8_board_io_expander_apply_sw4_mask()

ra8_err_t ra8_board_io_expander_apply_sw4_mask ( uint8_t output_byte,
uint8_t output_mask )
nodiscard

Override selected SW4 positions while releasing every other position.

Parameters
[in]output_byteOutput latch values using the SW4 active-low convention.
[in]output_maskBit mask of U15 pins to drive; clear bits remain inputs.
Returns
ra8_err_t Error code from RIIC1 or U15 programming.
Postcondition
U15's output latch is output_byte and IODIR is output_mask.
Note
Not thread-safe; call once from boot context.
Since
0.1.0

Definition at line 826 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_apply_mask().

Referenced by ra8_board_camera_select_parallel().

◆ ra8_board_io_expander_set_octospi_active()

ra8_err_t ra8_board_io_expander_set_octospi_active ( void )
nodiscard

Program the U15 I/O expander to request the Octo-SPI SW4 layout.

Writes k_ra8_board_pi4ioe_output_octospi_active (0xF8, the all-SW4-OFF layout with OSPI_OE_L asserted – see that enum's definition) to the U15 output register with the port set to outputs.

IMPORTANT – this does NOT, and CANNOT, connect the flash. A firmware sweep over the entire U15 output space (all 256 output bytes, plus released-inputs / Hi-Z / per-bit single-line overrides; 2026-06, issue #44, docs/HARDWARE_BRINGUP.md) re-read the 1S JEDEC ID after each config and saw zero change: the flash stays silent (bus at the board pull-ups) for every U15 state. The U15 expander is therefore a pure SW4 sense / override whose GPIOs are NOT in the OSPI DQ/CK/CS path; the flash is gated only by the SW4-3 analog mux, which is hardware-only and not reachable from firmware. (When U15 is released to inputs, reg 0x0F reads 0xF8, but the exact U15<->SW4 bit mapping is not published in the UM – it lives in the EK-RA8D2 Design Package schematic – and has not yet been verified on this EVM, so that value is NOT actionable.) This call is kept only as an inert courtesy write; it has no bearing on flash reachability. See examples/.../flash_journal/README.md and issue #44.

Returns
ra8_err_t Error code.
Return values
k_ra8_okAll U15 register writes succeeded.
k_ra8_err_busyRIIC1 bus was held by another controller.
k_ra8_err_hw_timeoutU15 did not respond on RIIC1.
k_ra8_err_nackU15 didn't ACK the register write.
Precondition
IOPORT module powered (reset default).
ra8_mstp_init has run.
Postcondition
P512/P511 are routed to SCL1/SDA1; RIIC1 is initialized at 100 kHz; U15.P0..P7 are outputs driven to k_ra8_board_pi4ioe_output_octospi_active (inert w.r.t. the OSPI bus, which is gated by the hardware-only SW4-3 mux – see

).

Note
Not thread-safe; call once from the boot context before the Octo-SPI bring-up.
Since
0.1.0

Definition at line 831 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_apply_mask(), k_ra8_board_pi4ioe_iodir_all_outputs, and k_ra8_board_pi4ioe_output_octospi_active.

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

◆ ra8_board_io_expander_set_usbhs_device_mode()

ra8_err_t ra8_board_io_expander_set_usbhs_device_mode ( void )
nodiscard

Drive the U15 PI4IOE5V6408 I/O expander to select USB-HS device mode.

The EK-RA8D2 v1 carries a PI4IOE5V6408 8-bit I2C I/O expander at U15 (I2C address 0x43, EK-RA8D2 v1 UM Rev 1.01 Section 5.5.3 p 32 + Section 4 p 16). U15 sits in parallel with the eight DIP switches of SW4 – when configured as outputs, U15's port pins override SW4 and gate the same on-board mux that SW4 drives, including SW4-8 which selects USB function on J7 (USB-HS): OFF = Device, ON = Host.

U15 register convention (from the PI4IOE5V6408 datasheet register map):

  • 0x01 Device-ID (expect 0xA0 or 0xA2)
  • 0x03 I/O direction (1 = output)
  • 0x05 Output state (1 = HIGH = SW4 OFF, 0 = LOW = SW4 ON)
  • 0x07 Output Hi-Z (1 = Hi-Z)
  • 0x0D Pull-up / pull-down select

Polarity: the PI4IOE5V6408 datasheet defines a HIGH output bit as the released (pulled-up) level, so SW4-8 OFF (the silk-screen "Device" position) corresponds to U15.P7 = 1. The exact bit<->SW4-channel mapping is not in the UM (it is in the Design Package schematic) and is pending on-hardware verification on this EVM. We write 0xFF (all bits HIGH = all SW4 channels in their default OFF position) which puts USB-HS into Device mode and leaves the other muxed peripherals at their EK-RA8D2 default routing.

Routes P512 -> SCL1 and P511 -> SDA1 and initializes RIIC channel 1 at 100 kHz.

Returns
ra8_err_t Error code.
Return values
k_ra8_okAll three register writes succeeded; U15 is driving SW4-8 = OFF (Device mode).
k_ra8_err_gpio_conflictP512/P511 already owned.
k_ra8_err_hw_init_failedRIIC1 initialization failed.
k_ra8_err_nackU15 didn't ACK the register write.
Precondition
IOPORT module powered (reset default).
ra8_mstp_init has run.
Postcondition
P512/P511 are routed to SCL1/SDA1; RIIC1 is initialized at 100 kHz; U15.P0..P7 are configured as outputs driven HIGH.
Note
Not thread-safe; call once from the boot context immediately before ra8_board_usbhs_device_init.
Since
0.1.0

Definition at line 762 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_apply_mask(), k_ra8_board_pi4ioe_iodir_all_outputs, and k_ra8_board_pi4ioe_output_all_high.

Referenced by ra8_board_usbhs_device_init().

◆ ra8_board_io_expander_set_usbhs_host_mode()

ra8_err_t ra8_board_io_expander_set_usbhs_host_mode ( void )
nodiscard

Drive the U15 I/O expander to select USB-HS HOST mode.

Same U15 mechanism as ra8_board_io_expander_set_usbhs_device_mode (see that function for the expander register convention), but writes k_ra8_board_pi4ioe_output_usbhs_host (0x72): the project-default SW4 layout with bit 7 (SW4-8, USBHS role) driven LOW = ON = Host. In the host position the board's J7 VBUS switch supplies bus power to an attached device; in the default OFF/device position J7 expects VBUS from an external host and an attached USB stick stays dark.

Returns
ra8_err_t Error code.
Return values
k_ra8_okU15 is driving SW4-8 = ON (Host mode).
k_ra8_err_gpio_conflictP512/P511 already owned.
k_ra8_err_hw_init_failedRIIC1 initialization failed.
k_ra8_err_nackU15 didn't ACK a register write.
Precondition
IOPORT module powered (reset default).
ra8_mstp_init has run.
Postcondition
U15.P0..P7 are outputs driving 0x72; J7 supplies VBUS.
P512/P511 are routed to SCL1/SDA1 with RIIC1 at 100 kHz.
Note
Not thread-safe; call once from the boot context before the USB host bring-up.
Since
0.1.0

Drive the U15 I/O expander to select USB-HS HOST mode.

See the public header for the documented contract; applies the project SW4 layout with SW4-8 (USBHS role) driven ON so the board supplies VBUS on J7.

Returns
Result code.
Return values
k_ra8_okU15 is driving the host-role layout.
Precondition
ra8_mstp_init has run.
The I2C bus to U15 is reachable.
Postcondition
U15 outputs 0x72; J7 is in host role.
RIIC1 is initialized as a side effect of the shared bring-up.
Note
Not thread-safe; boot context only.
Since
0.1.0

Definition at line 782 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_apply_mask(), k_ra8_board_pi4ioe_iodir_all_outputs, and k_ra8_board_pi4ioe_output_usbhs_host.

Referenced by cdc_route_usb_or_halt(), dfu_route_usb_or_halt(), fileops_route_usb_or_halt(), hid_route_usb_or_halt(), microsd_route_usb_or_halt(), mlun_route_usb_or_halt(), ospirw_route_usb_or_halt(), selftest_route_usb_or_halt(), and wlun_route_usb_or_halt().

◆ ra8_board_mipi_dsi_init()

ra8_err_t ra8_board_mipi_dsi_init ( void )
nodiscard

Bring the MIPI-DSI link up (PHY + DSI controller).

Return values
k_ra8_ok/ k_ra8_err_not_supported (until MIPI-DSI HAL lands)
Since
0.1.0

Definition at line 173 of file ra8_board_ek_ra8d2_comms.c.

References k_ra8_ok, ra8_mipi_dsi_hs_clock_start(), ra8_mipi_dsi_init(), ra8_mipi_phy_init(), s_mipi_panel_cfg, and s_mipi_phy_cfg.

◆ ra8_board_uart_console_flush()

ra8_err_t ra8_board_uart_console_flush ( void )
nodiscard

Block until every byte queued on the J-Link OB VCOM console has finished clocking out on the wire.

Thin wrapper around ra8_sci_flush(k_ra8_board_uart_console_sci_channel) that polls CSR.TEND on the SCI8 channel that backs the J-Link OB VCOM bridge (HUM Ch 38.2.17 "CSR : Common Status Register", p 2225). The intended caller is a panic-handler that needs the failure log to reach the host before WFI gates the SCI clock and silently drops the remaining FIFO contents.

Returns
ra8_err_t error code.
Return values
k_ra8_okTEND observed (or fake stub).
k_ra8_err_not_initializedra8_board_uart_console_init not called.
k_ra8_err_hw_timeoutSpin budget elapsed without TEND.
Precondition
ra8_board_uart_console_init succeeded.
Postcondition
On success, every byte previously passed to ra8_board_uart_console_write has been transmitted.
Note
Not thread-safe with respect to a concurrent ra8_board_uart_console_write – the writer may refill the shift register while the flush is polling.
See also
ra8_sci_flush
ra8_board_uart_console_write
Since
0.1.0

Definition at line 348 of file ra8_board_ek_ra8d2_comms.c.

References k_ra8_board_uart_console_sci_channel, k_ra8_err_not_initialized, ra8_sci_flush(), and s_uart_console_initialized.

Referenced by app_launch_hil_emit_pass(), app_shell_hil_emit_pass(), cache_hal_emit(), cache_mpu_emit(), demo_panic_halt(), dtc_coh_report(), dualcore_bg_hil_emit_pass(), dualcore_mailbox_hil_emit_pass(), imp_panic(), internal_emit_pass(), internal_npu_infer_emit(), internal_npu_smoke_emit(), internal_npu_vela_emit(), internal_rcs_panic_halt(), internal_report(), main(), and mpu_boot_emit().

◆ ra8_board_uart_console_init()

ra8_err_t ra8_board_uart_console_init ( uint32_t baud)
nodiscard

Configure SCI8 + PD02/PD03 as the debug-console UART.

Routes PD02 -> TXD8 and PD03 -> RXD8 (PSEL = SCI async) and brings SCI8 up via ra8_sci_init with 8N1 framing at the requested baud. The SCI module operating clock on RA8D2 is PCLKA (chip HUM Ch 38.2 "SCI registers"); the BRR divisor is computed from the current PCLKA frequency reported by ra8_cgc_get_clock_hz, so callers must call ra8_cgc_init() before ra8_board_uart_console_init. Applications that retune CGC afterwards must additionally call ra8_sci_set_baud((uint8_t)k_ra8_board_uart_console_sci_channel, baud, new_pclka_hz) to recompute the divisor.

Parameters
[in]baudTarget line rate in bps (e.g. 115200).
Return values
k_ra8_okConsole up, ready to TX/RX.
k_ra8_err_invalid_argbaud == 0.
k_ra8_err_not_initializedra8_cgc_init has not yet published a usable PCLKA value (chip still on MOCO / pre-PLL).
k_ra8_err_gpio_conflictPD02 or PD03 already owned.
k_ra8_err_hw_init_failedUnderlying ra8_sci_init failed.
Precondition
HAL pin validator initialized (single-threaded boot context).
ra8_cgc_init() has run and PCLKA is post-PLL.
ra8_mstp_init() has run.
Postcondition
SCI8 is enabled with TE=RE=1; PD02/PD03 are routed to SCI8.
BRR computed against the live PCLKA value (no hardcoded clock).
Note
Not thread-safe; call once during board bring-up.
Since
0.1.0

Definition at line 240 of file ra8_board_ek_ra8d2_comms.c.

References k_ra8_board_uart_console_min_pclka_hz, k_ra8_board_uart_console_pin_rxd, k_ra8_board_uart_console_pin_txd, k_ra8_board_uart_console_sci_channel, k_ra8_clock_id_pclka, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, k_ra8_psel_sci_async, k_ra8_sci_data_8, k_ra8_sci_parity_none, k_ra8_sci_stop_1, ra8_cgc_get_clock_hz(), ra8_pfs_route_peripheral(), ra8_sci_init(), and s_uart_console_initialized.

Referenced by adc_diag_setup_or_halt(), al_setup_or_halt(), app_bringup_clocks(), app_launch_hil_console_init(), app_setup(), app_shell_hil_console_init(), bm_setup_or_halt(), bs_setup_or_halt(), c6_fwver_setup_or_halt(), c6_hosted_setup_or_halt(), c6_join_setup_or_halt(), c6_probe_setup_or_halt(), c6_wifi_setup_or_halt(), cache_hal_setup(), cache_mpu_setup(), cam_bringup(), cdc_setup_or_halt(), ch_setup_or_halt(), cm_bringup_clocks(), combo_setup_or_halt(), crc_demo_setup_or_halt(), demo_setup_or_halt(), demo_setup_or_halt(), dfu_setup_or_halt(), drw_blend_setup_or_halt(), drw_demo_setup_or_halt(), dtc_arm_setup_or_halt(), dtc_coh_setup_or_halt(), dtc_demo_setup_or_halt(), dualcore_bg_hil_console_init(), dualcore_mailbox_hil_console_init(), ec_setup_or_halt(), ef_setup_or_halt(), ehb_setup_or_halt(), eoh_setup_or_halt(), eop_setup_or_halt(), ep_bringup_core(), ep_setup_or_halt(), erb_setup_or_halt(), es_setup_or_halt(), est_setup_or_halt(), etoc_setup_or_halt(), ez_bringup_clocks(), fc_setup_or_halt(), fileops_setup_or_halt(), fs_fmt_setup_or_halt(), gh_setup_or_halt(), gptp_setup_or_halt(), hid_setup_or_halt(), i3c_demo_setup_or_halt(), iic_setup_or_halt(), imp_setup_or_halt(), imu_demo_setup_or_halt(), internal_agt_periodic_setup_or_halt(), internal_audio_loopback_init_console(), internal_bkup_demo_setup_or_halt(), internal_c6_cam_setup_or_halt(), internal_console_init(), internal_demo_clocks_or_halt(), internal_demo_setup_or_halt(), internal_dotf_demo_setup_or_halt(), internal_eth_loopback_setup_or_halt(), internal_icu_extint_demo_setup_or_halt(), internal_kat_setup_or_halt(), internal_kint_demo_setup_or_halt(), internal_lpm_deep_setup_or_halt(), internal_lpm_demo_setup_or_halt(), internal_lpm_dpsby1_setup_or_halt(), internal_lpm_dpsby2_setup_or_halt(), internal_lpm_dpsby3_setup_or_halt(), internal_lpm_swstd_setup_or_halt(), internal_lpm_wake_setup_or_halt(), internal_lus_setup_or_halt(), internal_lvd_demo_setup_or_halt(), internal_mecc_setup_or_halt(), internal_motor_3phase_init_console(), internal_mpu_simple_setup_or_halt(), internal_npu_infer_setup_or_halt(), internal_npu_smoke_setup_or_halt(), internal_npu_vela_setup_or_halt(), internal_pc_setup_or_halt(), internal_pdg_demo_setup_or_halt(), internal_poeg_demo_setup_or_halt(), internal_rc_setup_or_halt(), internal_rcs_setup_or_halt(), internal_rng_demo_setup_or_halt(), internal_rtc_demo_setup_or_halt(), internal_sd_demo_setup_or_halt(), internal_setup_or_halt(), internal_ssie_loop_setup_or_halt(), internal_tc_setup_or_halt(), internal_td_setup_or_halt(), internal_uart_hello_setup_or_halt(), internal_usb_audio_setup_or_halt(), internal_wdt_demo_setup_or_halt(), ipc_demo_setup_or_halt(), iu_setup_or_halt(), iv_setup_or_halt(), kat_setup_or_halt(), kb_setup_or_halt(), l3_setup_or_halt(), lin_hil_setup_or_halt(), lk_setup_or_halt(), lpi_setup_or_halt(), main(), mem_setup_or_halt(), mg_bringup_clocks(), microsd_setup_or_halt(), mlun_setup_or_halt(), modem_setup_or_halt(), mpu_boot_setup(), ospirw_setup_or_halt(), pdm_demo_io_or_halt(), pp_demo_clocks_or_halt(), ra8_nsc_periph_init(), riic_target_setup_or_halt(), rot_setup_or_halt(), sb_setup_or_halt(), sbns_console_bringup(), scb_demo_setup_or_halt(), sd_demo_setup_or_halt(), sd_setup_or_halt(), sdhi_card_setup_or_halt(), sdhi_demo_setup_or_halt(), sdmsc_setup_or_halt(), sdram_demo_setup_or_halt(), selftest_setup_or_halt(), sh_setup_or_halt(), tb_setup_or_halt(), timer_demo_setup_or_halt(), tsn_setup_or_halt(), wa_setup_or_halt(), wc_setup_or_halt(), wd_setup_or_halt(), wdt_rr_setup_or_halt(), wdt_window_demo_setup_or_halt(), webp_demo_setup_or_halt(), wifi_hal_setup_or_halt(), wk_setup_or_halt(), and wlun_setup_or_halt().

◆ ra8_board_uart_console_read()

ra8_err_t ra8_board_uart_console_read ( uint8_t * out,
size_t cap,
size_t * out_len )
nodiscard

Polled non-blocking read from the J-Link OB VCOM console.

Drains up to cap bytes from SCI8 RDR while RDRF stays set. Stops (without error) the first time RDRF clears so the call never blocks waiting for a host that is silent.

Parameters
[out]outDestination buffer (non-NULL when cap > 0).
[in]capCapacity of out in bytes.
[out]out_lenNumber of bytes actually read; non-NULL.
Return values
k_ra8_okRead complete; *out_len in [0, cap].
k_ra8_err_invalid_argout / out_len NULL with non-zero cap.
k_ra8_err_not_initializedConsole not initialized.
Precondition
ra8_board_uart_console_init succeeded.
Postcondition
0 <= *out_len <= cap.
Since
0.1.0

Definition at line 308 of file ra8_board_ek_ra8d2_comms.c.

References k_ra8_board_uart_console_sci_channel, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, ra8_sci_getc_polling(), and s_uart_console_initialized.

◆ ra8_board_uart_console_write()

ra8_err_t ra8_board_uart_console_write ( const uint8_t * data,
size_t len )
nodiscard

Polled blocking write to the J-Link OB VCOM console.

Parameters
[in]dataBytes to transmit; must be non-NULL when len > 0.
[in]lenNumber of bytes in data.
Return values
k_ra8_okAll bytes pushed to TDR.
k_ra8_err_invalid_argdata NULL with non-zero len.
k_ra8_err_not_initializedra8_board_uart_console_init not called.
Precondition
ra8_board_uart_console_init succeeded.
Postcondition
All len bytes have been handed to the SCI8 TDR shift register.
Since
0.1.0

Definition at line 294 of file ra8_board_ek_ra8d2_comms.c.

References k_ra8_board_uart_console_sci_channel, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, ra8_sci_write_polling(), and s_uart_console_initialized.

Referenced by adc_diag_write(), al_print(), app_launch_hil_emit_pass(), app_print(), app_shell_hil_emit_pass(), bm_print(), bs_print(), c6_cam_put_u32(), c6_cam_puts(), c6_fwver_put_hex(), c6_fwver_put_text(), c6_fwver_put_u32(), c6_fwver_puts(), c6_hosted_put_hex(), c6_hosted_put_u32(), c6_hosted_puts(), c6_join_put_hex(), c6_join_put_u32(), c6_join_puts(), c6_probe_put_hex(), c6_probe_put_u32(), c6_probe_puts(), c6_wifi_put_hex(), c6_wifi_put_text(), c6_wifi_put_u32(), c6_wifi_puts(), cache_hal_emit(), cache_mpu_emit(), cam_put_hex(), cam_put_u32(), cam_puts(), cdc_sci_write(), ch_print(), cm_print(), crc_demo_one_iter(), demo_drain_print_job(), demo_emit(), demo_print(), demo_puts(), demo_read_test_file(), demo_report(), dfu_sci_write(), dfu_sci_write(), drw_blend_print_hex(), drw_blend_print_pass(), dtc_coh_report(), dualcore_bg_hil_emit_pass(), dualcore_mailbox_hil_emit_pass(), ec_print(), ef_print(), ehb_write(), eoh_print(), eop_log_sink(), eop_print(), ep_emit(), ep_print(), erb_print(), es_print(), est_print(), etoc_print(), ez_print(), fc_log_sink(), fc_print(), fileops_sci_write(), fs_fmt_print(), gh_print(), gptp_write(), hid_sci_write(), hid_sci_write(), iic_print(), imp_print(), imu_demo_tx(), internal_audio_loopback_print_count(), internal_bkup_demo_report_survival(), internal_demo_log(), internal_demo_print(), internal_demo_write_bytes(), internal_emit_pass(), internal_emit_tick(), internal_log_sink(), internal_lpm_demo_one_wake(), internal_motor_3phase_print_duty(), internal_mpu_simple_emit_banner(), internal_npu_infer_write(), internal_npu_smoke_write(), internal_npu_vela_write(), internal_pc_print(), internal_print(), internal_puts(), internal_rc_print(), internal_rcs_print(), internal_report(), internal_rng_demo_emit_one_line(), internal_sd_demo_print(), internal_sdcard_log(), internal_tc_print(), internal_td_print(), internal_usb_audio_log(), ipc_demo_log(), iu_print(), iv_print(), kat_setup_or_halt(), kb_print(), l3_write(), lk_print(), lpi_do_work(), ls_print(), main(), mem_print(), mg_print(), microsd_sci_write(), mlun_sci_write(), modem_tx(), mpu_boot_emit(), ospirw_sci_write(), pdm_demo_tx(), riic_target_on_event(), rot_write(), sb_write(), sbns_console_print_hex32(), sbns_console_say(), scb_demo_write(), sd_demo_print(), sd_print(), sdhi_card_print(), sdhi_demo_print(), sdmsc_sci_write(), selftest_sci_write(), selftest_sci_write(), selftest_sci_write(), selftest_sci_write(), selftest_sci_write(), sh_print(), tb_print(), timer_demo_one_capture(), tsn_write(), wa_print(), wc_print(), wd_print(), wdt_rr_arm_and_wait_for_reset(), wdt_window_demo_banner(), wifi_hal_put_hex(), wifi_hal_put_u32(), wifi_hal_puts(), wk_print(), and wlun_sci_write().

◆ ra8_board_usbhs_device_init()

ra8_err_t ra8_board_usbhs_device_init ( void )
nodiscard

Bring the chip USBHS module up in device mode (HS PHY).

Return values
k_ra8_ok/ k_ra8_err_not_supported (until USBHS HAL lands)
Since
0.1.0

Definition at line 912 of file ra8_board_ek_ra8d2_audio_usb.c.

References g_usbhs_probe, internal_usbhs_clock_and_mstp(), internal_usbhs_role_select_device(), k_ra8_ok, k_ra8_usb_speed_hs, k_usbhs_probe_post_usb_dev_init, k_usbhs_probe_pre_usb_dev_init, ra8_board_io_expander_set_usbhs_device_mode(), and ra8_usb_device_init().

Referenced by internal_usb_audio_usb_or_halt().

◆ ra8_board_usbhs_host_init()

ra8_err_t ra8_board_usbhs_host_init ( void )
nodiscard

Bring the chip USBHS module up in host mode.

Return values
k_ra8_ok/ k_ra8_err_not_supported (until USBHS HAL lands)
Since
0.1.0

Definition at line 948 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_usbhs_clock_and_mstp(), k_ra8_ok, k_ra8_usb_speed_hs, and ra8_usb_host_init().

◆ 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().