ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

USB self-loop: HS host reads the microSD card as a read-only MSC. More...

#include <stdint.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_cgc.h"
#include "ra8_err.h"
#include "ra8_gpio_constants.h"
#include "ra8_isr.h"
#include "ra8_port_constants.h"
#include "ra8_port_utils.h"
#include "ra8_sci_spi.h"
#include "ra8_sdmmc_spi.h"
#include "ra8_spi.h"
#include "ra8_time.h"
#include "usb_selftest_microsd_steps.h"
#include "tx_api.h"
#include "ux_dcd_ra8_usb.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

void _tx_timer_interrupt (void)
void SysTick_Handler (void)
 Service the SysTick exception selected by the linked application.
static ra8_err_t microsd_spi_set_clock (void *ctx, uint32_t hz)
 SD transport hook: program the Simple-SPI bit clock.
static ra8_err_t microsd_spi_cs (void *ctx, bool asserted)
 SD transport hook: drive the chip-select line.
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 ra8_err_t microsd_sd_spi_open (void)
 Route Pmod2 SCI0 pins and open the Simple-SPI controller for the card.
static ra8_err_t microsd_sd_snapshot (void)
 Bring the card up and snapshot LBA 0..63 into RAM (read-only).
VOID tx_application_define (VOID *first_unused_memory)
 ThreadX application-define hook.
static void microsd_panic_halt (void)
 Halt forever in WFI – panic stop on init failure.
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.
void main (void)
 Application entry: bring the board up, then hand off to ThreadX.

Variables

static volatile bool s_tx_kernel_up = false
 Set in tx_application_define; gates ThreadX tick delivery.
static const ra8_port_pin_t k_microsd_pin_fs_vbus = (ra8_port_pin_t)k_ra8_board_usbfs_pin_vbus
 USBFS VBUS sense pin (P4_07, PSEL = 0x13).
static const ra8_port_pin_t k_microsd_pin_fs_vbusen = (ra8_port_pin_t)k_ra8_board_usbfs_pin_vbusen
 USBFS VBUSEN (P5_00) – GPIO LOW for the device role.
static const ra8_port_pin_t k_microsd_pin_fs_dp = (ra8_port_pin_t)k_ra8_board_usbfs_pin_dp
 USBFS D+ (P8_14).
static const ra8_port_pin_t k_microsd_pin_fs_dm = (ra8_port_pin_t)k_ra8_board_usbfs_pin_dm
 USBFS D- (P8_15).
static const ra8_port_pin_t k_microsd_pin_hs_vbus = (ra8_port_pin_t)k_ra8_board_usbhs_pin_vbus
 USBHS_VBUS sense pin (P4_08, PSEL = 0x14).
static const ra8_port_pin_t k_microsd_pin_hs_pwr = (ra8_port_pin_t)k_ra8_board_usbhs_pin_pwr
 J7 host-power switch (PD07): HIGH = U18 supplies VBUS (UM 6.2).
static const ra8_port_pin_t k_microsd_pin_sd_sck = (ra8_port_pin_t)k_ra8_board_pmod2_spi_sck
 Pmod2 microSD SPI clock (SCI0, Simple-SPI).
static const ra8_port_pin_t k_microsd_pin_sd_cipo = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cipo
 Pmod2 microSD SPI CIPO (card -> MCU).
static const ra8_port_pin_t k_microsd_pin_sd_copi = (ra8_port_pin_t)k_ra8_board_pmod2_spi_copi
 Pmod2 microSD SPI COPI (MCU -> card).
static const ra8_port_pin_t k_microsd_pin_sd_cs = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cs
 Pmod2 microSD chip-select (GPIO, idle high).
static TX_THREAD s_device_thread
 ThreadX TCB for the USBX device-side worker thread.
static UCHAR s_device_stack [k_microsd_thread_stack]
 Stack backing storage for s_device_thread.
static TX_THREAD s_host_thread
 ThreadX TCB for the host-side worker thread.
static UCHAR s_host_stack [k_microsd_host_stack]
 Stack backing storage for s_host_thread.
static volatile uint32_t s_dbg_sd_err = (uint32_t)k_microsd_no_mismatch
 SD bring-up result: 0 = card read into snapshot OK, else error.
static volatile uint32_t s_dbg_sd_blocks
 SD card capacity in 512-B blocks (sanity probe).
