65typedef enum : uint8_t {
78typedef enum : uint8_t {
87typedef enum : uint8_t {
97typedef enum : uint8_t {
112typedef enum : uint8_t {
128typedef enum : uint8_t {
377 uint32_t timeout_iters);
void(* ra8_bkup_event_fn_t)(void *ctx, uint8_t tamper_flags)
Low-battery / tamper event callback signature.
ra8_err_t ra8_bkup_read_input(ra8_bkup_channel_t channel, bool *high_out)
Read the live RTCICn pin level via VBTIMONR.
ra8_err_t ra8_bkup_clear_status(uint8_t mask)
Clear latched VBPORF and tamper flags selected by mask.
ra8_err_t ra8_bkup_write_word(uint8_t word_index, uint32_t value)
Write one 32-bit word into the VBTBKRn array.
ra8_err_t ra8_bkup_tamper_disable(void)
Disable every tamper input and clear flags.
ra8_bkup_capture_src_t
RTC time-capture event source select (HUM Ch 12.2.16 p 511, VBTADCR2.VBRTCESn).
@ k_ra8_bkup_capture_src_pin
0 -> raw RTCICn pin.
@ k_ra8_bkup_capture_src_vbtadf
1 -> VBTADFn flag.
ra8_bkup_source_t
Live power-source decoded from VBTBPSR.BPWSWM.
@ k_ra8_bkup_source_vbatt
BPWSWM=0: VCC < VDETBATT, on VBATT.
@ k_ra8_bkup_source_vcc
BPWSWM=1: VCC > VDETBATT, on VCC.
ra8_err_t ra8_bkup_read_byte(uint16_t index, uint8_t *out)
Read one 8-bit byte from the VBTBKRn array.
ra8_err_t ra8_bkup_init(const ra8_bkup_config_t *cfg)
Configure the battery-backup block from cfg.
ra8_bkup_vdet_level_t
VDETBATT trip level (HUM Ch 12.2.12 p 508, VBTBPCR2.VDETLVL).
@ k_ra8_bkup_vdet_2p80v
000b: 2.80 V (default after reset).
@ k_ra8_bkup_vdet_2p53v
001b: 2.53 V.
@ k_ra8_bkup_vdet_2p10v
010b: 2.10 V.
@ k_ra8_bkup_vdet_1p85v
100b: 1.85 V.
@ k_ra8_bkup_vdet_1p75v
101b: 1.75 V.
@ k_ra8_bkup_vdet_1p95v
011b: 1.95 V.
ra8_err_t ra8_bkup_warm_start_check(bool *needs_reinit, uint32_t timeout_iters)
Warm-start sanity check (HUM Ch 12.3.7.2 p 517).
ra8_err_t ra8_bkup_security_get(ra8_bkup_security_config_t *cfg)
Read back the four security partition registers.
ra8_bkup_nc_width_t
Noise-canceller sampling clock select (HUM Ch 12.2.18 p 511, VBTNCWCR.VINCW).
@ k_ra8_bkup_nc_width_1hz
111b: 1 Hz.
@ k_ra8_bkup_nc_width_16hz
011b: 16 Hz.
@ k_ra8_bkup_nc_width_32hz
010b: 32 Hz.
@ k_ra8_bkup_nc_width_32768hz
000b: 32.768 kHz (sub-clock).
@ k_ra8_bkup_nc_width_8hz
100b: 8 Hz.
@ k_ra8_bkup_nc_width_2hz
110b: 2 Hz.
@ k_ra8_bkup_nc_width_4hz
101b: 4 Hz.
@ k_ra8_bkup_nc_width_64hz
001b: 64 Hz.
ra8_err_t ra8_bkup_attach_handler(ra8_bkup_event_fn_t fn, void *ctx)
Attach the shared low-battery / tamper event callback.
ra8_err_t ra8_bkup_get_voltage_monitor_enabled(bool *enabled_out)
Read the live VBATTMNSELR.VBTMNSEL bit.
ra8_err_t ra8_bkup_get_status(ra8_bkup_status_t *out)
Read VBTBPSR + VBTADSR and decode into out.
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.
ra8_bkup_edge_t
Tamper-detection edge select (HUM Ch 12.2.9 p 506).
@ k_ra8_bkup_edge_falling
VCHnEG = 0 -> falling edge.
@ k_ra8_bkup_edge_rising
VCHnEG = 1 -> rising edge.
ra8_err_t ra8_bkup_set_voltage_monitor(bool enable)
Enable / disable the VBATT/6 analog tap to ADC16H.
ra8_err_t ra8_bkup_cold_start_init(ra8_bkup_vdet_level_t level, uint32_t timeout_iters)
Drive the cold-start flow from HUM Ch 12.3.7.1 p 517.
ra8_err_t ra8_bkup_deinit(void)
Disable the battery-backup switch and close the VBTBKRn window.
ra8_bkup_channel_t
RTCICn tamper-detection channel index (HUM Ch 12.2.8 p 505).
@ k_ra8_bkup_chan_rtcic2
RTCIC2 -> VBTADF2 / VCH2*.
@ k_ra8_bkup_chan_rtcic1
RTCIC1 -> VBTADF1 / VCH1*.
@ k_ra8_bkup_chan_rtcic0
RTCIC0 -> VBTADF0 / VCH0*.
ra8_err_t ra8_bkup_read_word(uint8_t word_index, uint32_t *out)
Read one 32-bit word from the VBTBKRn array.
ra8_err_t ra8_bkup_write_byte(uint16_t index, uint8_t value)
Write one 8-bit byte into the VBTBKRn array.
ra8_err_t ra8_bkup_zero_all(void)
Bulk-zeroise the entire 128-byte backup-register array.
ra8_err_t ra8_bkup_security_apply(const ra8_bkup_security_config_t *cfg)
Apply BBFSAR + VBRSABAR + VBRPABAR{S,NS} from one descriptor.
void ra8_bkup_dispatch(uint8_t tamper_flags)
Fire the registered callback (called from the ISR shim).
ra8_err_t ra8_bkup_no_switch_init(uint32_t timeout_iters)
"Power-supply switch unused" init flow (HUM Ch 12.3.7.3 p 518).
ra8_err_t ra8_bkup_isr_handle(void)
ISR entry point that fires the registered callback.
Battery Backup Function (VBATT / BAT*) register layout for the RA8D2.
@ k_ra8_bkup_chan_count
RTCIC0..RTCIC2 tamper channels.
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Configuration descriptor passed to ra8_bkup_init.
ra8_bkup_vdet_level_t vdet_level
VDETBATT trip threshold (VBTBPCR2.VDETLVL).
bool enable_backup
true -> set VBTBER.VBAE so VBTBKRn is accessible.
bool enable_switch
true -> clear BPWSWSTP, allow VCC->VBATT switching.
BBFSAR + backup-register boundary descriptor.
uint16_t pabans
VBRPABARNS.PABANS (32-byte aligned).
uint16_t saba
VBRSABAR.SABA (32-byte aligned).
uint32_t bbfsar
OR of k_ra8_bkup_bbfsar_mask_* bits.
uint16_t pabas
VBRPABARS.PABAS (32-byte aligned).
Decoded snapshot of VBTBPSR.
uint8_t tamper_flags
Raw VBTADSR.VBTADF[2:0] mask.
bool por_detected
VBPORF: VBATT_POR reset latched (W0C).
uint8_t raw_vbtbpsr
Unmodified VBTBPSR (debug aid).
ra8_bkup_source_t source
Active power source right now.
bool vbatt_r_ok
VBPORM: VBATT_R > VPORBATT (post-OK).
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.