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

EK-RA8D2 BSP – DA7212 audio CODEC, USB-HS, and U15 I/O expander. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_board_ek_ra8d2_audio_usb_internal.h"
#include "ra8_cgc.h"
#include "ra8_err.h"
#include "ra8_gpio_constants.h"
#include "ra8_i2c.h"
#include "ra8_mpc.h"
#include "ra8_mstp.h"
#include "ra8_pfs_regs.h"
#include "ra8_port_constants.h"
#include "ra8_port_utils.h"
#include "ra8_ssie.h"
#include "ra8_time.h"
#include "ra8_usb.h"
Include dependency graph for ra8_board_ek_ra8d2_audio_usb.c:

Go to the source code of this file.

Enumerations

enum  ra8_audio_bit_depth_t : uint8_t {
  k_ra8_audio_bits_8 = 8U ,
  k_ra8_audio_bits_16 = 16U ,
  k_ra8_audio_bits_18 = 18U ,
  k_ra8_audio_bits_20 = 20U ,
  k_ra8_audio_bits_22 = 22U ,
  k_ra8_audio_bits_24 = 24U ,
  k_ra8_audio_bits_32 = 32U
}
 Supported PCM significant-bit-depth values for the DA7212 path. More...
enum  ra8_audio_channels_t : uint8_t {
  k_ra8_audio_channels_mono = 1U ,
  k_ra8_audio_channels_stereo = 2U
}
 Sample-frame channel counts the BSP accepts. More...
enum  ra8_audio_pack_t : uint8_t { k_ra8_audio_samples_per_word = 2U }
 Stereo-frame packing factor (two int16_t samples per 32-bit word). More...
enum  usbhs_probe_step_t : uint32_t {
  k_usbhs_probe_pre_pll_enable = 1U ,
  k_usbhs_probe_pre_mstp_init = 2U ,
  k_usbhs_probe_pre_mstp_enable = 3U ,
  k_usbhs_probe_pre_usb_dev_init = 4U ,
  k_usbhs_probe_post_usb_dev_init = 5U
}
 Bisect-probe step values for g_usbhs_probe. More...
enum  ra8_board_io_expander_addr_t : uint8_t { k_ra8_board_io_expander_addr = 0x43U }
 PI4IOE5V6408 7-bit I2C address on EK-RA8D2 v1 (SW4 sibling). More...
enum  ra8_board_pi4ioe_reg_t : uint8_t {
  k_ra8_board_pi4ioe_reg_devid = 0x01U ,
  k_ra8_board_pi4ioe_reg_iodir = 0x03U ,
  k_ra8_board_pi4ioe_reg_output = 0x05U ,
  k_ra8_board_pi4ioe_reg_hiz = 0x07U ,
  k_ra8_board_pi4ioe_reg_pud_sel = 0x0DU ,
  k_ra8_board_pi4ioe_reg_input_lvl = 0x0FU
}
 PI4IOE5V6408 register addresses. More...
enum  ra8_board_pi4ioe_magic_t : uint8_t {
  k_ra8_board_pi4ioe_iodir_all_outputs = 0xFFU ,
  k_ra8_board_pi4ioe_output_all_high = 0xFFU ,
  k_ra8_board_pi4ioe_hiz_none = 0x00U
}
 Magic-value writes for ra8_board_io_expander_set_usbhs_device_mode. More...
enum  ra8_board_io_expander_clk_t : uint32_t {
  k_ra8_board_io_expander_bus_hz = 100000U ,
  k_ra8_board_io_expander_pclkb_hz = 62500000U
}
 IIC1 (system I2C) configuration shared by every U15 access. More...
enum  ra8_board_io_expander_channel_t : uint8_t { k_ra8_board_io_expander_iic_channel = 1U }
 IIC channel index used for the U15 expander (RIIC channel 1). More...
enum  ra8_board_i2c_recover_t : uint32_t {
  k_ra8_board_i2c_recover_pulses = 9U ,
  k_ra8_board_i2c_recover_spins = 2000U
}
 Bit-bang bus-recovery tunables for the system I2C bus. More...
enum  io_exp_probe_step_t : uint32_t {
  k_io_exp_probe_pre_pfs = 1U ,
  k_io_exp_probe_pre_init = 2U ,
  k_io_exp_probe_pre_write_out = 3U ,
  k_io_exp_probe_pre_write_hiz = 4U ,
  k_io_exp_probe_pre_write_dir = 5U ,
  k_io_exp_probe_success = 6U
}
 Step values for s_io_expander_probe (see variable docs). More...
enum  usbhs_role_probe_step_t : uint32_t {
  k_usbhs_role_probe_pre_init = 1U ,
  k_usbhs_role_probe_post_init = 2U ,
  k_usbhs_role_probe_success = 3U
}
 Probe step values for g_usbhs_role_pin_probe. More...