volatile uint32_t s_usb_selftest_microsd_dbg_bootsig
 1 = LBA0 carries the 0x55AA FAT/exFAT boot signature.
static uint32_t s_pclka_hz = 0U
 PCLKA in Hz, captured at setup for the SD SPI clock adapter.
UCHAR s_usb_selftest_microsd_sd_snapshot [k_microsd_snap_bytes]
 Read-only RAM snapshot of SD LBA 0..63, taken once at boot.

Detailed Description

USB self-loop: HS host reads the microSD card as a read-only MSC.

Tag
[Ring 6 / APP] {World: S}

Exposes the onboard Pmod2 microSD card as a USB drive and verifies it against itself on-chip – no PC in the loop. The two USB ports are cabled to EACH OTHER and one firmware image runs both USB stacks plus the SCI0 Simple-SPI SD driver:

  • AT BOOT the device snapshots SD LBA 0..63 (the FAT/exFAT boot region) into a RAM buffer with ra8_sdmmc_spi_read_block and confirms the 0x55AA boot signature. The card is NEVER written (strictly read-only) so the user's filesystem is untouched.
  • USBFS (J11) = DEVICE: a ThreadX + USBX Mass-Storage class exposes that 64-sector window as a single READ-ONLY logical unit (GET_MAX_LUN = 0); media-read serves the boot snapshot (no live card access on the class thread). IRQ-driven through the port/usbx/ux_dcd_ra8_usb bridge.
  • USBHS (J7) = HOST: the first-party polled host MSC stack (ra8_usb_hmsc) enumerates the device, READ_CAPACITY + a full raw READ(10) sweep, and byte-checks every sector against the SD snapshot – proving the SD read path AND the USB transport deliver the card's real content intact, end to end on chip.

No filesystem parsing is involved (raw SCSI READ(10)); this is a pure read-path test that needs no host WRITE support and no SD writes.

The link runs at 12 Mbps (FS device ceiling; HS host serves an FS downstream device).

Verdicts stream over SCI8 (J-Link OB CDC console, 115200) and are mirrored in J-Link-readable probes (s_dbg_*).

Pinout

FS device: P4_07 VBUS sense, P5_00 VBUSEN GPIO LOW (device role), P8_14 D+, P8_15 D- (PSEL usb_fs). HS host: SW4-8 to Host via the U15 expander, PD07 HIGH (U18 supplies J7 VBUS), P4_08 USBHS_VBUS (PSEL usb_hs). Console: PD_02/PD_03 SCI8. microSD: Pmod2 SCI0 Simple-SPI (SCK/CIPO/COPI PSEL sci_async, CS GPIO idle high).

Author
Brighton Sikarskie
Date
2026-06-13
Since
0.1.0

Definition in file main.c.

Function Documentation

◆ _tx_timer_interrupt()

void _tx_timer_interrupt ( void )
extern

◆ main()

void main ( void )

Application entry: bring the board up, then hand off to ThreadX.

The application entry point Reset_Handler hands control to.

Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU, priority grouping.
Postcondition
On clean entry the CPU stays in tx_kernel_enter forever.
On any HAL init failure the function halts in WFI.
Note
Single entry point; not re-entrant.
Since
0.1.0

Definition at line 588 of file main.c.

References microsd_panic_halt(), microsd_setup_or_halt(), and ra8_isr_globals_enable().

◆ microsd_panic_halt()

void microsd_panic_halt ( void )
static

Halt forever in WFI – panic stop on init failure.

Last-resort stop; only a debugger or reset recovers.

Precondition
Called only after a fatal boot error.
Interrupts may be in any state.
Postcondition
CPU is parked.
No further code runs.
Note
Not reachable post-boot.
Since
0.1.0

Definition at line 469 of file main.c.

Referenced by main(), microsd_route_usb_or_halt(), and microsd_setup_or_halt().

◆ microsd_route_usb_or_halt()

void microsd_route_usb_or_halt ( void )
static

Route both ports' pins: FS as device, HS as host.

FS device: P4_07 VBUS sense, P5_00 VBUSEN GPIO LOW (else peripheral routing forces host VBUSEN and blocks device enum), P8_14/P8_15 data. HS host: SW4-8 to Host via the U15 expander, PD07 HIGH (U18 supplies J7), P4_08 VBUS sense.

Precondition
IOPORT and the U15 expander are reachable.
Called once from microsd_setup_or_halt.
Postcondition
FS pins carry the device role, HS pins the host role.
PD07 is HIGH (J7 powered).
Note
Panic-halts on any routing failure.
Since
0.1.0

