72static const char*
s_tag =
"VREG";
568 if (dcdcon_set && pd_clear) {
590 const uint8_t next = (uint8_t)(cur & (uint8_t)~mask);
615 s_state.last_standby = variant;
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).
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_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.
static uint8_t internal_lvocr_from_profile(ra8_vreg_lv_profile_t profile)
Translate a ra8_vreg_lv_profile_t enum to its LVOCR bit pattern.
ra8_err_t ra8_vreg_get_status(ra8_vreg_status_t *out)
Read the regulator status into a caller-supplied snapshot.
ra8_err_t ra8_vreg_set_ldo_boost(bool enable)
Enable / disable the LDO charge-pump boost.
ra8_err_t ra8_vreg_init(const ra8_vreg_cfg_t *cfg)
Initialise the internal voltage regulator from a config descriptor.
static ra8_err_t internal_validate_cfg(const ra8_vreg_cfg_t *cfg)
Validate every field of a ra8_vreg_cfg_t snapshot.
ra8_err_t ra8_vreg_set_mode(ra8_vreg_mode_t mode)
Switch between LDO and DCDC at runtime.
static ra8_vreg_event_fn_t s_vreg_fn
Registered fault callback.
void ra8_vreg_dispatch(void)
Fire the registered fault callback with the current DCDCCTL value.
ra8_err_t ra8_vreg_set_lv_profile(ra8_vreg_lv_profile_t profile)
Select a low-voltage operation profile.
ra8_err_t ra8_vreg_clear_status(uint8_t mask)
Clear the bits in DCDCCTL named by mask.
ra8_err_t ra8_vreg_exit_stop(void)
Legacy alias for ra8_vreg_exit_standby().
ra8_err_t ra8_vreg_enter_standby(ra8_vreg_standby_t variant)
Park the regulator for one of the Software Standby variants.
static void * s_vreg_ctx
Context forwarded to the registered callback.
ra8_err_t ra8_vreg_exit_standby(void)
Restore the regulator after Software Standby exit.
ra8_err_t ra8_vreg_deinit(void)
Tear down the regulator – return DCDCCTL/VCCSEL/LVOCR to reset state.
static uint8_t internal_pack_ldo_dcdcctl(const ra8_vreg_cfg_t *cfg)
Build the DCDCCTL value for a given config snapshot in LDO mode.
ra8_err_t ra8_vreg_set_vccsel(ra8_vreg_vccsel_t sel)
Set the DCDC supply-voltage-range select.
ra8_err_t ra8_vreg_enter_stop(void)
Legacy alias for ra8_vreg_enter_standby(k_ra8_vreg_standby_software).
static void internal_dcdc_enable_sequence(bool fast)
Run the FSP-style LDO->DCDC handshake (writes only – caller owns the inter-step delays).
ra8_err_t ra8_vreg_attach_handler(ra8_vreg_event_fn_t fn, void *ctx)
Attach a fault callback (LVD / over-current dispatch hook).
ra8_err_t ra8_vreg_set_ocp(ra8_vreg_ocp_t level)
Program the DCDC over-current-protection level.
ra8_err_t ra8_vreg_reset(void)
Reset the regulator to its OFS-byte default state.
ra8_err_t ra8_vreg_set_fast_startup(bool enable)
Enable / disable the DCDC fast-startup sequence.
static ra8_vreg_lv_profile_t internal_profile_from_lvocr(uint8_t lvocr)
Decode an LVOCR byte back into the profile enum.
static ra8_vreg_ocp_t internal_ocp_from_dcdcctl(uint8_t dcdcctl)
Decode the live DCDCCTL byte into the OCP enum.
static void internal_dcdc_disable_sequence(bool keep_lcboost)
Switch DCDC -> LDO.
Internal Voltage Regulator (DCDC / LDO) driver – full HUM Ch 68 surface.
void(* ra8_vreg_event_fn_t)(void *ctx, uint8_t status_word)
Voltage-regulator fault callback.
ra8_vreg_lv_profile_t
Low-voltage operation profile (LVOCR).
@ k_ra8_vreg_lv_off
Both LVO0E and LVO1E cleared (full-speed).
@ k_ra8_vreg_lv_p1
LVO1E set, LVO0E cleared.
@ k_ra8_vreg_lv_p0
LVO0E set, LVO1E cleared.
ra8_vreg_ocp_t
DCDC over-current protection threshold programming.
@ k_ra8_vreg_ocp_off
OCPEN cleared.
@ k_ra8_vreg_ocp_normal
OCPEN set; default threshold.
@ k_ra8_vreg_ocp_high
OCPEN set; reserved for future use.
ra8_vreg_standby_t
Software Standby variant the caller intends to enter next.
@ k_ra8_vreg_standby_software
Software Standby mode.
@ k_ra8_vreg_standby_battery_backup
Battery Backup wake source.
ra8_vreg_mode_t
Runtime regulator mode selection (DCDCCTL.DCDCON).
@ k_ra8_vreg_mode_dcdc
Switching regulator (DCDC).
@ k_ra8_vreg_mode_ldo
Low-dropout linear regulator (default at reset).
Internal Voltage Regulator (VREG / DCDC / LDO) register layout for RA8D2.
static volatile uint8_t * ra8_vreg_vccsel(void)
Get a volatile pointer to the 8-bit VCCSEL register.
static volatile uint8_t * ra8_vreg_dcdcctl(void)
Get a volatile pointer to the 8-bit DCDCCTL register.
@ k_ra8_vreg_dcdc_step_fast_on
STOPZA + DCDCON + OCPEN + FST – fast.
@ k_ra8_vreg_dcdc_step_lp_vref
STOPZA only – low-power Vref step.
@ k_ra8_vreg_dcdc_step_dcdc_on
STOPZA + DCDCON – LDO off, DCDC on.
@ k_ra8_vreg_dcdc_step_with_ocp
STOPZA + DCDCON + OCPEN – final DCDC.
static volatile uint8_t * ra8_vreg_lvocr(void)
Get a volatile pointer to the 8-bit LVOCR register.
@ k_ra8_vreg_mask_lvo_all
Union of every LVOCR writable bit.
@ k_ra8_vreg_mask_lvo1e
LVO1E – low-voltage profile 1 enable.
@ k_ra8_vreg_mask_lvo0e
LVO0E – low-voltage profile 0 enable.
ra8_vreg_vccsel_t
VCCSEL[1:0] supply-voltage range selection (DCDC mode only).
@ k_ra8_vreg_vccsel_3v0_to_3v6
3.0 V <= VCC <= 3.6 V.
@ k_ra8_vreg_vccsel_mask
2-bit field mask.
@ k_ra8_vreg_vccsel_2v4_to_2v7
2.4 V <= VCC < 2.7 V.
@ k_ra8_vreg_mask_fst
Bit 6.
@ k_ra8_vreg_mask_lcboost
Bit 5.
@ k_ra8_vreg_mask_dcdcctl_all
Union of all writable bits (0,1,4,5,6,7).
@ k_ra8_vreg_mask_pd
Bit 7.
@ k_ra8_vreg_mask_ocpen
Bit 1.
@ k_ra8_vreg_mask_stopza
Bit 4.
@ k_ra8_vreg_mask_dcdcon
Bit 0.
Configuration descriptor for ra8_vreg_init.
ra8_vreg_mode_t mode
Initial regulator mode.
bool ldo_boost
Enable LDO charge-pump boost (DCDCCTL.LCBOOST).
ra8_vreg_ocp_t ocp
OCP threshold (DCDC mode only).
ra8_vreg_vccsel_t vccsel
Supply-voltage range (used only in DCDC mode).
ra8_vreg_lv_profile_t lv_profile
Low-voltage operation profile (LVOCR).
bool fast_startup
Use fast-startup sequence (DCDCCTL.FST).
Cached "desired" state used by the enter/exit-standby pair.
uint8_t dcdcctl
Last value written to DCDCCTL.
uint8_t lvocr
Last value written to LVOCR.
ra8_vreg_vccsel_t vccsel
Last value written to VCCSEL.
ra8_vreg_lv_profile_t lv_profile
Cached LV profile.
bool ldo_boost
Cached LCBOOST bit.
bool initialized
True once ra8_vreg_init ran.
ra8_vreg_standby_t last_standby
Last standby variant requested.
ra8_vreg_ocp_t ocp
Cached OCP level (no HW readback).
bool fast_startup
Cached FST bit.
Snapshot of the regulator state.
ra8_vreg_mode_t mode
Decoded mode (LDO / DCDC).
bool dcdc_ready
True when DCDCON=1 and PD=0.
bool ldo_boost
True when DCDCCTL.LCBOOST is set.
ra8_vreg_lv_profile_t lv_profile
Decoded LVOCR profile.
ra8_vreg_vccsel_t vccsel_dec
Decoded VCCSEL.
uint8_t lvocr
Raw LVOCR value.
ra8_vreg_ocp_t ocp
Decoded OCP setting.
bool fast_startup
True when DCDCCTL.FST is set.
uint8_t dcdcctl
Raw DCDCCTL value.
bool io_buf_on
True when DCDCCTL.STOPZA is set.
uint8_t vccsel
Raw VCCSEL value.