Functions

static ra8_err_t internal_audio_bits_to_word (uint8_t bit_depth, ra8_ssie_data_word_t *out_dwl, ra8_ssie_system_word_t *out_swl)
static ra8_err_t internal_audio_route_pins (void)
static ra8_ssie_cfg_t internal_audio_build_ssie_cfg (uint8_t channels, ra8_ssie_data_word_t dwl, ra8_ssie_system_word_t swl)
 Build the SSIE0 controller-mode I2S config for the DA7212 link.
ra8_err_t ra8_board_audio_init (uint32_t sample_rate_hz, uint8_t bit_depth, uint8_t channels)
 Route the CODEC pins and bring up SSIE0 in I2S controller mode.
ra8_err_t ra8_board_audio_play_sample_block (const int16_t *buf, uint32_t len)
 Push one block of stereo PCM samples to the CODEC's DAC.
static ra8_err_t internal_usbhs_clock_and_mstp (void)
 Shared CGC + MSTP bring-up for both USBHS modes.
static ra8_err_t internal_io_expander_write_reg (uint8_t reg, uint8_t val)
static void internal_io_expander_bus_settle (void)
 Crude busy-wait for roughly one I2C SCL half-period.
static ra8_err_t internal_io_expander_bus_recover (void)
 Bit-bang up to 9 SCL clocks to free a wedged system I2C bus.
static ra8_err_t internal_io_expander_enable_pullups (void)
 Drive the system-I2C pull-up enable pins (P109/P311) high.
static ra8_err_t internal_io_expander_route_pins (void)
 Route P512/P511 to SCL1/SDA1 with N-channel open-drain enabled.
static ra8_err_t internal_io_expander_program_u15 (uint8_t output_byte, uint8_t output_mask)
 Issue the three U15 register writes that latch a given SW4 layout.
static ra8_err_t internal_io_expander_apply_mask (uint8_t output_byte, uint8_t output_mask)
 Shared U15 bring-up: route SCL1/SDA1, initialize RIIC1, then load output_byte into the expander's output register.
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)
 Implementation of ra8_board_io_expander_set_usbhs_host_mode().
ra8_err_t ra8_board_io_expander_apply_project_sw4_defaults (void)
 Program U15 with this project's SW4 override pattern.
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.
static ra8_err_t internal_usbhs_role_select_device (void)
 Drive PD07 low to strap the J7 USB-HS role line to "Device".
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.

Variables

static bool s_audio_initialized = false
 Tracks whether ra8_board_audio_init has succeeded.
volatile uint32_t g_usbhs_probe = 0U
 Temporary bisect probe for USBHS bring-up HardFault.
static const ra8_port_pin_t s_ra8_board_io_expander_pin_scl
 Pins that carry SCL1 / SDA1 to U15 (the system I2C bus).
static const ra8_port_pin_t s_ra8_board_io_expander_pin_sda
 SDA1 (P511).
static const ra8_port_pin_t s_ra8_board_io_expander_pin_pullup_a
 Pull-up enable pins for the system I2C bus (P109 / P311).
static const ra8_port_pin_t s_ra8_board_io_expander_pin_pullup_b
 P311 pull-up enable.
static volatile uint32_t s_io_expander_probe = 0U
 Bisect-probe progress counter for ra8_board_io_expander_set_usbhs_device_mode.
volatile uint32_t g_usbhs_role_pin_probe = 0U
 Bisect-probe progress counter for the PD07 USB-HS role-select drive.
volatile uint32_t g_usbhs_role_pin_err = 0U
 Last ra8_err_t returned by the PD07 GPIO drive (0 = k_ra8_ok).

Detailed Description

EK-RA8D2 BSP – DA7212 audio CODEC, USB-HS, and U15 I/O expander.

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

Sibling translation unit of ra8_board_ek_ra8d2.c carrying the board's audio + USB sub-responsibilities:

  • DA7212 audio CODEC link over SSIE0 + the IIC control pair (UM Table 32 p 38).
  • USB-HS device/host bring-up (CGC PHY clock + MSTP ungate) plus the PD07 role-select strap.
  • The U15 PI4IOE5V6408 I2C I/O expander used to override the SW4 configuration switches (UM Section 5.5.3).

The BSP itself never touches MCU registers; ra8_ssie_* / ra8_i2c_* / ra8_mpc_* / ra8_usb_* / ra8_pfs_route_peripheral 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).

Since
0.1.0

Definition in file ra8_board_ek_ra8d2_audio_usb.c.

Enumeration Type Documentation

◆ io_exp_probe_step_t

enum io_exp_probe_step_t : uint32_t

Step values for s_io_expander_probe (see variable docs).