Definition at line 492 of file main.c.

References k_microsd_pin_fs_dm, k_microsd_pin_fs_dp, k_microsd_pin_fs_vbus, k_microsd_pin_fs_vbusen, k_microsd_pin_hs_pwr, k_microsd_pin_hs_vbus, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, k_ra8_psel_usb_fs, k_ra8_psel_usb_hs, microsd_panic_halt(), ra8_board_io_expander_set_usbhs_host_mode(), ra8_gpio_output_init(), and ra8_pfs_route_peripheral().

Referenced by microsd_setup_or_halt().

◆ microsd_sd_snapshot()

ra8_err_t microsd_sd_snapshot ( void )
staticnodiscard

Bring the card up and snapshot LBA 0..63 into RAM (read-only).

Opens the SPI controller, inits ::ra8_sdmmc_spi (card enumeration), records capacity, then reads the exposed window into s_usb_selftest_microsd_sd_snapshot with ra8_sdmmc_spi_read_block. NEVER writes the card. Stamps the SD probes and flags the FAT/exFAT 0x55AA boot signature on LBA 0.

Returns
ra8_err_t verdict.
Return values
k_ra8_okSnapshot captured; the snapshot buffer is valid.
(other)First failing bring-up or block-read step.
Precondition
s_pclka_hz is set; the console is up for diagnostics.
A card is seated in the Pmod2 slot.
Postcondition
s_usb_selftest_microsd_sd_snapshot holds LBA 0..63; SD probes reflect the outcome.
The card is untouched (no writes).
Note
Boot context; runs once before the kernel starts.
Since
0.1.0

Definition at line 367 of file main.c.

References k_microsd_block_size, k_microsd_bootsig_hi, k_microsd_bootsig_lo, k_microsd_bootsig_off, k_microsd_sectors, k_ra8_ok, microsd_sd_spi_open(), microsd_spi_cs(), microsd_spi_set_clock(), microsd_spi_xfer(), ra8_sdmmc_spi_get_capacity(), ra8_sdmmc_spi_init(), ra8_sdmmc_spi_read_block(), s_dbg_sd_blocks, s_dbg_sd_err, s_pclka_hz, s_usb_selftest_microsd_dbg_bootsig, and s_usb_selftest_microsd_sd_snapshot.

Referenced by microsd_setup_or_halt().

◆ microsd_sd_spi_open()

ra8_err_t microsd_sd_spi_open ( void )
staticnodiscard

Route Pmod2 SCI0 pins and open the Simple-SPI controller for the card.

SCK/CIPO/COPI go to the SCI async PSEL; CS is a plain GPIO held across each multi-byte SD command (the SCI hardware CS pulses per word and cannot frame an SD transaction), idle high. Boots SPI at the slow init clock; ra8_sdmmc_spi_init negotiates up afterwards.

Returns
ra8_err_t verdict.
Return values
k_ra8_okSCI0 Simple-SPI controller is up.
(other)A pin route, GPIO, or SPI-init step failed.
Precondition
s_pclka_hz holds the live PCLKA frequency.
The Pmod2 microSD module is seated.
Postcondition
SCI0 Simple-SPI is initialized; CS idles high.
Pmod2 SPI pins carry the SCI peripheral function.
Note
Boot context; single-threaded.
Since
0.1.0

Definition at line 317 of file main.c.

References k_microsd_pin_sd_cipo, k_microsd_pin_sd_copi, k_microsd_pin_sd_cs, k_microsd_pin_sd_sck, k_microsd_sd_spi_channel, k_ra8_level_high, k_ra8_ok, k_ra8_psel_sci_async, k_ra8_sdmmc_spi_clock_init_hz, k_ra8_spi_mode_0, ra8_gpio_output_init(), ra8_pfs_route_peripheral(), ra8_sci_spi_init(), and s_pclka_hz.

Referenced by microsd_sd_snapshot().

◆ microsd_setup_or_halt()

void microsd_setup_or_halt ( void )
static

Bring CGC + both USB clocks + SysTick + SCI8 + LEDs + pins up.

USBFS needs the 48 MHz PLL2 reference; USBHS needs its UTMI PLL. SCI8 is the J-Link OB CDC console at 115200.

