67typedef enum : uint8_t {
80typedef enum : uint8_t {
88typedef enum : uint8_t {
149 for (uint32_t i = 0U; i <
sizeof(routes) /
sizeof(routes[0]); ++i) {
189 .use_gpt_clk =
false,
191 .bckp_rising =
false,
195 .lr_continue =
false,
196 .bck_idle_stop =
false,
197 .enable_aucke =
true,
205 if (sample_rate_hz == 0U) {
227 (void)sample_rate_hz;
239 if (buf ==
nullptr) {
257 const uintptr_t addr = (uintptr_t)buf;
258 const uint32_t*
const packed = (
const uint32_t*)addr;
259 uint16_t written = 0U;
267 if (written != (uint16_t)words) {
300typedef enum : uint32_t {
368typedef enum : uint8_t {
379typedef enum : uint8_t {
398typedef enum : uint8_t {
405typedef enum : uint32_t {
411typedef enum : uint8_t {
450typedef enum : uint32_t {
458 const uint8_t buf[2] = {reg, val};
497typedef enum : uint32_t {
522 __asm__
volatile(
"nop");
625 "ra8_board.io_exp.scl1");
635 "ra8_board.io_exp.sda1");
870typedef enum : uint32_t {
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_board_io_expander_channel_t
IIC channel index used for the U15 expander (RIIC channel 1).
@ k_ra8_board_io_expander_iic_channel
RA8 board io expander iic channel.
ra8_err_t ra8_board_io_expander_set_usbhs_host_mode(void)
Implementation of ra8_board_io_expander_set_usbhs_host_mode().
static ra8_err_t internal_usbhs_role_select_device(void)
Drive PD07 low to strap the J7 USB-HS role line to "Device".
ra8_audio_channels_t
Sample-frame channel counts the BSP accepts.
@ k_ra8_audio_channels_mono
RA8 audio channels mono.
@ k_ra8_audio_channels_stereo
RA8 audio channels stereo.
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 bool s_audio_initialized
Tracks whether ra8_board_audio_init has succeeded.
volatile uint32_t g_usbhs_probe
Temporary bisect probe for USBHS bring-up HardFault.
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_io_expander_apply_project_sw4_defaults(void)
Program U15 with this project's SW4 override pattern.
static const ra8_port_pin_t s_ra8_board_io_expander_pin_pullup_b
P311 pull-up enable.
ra8_err_t ra8_board_usbhs_host_init(void)
Bring the chip USBHS module up in host mode.
ra8_audio_bit_depth_t
Supported PCM significant-bit-depth values for the DA7212 path.
@ k_ra8_audio_bits_18
RA8 audio bits 18.
@ k_ra8_audio_bits_20
RA8 audio bits 20.
@ k_ra8_audio_bits_16
RA8 audio bits 16.
@ k_ra8_audio_bits_32
RA8 audio bits 32.
@ k_ra8_audio_bits_22
RA8 audio bits 22.
@ k_ra8_audio_bits_24
RA8 audio bits 24.
@ k_ra8_audio_bits_8
RA8 audio bits 8.
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_audio_pack_t
Stereo-frame packing factor (two int16_t samples per 32-bit word).
@ k_ra8_audio_samples_per_word
RA8 audio samples per word.
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_audio_route_pins(void)
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.
static ra8_err_t internal_usbhs_clock_and_mstp(void)
Shared CGC + MSTP bring-up for both USBHS modes.
ra8_board_i2c_recover_t
Bit-bang bus-recovery tunables for the system I2C bus.
@ k_ra8_board_i2c_recover_spins
Busy-loop iterations ~= one SCL half-period.
@ k_ra8_board_i2c_recover_pulses
SCL clocks to flush one stuck byte + ACK.
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 volatile uint32_t s_io_expander_probe
Bisect-probe progress counter for ra8_board_io_expander_set_usbhs_device_mode.
ra8_board_io_expander_addr_t
PI4IOE5V6408 7-bit I2C address on EK-RA8D2 v1 (SW4 sibling).
@ k_ra8_board_io_expander_addr
RA8 board io expander address.
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.
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).
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_set_octospi_active(void)
Program the U15 I/O expander to request the Octo-SPI SW4 layout.
static ra8_err_t internal_io_expander_enable_pullups(void)
Drive the system-I2C pull-up enable pins (P109/P311) high.
ra8_board_io_expander_clk_t
IIC1 (system I2C) configuration shared by every U15 access.
@ k_ra8_board_io_expander_pclkb_hz
PCLKB = PLL1P/16 post-CGC.
@ k_ra8_board_io_expander_bus_hz
100 kHz Sm.
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.
io_exp_probe_step_t
Step values for s_io_expander_probe (see variable docs).
@ k_io_exp_probe_pre_init
Io exp probe pre init.
@ 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_pre_write_out
Io exp probe pre write out.
@ k_io_exp_probe_pre_pfs
Io exp probe pre PFS.
@ k_io_exp_probe_success
Io exp probe success.
volatile uint32_t g_usbhs_role_pin_probe
Bisect-probe progress counter for the PD07 USB-HS role-select drive.
static const ra8_port_pin_t s_ra8_board_io_expander_pin_sda
SDA1 (P511).
volatile uint32_t g_usbhs_role_pin_err
Last ra8_err_t returned by the PD07 GPIO drive (0 = k_ra8_ok).
static ra8_err_t internal_io_expander_route_pins(void)
Route P512/P511 to SCL1/SDA1 with N-channel open-drain enabled.
ra8_board_pi4ioe_magic_t
Magic-value writes for ra8_board_io_expander_set_usbhs_device_mode.
@ k_ra8_board_pi4ioe_hiz_none
RA8 board pi4ioe hiz none.
@ k_ra8_board_pi4ioe_output_all_high
RA8 board pi4ioe output all high.
@ k_ra8_board_pi4ioe_iodir_all_outputs
RA8 board pi4ioe iodir all outputs.
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 out...
usbhs_probe_step_t
Bisect-probe step values for g_usbhs_probe.
@ 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_post_usb_dev_init
after ra8_usb_device_init.
@ k_usbhs_probe_pre_usb_dev_init
before ra8_usb_device_init(hs).
ra8_board_pi4ioe_reg_t
PI4IOE5V6408 register addresses.
@ k_ra8_board_pi4ioe_reg_devid
Device ID register.
@ k_ra8_board_pi4ioe_reg_input_lvl
Input state.
@ k_ra8_board_pi4ioe_reg_hiz
1 = output Hi-Z.
@ k_ra8_board_pi4ioe_reg_iodir
1 = output.
@ k_ra8_board_pi4ioe_reg_output
1 = HIGH (== SW4 OFF).
@ k_ra8_board_pi4ioe_reg_pud_sel
Pull-up/down select.
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_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.
usbhs_role_probe_step_t
Probe step values for g_usbhs_role_pin_probe.
@ k_usbhs_role_probe_pre_init
Usbhs role probe pre init.
@ k_usbhs_role_probe_success
Usbhs role probe success.
@ k_usbhs_role_probe_post_init
Usbhs role probe post init.
static ra8_err_t internal_io_expander_bus_recover(void)
Bit-bang up to 9 SCL clocks to free a wedged system I2C bus.
Private diagnostic surface for the EK-RA8D2 audio and USB BSP.
@ k_ra8_board_pi4ioe_output_project_default
U15 output byte that drives the SW4 layout above.
@ k_ra8_board_pi4ioe_output_usbhs_host
Project layout with USBHS in HOST role: the project default (0xF2) with bit 7 (SW4-8,...
@ k_ra8_board_pi4ioe_output_octospi_active
U15 output byte that ELECTRICALLY ENABLES the on-board Octo-SPI flash.
@ k_ra8_board_audio_pin_i2c_sda
P511 (SDA1), EK-RA8D2 UM Table 32 p 38.
@ k_ra8_board_audio_pin_datin
P405 (J41), EK-RA8D2 UM Table 32 p 38.
@ k_ra8_board_audio_pin_bclk
P403, EK-RA8D2 UM Table 32 p 38.
@ k_ra8_board_audio_pin_wclk
P404, EK-RA8D2 UM Table 32 p 38.
@ k_ra8_board_audio_pin_i2c_scl
P512 (SCL1), EK-RA8D2 UM Table 32 p 38.
@ k_ra8_board_audio_pin_datout
P406 (J41), EK-RA8D2 UM Table 32 p 38.
@ k_ra8_board_audio_ssie_channel
RA8 board audio ssie channel.
ra8_board_eth_pin_t pin
Pin.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_usbhs_pll_enable(void)
Bring up the USBHS PHY reference clock + module clock.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
PSEL codes for peripheral pin routing on the RA8D2.
ra8_psel_t
Peripheral-function select codes (written to PSEL[4:0]).
@ k_ra8_psel_iic
00111b: IIC / I3C controller-peripheral.
@ k_ra8_psel_ssie
10010b: SSIE I2S audio.
I2C Bus Interface (IIC) controller driver – polling mode.
ra8_err_t ra8_i2c_init(uint8_t channel, const ra8_i2c_cfg_t *cfg)
Initialise an IIC channel as a controller and bring the bus up.
ra8_err_t ra8_i2c_write(uint8_t channel, uint8_t peripheral_7b, const uint8_t *data, uint32_t len, bool send_stop)
Polling write of len bytes to a 7-bit peripheral address.
Multi-function Pin Controller (MPC) facade.
ra8_err_t ra8_mpc_set_open_drain(ra8_port_t port, ra8_pin_t pin, bool enable)
Enable or disable N-channel open-drain on a pin.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
@ k_ra8_mstp_usbhs
MSTPB12 USBHS.
Pin Function Select (PFS) register layout for the Renesas RA8D2.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_port_13
RA8 port 13.
@ k_ra8_port_3
RA8 port 3.
@ k_ra8_port_5
RA8 port 5.
@ k_ra8_port_1
RA8 port 1.
#define RA8_PIN(port, pin)
Build a ra8_port_pin_t from explicit port / pin indices.
ra8_level_t
Digital output / input level.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
@ k_ra8_pin_11
RA8 pin 11.
@ k_ra8_pin_12
RA8 pin 12.
@ k_ra8_pull_up
Internal pull-up.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_gpio_read(ra8_port_pin_t pin, ra8_level_t *out_level)
Read a previously-configured input.
ra8_err_t ra8_gpio_input_init(ra8_port_pin_t pin, ra8_pin_pull_t pull)
Configure a pin as a digital input.
ra8_err_t ra8_gpio_output_init(ra8_port_pin_t pin, ra8_level_t init_level)
Configure a pin as a digital output and drive it to an initial level.
ra8_err_t ra8_gpio_write(ra8_port_pin_t pin, ra8_level_t level)
Drive a previously-configured output to the given level.
ra8_err_t ra8_gpio_release(ra8_port_pin_t pin)
Release a GPIO pin claim.
ra8_err_t ra8_pfs_route_peripheral(ra8_port_pin_t pin, ra8_psel_t psel, const char *owner)
Route a pin to a non-IRQ peripheral function via PFS.PSEL.
Serial Sound Interface Enhanced (SSIE / I2S audio) driver.
ra8_err_t ra8_ssie_write_buffer(uint8_t channel, const uint32_t *buffer, uint16_t samples, uint16_t *out_written)
Drain a host buffer into the TX FIFO until either runs out.
ra8_err_t ra8_ssie_init(uint8_t channel, const ra8_ssie_cfg_t *cfg)
Initialise an SSIE channel for I2S / TDM / monaural transfer.
@ k_ra8_ssie_format_i2s
I2S, 2 channels per frame.
@ k_ra8_ssie_format_monaural
Monaural single-channel.
ra8_ssie_system_word_t
System word length (drives SSICR.SWL[2:0]).
@ k_ra8_ssie_swl_32
32-bit system word.
@ k_ra8_ssie_swl_24
24-bit system word.
@ k_ra8_ssie_swl_16
16-bit system word.
@ k_ra8_ssie_swl_8
8-bit system word.
@ k_ra8_ssie_bclk_div_4
AUDIO_MCK / 4.
ra8_ssie_data_word_t
Data word length (drives SSICR.DWL[2:0]).
@ k_ra8_ssie_dwl_32
32-bit data word.
@ k_ra8_ssie_dwl_16
16-bit data word.
@ k_ra8_ssie_dwl_20
20-bit data word.
@ k_ra8_ssie_dwl_18
18-bit data word.
@ k_ra8_ssie_dwl_8
8-bit data word.
@ k_ra8_ssie_dwl_24
24-bit data word.
@ k_ra8_ssie_dwl_22
22-bit data word.
@ k_ra8_ssie_role_controller
Bit clock + LR clock are outputs.
SysTick-based tick counter, delay and timestamp helpers.
Native USB controller driver public API (device + host modes).
ra8_err_t ra8_usb_device_init(ra8_usb_speed_t speed)
Bring up a USB controller in device mode.
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
ra8_err_t ra8_usb_host_init(ra8_usb_speed_t speed)
Bring up a USB controller in HOST mode.
Configuration descriptor for ra8_i2c_init.
Configuration descriptor for ra8_ssie_init.