49typedef enum : uint16_t {
117 return (uint8_t)((uint32_t)base_mask << (uint32_t)channel);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
const char * g_bkup_tag
Log tag used for this driver's diagnostics.
bool s_bkup_initialized
true once any of the lifecycle init helpers have run.
void priv_ra8_bkup_internal_rmw8(volatile uint8_t *reg, uint8_t mask, bool enable, uint16_t unlock_val)
Set or clear a bit in an 8-bit PRCR-protected RMW register.
Battery Backup Function (VBATT) HAL driver – public API.
@ k_ra8_bkup_capture_src_pin
0 -> raw RTCICn pin.
@ k_ra8_bkup_capture_src_vbtadf
1 -> VBTADFn flag.
@ k_ra8_bkup_nc_width_1hz
111b: 1 Hz.
@ k_ra8_bkup_edge_falling
VCHnEG = 0 -> falling edge.
@ k_ra8_bkup_edge_rising
VCHnEG = 1 -> rising edge.
ra8_bkup_channel_t
RTCICn tamper-detection channel index (HUM Ch 12.2.8 p 505).
Cross-TU shared surface for the ra8_bkup driver split.
Battery Backup Function (VBATT / BAT*) register layout for the RA8D2.
@ k_ra8_bkup_chan_count
RTCIC0..RTCIC2 tamper channels.
@ k_ra8_bkup_vbtimonr_mask_vch0mon
VCH0MON @ bit 0.
static volatile uint8_t * ra8_bkup_vbtictlr2(void)
Pointer to 8-bit VBTICTLR2 (HUM Ch 12.2.9 p 506).
static volatile uint8_t * ra8_bkup_vbtadcr3(void)
Pointer to 8-bit VBTADCR3 (HUM Ch 12.2.17 p 511).
@ k_ra8_bkup_vbtadcr3_mask_vbtadze0
VBTADZE0 @ bit 0.
static volatile uint8_t * ra8_bkup_vbtadcr2(void)
Pointer to 8-bit VBTADCR2 (HUM Ch 12.2.16 p 511).
@ k_ra8_bkup_vbtncwcr_mask_vincw
VINCW[2:0] @ [2:0].
static volatile uint8_t * ra8_bkup_vbtimonr(void)
Pointer to 8-bit VBTIMONR (HUM Ch 12.2.10 p 506).
@ k_ra8_bkup_vbtictlr2_mask_vch0eg
VCH0EG @ bit 4.
@ k_ra8_bkup_vbtictlr2_mask_vch0nce
VCH0NCE @ bit 0.
static volatile uint8_t * ra8_bkup_vbtadsr(void)
Pointer to 8-bit VBTADSR (HUM Ch 12.2.14 p 509).
static volatile uint8_t * ra8_bkup_vbtictlr(void)
Pointer to 8-bit VBTICTLR (HUM Ch 12.2.8 p 505).
static volatile uint8_t * ra8_bkup_vbtadcr1(void)
Pointer to 8-bit VBTADCR1 (HUM Ch 12.2.15 p 510).
@ k_ra8_bkup_vbtictlr_mask_vch0inen
VCH0INEN @ bit 0.
static volatile uint8_t * ra8_bkup_vbtncwcr(void)
Pointer to 8-bit VBTNCWCR (HUM Ch 12.2.18 p 511).
@ k_ra8_bkup_vbtadcr2_mask_vbrtces0
VBRTCES0 @ bit 0.
@ k_ra8_bkup_vbtadcr1_mask_vbtadie0
VBTADIE0 @ bit 0.
@ k_ra8_bkup_vbtadcr1_mask_vbtadce0
VBTADCE0 @ bit 4.
static uint8_t internal_compose_vbtictlr(const ra8_bkup_tamper_config_t *cfg)
Compose the VBTICTLR (VCHnINEN) byte from per-channel flags.
ra8_err_t ra8_bkup_read_input(ra8_bkup_channel_t channel, bool *high_out)
Read the live RTCICn pin level via VBTIMONR.
static ra8_err_t internal_validate_tamper_channels(const ra8_bkup_tamper_config_t *cfg)
Validate every channel descriptor in a tamper config.
ra8_err_t ra8_bkup_tamper_disable(void)
Disable every tamper input and clear flags.
static uint8_t internal_compose_vbtictlr2(const ra8_bkup_tamper_config_t *cfg)
Compose the VBTICTLR2 (VCHnNCE + VCHnEG) byte from per-channel flags.
static uint8_t internal_chan_mask(uint8_t base_mask, ra8_bkup_channel_t channel)
Convert channel + bit-base mask into the actual masked bit.
ra8_bkup_tamper_internal_t
Local numeric constants – avoid magic numbers per CLAUDE.md.
@ k_ra8_bkup_max_nc_width
Highest legal VINCW encoding.
static uint8_t internal_compose_vbtadcr2(const ra8_bkup_tamper_config_t *cfg)
Compose the VBTADCR2 (capture-source) byte.
ra8_err_t ra8_bkup_tamper_init(const ra8_bkup_tamper_config_t *cfg)
Apply per-channel tamper configuration in one shot.
ra8_err_t ra8_bkup_set_input_enable(ra8_bkup_channel_t channel, bool enable)
Convenience wrapper that just sets / clears VCHnINEN.
static uint8_t internal_compose_vbtadcr3(const ra8_bkup_tamper_config_t *cfg)
Compose the VBTADCR3 (HUK-zeroize) byte.
static uint8_t internal_compose_vbtadcr1(const ra8_bkup_tamper_config_t *cfg)
Compose the VBTADCR1 (IRQ-enable + clear-backup) byte.
static ra8_err_t internal_validate_chan(const ra8_bkup_tamper_chan_cfg_t *ch)
Validate a per-channel tamper descriptor.
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_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_info(tag, message)
RA8 log info.
Scoped PRCR unlock helper.
#define RA8_PROTECTED_WRITE(unlock_val)
Scoped PRCR unlock block.
@ k_ra8_prcr_unlock_lpm
RA8 prcr unlock lpm.
Per-channel tamper-detection configuration.
bool zeroize_huk
VBTADZEn: assert HUK zeroize on flag.
ra8_bkup_capture_src_t capture_src
VBRTCESn: RTC time-capture source select.
bool clear_backup
VBTADCEn: zeroise VBTBKRn on flag.
ra8_bkup_edge_t edge
VCHnEG: falling vs rising trigger edge.
bool input_enable
VCHnINEN: drive RTCICn pad as input.
bool irq_enable
VBTADIEn: route flag to VBATTADI ICU slot.
bool noise_canceller_en
VCHnNCE: enable 3-tap synchroniser.
Whole-block tamper-detection configuration.
ra8_bkup_nc_width_t nc_width
VINCW noise-sampling clock.
ra8_bkup_tamper_chan_cfg_t channels[(uint8_t) k_ra8_bkup_chan_count]
Channels.