|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
BSP-driven I2S audio playback demo for EK-RA8D2 (DA7212 CODEC). More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | audio_loopback_config_t : uint32_t { k_audio_loopback_baud = 115200U , k_audio_loopback_print_period = 1000U , k_audio_loopback_sample_rate = 48000U } |
| Compile-time settings for the BSP-driven audio playback demo. More... | |
| enum | audio_loopback_chan_t : uint8_t { k_audio_loopback_bit_depth = 16U , k_audio_loopback_channels = 2U } |
| uint8_t format ids consumed by the BSP audio path. More... | |
| enum | audio_loopback_block_t : uint32_t { k_audio_loopback_block_samples = 128U } |
| Stereo block size in interleaved L/R 16-bit samples. More... | |
Functions | |
| static void | internal_audio_loopback_panic_halt (void) |
| Halt forever in WFI – used as a panic stop on init failure. | |
| static void | internal_audio_loopback_init_clocks_and_led (void) |
| Bring CGC + SysTick + LED1 up. | |
| static void | internal_audio_loopback_init_console (void) |
| Open the BSP J-Link console (SCI8 @ 115200 8N1, PD02/PD03). | |
| static void | internal_audio_loopback_init_codec (void) |
| Bring the on-board DA7212 CODEC + SSIE0 up via the BSP. | |
| static uint32_t | internal_audio_loopback_u32_to_dec (uint32_t value, uint8_t *buf) |
| Convert a 32-bit unsigned integer into an ASCII decimal string. | |
| static void | internal_audio_loopback_print_count (uint32_t block_count) |
| Print "audio: <count> blocks played\\r\\n" over the BSP console. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static const uint8_t | s_audio_loopback_msg_prefix [] = "audio: " |
| Diagnostic banner emitted every k_audio_loopback_print_period blocks. | |
| static const uint8_t | s_audio_loopback_msg_suffix [] = " blocks played\r\n" |
| static const int16_t | s_audio_loopback_silence [k_audio_loopback_block_samples] = {} |
| Static stereo silence buffer fed to the CODEC each iteration. | |
BSP-driven I2S audio playback demo for EK-RA8D2 (DA7212 CODEC).
Brings the chip up via ra8_cgc_init() (XTAL -> PLL1 -> CPUCLK0 = 1 GHz, PCLKA = 125 MHz, SCICLK = PLL1R / 4), then hands the entire SSIE0 + DA7212 CODEC bring-up to the EK-RA8D2 BSP via ra8_board_audio_init(48000, 16, 2). The BSP routes the CODEC pins (P403/P404/P405/P406/PD06 + I2C control on P511/P512 per UM Table 32 p 38), enables SSIE0 in I2S controller mode, and exposes ra8_board_audio_play_sample_block for stereo PCM block writes.
After init the firmware loops feeding a small repeating stereo buffer to ra8_board_audio_play_sample_block, prints "audio: <N> blocks played\r\n" over the J-Link OB CDC port (SCI8 @ 115200) every k_audio_loopback_print_period blocks, and toggles LED1 once per log line.
Sequence:
Definition in file main.c.
| enum audio_loopback_block_t : uint32_t |
| enum audio_loopback_chan_t : uint8_t |
| enum audio_loopback_config_t : uint32_t |
Compile-time settings for the BSP-driven audio playback demo.
The print throttle is per-1000 blocks; at 48 kHz with 64 stereo frames per block that is one log line every ~1.3 s.
| Enumerator | |
|---|---|
| k_audio_loopback_baud | Audio loopback baud. |
| k_audio_loopback_print_period | Audio loopback print period. |
| k_audio_loopback_sample_rate | Audio loopback sample rate. |
|
static |
Bring CGC + SysTick + LED1 up.
Halts on any fail.
Splits the long boot sequence so each step stays under the NASA Power-of-10 60-line function-size cap.
Definition at line 135 of file main.c.
References internal_audio_loopback_panic_halt(), k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, and ra8_time_init().
Referenced by main().
|
static |
Bring the on-board DA7212 CODEC + SSIE0 up via the BSP.
ra8_board_audio_init routes the CODEC pins (P403/P404/P405/P406/ PD06 per UM Table 32 p 38) and brings SSIE0 up in I2S controller mode at the requested format. The application no longer touches SSIE registers directly.
Definition at line 196 of file main.c.
References internal_audio_loopback_panic_halt(), k_audio_loopback_bit_depth, k_audio_loopback_channels, k_audio_loopback_sample_rate, k_ra8_ok, ra8_board_audio_init(), and RA8_INTERNAL.
Referenced by main().
|
static |
Open the BSP J-Link console (SCI8 @ 115200 8N1, PD02/PD03).
Hands the SCI8 + PD02 TXD / PD03 RXD pin routing and baud setup to the EK-RA8D2 BSP via ra8_board_uart_console_init.
Definition at line 170 of file main.c.
References internal_audio_loopback_panic_halt(), k_audio_loopback_baud, k_ra8_ok, ra8_board_uart_console_init(), and RA8_INTERNAL.
Referenced by main().
|
static |
Halt forever in WFI – used as a panic stop on init failure.
Masks no additional interrupts; repeated WFI instructions keep the core quiescent while preserving register state for a debugger.
Definition at line 110 of file main.c.
References RA8_INTERNAL.
Referenced by internal_audio_loopback_init_clocks_and_led(), internal_audio_loopback_init_codec(), internal_audio_loopback_init_console(), and main().
|
static |
Print "audio: <count> blocks played\\r\\n" over the BSP console.
Formats the count into a bounded stack buffer and emits the prefix, digits, and suffix as three allocation-free console writes.
| [in] | block_count | Cumulative block count. |
< Dec buffer.
Definition at line 272 of file main.c.
References internal_audio_loopback_u32_to_dec(), ra8_board_uart_console_write(), RA8_INTERNAL, s_audio_loopback_msg_prefix, and s_audio_loopback_msg_suffix.
Referenced by main().
|
static |
Convert a 32-bit unsigned integer into an ASCII decimal string.
Builds digits least-significant first in a bounded local array, then reverses them into the caller's output buffer without heap use.
| [in] | value | Integer value to convert. |
| [out] | buf | Caller buffer, must hold at least 11 bytes. |
| 1 | One byte was written for the value zero. |
| 2..10 | The number of decimal digits written for a nonzero value. |
< '0'.
< Radix.
< 2^32 - 1 has at most 10 digits.
Definition at line 229 of file main.c.
References RA8_INTERNAL.
Referenced by internal_audio_loopback_print_count().
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
|
static |
Diagnostic banner emitted every k_audio_loopback_print_period blocks.
Definition at line 80 of file main.c.
Referenced by internal_audio_loopback_print_count().
|
static |
Definition at line 81 of file main.c.
Referenced by internal_audio_loopback_print_count().
|
static |