|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
SPI_B internal-loopback HIL test for the EK-RA8D2. 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_mstp.h"#include "ra8_spi.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | spi_demo_const_t : uint32_t { k_spi_demo_baud = 115200U , k_spi_demo_period_ms = 1000U , k_spi_demo_spi_baud_hz = 1000000U , k_spi_demo_spi_channel = 0U } |
| App-wide tunables. More... | |
| enum | spi_demo_byte_t : uint8_t { k_spi_demo_pattern_len = 16U , k_spi_demo_pattern_base = 0xA0U } |
| Test pattern width and seed. More... | |
Functions | |
| static void | internal_panic_halt (void) |
| Park forever after a fatal initialization failure. | |
| static void | internal_clocks_or_halt (uint32_t *out_pclka) |
| Bring CGC, MSTP and SysTick up. | |
| static void | internal_setup_or_halt (void) |
| Bring CGC + SysTick + console + SPI_B up. | |
| static bool | internal_round_trip_ok (void) |
| Walk the test pattern once and return whether RX matches TX. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static const uint8_t | s_spi_demo_msg_pass [] = "spi: pass\r\n" |
| static const uint8_t | s_spi_demo_msg_fail [] = "spi: FAIL\r\n" |
SPI_B internal-loopback HIL test for the EK-RA8D2.
Standalone EVM-tier app that exercises the SPI_B controller driver (libs/ra8_hal/inc/ra8_spi.h) via the silicon's internal-loopback mode – no external CIPO/COPI jumper required. The flow:
SCI8 prints "spi: pass\r\n" once a second.
Bare EK-RA8D2 only – no shields or external loopback wiring.
Definition in file main.c.
| enum spi_demo_byte_t : uint8_t |
| enum spi_demo_const_t : uint32_t |
|
static |
Bring CGC, MSTP and SysTick up.
Returns PCLKA Hz via out_pclka.
Initializes the canonical clock tree, samples CPUCLK0 and PCLKA, ungates peripheral modules, and starts the millisecond timebase.
| [out] | out_pclka | Receives the measured peripheral clock frequency. |
Definition at line 98 of file main.c.
References internal_panic_halt(), k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_mstp_init(), and ra8_time_init().
|
static |
Park forever after a fatal initialization failure.
Repeatedly executes WFI so an attached debugger can inspect the failed clock or SPI state without further bus traffic.
Definition at line 78 of file main.c.
References RA8_INTERNAL.
|
static |
Walk the test pattern once and return whether RX matches TX.
Sends the deterministic 0xA0..0xAF sequence one byte at a time and stops at the first HAL error or non-identical loopback byte.
| true | All pattern bytes completed and matched. |
| false | A transfer failed or a received byte differed. |
Definition at line 177 of file main.c.
References k_ra8_ok, k_spi_demo_pattern_base, k_spi_demo_pattern_len, k_spi_demo_spi_channel, RA8_INTERNAL, and ra8_spi_xfer8().
Referenced by main().
|
static |
Bring CGC + SysTick + console + SPI_B up.
Panic-halts on fail.
Passes cfg.loopback = true to ra8_spi_init so the HAL programmes SPCR2.SPLP2=1 while SPE is still 0 (HUM Ch 43.2.4 p 2889). The silicon then ties COPI to CIPO internally; no external loopback jumper required.
Definition at line 134 of file main.c.
References internal_clocks_or_halt(), internal_panic_halt(), k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, k_ra8_spi_mode_0, k_spi_demo_baud, k_spi_demo_spi_baud_hz, k_spi_demo_spi_channel, ra8_board_led_init(), ra8_board_uart_console_init(), RA8_INTERNAL, and ra8_spi_init().
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Brings up SPI_B + loops a self-test pattern.
Definition at line 203 of file main.c.
References internal_panic_halt(), internal_round_trip_ok(), internal_setup_or_halt(), k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, k_spi_demo_period_ms, ra8_board_led_on(), ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), ra8_isr_globals_enable(), s_spi_demo_msg_fail, and s_spi_demo_msg_pass.
|
static |