39static const char*
s_tag =
"LVD";
316 const uint8_t fsamp_bits =
static const char * s_tag
Logging / check tag.
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_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ 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.
const ra8_lvd_channel_map_t g_lvd_map[k_ra8_lvd_map_idx_count]
Lookup table from ra8_lvd_map_idx_t to register offsets.
ra8_err_t priv_ra8_lvd_internal_channel_to_idx(ra8_lvd_channel_t channel, uint8_t *out_idx)
Implementation of priv_ra8_lvd_internal_channel_to_idx() – switch on PVD id.
ra8_err_t priv_ra8_lvd_internal_validate_div(ra8_lvd_loco_div_t div)
Implementation of priv_ra8_lvd_internal_validate_div() – upper-bound check.
uint8_t priv_ra8_lvd_internal_read_ri(const ra8_lvd_channel_map_t *map)
Implementation of priv_ra8_lvd_internal_read_ri() – masked CR0 read.
void priv_ra8_lvd_internal_cr0_rmw(const ra8_lvd_channel_map_t *map, uint8_t clear_mask, uint8_t set_bits)
Implementation of priv_ra8_lvd_internal_cr0_rmw() – RMW with reserved-bit refold.
Programmable Voltage Detection (PVD / LVD) HAL driver.
Test-access surface for ra8_lvd internal helpers (MC/DC).
Programmable Voltage Detection (PVD / LVD) register layout for the RA8D2.
@ k_ra8_lvd_sr_mask_det
DET latched-crossing flag.
@ k_ra8_lvd_sr_mask_mon
MON live above-threshold flag.
@ k_ra8_lvd_cr0_mask_re
RE (n) – reset-only enable.
@ k_ra8_lvd_cr0_mask_rn
RN reset-negate timing (m).
@ k_ra8_lvd_cr0_mask_cmpe
CMPE comparator-output enable.
@ k_ra8_lvd_cr0_mask_ri
RI reset-on-cross select (m).
@ k_ra8_lvd_cr0_mask_rie
RIE (m) – IRQ/reset enable.
@ k_ra8_lvd_cr0_mask_dfdis
DFDIS digital-filter disable.
@ k_ra8_lvd_cr0_mask_fsamp
FSAMP[1:0] divider field.
static volatile uint8_t * ra8_lvd_reg8(ra8_lvd_off_t off)
Get a volatile uint8_t* to a PVD 8-bit register.
@ k_ra8_lvd_cmpcr_mask_pvde
PVDE detector enable.
@ k_ra8_lvd_fcr_mask_rhsel
RHSEL hysteresis-band selector.
@ k_ra8_lvd_cr0_shift_fsamp
FSAMP[1:0] starts at bit 4.
ra8_err_t ra8_lvd_enable_cmpe(ra8_lvd_channel_t channel)
Set CR0.CMPE so the comparator output drives the response logic.
ra8_err_t ra8_lvd_clear_status(ra8_lvd_channel_t channel)
Acknowledge PVDmSR.DET via write-0-to-clear.
ra8_err_t ra8_lvd_disable_reset(ra8_lvd_channel_t channel)
Disarm the reset response for a PVD channel.
ra8_err_t ra8_lvd_get_status(ra8_lvd_channel_t channel, ra8_lvd_status_t *out)
Read PVDmSR and decode DET / MON into ra8_lvd_status_t.
ra8_err_t ra8_lvd_enable_irq(ra8_lvd_channel_t channel)
Set CR0.RIE on an IRQ-capable PVDm channel.
ra8_err_t ra8_lvd_set_negate_mode(ra8_lvd_channel_t channel, ra8_lvd_negate_t negate)
Update CR0.RN (negate-after-assert) for a PVDm channel.
ra8_err_t ra8_lvd_set_filter(ra8_lvd_channel_t channel, ra8_lvd_loco_div_t filter_div, bool filter_en)
Update FSAMP and DFDIS for a PVD channel at runtime.
ra8_err_t ra8_lvd_disable_irq(ra8_lvd_channel_t channel)
Clear CR0.RIE on an IRQ-capable PVDm channel.
ra8_err_t ra8_lvd_enable_reset(ra8_lvd_channel_t channel)
Arm the reset response for a PVD channel.
ra8_err_t ra8_lvd_set_hysteresis_mode(ra8_lvd_channel_t channel, ra8_lvd_hysteresis_t hyst)
Update FCR.RHSEL (hysteresis mode) for a PVD channel.
ra8_err_t ra8_lvd_disable_cmpe(ra8_lvd_channel_t channel)
Clear CR0.CMPE so the comparator stops driving the response logic.
ra8_lvd_loco_div_t
PVDmCR0.FSAMP[1:0] / PVDnCR0.FSAMP[1:0] sampling-clock divider.
ra8_lvd_negate_t
PVDmCR0.RN value – reset deassertion timing.
@ k_ra8_lvd_negate_after_assert
Negate after reset asserts.
ra8_lvd_hysteresis_t
PVDmFCR.RHSEL / PVDnFCR.RHSEL value.
@ k_ra8_lvd_hysteresis_hvd
RHSEL = 1 (rise detect).
ra8_lvd_channel_t
Voltage-monitor channel selector.
Per-channel register-offset bundle.
ra8_lvd_off_t fcr
PVDxFCR (RHSEL).
ra8_lvd_off_t cmpcr
PVDxCMPCR offset.
ra8_lvd_off_t sr
PVDxSR (m only; n: same as cr0 stub).
bool has_irq
true for monitor m channels (1, 2).
bool crossed
DET flag: a Vdetm crossing was latched.
bool above
MON flag: VCC currently above Vdetm threshold.