33static const char*
const s_tag =
"ra8_systick";
43typedef enum : uintptr_t {
58typedef enum : uint32_t {
89 return (
volatile uint32_t*)addr;
98 if ((cpu_hz == 0U) || (tick_hz == 0U)) {
103 const uint32_t ticks = cpu_hz / tick_hz;
110 const uint32_t reload = ticks - 1U;
118 *out_reload = reload;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_HW_REGISTER_ACCESS
Mark an MMIO accessor function (returns volatile register pointer).
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ 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.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error(tag, message)
RA8 log error.
ra8_err_t ra8_systick_reload_for(uint32_t cpu_hz, uint32_t tick_hz, uint32_t *out_reload)
Compute the SysTick reload for a given core clock and tick rate.
uint32_t ra8_systick_current_value(void)
Read the live SysTick current-value register (SYST_CVR).
ra8_systick_bit_t
Control bits for SYST_CSR, DEMCR, and DWT_CTRL.
@ k_ra8_systick_csr_enable
SYST_CSR.ENABLE (bit 0).
@ k_ra8_dwt_demcr_trcena
DEMCR.TRCENA (bit 24).
@ k_ra8_dwt_ctrl_cyccntena
DWT_CTRL.CYCCNTENA (bit 0).
@ k_ra8_systick_csr_clksource
SYST_CSR.CLKSOURCE (bit 2).
@ k_ra8_systick_csr_tickint
SYST_CSR.TICKINT (bit 1).
ra8_systick_reg_addr_t
Arm v8-M SCS timebase register addresses (PPB 0xE000Exxx).
@ k_ra8_systick_csr
SYST_CSR control and status.
@ k_ra8_dwt_cyccnt
DWT_CYCCNT free-running counter.
@ k_ra8_dwt_ctrl
DWT_CTRL: bit 0 CYCCNTENA.
@ k_ra8_systick_rvr
SYST_RVR reload value.
@ k_ra8_dwt_demcr
DEMCR: bit 24 TRCENA unlocks DWT.
@ k_ra8_systick_cvr
SYST_CVR current value.
ra8_err_t ra8_systick_set_reload(uint32_t reload)
Re-arm SysTick with a new reload, leaving the control bits untouched.
static volatile uint32_t * internal_systick_reg(ra8_systick_reg_addr_t addr)
Typed pointer to a 32-bit SCS timebase register.
void ra8_dwt_cyccnt_reset(void)
Zero the DWT cycle counter (DWT_CYCCNT).
ra8_err_t ra8_systick_configure(uint32_t reload, ra8_systick_clock_source_t src, bool tick_irq)
Arm and start SysTick with a reload value and clock source.
uint32_t ra8_dwt_cyccnt_read(void)
Sample the DWT cycle counter (DWT_CYCCNT).
void ra8_dwt_cyccnt_enable(void)
Enable the DWT free-running cycle counter (DWT_CYCCNT).
Cortex-M85 SysTick + DWT cycle-counter timebase primitive.
@ k_ra8_systick_rvr_max
Max SYST_RVR reload (24-bit).
ra8_systick_clock_source_t
Selects the SysTick counter clock (SYST_CSR.CLKSOURCE).
@ k_ra8_systick_clk_cpu
CLKSOURCE = 1: processor (CPU) clock.