Enumerator
k_io_exp_probe_pre_pfs 

Io exp probe pre PFS.

k_io_exp_probe_pre_init 

Io exp probe pre init.

k_io_exp_probe_pre_write_out 

Io exp probe pre write out.

k_io_exp_probe_pre_write_hiz 

Io exp probe pre write hiz.

k_io_exp_probe_pre_write_dir 

Io exp probe pre write dir.

k_io_exp_probe_success 

Io exp probe success.

Definition at line 497 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_audio_bit_depth_t

enum ra8_audio_bit_depth_t : uint8_t

Supported PCM significant-bit-depth values for the DA7212 path.

Names every bit depth the BSP knows how to map to an SSIE DWL/SWL pair. The DA7212 supports 16/24/32-bit native; 8/18/20/22 are accepted because the SSIE itself supports those data-word widths and an application may want to feed pre-padded streams.

Enumerator
k_ra8_audio_bits_8 

RA8 audio bits 8.

k_ra8_audio_bits_16 

RA8 audio bits 16.

k_ra8_audio_bits_18 

RA8 audio bits 18.

k_ra8_audio_bits_20 

RA8 audio bits 20.

k_ra8_audio_bits_22 

RA8 audio bits 22.

k_ra8_audio_bits_24 

RA8 audio bits 24.

k_ra8_audio_bits_32 

RA8 audio bits 32.

Definition at line 67 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_audio_channels_t

enum ra8_audio_channels_t : uint8_t

Sample-frame channel counts the BSP accepts.

Enumerator
k_ra8_audio_channels_mono 

RA8 audio channels mono.

k_ra8_audio_channels_stereo 

RA8 audio channels stereo.

Definition at line 80 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_audio_pack_t

enum ra8_audio_pack_t : uint8_t

Stereo-frame packing factor (two int16_t samples per 32-bit word).

Enumerator
k_ra8_audio_samples_per_word 

RA8 audio samples per word.

Definition at line 88 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_board_i2c_recover_t

enum ra8_board_i2c_recover_t : uint32_t

Bit-bang bus-recovery tunables for the system I2C bus.

Enumerator
k_ra8_board_i2c_recover_pulses 

SCL clocks to flush one stuck byte + ACK.

k_ra8_board_i2c_recover_spins 

Busy-loop iterations ~= one SCL half-period.

Definition at line 450 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_board_io_expander_addr_t

PI4IOE5V6408 7-bit I2C address on EK-RA8D2 v1 (SW4 sibling).

Enumerator
k_ra8_board_io_expander_addr 

RA8 board io expander address.

Definition at line 368 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_board_io_expander_channel_t

IIC channel index used for the U15 expander (RIIC channel 1).

Enumerator
k_ra8_board_io_expander_iic_channel 

RA8 board io expander iic channel.

Definition at line 411 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_board_io_expander_clk_t

enum ra8_board_io_expander_clk_t : uint32_t

IIC1 (system I2C) configuration shared by every U15 access.

Enumerator
k_ra8_board_io_expander_bus_hz 

100 kHz Sm.

k_ra8_board_io_expander_pclkb_hz 

PCLKB = PLL1P/16 post-CGC.

Definition at line 405 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_board_pi4ioe_magic_t

enum ra8_board_pi4ioe_magic_t : uint8_t

Magic-value writes for ra8_board_io_expander_set_usbhs_device_mode.

Polarity per FSP reference: OFF == output bit HIGH. SW4-8 OFF selects USB-HS device mode on J7, so bit 7 must be HIGH. We write 0xFF (every SW4 channel in its mechanical-default OFF position), which keeps every other SW4-gated peripheral at its EK-RA8D2 default routing while still forcing SW4-8 = OFF.

Enumerator
k_ra8_board_pi4ioe_iodir_all_outputs 

RA8 board pi4ioe iodir all outputs.

k_ra8_board_pi4ioe_output_all_high 

RA8 board pi4ioe output all high.

k_ra8_board_pi4ioe_hiz_none 

RA8 board pi4ioe hiz none.

Definition at line 398 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ ra8_board_pi4ioe_reg_t

enum ra8_board_pi4ioe_reg_t : uint8_t

PI4IOE5V6408 register addresses.

The expander is auto-incrementing; we always do single-byte writes. Values cite ra-fsp-examples/ek_ra8t2/board_cfg_switch.c.

Enumerator
k_ra8_board_pi4ioe_reg_devid 

Device ID register.

k_ra8_board_pi4ioe_reg_iodir 

1 = output.

k_ra8_board_pi4ioe_reg_output 

1 = HIGH (== SW4 OFF).

k_ra8_board_pi4ioe_reg_hiz 

1 = output Hi-Z.

k_ra8_board_pi4ioe_reg_pud_sel 