Precondition
Reset_Handler finished C runtime init.
SystemInit has run.
Postcondition
Console works; both USB ports' pins and clocks are live.
LED1/LED2 are initialized.
Note
Panic-halts on any failure; called once from main.
Since
0.1.0

Definition at line 535 of file main.c.

References k_microsd_baud, k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, microsd_panic_halt(), microsd_route_usb_or_halt(), microsd_sd_snapshot(), ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_cgc_usbfs_clock_enable(), ra8_cgc_usbhs_pll_enable(), ra8_time_init(), and s_pclka_hz.

Referenced by main().

◆ microsd_spi_cs()

ra8_err_t microsd_spi_cs ( void * ctx,
bool asserted )
static

SD transport hook: drive the chip-select line.

Parameters
[in]ctxUnused.
[in]assertedtrue = select (CS low), false = deselect (CS high).
Returns
ra8_err_t from ra8_gpio_write.
Return values
k_ra8_okCS level updated.
Precondition
CS was configured as a GPIO output.
The pin maps to the Pmod2 microSD CS.
Postcondition
CS reflects asserted (active-low).
No other state changes.
Note
SD SPI framing needs CS held across the whole command.
Since
0.1.0

Definition at line 265 of file main.c.

References k_microsd_pin_sd_cs, k_ra8_level_high, k_ra8_level_low, and ra8_gpio_write().

Referenced by microsd_sd_snapshot().

◆ microsd_spi_set_clock()

ra8_err_t microsd_spi_set_clock ( void * ctx,
uint32_t hz )
static

SD transport hook: program the Simple-SPI bit clock.

Parameters
[in]ctxPCLKA-Hz pointer (s_pclka_hz).
[in]hzRequested SCLK frequency in Hz.
Returns
ra8_err_t from ra8_sci_spi_set_clock.
Return values
k_ra8_okClock applied.
Precondition
ra8_sci_spi_init has run for the SD channel.
ctx is non-null.
Postcondition
SCI0 Simple-SPI baud reflects hz.
No other state changes.
Note
Boot context; not ISR-safe.
Since
0.1.0

Definition at line 242 of file main.c.

References k_microsd_sd_spi_channel, and ra8_sci_spi_set_clock().

Referenced by microsd_sd_snapshot().

◆ microsd_spi_xfer()

ra8_err_t microsd_spi_xfer ( void * ctx,
const uint8_t * tx,
uint8_t * rx,
uint32_t len )
static

SD transport hook: full-duplex SPI byte exchange.

Parameters
[in]ctxUnused.
[in]txBytes to clock out (may be null for read-only).
[out]rxBytes clocked in (may be null for write-only).
[in]lenTransfer length in bytes.
Returns
ra8_err_t from ra8_sci_spi_xfer.
Return values
k_ra8_okTransfer complete.
Precondition
ra8_sci_spi_init has run for the SD channel.
CS is asserted by the caller around the framed command.
Postcondition
rx holds the clocked-in bytes when non-null.
No other state changes.
Note
Boot context; not ISR-safe.
Since
0.1.0

Definition at line 290 of file main.c.

References k_microsd_sd_spi_channel, and ra8_sci_spi_xfer().

Referenced by microsd_sd_snapshot().

◆ SysTick_Handler()

void SysTick_Handler ( void )

Service the SysTick exception selected by the linked application.

Service one SysTick event for the core timebase.

Service one SysTick event for the core timebase.

Resolves to the weak core timebase handler unless a strong RTOS or application handler overrides it. The vector table references the selected implementation without owning its subsystem policy.

Precondition
Entered for a SysTick exception with a valid exception frame.
The selected handler's timebase or scheduler state is initialised.
Postcondition
The selected implementation has processed one SysTick event.
The vector table itself remains unchanged.
Note
Runs in handler mode; thread-safety follows the selected implementation.
Since
0.1.0

The weak firmware implementation advances the millisecond counter, then services linked ThreadX and USB hooks when their weak symbols and readiness state permit. The host-test implementation advances only the counter. An application may replace either weak definition with a strong handler.

Precondition
The handler is entered for one SysTick event or a host-test equivalent.
On target, ra8_time_init() configured the SysTick period.
Postcondition
s_tick_ms has advanced by exactly one.
Optional subsystem hooks run only when linked and ready.
Note
IRQ-safe; the weak symbol may be overridden by an application handler.
Since
0.1.0

Service the SysTick exception selected by the linked application.

