32static const char*
s_tag =
"CAC";
34typedef enum : uint8_t {
50typedef enum : uint32_t {
60typedef enum : uint8_t {
86#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
88 const bool settled = ra8_fake_mmio_poll(®->
CACR0, i, reg->
CACR0 == expect);
91 const bool settled = reg->
CACR0 == expect;
135 reg->
CACR0 = cfme_set;
201 reg->
CAICR = caicr_clr;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_castr_mendf
Measurement end flag (CASTR bit 1).
@ k_ra8_cacr0_cfme
CFME: clock frequency measurement en.
@ k_ra8_castr_ovff
Counter overflow flag (CASTR bit 2).
@ k_ra8_castr_ferrf
Frequency error flag (CASTR bit 0).
ra8_err_t ra8_cac_init(uint16_t upper, uint16_t lower)
Programme CAC with upper + lower bounds on measured cycles.
ra8_cac_bits_w43_t
Combined CASTR status mask for FERRF | MENDF | OVFF.
@ k_ra8_cac_status_mask_all
RA8 cac status mask all.
static void internal_cac_wait_cfme(volatile r_cac_regs_t *reg, uint8_t expect)
Bounded busy-spin until CACR0 reads back expect.
ra8_err_t ra8_cac_exit_stop(void)
Exit MSTP-gated stop.
static ra8_cac_state_t s_cac_state
ra8_err_t ra8_cac_deinit(void)
Tear down the CAC (disable + MSTP release).
ra8_err_t ra8_cac_clear_status(uint8_t mask)
Clear the CASTR flag bits via CAICR.
void ra8_cac_dispatch(void)
Dispatch CAC events – snapshot + fire callback.
ra8_err_t ra8_cac_attach_handler(ra8_cac_event_fn_t fn, void *ctx)
Attach a callback for CAC events.
ra8_cac_misc_t
Miscellaneous shifts and bounded-spin budgets.
@ k_ra8_cac_castr_to_caicr_shift
CASTR -> CAICR.
@ k_ra8_cac_poll_limit
Bounded MENDF poll budget.
@ k_ra8_cac_cfme_settle_iters
Bounded settle on CACR0 write-back.
ra8_err_t ra8_cac_measure(uint16_t *out_count)
Kick off a CAC measurement and wait for completion.
ra8_err_t ra8_cac_get_status(uint8_t *out_mask)
Read the CASTR flag bits.
ra8_err_t ra8_cac_enter_stop(void)
Put CAC into MSTP-gated stop.
Clock Accuracy Check driver.
void(* ra8_cac_event_fn_t)(void *ctx, uint8_t status_mask)
CAC event callback.
@ k_ra8_cac_status_ferrf
Frequency error (CASTR bit 0).
@ k_ra8_cac_status_mendf
Measurement end (CASTR bit 1).
@ k_ra8_cac_status_ovff
Counter overflow (CASTR bit 2).
Clock Accuracy Check (CAC) register layout for the Renesas RA8D2.
static volatile r_cac_regs_t * ra8_cac(void)
Get pointer to the CAC block.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#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_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ 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.
Bounded wait-flag primitives for RA8D2 HAL drivers.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info(tag, message)
RA8 log info.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
ra8_err_t ra8_mstp_disable(ra8_mstp_t id)
Reference-counted "gate this peripheral" request.
@ k_ra8_mstp_cac
MSTPC0 CAC.
volatile uint16_t CALLVR
+0x08 Lower Limit.
volatile uint8_t CACR0
+0x00 Control 0.
volatile uint16_t CAULVR
+0x06 Upper Limit.
volatile uint8_t CAICR
+0x03 Int Control.
volatile uint16_t CACNTBR
+0x0A Counter Buf.
volatile uint8_t CASTR
+0x04 Status.
volatile uint8_t CACR2
+0x02 Control 2.
volatile uint8_t CACR1
+0x01 Control 1.
Driver-wide runtime state.