Pull-up/down select.

k_ra8_board_pi4ioe_reg_input_lvl 

Input state.

Definition at line 379 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ usbhs_probe_step_t

enum usbhs_probe_step_t : uint32_t

Bisect-probe step values for g_usbhs_probe.

Enumerator
k_usbhs_probe_pre_pll_enable 

before ra8_cgc_usbhs_pll_enable.

k_usbhs_probe_pre_mstp_init 

before ra8_mstp_init.

k_usbhs_probe_pre_mstp_enable 

before ra8_mstp_enable(usbhs).

k_usbhs_probe_pre_usb_dev_init 

before ra8_usb_device_init(hs).

k_usbhs_probe_post_usb_dev_init 

after ra8_usb_device_init.

Definition at line 300 of file ra8_board_ek_ra8d2_audio_usb.c.

◆ usbhs_role_probe_step_t

enum usbhs_role_probe_step_t : uint32_t

Probe step values for g_usbhs_role_pin_probe.

Enumerator
k_usbhs_role_probe_pre_init 

Usbhs role probe pre init.

k_usbhs_role_probe_post_init 

Usbhs role probe post init.

k_usbhs_role_probe_success 

Usbhs role probe success.

Definition at line 870 of file ra8_board_ek_ra8d2_audio_usb.c.

Function Documentation

◆ internal_audio_bits_to_word()

◆ internal_audio_build_ssie_cfg()

ra8_ssie_cfg_t internal_audio_build_ssie_cfg ( uint8_t channels,
ra8_ssie_data_word_t dwl,
ra8_ssie_system_word_t swl )
static

Build the SSIE0 controller-mode I2S config for the DA7212 link.

AUDIO_MCK / 4 lands close to 12.288 MHz / 4 = 3.072 MHz BCK for 48 kHz x 2ch x 32-bit frames; finer rate matching is left to applications that re-call ra8_ssie_init() with a tuned divider.

Parameters
[in,out]channelsSee function signature.
[in,out]dwlSee function signature.
[in,out]swlSee function signature.
Returns
Result code or value; see implementation.
Return values
0Success or default value.
Precondition
Module has been initialized.
Caller has validated arguments.
Postcondition
Side effects bounded to documented state.
State reflects operation result.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 178 of file ra8_board_ek_ra8d2_audio_usb.c.

References k_ra8_audio_channels_mono, k_ra8_ssie_bclk_div_4, k_ra8_ssie_format_i2s, k_ra8_ssie_format_monaural, k_ra8_ssie_role_controller, and RA8_INTERNAL.

Referenced by ra8_board_audio_init().

◆ internal_audio_route_pins()

◆ internal_io_expander_apply_mask()

ra8_err_t internal_io_expander_apply_mask ( uint8_t output_byte,
uint8_t output_mask )
static

Shared U15 bring-up: route SCL1/SDA1, initialize RIIC1, then load output_byte into the expander's output register.

The public entry points differ only in the SW4 layout they program, so factor the PFS route + RIIC1 init + U15 write sequence into one helper. The probe word s_io_expander_probe is updated between steps so a JLink halt can pinpoint which step NACKed.

Parameters
[in]output_byteValue to latch into U15's output register (see internal_io_expander_program_u15).
[in]output_maskValue to latch into U15's IODIR register.
Returns
ra8_err_t Error code.
Return values
k_ra8_okAll bring-up steps completed.
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 P512/P511 are routed to SCL1/SDA1; RIIC1 is at 100 kHz; selected U15 pins drive output_byte.
s_io_expander_probe ends at k_io_exp_probe_success on OK or at the failing step on error.
Note
Not thread-safe.
Since
0.1.0

Definition at line 714 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_bus_recover(), internal_io_expander_enable_pullups(), internal_io_expander_program_u15(), internal_io_expander_route_pins(), k_io_exp_probe_pre_init, k_io_exp_probe_pre_pfs, k_io_exp_probe_success, k_ra8_board_io_expander_bus_hz, k_ra8_board_io_expander_iic_channel, k_ra8_board_io_expander_pclkb_hz, k_ra8_ok, ra8_i2c_init(), RA8_INTERNAL, and s_io_expander_probe.

Referenced by ra8_board_io_expander_apply_project_sw4_defaults(), ra8_board_io_expander_apply_sw4(), ra8_board_io_expander_apply_sw4_mask(), ra8_board_io_expander_set_octospi_active(), ra8_board_io_expander_set_usbhs_device_mode(), and ra8_board_io_expander_set_usbhs_host_mode().

◆ internal_io_expander_bus_recover()

ra8_err_t internal_io_expander_bus_recover ( void )
static

Bit-bang up to 9 SCL clocks to free a wedged system I2C bus.

