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
Go to the documentation of this file.
1
28
29#include <stddef.h>
30#include <stdint.h>
31
32#include "ra8_attributes.h"
33#include "ra8_board_ek_ra8d2.h"
35#include "ra8_cgc.h"
36#include "ra8_err.h"
37#include "ra8_gpio_constants.h"
38#include "ra8_i2c.h"
39#include "ra8_mpc.h"
40#include "ra8_mstp.h"
41#include "ra8_pfs_regs.h"
42#include "ra8_port_constants.h"
43#include "ra8_port_utils.h"
44#include "ra8_ssie.h"
45#include "ra8_time.h"
46#include "ra8_usb.h"
47
48/* =============================================================================
49 * 4. Audio CODEC (UM Table 32, page 38)
50 * =============================================================================
51 */
52
56static bool s_audio_initialized = false;
57
76
84
88typedef enum : uint8_t {
91
92/* Map ``bit_depth`` (significant bits) to SSIE DWL / SWL pair -- see implementation for details. */
94 ra8_ssie_data_word_t* out_dwl,
96{
97 switch ((ra8_audio_bit_depth_t)bit_depth) {
99 *out_dwl = k_ra8_ssie_dwl_8;
100 *out_swl = k_ra8_ssie_swl_8;
101 return k_ra8_ok;
103 *out_dwl = k_ra8_ssie_dwl_16;
104 *out_swl = k_ra8_ssie_swl_16;
105 return k_ra8_ok;
107 *out_dwl = k_ra8_ssie_dwl_18;
108 *out_swl = k_ra8_ssie_swl_24;
109 return k_ra8_ok;
111 *out_dwl = k_ra8_ssie_dwl_20;
112 *out_swl = k_ra8_ssie_swl_24;
113 return k_ra8_ok;
115 *out_dwl = k_ra8_ssie_dwl_22;
116 *out_swl = k_ra8_ssie_swl_24;
117 return k_ra8_ok;
119 *out_dwl = k_ra8_ssie_dwl_24;
120 *out_swl = k_ra8_ssie_swl_24;
121 return k_ra8_ok;
123 *out_dwl = k_ra8_ssie_dwl_32;
124 *out_swl = k_ra8_ssie_swl_32;
125 return k_ra8_ok;
126 default:
128 }
129}
130
131/* Route the six DA7212 audio pins (4 SSIE + 2 IIC) to their alt fns -- see implementation for details. */
133{
134 /* k_ra8_psel_ssie comes from HUM Ch 19 PFS PSEL field. MCLK on PD06
135 * stays in GPIO mode -- the application picks SSIE EXTAL or CGC
136 * clock-out explicitly. */
137 const struct {
139 ra8_psel_t psel;
140 const char* owner;
141 } routes[] = {
145 {(ra8_port_pin_t)k_ra8_board_audio_pin_datout, k_ra8_psel_ssie, "ra8_board.audio.datout"},
146 {(ra8_port_pin_t)k_ra8_board_audio_pin_i2c_sda, k_ra8_psel_iic, "ra8_board.audio.i2c.sda"},
147 {(ra8_port_pin_t)k_ra8_board_audio_pin_i2c_scl, k_ra8_psel_iic, "ra8_board.audio.i2c.scl"},
148 };
149 for (uint32_t i = 0U; i < sizeof(routes) / sizeof(routes[0]); ++i) {
150 const ra8_err_t err = ra8_pfs_route_peripheral(routes[i].pin, routes[i].psel, routes[i].owner);
151 if (err != k_ra8_ok) {
152 return err;
153 }
154 }
155 return k_ra8_ok;
156}
157
181{
182 return (ra8_ssie_cfg_t){
184 .format = (channels == (uint8_t)k_ra8_audio_channels_mono) ? k_ra8_ssie_format_monaural
186 .data_word = dwl,
187 .system_word = swl,
188 .bclk_div = k_ra8_ssie_bclk_div_4,
189 .use_gpt_clk = false,
190 .long_frame = false,
191 .bckp_rising = false,
192 .lrckp_low = false,
193 .spdp_high = false,
194 .byte_swap = false,
195 .lr_continue = false,
196 .bck_idle_stop = false,
197 .enable_aucke = true,
198 .tx_threshold = 0U,
199 .rx_threshold = 0U,
200 };
201}
202
203ra8_err_t ra8_board_audio_init(uint32_t sample_rate_hz, uint8_t bit_depth, uint8_t channels)
204{
205 if (sample_rate_hz == 0U) {
207 }
208 if (channels != (uint8_t)k_ra8_audio_channels_mono &&
209 channels != (uint8_t)k_ra8_audio_channels_stereo) {
211 }
214 ra8_err_t berr = internal_audio_bits_to_word(bit_depth, &dwl, &swl);
215 if (berr != k_ra8_ok) {
216 return berr;
217 }
218
219 /* Step 1: route the four DAI pins to SSIE0 + the I2C control pair
220 * to IIC1 (UM Table 32 p 38). */
222 if (rerr != k_ra8_ok) {
223 return rerr;
224 }
225
226 /* Step 2: bring up SSIE0 in I2S controller mode. */
227 (void)sample_rate_hz;
228 const ra8_ssie_cfg_t cfg = internal_audio_build_ssie_cfg(channels, dwl, swl);
229 const ra8_err_t serr = ra8_ssie_init((uint8_t)k_ra8_board_audio_ssie_channel, &cfg);
230 if (serr != k_ra8_ok) {
232 }
233 s_audio_initialized = true;
234 return k_ra8_ok;
235}
236
237ra8_err_t ra8_board_audio_play_sample_block(const int16_t* buf, uint32_t len)
238{
239 if (buf == nullptr) {
241 }
242 if (len == 0U || (len % (uint32_t)k_ra8_audio_samples_per_word) != 0U) {
244 }
245 if (!s_audio_initialized) {
247 }
248 /* Two int16_t samples (one stereo frame) pack into one 32-bit SSIE
249 * FIFO word; len is guaranteed even by the check above. The buffer
250 * is a contiguous PCM stream the SSIE FIFO consumes 32 bits at a
251 * time. Reinterpret via uintptr_t so we neither (a) double-hop
252 * through void* (bugprone-casting-through-void) nor (b) trip
253 * cast-align by going int16_t* -> uint32_t* directly. The caller
254 * contract requires ``buf`` to be 32-bit aligned (one stereo frame
255 * naturally aligns); see ra8_board_audio_play_sample_block docs. */
256 const uint32_t words = len / (uint32_t)k_ra8_audio_samples_per_word;
257 const uintptr_t addr = (uintptr_t)buf;
258 const uint32_t* const packed = (const uint32_t*)addr;
259 uint16_t written = 0U;
261 packed,
262 (uint16_t)words,
263 &written);
264 if (err != k_ra8_ok) {
265 return err;
266 }
267 if (written != (uint16_t)words) {
269 }
270 return k_ra8_ok;
271}
272
273/* =============================================================================
274 * 7. USB stubs (HS HAL not yet wired to BSP)
275 * =============================================================================
276 */
277
294volatile uint32_t g_usbhs_probe = 0U;
295
307
336{
339 if (err != k_ra8_ok) {
340 return err;
341 }
342 /* DO NOT call ra8_mstp_init() here -- it gates ALL modules (IOPORT,
343 * SCI, etc.) and the chip faults trying to access already-running
344 * peripherals. ra8_mstp_init must run exactly once per boot, before
345 * any peripheral is brought up; the boot-time path handles that.
346 * ra8_mstp_enable below uses the existing ref-counted state. */
349}
350
351/* =============================================================================
352 * U15 PI4IOE5V6408 I/O expander -- SW4 override (J7 USB role select etc.)
353 *
354 * EK-RA8D2 v1 UM Rev 1.01 Section 5.5.3 + Section 4 p 16:
355 * "The EK-RA8D2 features an I2C I/O Port Expander (PI4IOE5V6408) at
356 * U15 which has the I2C address 0x43. The port expander is connected
357 * to the configuration switches SW4 and allows the settings to be
358 * read (when the I/O expander port is set to input) or overridden
359 * (when the I/O expander port is set to output) by software."
360 *
361 * Register map and polarity convention come from Renesas's reference
362 * driver in ``ra-fsp-examples/ek_ra8t2/board_cfg_switch.c`` (the EK-RA8T2
363 * sister board uses an identical wiring).
364 * =============================================================================
365 */
366
371
387
403
409
414
431
448
454
455/* internal_io_expander_write_reg -- see implementation for details. */
457{
458 const uint8_t buf[2] = {reg, val};
459 /* Each PI4IOE5V6408 register write is a complete START..STOP
460 * transaction. Chaining them with repeated-START (send_stop = false)
461 * leaves the bus held and the device's command parser misaligned on the
462 * third back-to-back write, so always close the transaction with a STOP. */
465 buf,
466 sizeof(buf),
467 true);
468}
469
492static volatile uint32_t s_io_expander_probe = 0U;
493
505
520{
521 for (volatile uint32_t i = 0U; i < (uint32_t)k_ra8_board_i2c_recover_spins; i++) {
522 __asm__ volatile("nop");
523 }
524}
525
545{
549 if (err != k_ra8_ok) {
550 return err;
551 }
553 if (err != k_ra8_ok) {
554 (void)ra8_gpio_release(scl);
555 return err;
556 }
557 for (uint32_t i = 0U; i < (uint32_t)k_ra8_board_i2c_recover_pulses; i++) {
559 const ra8_err_t rd = ra8_gpio_read(sda, &sda_lvl);
560 if (rd == k_ra8_ok) {
561 if (sda_lvl == k_ra8_level_high) {
562 break; /* peripheral released SDA -- bus is free */
563 }
564 }
569 }
570 /* Frame a STOP (SDA low->high while SCL high) to end any partial frame,
571 * then release both pins for the IIC mux to re-claim. */
572 (void)ra8_gpio_release(sda);
578 (void)ra8_gpio_release(sda);
579 (void)ra8_gpio_release(scl);
580 return k_ra8_ok;
581}
582
607
622{
625 "ra8_board.io_exp.scl1");
626 if (err != k_ra8_ok) {
627 return err;
628 }
630 if (err != k_ra8_ok) {
631 return err;
632 }
635 "ra8_board.io_exp.sda1");
636 if (err != k_ra8_ok) {
637 return err;
638 }
640}
641
667 uint8_t output_mask)
668{
670 ra8_err_t err =
672 if (err != k_ra8_ok) {
673 return err;
674 }
678 if (err != k_ra8_ok) {
679 return err;
680 }
683}
684
715 uint8_t output_mask)
716{
717 /* Step -1: clock out any wedged peripheral (stuck SDA) before touching
718 * the bus, so a prior aborted transfer cannot deadlock every START. */
720 if (err != k_ra8_ok) {
721 return err;
722 }
723
724 /* Step 0: drive P109/P311 high so the SCL1/SDA1 bus has pull-ups
725 * (EK-RA8D2 v1 UM Table 23). Without this the open-drain bus floats
726 * and U15 cannot ACK. */
728 if (err != k_ra8_ok) {
729 return err;
730 }
731
732 /* Step 1: route P512 -> SCL1 and P511 -> SDA1 with NCODR on both
733 * (HUM Ch 20.6 PSEL table p 859). */
736 if (err != k_ra8_ok) {
737 return err;
738 }
739
740 /* Step 2: bring RIIC channel 1 up at 100 kHz. ra8_i2c_init ungates
741 * the per-channel MSTP gate (IIC1 = MSTPB8) itself, so no separate
742 * MSTP enable is needed here. */
744 const ra8_i2c_cfg_t cfg = {
745 .bus_hz = (uint32_t)k_ra8_board_io_expander_bus_hz,
746 .pclkb_hz = (uint32_t)k_ra8_board_io_expander_pclkb_hz,
747 };
749 if (err != k_ra8_ok) {
750 return err;
751 }
752
753 /* Step 4: program U15 in FSP-reference order. */
754 err = internal_io_expander_program_u15(output_byte, output_mask);
755 if (err != k_ra8_ok) {
756 return err;
757 }
759 return k_ra8_ok;
760}
761
767
787
819
821{
822 return internal_io_expander_apply_mask(output_byte,
824}
825
826ra8_err_t ra8_board_io_expander_apply_sw4_mask(uint8_t output_byte, uint8_t output_mask)
827{
828 return internal_io_expander_apply_mask(output_byte, output_mask);
829}
830
836
858volatile uint32_t g_usbhs_role_pin_probe = 0U;
859
867volatile uint32_t g_usbhs_role_pin_err = 0U;
868
875
896{
898 /* PD07 (port 13, pin 7). The ra8_port_pin_t enum only pre-defines LED
899 * pins, so any other packed value lands outside the enumerator set
900 * and trips clang-analyzer EnumCastOutOfRange; suppress in the same
901 * pattern used elsewhere in this file for board-specific pins. */
904 g_usbhs_role_pin_err = (uint32_t)err;
906 if (err == k_ra8_ok) {
908 }
909 return err;
910}
911
913{
914 /* HUM Ch 9 (CGC) USBCKCR p 365 + HUM Ch 11 (MSTP) MSTPCRB12 p 469
915 * stage the PHY clock and ungate the controller block; then the
916 * generic device-mode entry in libs/ra8_hal/inc/ra8_usb.h drives
917 * SYSCFG.SCKE / USBE / HSE and arms the device IRQ set.
918 *
919 * EK-RA8D2 v1 UM Rev 1.01 Section 6.2 p 34 ("USB High Speed"): J7's
920 * role is selected by the MCU GPIO PD07 -- LOW = Device, HIGH = Host.
921 * Drive PD07 low directly (no U15 I/O-expander dependency required;
922 * U15 is only an SW4 override path, see Section 4.3.4 p 16 / Table 23
923 * pullup-config p 31). The U15 helper is invoked best-effort below
924 * for boards where PD07 alone is insufficient (e.g. SW4-8 mechanical
925 * position contradicts the firmware intent), but its failure is
926 * non-fatal because PD07 already strapped the role line. */
928 if (pd07_err != k_ra8_ok) {
929 return pd07_err;
930 }
931
932 /* Best-effort U15 override (logged via s_io_expander_probe). The U15
933 * I2C path may NACK if SW4-5 is OFF (I2C/I3C-Select strap routes the
934 * shared bus elsewhere) -- non-fatal because PD07 already strapped
935 * the role. */
937 (void)io_err;
939 if (err != k_ra8_ok) {
940 return err;
941 }
945 return rc_dev;
946}
947
949{
950 /* Symmetric to ra8_board_usbhs_device_init. EK-RA8D2 v1 UM Rev 1.01
951 * Table 28 lists USBHS_VBUSEN / USBHS_OVRCUR as PHY-controller
952 * pins not routed to RA8D2 port pins, so VBUS sourcing is left to
953 * the on-board USB-PD controller. ra8_usb_host_init drives
954 * SYSCFG.DCFM=1 / DRPD=1 / USBE=1 plus the DCP setup. */
956 if (err != k_ra8_ok) {
957 return err;
958 }
960}
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.
const char * owner
Owner.
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.
Definition ra8_err.h:290
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
Definition ra8_err.h:304
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
Definition ra8_err.h:235
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
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.
Definition ra8_i2c.c:579
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.
Definition ra8_mpc.c:198
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.
Definition ra8_mstp.c:343
@ 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_7
RA8 pin 7.
@ k_ra8_pin_12
RA8 pin 12.
@ k_ra8_pin_9
RA8 pin 9.
@ 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.
Definition gpio.c:210
ra8_err_t ra8_gpio_input_init(ra8_port_pin_t pin, ra8_pin_pull_t pull)
Configure a pin as a digital input.
Definition gpio.c:121
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.
Definition gpio.c:88
ra8_err_t ra8_gpio_write(ra8_port_pin_t pin, ra8_level_t level)
Drive a previously-configured output to the given level.
Definition gpio.c:154
ra8_err_t ra8_gpio_release(ra8_port_pin_t pin)
Release a GPIO pin claim.
Definition gpio.c:233
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.
Definition gpio.c:238
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.
Definition ra8_ssie.c:794
ra8_err_t ra8_ssie_init(uint8_t channel, const ra8_ssie_cfg_t *cfg)
Initialise an SSIE channel for I2S / TDM / monaural transfer.
Definition ra8_ssie.c:610
@ k_ra8_ssie_format_i2s
I2S, 2 channels per frame.
Definition ra8_ssie.h:128
@ k_ra8_ssie_format_monaural
Monaural single-channel.
Definition ra8_ssie.h:131
ra8_ssie_system_word_t
System word length (drives SSICR.SWL[2:0]).
Definition ra8_ssie.h:169
@ k_ra8_ssie_swl_32
32-bit system word.
Definition ra8_ssie.h:173
@ k_ra8_ssie_swl_24
24-bit system word.
Definition ra8_ssie.h:172
@ k_ra8_ssie_swl_16
16-bit system word.
Definition ra8_ssie.h:171
@ k_ra8_ssie_swl_8
8-bit system word.
Definition ra8_ssie.h:170
@ k_ra8_ssie_bclk_div_4
AUDIO_MCK / 4.
Definition ra8_ssie.h:192
ra8_ssie_data_word_t
Data word length (drives SSICR.DWL[2:0]).
Definition ra8_ssie.h:151
@ k_ra8_ssie_dwl_32
32-bit data word.
Definition ra8_ssie.h:158
@ k_ra8_ssie_dwl_16
16-bit data word.
Definition ra8_ssie.h:153
@ k_ra8_ssie_dwl_20
20-bit data word.
Definition ra8_ssie.h:155
@ k_ra8_ssie_dwl_18
18-bit data word.
Definition ra8_ssie.h:154
@ k_ra8_ssie_dwl_8
8-bit data word.
Definition ra8_ssie.h:152
@ k_ra8_ssie_dwl_24
24-bit data word.
Definition ra8_ssie.h:157
@ k_ra8_ssie_dwl_22
22-bit data word.
Definition ra8_ssie.h:156
@ k_ra8_ssie_role_controller
Bit clock + LR clock are outputs.
Definition ra8_ssie.h:105
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.
Definition ra8_i2c.h:97
Configuration descriptor for ra8_ssie_init.
Definition ra8_ssie.h:246