The weak firmware implementation advances the millisecond counter, then services linked ThreadX and USB hooks when their weak symbols and readiness state permit. The host-test implementation advances only the counter. An application may replace either weak definition with a strong handler.

Precondition
The handler is entered for one SysTick event or a host-test equivalent.
On target, ra8_time_init() configured the SysTick period.
Postcondition
s_tick_ms has advanced by exactly one.
Optional subsystem hooks run only when linked and ready.
Note
IRQ-safe; the weak symbol may be overridden by an application handler.
Since
0.1.0

Service the SysTick exception selected by the linked application.

Precondition
Called from exception context (IPSR == 15).
_tx_initialize_low_level has programmed SysTick.
Postcondition
One ThreadX tick elapsed; PendSV may be pending.

Definition at line 91 of file main.c.

References _tx_timer_interrupt(), ra8_time_on_tick(), s_tx_kernel_up, and ux_dcd_ra8_usb_irq_reenable().

◆ tx_application_define()

VOID tx_application_define ( VOID * first_unused_memory)

ThreadX application-define hook.

Spawns both workers.

Device worker at priority 8, host worker at 24 (below the USBX class threads). Sets s_tx_kernel_up so SysTick may feed ThreadX from here on.

Parameters
[in]first_unused_memorySentinel (unused; static stacks).
Precondition
Called from tx_kernel_enter after scheduler init.
Static stacks are reserved at file scope.
Postcondition
Two auto-start worker threads are queued.
s_tx_kernel_up is true.
Note
Called once at boot; not thread-safe.
Since
0.1.0

Definition at line 422 of file main.c.

References k_microsd_dev_priority, k_microsd_host_priority, k_microsd_host_stack, k_microsd_thread_stack, microsd_device_worker(), microsd_host_worker(), s_device_stack, s_device_thread, s_device_thread_name, s_host_stack, s_host_thread, s_host_thread_name, s_tx_kernel_up, TX_AUTO_START, TX_NO_TIME_SLICE, and tx_thread_create.

Variable Documentation

◆ k_microsd_pin_fs_dm

const ra8_port_pin_t k_microsd_pin_fs_dm = (ra8_port_pin_t)k_ra8_board_usbfs_pin_dm
static

USBFS D- (P8_15).

Definition at line 115 of file main.c.

Referenced by microsd_route_usb_or_halt().

◆ k_microsd_pin_fs_dp

const ra8_port_pin_t k_microsd_pin_fs_dp = (ra8_port_pin_t)k_ra8_board_usbfs_pin_dp
static

USBFS D+ (P8_14).

Definition at line 112 of file main.c.

Referenced by microsd_route_usb_or_halt().

◆ k_microsd_pin_fs_vbus

const ra8_port_pin_t k_microsd_pin_fs_vbus = (ra8_port_pin_t)k_ra8_board_usbfs_pin_vbus
static

USBFS VBUS sense pin (P4_07, PSEL = 0x13).

Definition at line 106 of file main.c.

Referenced by microsd_route_usb_or_halt().

◆ k_microsd_pin_fs_vbusen

const ra8_port_pin_t k_microsd_pin_fs_vbusen = (ra8_port_pin_t)k_ra8_board_usbfs_pin_vbusen
static

USBFS VBUSEN (P5_00) – GPIO LOW for the device role.

Definition at line 109 of file main.c.

Referenced by microsd_route_usb_or_halt().

◆ k_microsd_pin_hs_pwr

const ra8_port_pin_t k_microsd_pin_hs_pwr = (ra8_port_pin_t)k_ra8_board_usbhs_pin_pwr
static

J7 host-power switch (PD07): HIGH = U18 supplies VBUS (UM 6.2).

Definition at line 121 of file main.c.

Referenced by microsd_route_usb_or_halt().

◆ k_microsd_pin_hs_vbus

const ra8_port_pin_t k_microsd_pin_hs_vbus = (ra8_port_pin_t)k_ra8_board_usbhs_pin_vbus
static

USBHS_VBUS sense pin (P4_08, PSEL = 0x14).

Definition at line 118 of file main.c.

Referenced by microsd_route_usb_or_halt().

◆ k_microsd_pin_sd_cipo

const ra8_port_pin_t k_microsd_pin_sd_cipo = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cipo
static

Pmod2 microSD SPI CIPO (card -> MCU).

Definition at line 126 of file main.c.

Referenced by microsd_sd_spi_open().

◆ k_microsd_pin_sd_copi

