143#ifndef RA8_OFF_TARGET
244 const uint32_t pclka = *(
const uint32_t*)ctx;
385 uint32_t blocks = 0U;
427 (void)first_unused_memory;
472 __asm__
volatile(
"wfi");
537 uint32_t cpuclk0_hz = 0U;
538 uint32_t pclka_hz = 0U;
594#ifndef RA8_OFF_TARGET
void main(void)
Secure fallback main entry point.
static uint32_t s_pclka_hz
void tx_application_define(void *first_unused_memory)
ThreadX system-define hook: build worker thread + byte pool.
void _tx_timer_interrupt(void)
void SysTick_Handler(void)
SysTick exception handler – tail-calls the ThreadX timer.
static volatile bool s_tx_kernel_up
Set in tx_application_define; gates ThreadX tick delivery.
static UCHAR s_host_stack[k_wlun_host_stack]
Stack backing storage for s_host_thread.
static TX_THREAD s_device_thread
ThreadX TCB for the USBX device-side worker thread.
static CHAR s_host_thread_name[]
static TX_THREAD s_host_thread
ThreadX TCB for the host-side worker thread.
static UCHAR s_device_stack[k_wlun_thread_stack]
Stack backing storage for s_device_thread.
static CHAR s_device_thread_name[]
static volatile uint32_t s_dbg_sd_err
SD bring-up result: 0 = card enumerated OK, else the error code.
static void microsd_route_usb_or_halt(void)
Route both ports' pins: FS as device, HS as host.
static void microsd_setup_or_halt(void)
Bring CGC + both USB clocks + SysTick + SCI8 + LEDs + pins up.
static ra8_err_t microsd_sd_snapshot(void)
Bring the card up and snapshot LBA 0..63 into RAM (read-only).
static const ra8_port_pin_t k_microsd_pin_sd_cipo
Pmod2 microSD SPI CIPO (card -> MCU).
static const ra8_port_pin_t k_microsd_pin_sd_copi
Pmod2 microSD SPI COPI (MCU -> card).
static ra8_err_t microsd_spi_cs(void *ctx, bool asserted)
SD transport hook: drive the chip-select line.
static const ra8_port_pin_t k_microsd_pin_sd_sck
Pmod2 microSD SPI clock (SCI0, Simple-SPI).
static ra8_err_t microsd_spi_xfer(void *ctx, const uint8_t *tx, uint8_t *rx, uint32_t len)
SD transport hook: full-duplex SPI byte exchange.
static const ra8_port_pin_t k_microsd_pin_fs_dm
USBFS D- (P8_15).
static const ra8_port_pin_t k_microsd_pin_fs_vbusen
USBFS VBUSEN (P5_00) – GPIO LOW for the device role.
static volatile uint32_t s_dbg_sd_blocks
SD card capacity in 512-B blocks (sanity probe).
static void microsd_panic_halt(void)
Halt forever in WFI – panic stop on init failure.
static ra8_err_t microsd_spi_set_clock(void *ctx, uint32_t hz)
SD transport hook: program the Simple-SPI bit clock.
static const ra8_port_pin_t k_microsd_pin_sd_cs
Pmod2 microSD chip-select (GPIO, idle high).
static const ra8_port_pin_t k_microsd_pin_hs_pwr
J7 host-power switch (PD07): HIGH = U18 supplies VBUS (UM 6.2).
static const ra8_port_pin_t k_microsd_pin_fs_dp
USBFS D+ (P8_14).
static ra8_err_t microsd_sd_spi_open(void)
Route Pmod2 SCI0 pins and open the Simple-SPI controller for the card.
static const ra8_port_pin_t k_microsd_pin_hs_vbus
USBHS_VBUS sense pin (P4_08, PSEL = 0x14).
static const ra8_port_pin_t k_microsd_pin_fs_vbus
USBFS VBUS sense pin (P4_07, PSEL = 0x13).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
@ k_ra8_board_pmod2_spi_cipo
Pmod2.3 CIPO (CIPO0_B), P602.
@ k_ra8_board_pmod2_spi_cs
Pmod2.1 CS (SS0_B), P604.
@ k_ra8_board_pmod2_spi_copi
Pmod2.2 COPI (COPI0_B), P603.
@ k_ra8_board_pmod2_spi_sck
Pmod2.4 SCK (SCK0_B), P601.
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
ra8_err_t ra8_board_io_expander_set_usbhs_host_mode(void)
Drive the U15 I/O expander to select USB-HS HOST mode.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
@ k_ra8_board_usbhs_pin_pwr
PD07 J7 host-power switch (HIGH = U18 drives 5 V VBUS).
@ k_ra8_board_usbhs_pin_vbus
P4_08 USBHS_VBUS sense.
@ k_ra8_board_usbfs_pin_dm
P8_15 D-.
@ k_ra8_board_usbfs_pin_vbusen
P5_00 VBUSEN GPIO.
@ k_ra8_board_usbfs_pin_vbus
P4_07 VBUS sense.
@ k_ra8_board_usbfs_pin_dp
P8_14 D+.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
@ k_ra8_clock_id_pclka
PCLKA.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
ra8_err_t ra8_cgc_usbfs_clock_enable(void)
Bring up the USB-FS module clock (USBCKCR / USBCKDIVCR).
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_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.
@ k_ra8_psel_usb_fs
10011b: USB Full-Speed.
@ k_ra8_psel_sci_async
00100b: SCI async serial (UART).
@ k_ra8_psel_usb_hs
10100b: USB High-Speed (e.g.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
High-level GPIO helpers on top of the PORT + PFS register layer.
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_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.
SCI Simple-SPI controller-mode driver (polling, full-duplex).
ra8_err_t ra8_sci_spi_set_clock(uint8_t channel, uint32_t baud_hz, uint32_t pclk_hz)
Re-program the bit-rate without otherwise reconfiguring.
ra8_err_t ra8_sci_spi_xfer(uint8_t channel, const uint8_t *tx, uint8_t *rx, uint32_t len)
Full-duplex multi-byte transfer.
ra8_err_t ra8_sci_spi_init(uint8_t channel, const ra8_sci_spi_cfg_t *cfg)
Bring an SCI channel up as a Simple-SPI controller.
SD card driver in SPI-mode (PMOD-attached cards).
@ k_ra8_sdmmc_spi_clock_init_hz
Mandatory init clock floor.
ra8_err_t ra8_sdmmc_spi_read_block(uint32_t lba, uint8_t *buf)
Read one 512-byte block at logical block address lba.
ra8_err_t ra8_sdmmc_spi_get_capacity(uint32_t *out_blocks)
Return the card capacity in 512-byte blocks.
ra8_err_t ra8_sdmmc_spi_init(const ra8_sdmmc_spi_transport_t *transport)
Run the SD SPI-mode identification sequence on a card.
SPI_B controller driver (RA8D2 Type-B SPI peripheral).
@ k_ra8_spi_mode_0
CPOL=0, CPHA=0.
void ux_dcd_ra8_usb_irq_reenable(void)
Storm-guard recovery: zero the run counter and re-enable the USB IRQ.
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
void ra8_time_on_tick(void)
SysTick IRQ handler – called from the vector table.
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
char CHAR
ThreadX-compatible CHAR (host stub).
Opaque thread stand-in for the host build.
Configuration descriptor for ra8_sci_spi_init.
Driver-to-bus binding (Dependency Inversion seam).
examples/ek_ra8d2/hw_validated/hil/usb_selftest_microsd/inc/usb_selftest_microsd_steps....
unsigned char s_usb_selftest_microsd_sd_snapshot[(uint32_t) k_microsd_snap_bytes]
Read-only RAM snapshot of SD LBA 0..63, taken once at boot.
@ k_microsd_sd_spi_channel
SCI0 Simple-SPI -> Pmod2 microSD.
@ k_microsd_thread_stack
Device worker stack (bytes).
@ k_microsd_host_priority
Host worker priority (below USBX).
@ k_microsd_host_stack
Host worker stack (bytes).
@ k_microsd_dev_priority
Device bring-up worker priority.
@ k_microsd_baud
J-Link OB CDC log baud.
@ k_microsd_block_size
SCSI logical block size.
@ k_microsd_no_mismatch
Probe: no mismatch.
@ k_microsd_bootsig_off
FAT/exFAT 0x55AA at byte 510.
@ k_microsd_snap_bytes
RAM snapshot of LBA 0..63.
@ k_microsd_sectors
Exposed sectors (LBA 0..63).
@ k_microsd_bootsig_lo
Boot-signature byte 510.
@ k_microsd_bootsig_hi
Boot-signature byte 511.
VOID microsd_host_worker(ULONG arg)
Host-side worker: retry the full pass until it succeeds.
VOID microsd_device_worker(ULONG arg)
Device-side worker: bring the read-only SD FS device up, then park.
volatile uint32_t s_usb_selftest_microsd_dbg_bootsig
1 = LBA0 carries the 0x55AA FAT/exFAT boot signature.
USBX device-controller-driver (DCD) bridge to ra8_usb.