If a previous, aborted transfer left a peripheral (e.g. U15) holding SDA low mid-byte, the bus is stuck and every START fails. Drive SCL (P512) as a GPIO output and pulse it – with SDA (P511) released as an input – until SDA reads high or the pulse budget is spent, then frame a STOP. Finally release both pins so the caller can route them to the IIC mux. Runs before every U15 access so a wedged bus self-recovers on the next boot.

Returns
ra8_err_t Error from the first failing GPIO sub-call, else k_ra8_ok.
Return values
k_ra8_okRecovery sequence completed and pins released.
Precondition
IOPORT module powered (reset default).
P512/P511 are not currently claimed by another driver.
Postcondition
P512/P511 are released (unclaimed), ready for the IIC route.
SDA has been clocked toward release and a STOP edge was framed.
Note
Not thread-safe.
Since
0.1.0

Definition at line 544 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_bus_settle(), k_ra8_board_i2c_recover_pulses, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, k_ra8_pull_up, ra8_gpio_input_init(), ra8_gpio_output_init(), ra8_gpio_read(), ra8_gpio_release(), ra8_gpio_write(), RA8_INTERNAL, s_ra8_board_io_expander_pin_scl, and s_ra8_board_io_expander_pin_sda.

Referenced by internal_io_expander_apply_mask().

◆ internal_io_expander_bus_settle()

void internal_io_expander_bus_settle ( void )
static

Crude busy-wait for roughly one I2C SCL half-period.

Used only by the bit-bang bus-recovery, which does not need precise timing – any peripheral that clock-stretches will release on the slow clocks this produces. Avoids a dependency on ra8_time being initialized this early in board bring-up.

Precondition
None.
None.
Postcondition
Approximately one SCL half-period of wall-clock time has passed.
No register or pin state is modified.
Note
Not thread-safe (timing only).
Since
0.1.0

Definition at line 519 of file ra8_board_ek_ra8d2_audio_usb.c.

References k_ra8_board_i2c_recover_spins, and RA8_INTERNAL.

Referenced by internal_io_expander_bus_recover().

◆ internal_io_expander_enable_pullups()

ra8_err_t internal_io_expander_enable_pullups ( void )
static

Drive the system-I2C pull-up enable pins (P109/P311) high.

EK-RA8D2 v1 UM Table 23 routes the SCL1/SDA1 bus pull-ups through P109 and P311; in I2C mode they must be push-pull outputs driven high or the open-drain bus has no pull-ups and no peripheral can ACK. Run before routing SCL1/SDA1 so the bus is pulled up the instant the IIC mux takes the pins.

Returns
ra8_err_t Error code from the first failing sub-call, else k_ra8_ok.
Return values
k_ra8_okBoth pull-up enables are driven high.
Precondition
IOPORT module powered (reset default).
Caller has not already claimed P109/P311.
Postcondition
On success P109 and P311 are push-pull outputs at level high.
On failure the first pin may remain claimed (caller aborts boot).
Note
Not thread-safe.
Since
0.1.0

Definition at line 599 of file ra8_board_ek_ra8d2_audio_usb.c.

References k_ra8_level_high, k_ra8_ok, ra8_gpio_output_init(), RA8_INTERNAL, s_ra8_board_io_expander_pin_pullup_a, and s_ra8_board_io_expander_pin_pullup_b.

Referenced by internal_io_expander_apply_mask().

◆ internal_io_expander_program_u15()

ra8_err_t internal_io_expander_program_u15 ( uint8_t output_byte,
uint8_t output_mask )
static

Issue the three U15 register writes that latch a given SW4 layout.

Order matches the FSP reference (output-latch -> Hi-Z clear -> iodir) so each pin only flips to output once the latch is already driving the desired level. Updates s_io_expander_probe between writes so JLink can pinpoint a NACK.

Parameters
[in]output_byteBit-pattern written to PI4IOE5V6408 reg 0x05 (Output state). Bit n = 1 -> SW4-(n+1) reads OFF; bit n = 0 -> reads ON. Use 0xFF to mirror the all-DIPs-OFF mechanical default or k_ra8_board_pi4ioe_output_project_default (0xF2) for this project's wiring.
[in]output_maskBit n = 1 drives U15 pin n as an output; clear bits release that SW4 position to the physical switch.
Returns
ra8_err_t Error code; k_ra8_ok if all three writes ack.
Return values
k_ra8_okU15 driving exactly the positions selected by output_mask.
k_ra8_err_nackU15 didn't ACK one of the register writes.
Precondition
ra8_i2c_init has already configured channel 1.
I2C bus is idle.
Postcondition
On success, U15 IODIR=output_mask, OUTPUT=output_byte, HIZ=0x00.
On failure, s_io_expander_probe records the failing step.
Note
Not thread-safe.
Since
0.1.0