const ra8_port_pin_t k_microsd_pin_sd_copi = (ra8_port_pin_t)k_ra8_board_pmod2_spi_copi
static

Pmod2 microSD SPI COPI (MCU -> card).

Definition at line 128 of file main.c.

Referenced by microsd_sd_spi_open().

◆ k_microsd_pin_sd_cs

const ra8_port_pin_t k_microsd_pin_sd_cs = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cs
static

Pmod2 microSD chip-select (GPIO, idle high).

Definition at line 130 of file main.c.

Referenced by microsd_sd_spi_open(), and microsd_spi_cs().

◆ k_microsd_pin_sd_sck

const ra8_port_pin_t k_microsd_pin_sd_sck = (ra8_port_pin_t)k_ra8_board_pmod2_spi_sck
static

Pmod2 microSD SPI clock (SCI0, Simple-SPI).

Definition at line 124 of file main.c.

Referenced by microsd_sd_spi_open().

◆ s_dbg_sd_blocks

volatile uint32_t s_dbg_sd_blocks
static

SD card capacity in 512-B blocks (sanity probe).

Definition at line 191 of file main.c.

Referenced by microsd_sd_snapshot().

◆ s_dbg_sd_err

volatile uint32_t s_dbg_sd_err = (uint32_t)k_microsd_no_mismatch
static

SD bring-up result: 0 = card read into snapshot OK, else error.

Definition at line 189 of file main.c.

◆ s_device_stack

UCHAR s_device_stack[k_microsd_thread_stack]
static

Stack backing storage for s_device_thread.

Since
0.1.0

Definition at line 162 of file main.c.

◆ s_device_thread

TX_THREAD s_device_thread
static

ThreadX TCB for the USBX device-side worker thread.

Note
Single-writer (worker only).
Since
0.1.0

Definition at line 155 of file main.c.

◆ s_host_stack

UCHAR s_host_stack[k_microsd_host_stack]
static

Stack backing storage for s_host_thread.

Since
0.1.0

Definition at line 177 of file main.c.

◆ s_host_thread

TX_THREAD s_host_thread
static

ThreadX TCB for the host-side worker thread.

Note
Single-writer (worker only).
Since
0.1.0

Definition at line 170 of file main.c.

◆ s_pclka_hz

uint32_t s_pclka_hz = 0U
static

PCLKA in Hz, captured at setup for the SD SPI clock adapter.

Definition at line 204 of file main.c.

◆ s_tx_kernel_up

volatile bool s_tx_kernel_up = false
static

Set in tx_application_define; gates ThreadX tick delivery.

main() starts SysTick before tx_kernel_enter and the setup window is long (U15 expander I2C blocks for ms), so the tick fires pre-kernel; feeding _tx_timer_interrupt into ThreadX's zeroed timer state bus-faults. Gate it until the kernel runs.

Since
0.1.0

Definition at line 88 of file main.c.

◆ s_usb_selftest_microsd_dbg_bootsig

volatile uint32_t s_usb_selftest_microsd_dbg_bootsig

1 = LBA0 carries the 0x55AA FAT/exFAT boot signature.

Defined and stamped in main.c during SD bring-up; read by the host-side verify ladder to confirm the snapshot is a valid boot region before the READ(10) sweep.

Note
Single-writer at boot; read-only afterwards.
Since
0.1.0

Stamped here at SD bring-up and read by the host-side verify ladder in "usb_selftest_microsd_steps.c".

Note
Single-writer at boot; read-only afterwards.
Since
0.1.0

Definition at line 201 of file main.c.

Referenced by microsd_sd_snapshot(), and microsd_verify_one().

◆ s_usb_selftest_microsd_sd_snapshot

UCHAR s_usb_selftest_microsd_sd_snapshot[k_microsd_snap_bytes]

Read-only RAM snapshot of SD LBA 0..63, taken once at boot.

Defined in main.c (populated before the kernel starts by the SD bring-up step) and read by both the device-side media-read callback and the host-side verify ladder in usb_selftest_microsd_steps.c.

Note
Single-writer at boot; read-only afterwards.
Since
0.1.0

Populated here before the kernel starts; consumed by both the device-side media-read callback and the host-side verify ladder in "usb_selftest_microsd_steps.c".

Note
Single-writer at boot; read-only afterwards.
Since
0.1.0

Definition at line 215 of file main.c.

Referenced by microsd_msc_read(), microsd_sd_snapshot(), and microsd_verify_one().