|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Eclipse ThreadX SD-card boot-sector dump on the EK-RA8D2. More...
#include <stddef.h>#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_sdcard.h"#include "ra8_threadx.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | sdcard_stack_t : uint16_t { k_sdcard_thread_stack_bytes = 4096U } |
| Stack size, in bytes, for the SD card thread. More... | |
| enum | sdcard_priority_t : uint8_t { k_sdcard_thread_priority = 4U } |
| Thread priority for the SD card thread. More... | |
| enum | sdcard_baud_t : uint32_t { k_sdcard_console_baud = 115200U } |
| Console baud (115200 8N1). More... | |
| enum | sdcard_period_t : uint16_t { k_sdcard_loop_ticks = 5000U } |
| Loop period in ThreadX ticks (port/threadx/inc/tx_user.h pins to 1 ms). More... | |
| enum | sdcard_layout_t : uint8_t { k_sdcard_sdhi_instance = 0U , k_sdcard_dump_bytes = 16U } |
| SDHI pin layout constants. More... | |
| enum | sdcard_hex_t : uint8_t { k_sdcard_hex_chars_per_byte = 3U , k_sdcard_hex_nibble_shift = 4U , k_sdcard_hex_nibble_mask = 0x0FU , k_sdcard_hex_alpha_threshold = 10U } |
| ASCII-hex formatting constants. More... | |
| enum | sdcard_block_size_t : uint16_t { k_sdcard_block_bytes = 512U } |
| SD logical block size (512 bytes for SDHC/SDXC). More... | |
Functions | |
| void | _tx_timer_interrupt (void) |
| void | SysTick_Handler (void) |
| SysTick exception handler – tail-calls the ThreadX timer. | |
| static char | internal_sdcard_nibble_to_hex (uint8_t nibble) |
| Convert a single nibble to its ASCII hex character. | |
| static void | internal_sdcard_hex_dump (const uint8_t *in, uint8_t len, char *out) |
| Format len bytes from in into "XX XX ..." ASCII. | |
| static void | internal_sdcard_log (const char *s) |
| Push a NUL-terminated ASCII string out the J-Link OB VCOM. | |
| static void | internal_sdcard_one_pass (void) |
| Read sector 0 into s_sdcard_block and log status / hex dump. | |
| static void | internal_sdcard_thread_entry (ULONG thread_input) |
| Thread entry: init the card once, then loop reading sector 0. | |
| void | tx_application_define (void *first_unused_memory) |
| ThreadX application initialisation callback. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static uint8_t | s_sdcard_stack [k_sdcard_thread_stack_bytes] |
| Stack for the SD card thread (32-bit aligned per ARMv8-M AAPCS). | |
| static TX_THREAD | s_sdcard_thread |
| Thread control block. | |
| static uint8_t | s_sdcard_block [k_sdcard_block_bytes] |
| Block buffer for one SD sector. | |
Eclipse ThreadX SD-card boot-sector dump on the EK-RA8D2.
One ThreadX thread that exercises the full ra8_sdcard HAL stack:
SDHI pin map is owned by the BSP (ra8_board_sdhi_pins_init): port 4, pins 0..7 routed to the on-chip SDHI block.
| Name | Priority | Period | Action |
|---|---|---|---|
| sdcard | 4 | 5000 ms loop | Read block 0, dump 16 bytes |
Definition in file main.c.
| enum sdcard_baud_t : uint32_t |
| enum sdcard_block_size_t : uint16_t |
| enum sdcard_hex_t : uint8_t |
| enum sdcard_layout_t : uint8_t |
| enum sdcard_period_t : uint16_t |
Loop period in ThreadX ticks (port/threadx/inc/tx_user.h pins to 1 ms).
| Enumerator | |
|---|---|
| k_sdcard_loop_ticks | Sdcard loop ticks. |
| enum sdcard_priority_t : uint8_t |
| enum sdcard_stack_t : uint16_t |
|
extern |
Referenced by SysTick_Handler().
|
static |
Format len bytes from in into "XX XX ..." ASCII.
Expands each source byte to two uppercase hex digits followed by a space, using no terminator so the caller controls final framing.
| [in] | in | Source buffer. |
| [in] | len | Number of source bytes to format. |
| [out] | out | Destination buffer; must hold len * 3 bytes. |
Definition at line 196 of file main.c.
References internal_sdcard_nibble_to_hex(), k_sdcard_hex_chars_per_byte, k_sdcard_hex_nibble_mask, k_sdcard_hex_nibble_shift, and RA8_INTERNAL.
Referenced by internal_sdcard_one_pass().
|
static |
Push a NUL-terminated ASCII string out the J-Link OB VCOM.
Measures a non-NULL string and submits exactly the payload bytes to the BSP console without heap allocation.
| [in] | s | NUL-terminated string. NULL is a no-op. |
Definition at line 222 of file main.c.
References ra8_board_uart_console_write(), and RA8_INTERNAL.
Referenced by internal_sdcard_one_pass(), and internal_sdcard_thread_entry().
|
static |
Convert a single nibble to its ASCII hex character.
Masks the input to four bits, then maps the value through the numeric or uppercase alphabetic ASCII range.
| [in] | nibble | Low 4 bits of an arbitrary uint8_t. |
| '0'..'9' | Numeric hexadecimal digit. |
| 'A'..'F' | Alphabetic hexadecimal digit. |
Definition at line 171 of file main.c.
References k_sdcard_hex_alpha_threshold, k_sdcard_hex_nibble_mask, and RA8_INTERNAL.
Referenced by internal_sdcard_hex_dump().
|
static |
Read sector 0 into s_sdcard_block and log status / hex dump.
Performs one block read, formats the first fixed-size prefix on the stack, and emits either the formatted prefix or an error line.
Definition at line 250 of file main.c.
References internal_sdcard_hex_dump(), internal_sdcard_log(), k_ra8_ok, k_sdcard_dump_bytes, k_sdcard_hex_chars_per_byte, RA8_INTERNAL, ra8_sdcard_read_blocks(), and s_sdcard_block.
Referenced by internal_sdcard_thread_entry().
|
static |
Thread entry: init the card once, then loop reading sector 0.
Initializes the fixed SDHI instance and, on success, performs a read/log/LED/sleep cycle forever; failed initialization sleeps without I/O.
| [in] | thread_input | Unused (ThreadX cookie). |
Definition at line 279 of file main.c.
References internal_sdcard_log(), internal_sdcard_one_pass(), k_ra8_board_led1, k_ra8_ok, k_sdcard_loop_ticks, k_sdcard_sdhi_instance, ra8_board_led_toggle(), RA8_INTERNAL, ra8_sdcard_init(), and tx_thread_sleep.
Referenced by tx_application_define().
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
Definition at line 364 of file main.c.
References k_ra8_board_led1, k_ra8_ok, k_sdcard_console_baud, ra8_board_led_init(), ra8_board_sdhi_pins_init(), ra8_board_uart_console_init(), ra8_cgc_init(), and ra8_isr_globals_enable().
| void SysTick_Handler | ( | void | ) |
SysTick exception handler – tail-calls the ThreadX timer.
Service one SysTick event for the core timebase.
Service the SysTick exception selected by the linked application.
Definition at line 146 of file main.c.
References _tx_timer_interrupt().
| void tx_application_define | ( | void * | first_unused_memory | ) |
ThreadX application initialisation callback.
| [in] | first_unused_memory | Unused – the demo uses a static stack. |
Definition at line 313 of file main.c.
References internal_sdcard_thread_entry(), k_ra8_ok, k_sdcard_thread_priority, k_sdcard_thread_stack_bytes, ra8_threadx_systick_retune(), s_sdcard_stack, s_sdcard_thread, s_thread_name, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
|
static |
Block buffer for one SD sector.
File-scope so it does not eat thread-stack budget.
Definition at line 136 of file main.c.
Referenced by internal_sdcard_one_pass().
|
static |
Stack for the SD card thread (32-bit aligned per ARMv8-M AAPCS).
Definition at line 125 of file main.c.
Referenced by tx_application_define().
|
static |
Thread control block.
ThreadX zeroes it on tx_thread_create.
Definition at line 130 of file main.c.
Referenced by tx_application_define().