Definition at line 666 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_io_expander_write_reg(), k_io_exp_probe_pre_write_dir, k_io_exp_probe_pre_write_hiz, k_io_exp_probe_pre_write_out, k_ra8_board_pi4ioe_hiz_none, k_ra8_board_pi4ioe_reg_hiz, k_ra8_board_pi4ioe_reg_iodir, k_ra8_board_pi4ioe_reg_output, k_ra8_ok, RA8_INTERNAL, and s_io_expander_probe.

Referenced by internal_io_expander_apply_mask().

◆ internal_io_expander_route_pins()

ra8_err_t internal_io_expander_route_pins ( void )
static

Route P512/P511 to SCL1/SDA1 with N-channel open-drain enabled.

I2C requires NCODR on both signals; ra8_pfs_route_peripheral leaves NCODR clear, so the route+open-drain pair runs per pin.

Returns
ra8_err_t Error code from the first failing sub-call, else k_ra8_ok.
Return values
k_ra8_okAll four register writes succeeded.
Precondition
IRQs masked or single-threaded init context.
Caller has not already claimed P512/P511.
Postcondition
On success, P512/P511 are owned by the IIC1 mux in open-drain mode.
On failure, partially-claimed pins remain claimed (caller aborts boot).
Note
Not thread-safe.
Since
0.1.0

Definition at line 621 of file ra8_board_ek_ra8d2_audio_usb.c.

References k_ra8_ok, k_ra8_pin_11, k_ra8_pin_12, k_ra8_port_5, k_ra8_psel_iic, RA8_INTERNAL, ra8_mpc_set_open_drain(), ra8_pfs_route_peripheral(), s_ra8_board_io_expander_pin_scl, and s_ra8_board_io_expander_pin_sda.

Referenced by internal_io_expander_apply_mask().

◆ internal_io_expander_write_reg()

ra8_err_t internal_io_expander_write_reg ( uint8_t reg,
uint8_t val )
static

◆ internal_usbhs_clock_and_mstp()

ra8_err_t internal_usbhs_clock_and_mstp ( void )
static

Shared CGC + MSTP bring-up for both USBHS modes.

Sequence per HUM Ch 9 (CGC, USBCKCR / USBCKDIVCR, p 365) and Ch 11 (MSTP, MSTPCRB12 USBHS, p 469):

  1. ra8_cgc_usbhs_pll_enable() – arms the PHY 12 MHz reference derived from the main XTAL.
  2. ra8_mstp_init() – ensures the MSTP refcount table exists (idempotent across BSP veneers).
  3. ra8_mstp_enable(k_ra8_mstp_usbhs) – ungates MSTPCRB.MSTPB12 so the controller's SYSCFG block is reachable.
Returns
ra8_err_t First non-OK result, or k_ra8_ok on a clean run.
Precondition
ra8_cgc_init() has been called.
Postcondition
On k_ra8_ok, USBHS controller registers are clocked and ready for ra8_usb_device_init / ra8_usb_host_init.
Note
Not thread-safe.
Since
0.1.0
Return values
0Success or default value.
Precondition
Module has been initialized.
Postcondition
Side effects bounded to documented state.

Definition at line 335 of file ra8_board_ek_ra8d2_audio_usb.c.

References g_usbhs_probe, k_ra8_mstp_usbhs, k_ra8_ok, k_usbhs_probe_pre_mstp_enable, k_usbhs_probe_pre_pll_enable, ra8_cgc_usbhs_pll_enable(), RA8_INTERNAL, and ra8_mstp_enable().

Referenced by ra8_board_usbhs_device_init(), and ra8_board_usbhs_host_init().

◆ internal_usbhs_role_select_device()

ra8_err_t internal_usbhs_role_select_device ( void )
static

Drive PD07 low to strap the J7 USB-HS role line to "Device".

EK-RA8D2 v1 UM Rev 1.01 Section 6.2 p 34: PD07 is the J7 USB-HS role select. Low = Device, High = Host. This is a plain MCU GPIO; the U15 I/O expander only matters if the firmware needs to override the SW4-8 strap from a different code path.

Returns
ra8_err_t Result of ra8_gpio_output_init.
Return values
k_ra8_okPD07 owned and driven low.
Precondition
IOPORT module clock is on (always-on after reset).
Pin validator initialized.
Postcondition
On success, PD07 is GPIO-output low and owned by GPIO tag.
On any return, g_usbhs_role_pin_probe is updated and g_usbhs_role_pin_err records the gpio-init result.
Note
Not thread-safe.
Since
0.1.0

Definition at line 895 of file ra8_board_ek_ra8d2_audio_usb.c.

