|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Eclipse ThreadX bring-up HIL test on 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_port_constants.h"#include "ra8_port_utils.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | blink_stack_t : uint16_t { k_blink_thread_stack_bytes = 1024U } |
| Stack size, in bytes, for each user blink thread. More... | |
| enum | blink_priority_t : uint8_t { k_blink_thread_priority = 4U } |
| Thread priority for both blink threads. More... | |
| enum | blink_period_t : uint16_t { k_blink_a_ticks = 500U , k_blink_b_ticks = 1000U } |
| Sleep durations expressed in ThreadX ticks. More... | |
Functions | |
| static void | internal_thread_a_entry (ULONG thread_input) |
| Thread A entry point: toggle LED1 every k_blink_a_ticks ms. | |
| static void | internal_thread_b_entry (ULONG thread_input) |
| Thread B entry point: toggle LED2 every k_blink_b_ticks ms. | |
| void | tx_application_define (void *first_unused_memory) |
| ThreadX application initialization callback. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static uint8_t | s_thread_a_stack [k_blink_thread_stack_bytes] |
| Stack for thread A (LED1 blinker). | |
| static uint8_t | s_thread_b_stack [k_blink_thread_stack_bytes] |
| Stack for thread B (LED2 blinker). | |
| static TX_THREAD | s_thread_a |
| Thread A control block. | |
| static TX_THREAD | s_thread_b |
| Thread B control block. | |
| volatile uint32_t | g_threadx_blink_tick = 0U |
| HIL liveness counter – incremented by thread A on each LED-A toggle. | |
Eclipse ThreadX bring-up HIL test on the EK-RA8D2.
Two ThreadX threads, each blinking a different LED at a different rate, sharing the Cortex-M85 via cooperative-plus-preemptive scheduling. This is the canonical "is the RTOS alive?" demo and the first piece of code that exercises:
Like examples/blink_hal, this app deliberately skips ra8_cgc_init() – it runs on the boot-default MOCO (~8.4 MHz) so the SysTick reload programmed in tx_initialize_low_level.S stays accurate.
| Name | Priority | Period | LED |
|---|---|---|---|
| blink_a | 4 | 1000 ms (1 Hz) | LED1 P6_00 |
| blink_b | 4 | 2000 ms (0.5 Hz) | LED2 P3_03 |
Both threads run at the same priority; ThreadX round-robins them on each tx_thread_sleep wake.
Definition in file main.c.
| enum blink_period_t : uint16_t |
Sleep durations expressed in ThreadX ticks.
port/threadx/inc/tx_user.h pins the tick rate to 1000 Hz, so a tick is 1 ms. k_blink_a_ticks therefore lights LED1 at 1 Hz and k_blink_b_ticks lights LED2 at 0.5 Hz.
| Enumerator | |
|---|---|
| k_blink_a_ticks | Blink a ticks. |
| k_blink_b_ticks | Blink b ticks. |
| enum blink_priority_t : uint8_t |
| enum blink_stack_t : uint16_t |
Stack size, in bytes, for each user blink thread.
1 KiB is comfortably above TX_MINIMUM_STACK (set to 512 in port/threadx/inc/tx_user.h) and accommodates the FPU + Helium register save area on a context switch. Static allocation keeps the demo compatible with NASA Power of 10 Rule 3 (no dynamic memory).
| Enumerator | |
|---|---|
| k_blink_thread_stack_bytes | Blink thread stack bytes. |
|
static |
Thread A entry point: toggle LED1 every k_blink_a_ticks ms.
Drives the first board LED, advances the HIL liveness counter, and sleeps for the configured ThreadX interval on every iteration.
| [in] | thread_input | Unused (ThreadX cookie). |
Definition at line 179 of file main.c.
References g_threadx_blink_tick, k_blink_a_ticks, k_ra8_board_led1, ra8_board_led_toggle(), RA8_INTERNAL, and tx_thread_sleep.
Referenced by tx_application_define().
|
static |
Thread B entry point: toggle LED2 every k_blink_b_ticks ms.
Independently drives the second board LED at its slower cadence and yields after every toggle so the scheduler can dispatch thread A.
| [in] | thread_input | Unused (ThreadX cookie). |
Definition at line 208 of file main.c.
References k_blink_b_ticks, k_ra8_board_led2, ra8_board_led_toggle(), RA8_INTERNAL, and tx_thread_sleep.
Referenced by tx_application_define().
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Configures GPIO, then launches ThreadX.
Definition at line 301 of file main.c.
References k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, ra8_board_led_init(), and ra8_cgc_init().
| void tx_application_define | ( | void * | first_unused_memory | ) |
ThreadX application initialization callback.
| [in] | first_unused_memory | Pointer to the first byte of free RAM after the kernel's internal allocations. Unused here – both threads use static stacks declared at file scope. |
Definition at line 244 of file main.c.
References internal_thread_a_entry(), internal_thread_b_entry(), k_blink_thread_priority, k_blink_thread_stack_bytes, s_thread_a, s_thread_a_stack, s_thread_b, s_thread_b_stack, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
| volatile uint32_t g_threadx_blink_tick = 0U |
HIL liveness counter – incremented by thread A on each LED-A toggle.
Read externally by hil_jlink_memprobe.sh.
If ThreadX schedules thread A correctly, the counter advances at 1/k_blink_a_ticks Hz. The memprobe HIL mode asserts the counter has advanced over a sample window – catches "scheduler wedged" and "thread crashed before first iteration" failure modes that the plain HIL_MODE=alive check misses.
volatile keeps the increment alive under optimization; the global (non-static) keeps the symbol linker-visible without –gc-sections culling.
Definition at line 148 of file main.c.
Referenced by internal_thread_a_entry().
|
static |
Thread A control block.
ThreadX zeroes it on tx_thread_create.
Definition at line 122 of file main.c.
Referenced by tx_application_define(), and wdt_sup_demo_spawn_workers().
|
static |
Stack for thread A (LED1 blinker).
Definition at line 112 of file main.c.
Referenced by tx_application_define(), and wdt_sup_demo_spawn_workers().
|
static |
Thread B control block.
Definition at line 127 of file main.c.
Referenced by tx_application_define(), and wdt_sup_demo_spawn_workers().
|
static |
Stack for thread B (LED2 blinker).
Definition at line 117 of file main.c.
Referenced by tx_application_define(), and wdt_sup_demo_spawn_workers().