|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Eclipse ThreadX SysTick retune-to-live-CPUCLK0 demo (issue #287). 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_threadx.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | retune_stack_t : uint16_t { k_retune_thread_stack_bytes = 1024U } |
| Stack size, in bytes, for the worker thread. More... | |
| enum | retune_priority_t : uint8_t { k_retune_thread_priority = 4U } |
| Thread priority for the worker thread. More... | |
| enum | retune_period_t : uint16_t { k_retune_loop_ticks = 250U } |
| Worker sleep period in ThreadX ticks (tx_user.h pins a tick to 1 ms). More... | |
| enum | retune_syst_addr_t : uintptr_t { k_retune_syst_rvr_addr = 0xE000E014UL } |
| SysTick reload register address (Cortex-M System Control Space). More... | |
Functions | |
| static uint32_t | internal_retune_read_syst_rvr (void) |
| Read back the SysTick reload register (SYST_RVR). | |
| static void | internal_retune_thread_entry (ULONG thread_input) |
| Worker entry: toggle LED1 and advance the liveness counter. | |
| void | tx_application_define (void *first_unused_memory) |
| ThreadX application-define callback: retune SysTick, then spawn. | |
| void | main (void) |
| Application entry. | |
Variables | |
| volatile uint32_t | g_threadx_retune_tick = 0U |
| Scheduler-liveness counter – bumped by the worker on each wake. | |
| volatile uint32_t | g_threadx_retune_reload = 0U |
| SysTick reload the retune computed for the live CPUCLK0. | |
| volatile uint32_t | g_threadx_retune_bad = 0U |
| Non-zero iff the retune failed or SYST_RVR did not match the independently-computed reload for the live clock. | |
| static uint8_t | s_retune_stack [k_retune_thread_stack_bytes] |
| Stack for the worker thread (32-bit aligned per ARMv8-M AAPCS). | |
| static TX_THREAD | s_retune_thread |
| Worker thread control block. | |
Eclipse ThreadX SysTick retune-to-live-CPUCLK0 demo (issue #287).
Proves that ra8_threadx_systick_retune reprograms SysTick.LOAD from the live CPUCLK0 rate so the ThreadX kernel tick is accurate no matter which clock the app raised. Unlike threadx_blink – which relies on ra8_cgc_init() bringing CPUCLK0 to exactly the 1 GHz the tx_initialize_low_level.S reload assumes – this app additionally calls the retune hook from tx_application_define and self-checks the result:
| Name | Priority | Period | Action |
|---|---|---|---|
| retune | 4 | 250 ms loop | Toggle LED1, bump tick |
Definition in file main.c.
| enum retune_period_t : uint16_t |
| enum retune_priority_t : uint8_t |
| enum retune_stack_t : uint16_t |
| enum retune_syst_addr_t : uintptr_t |
|
static |
Read back the SysTick reload register (SYST_RVR).
Performs one volatile read from the architected Cortex-M System Control Space address used to verify the ThreadX clock retune.
| 0..k_ra8_systick_reload_max | Whatever was last programmed. |
Definition at line 174 of file main.c.
References k_retune_syst_rvr_addr, and RA8_INTERNAL.
Referenced by tx_application_define().
|
static |
Worker entry: toggle LED1 and advance the liveness counter.
Repeats the visible LED toggle and externally observed counter increment at the configured ThreadX sleep cadence.
| [in] | thread_input | Unused (ThreadX cookie). |
Definition at line 202 of file main.c.
References g_threadx_retune_tick, k_ra8_board_led1, k_retune_loop_ticks, 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.
Raises CPUCLK0, configures LED1, launches ThreadX.
Definition at line 284 of file main.c.
References k_ra8_board_led1, k_ra8_ok, ra8_board_led_init(), ra8_cgc_init(), and ra8_isr_globals_enable().
| void tx_application_define | ( | void * | first_unused_memory | ) |
ThreadX application-define callback: retune SysTick, then spawn.
| [in] | first_unused_memory | Unused – the demo uses a static stack. |
Definition at line 227 of file main.c.
References g_threadx_retune_bad, g_threadx_retune_reload, internal_retune_read_syst_rvr(), internal_retune_thread_entry(), k_ra8_clock_id_cpuclk0, k_ra8_ok, k_ra8_threadx_tick_hz, k_retune_thread_priority, k_retune_thread_stack_bytes, ra8_cgc_get_clock_hz(), ra8_threadx_systick_reload_for(), ra8_threadx_systick_retune(), s_retune_stack, s_retune_thread, s_thread_name, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
| volatile uint32_t g_threadx_retune_bad = 0U |
Non-zero iff the retune failed or SYST_RVR did not match the independently-computed reload for the live clock.
Definition at line 135 of file main.c.
Referenced by tx_application_define().
| volatile uint32_t g_threadx_retune_reload = 0U |
SysTick reload the retune computed for the live CPUCLK0.
Published for observability (999999 at CPUCLK0 = 1 GHz).
Definition at line 125 of file main.c.
Referenced by tx_application_define().
| volatile uint32_t g_threadx_retune_tick = 0U |
Scheduler-liveness counter – bumped by the worker on each wake.
Definition at line 116 of file main.c.
Referenced by internal_retune_thread_entry().
|
static |
Stack for the worker thread (32-bit aligned per ARMv8-M AAPCS).
Definition at line 146 of file main.c.
Referenced by tx_application_define().
|
static |
Worker thread control block.
ThreadX zeroes it on tx_thread_create.
Definition at line 151 of file main.c.
Referenced by tx_application_define().