References g_usbhs_role_pin_err, g_usbhs_role_pin_probe, k_ra8_level_low, k_ra8_ok, k_ra8_pin_7, k_ra8_port_13, k_usbhs_role_probe_post_init, k_usbhs_role_probe_pre_init, k_usbhs_role_probe_success, ra8_gpio_output_init(), RA8_INTERNAL, and RA8_PIN.

Referenced by ra8_board_usbhs_device_init().

◆ ra8_board_audio_init()

ra8_err_t ra8_board_audio_init ( uint32_t sample_rate_hz,
uint8_t bit_depth,
uint8_t channels )
nodiscard

Route the CODEC pins and bring up SSIE0 in I2S controller mode.

Return values
k_ra8_ok/ k_ra8_err_invalid_arg / k_ra8_err_gpio_conflict
Precondition
J41 jumpers populated (CODEC selected over camera).
Postcondition
All CODEC pins are routed; SSIE0 is enabled.
Since
0.1.0

Definition at line 203 of file ra8_board_ek_ra8d2_audio_usb.c.

References internal_audio_bits_to_word(), internal_audio_build_ssie_cfg(), internal_audio_route_pins(), k_ra8_audio_channels_mono, k_ra8_audio_channels_stereo, k_ra8_board_audio_ssie_channel, k_ra8_err_hw_init_failed, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_dwl_16, k_ra8_ssie_swl_16, ra8_ssie_init(), and s_audio_initialized.

Referenced by internal_audio_loopback_init_codec().

◆ ra8_board_audio_play_sample_block()

ra8_err_t ra8_board_audio_play_sample_block ( const int16_t * buf,
uint32_t len )
nodiscard

Push one block of stereo PCM samples to the CODEC's DAC.

Parameters
[in]bufSample buffer (interleaved L/R, 16-bit).
[in]lenNumber of samples (must be even).
Return values
k_ra8_okBlock enqueued or transmitted.
k_ra8_err_invalid_argbuf NULL or len odd / zero.
k_ra8_err_not_initializedra8_board_audio_init not called.
Precondition
ra8_board_audio_init succeeded.
Postcondition
Sample block has been handed to SSIE0.
Since
0.1.0

Definition at line 237 of file ra8_board_ek_ra8d2_audio_usb.c.

References k_ra8_audio_samples_per_word, k_ra8_board_audio_ssie_channel, k_ra8_err_hw_timeout, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, ra8_ssie_write_buffer(), and s_audio_initialized.

Referenced by main().

◆ ra8_board_io_expander_apply_project_sw4_defaults()

ra8_err_t ra8_board_io_expander_apply_project_sw4_defaults ( void )
nodiscard

Program U15 with this project's SW4 override pattern.

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

Implementation of ra8_board_io_expander_set_usbhs_host_mode().

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

Variable Documentation

◆ g_usbhs_probe

volatile uint32_t g_usbhs_probe = 0U

Temporary bisect probe for USBHS bring-up HardFault.

USB-HS bring-up step visible to host tests and J-Link.

Stepped through the sub-calls of internal_usbhs_clock_and_mstp + ra8_usb_device_init so a JLink session can read which sub-step is in flight when the worker thread takes the IACCVIOL/PRECISERR fault. Values: 1 = pre cgc_usbhs_pll_enable, 2 = pre mstp_init, 3 = pre mstp_enable(usbhs), 4 = pre ra8_usb_device_init(hs), 5 = post ra8_usb_device_init returned. Remove once the offending sub-call is identified.

Note
File-scope, single-writer (worker thread).
Since
0.1.0

The board implementation advances this value around clock, module-stop, and device-initialization operations. It is volatile because a debugger reads it asynchronously and because every intermediate step must remain observable.

Note
The board worker is the only writer; tests and J-Link only read it.
Since
0.1.0

Definition at line 294 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_usbhs_clock_and_mstp(), and ra8_board_usbhs_device_init().

◆ g_usbhs_role_pin_err

volatile uint32_t g_usbhs_role_pin_err = 0U

Last ra8_err_t returned by the PD07 GPIO drive (0 = k_ra8_ok).

JLink-readable so the bench operator can disambiguate a pin conflict from a port-mux failure.

Since
0.1.0

Definition at line 867 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_usbhs_role_select_device().

◆ g_usbhs_role_pin_probe

volatile uint32_t g_usbhs_role_pin_probe = 0U

Bisect-probe progress counter for the PD07 USB-HS role-select drive.

EK-RA8D2 v1 UM Rev 1.01 Section 6.2 p 34 ("USB High Speed"): "For a USB Device configuration, set PD07 to low and configure the RA MCU firmware to use the USB High Speed ports in device mode." PD07 is a direct-drive MCU GPIO (PORT 13, pin 7) that selects the J7 role; the U15 I/O expander is an alternate override path but is not required when PD07 is driven explicitly. JLink-readable so a bench reflash can confirm the pin was reached and driven low.

Step values: 0 = not yet entered 1 = pre ra8_gpio_output_init(PD07, low) 2 = output-init returned (success or failure recorded in g_usbhs_role_pin_err) 3 = drive confirmed (gpio_init returned k_ra8_ok)

Since
0.1.0

Definition at line 858 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_usbhs_role_select_device().

◆ s_audio_initialized

bool s_audio_initialized = false
static

Tracks whether ra8_board_audio_init has succeeded.

Definition at line 56 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by ra8_board_audio_init(), and ra8_board_audio_play_sample_block().

◆ s_io_expander_probe

volatile uint32_t s_io_expander_probe = 0U
static

Bisect-probe progress counter for ra8_board_io_expander_set_usbhs_device_mode.

JLink-readable counter that records the last step the U15 bring-up function reached before either succeeding or returning an error. Mirrors the g_usbhs_probe pattern used by internal_usbhs_clock_and_mstp.

Step values: 1 = pre-PFS (entered function, before SCL/SDA route) 2 = pre-init (PFS + open-drain done, before ra8_i2c_init) 3 = pre-write-output (init done, before output-latch write) 4 = pre-write-hiz (output-latch written, before Hi-Z clear) 5 = pre-write-iodir (Hi-Z cleared, before iodir write) 6 = success (all three U15 writes acknowledged)

Note
Volatile so the optimiser cannot lift the writes out of the step sequence; declared at file scope so JLink can resolve it by symbol name.
Since
0.1.0

Definition at line 492 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_io_expander_apply_mask(), and internal_io_expander_program_u15().

◆ s_ra8_board_io_expander_pin_pullup_a

const ra8_port_pin_t s_ra8_board_io_expander_pin_pullup_a
static
Initial value:
=
(ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_1) << 8) | (uint16_t)(k_ra8_pin_9)))
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_port_1
RA8 port 1.
@ k_ra8_pin_9
RA8 pin 9.

Pull-up enable pins for the system I2C bus (P109 / P311).

EK-RA8D2 v1 UM Table 23 ("I2C/I3C Pullup Configuration") routes the SCL1/SDA1 bus pull-up resistors through P109 and P311: in I2C mode (SW4-5 OFF, P512/P511) these two pins must be driven as push-pull outputs HIGH for the bus to have pull-ups at all. Without them SCL1/ SDA1 float, the open-drain bus never reaches a valid high level, and U15 (and every other I2C peripheral) cannot ACK – the symptom that made every RIIC1 transaction time out. P109 pull-up enable.

Definition at line 444 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_io_expander_enable_pullups().

◆ s_ra8_board_io_expander_pin_pullup_b

const ra8_port_pin_t s_ra8_board_io_expander_pin_pullup_b
static
Initial value:
=
(ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_3) << 8) | (uint16_t)(k_ra8_pin_11)))
@ k_ra8_port_3
RA8 port 3.
@ k_ra8_pin_11
RA8 pin 11.

P311 pull-up enable.

Definition at line 446 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_io_expander_enable_pullups().

◆ s_ra8_board_io_expander_pin_scl

const ra8_port_pin_t s_ra8_board_io_expander_pin_scl
static
Initial value:
=
(ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_5) << 8) | (uint16_t)(k_ra8_pin_12)))
@ k_ra8_port_5
RA8 port 5.
@ k_ra8_pin_12
RA8 pin 12.

Pins that carry SCL1 / SDA1 to U15 (the system I2C bus).

The EK-RA8D2 v1 wires U15 (and the Grove / Pmod / mikroBUS / Arduino I2C) to the SYS_I2C bus = RIIC channel 1 on P512 (SCL1) / P511 (SDA1) – confirmed against the FSP EK-RA8D2 quickstart board_cfg_switch (R_IIC_MASTER channel 1, iic1.scl1.p512 / iic1.sda1.p511) and HUM Ch 39. NOT P400/P401 (those are the I3C bus). The earlier P400/P401

  • ra8_i3c_i2c (I3C) wiring talked on the wrong peripheral, which is why every U15 access timed out. SCL1 (P512).

Definition at line 427 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_io_expander_bus_recover(), and internal_io_expander_route_pins().

◆ s_ra8_board_io_expander_pin_sda

const ra8_port_pin_t s_ra8_board_io_expander_pin_sda
static
Initial value:
=
(ra8_port_pin_t) ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_5) << 8) | (uint16_t)(k_ra8_pin_11)))

SDA1 (P511).

Definition at line 429 of file ra8_board_ek_ra8d2_audio_usb.c.

Referenced by internal_io_expander_bus_recover(), and internal_io_expander_route_pins().