ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_vreg.c
Go to the documentation of this file.
1
57
58#include "ra8_vreg.h"
59
60#include <stdint.h>
61
62#include "ra8_attributes.h"
63#include "ra8_check.h"
64#include "ra8_err.h"
65#include "ra8_log.h"
66#include "ra8_vreg_regs.h"
67
72static const char* s_tag = "VREG";
73
93
96
99
101static void* s_vreg_ctx;
102
103/* =============================================================================
104 * Internal helpers
105 * =============================================================================
106 */
107
126{
127 if ((uint8_t)cfg->mode > k_ra8_vreg_mode_dcdc) {
129 }
130 if ((uint8_t)cfg->vccsel > k_ra8_vreg_vccsel_3v0_to_3v6) {
132 }
133 if ((uint8_t)cfg->ocp > k_ra8_vreg_ocp_high) {
135 }
136 if ((uint8_t)cfg->lv_profile > k_ra8_vreg_lv_p1) {
138 }
139 return k_ra8_ok;
140}
141
158{
159 if (profile == k_ra8_vreg_lv_p0) {
161 }
162 if (profile == k_ra8_vreg_lv_p1) {
164 }
165 return 0U;
166}
167
184{
185 const uint8_t bits = (uint8_t)(lvocr & k_ra8_vreg_mask_lvo_all);
186 if (bits == k_ra8_vreg_mask_lvo0e) {
187 return k_ra8_vreg_lv_p0;
188 }
189 if (bits == k_ra8_vreg_mask_lvo1e) {
190 return k_ra8_vreg_lv_p1;
191 }
192 return k_ra8_vreg_lv_off;
193}
194
211{
212 if ((dcdcctl & k_ra8_vreg_mask_ocpen) == 0U) {
213 return k_ra8_vreg_ocp_off;
214 }
215 /* Hardware can only report "OCP enabled"; fall back to the cached
216 * level so the caller sees the value last written via
217 * `ra8_vreg_set_ocp()`. */
219}
220
240{
241 uint8_t v = 0U;
242 if (cfg->ocp != k_ra8_vreg_ocp_off) {
244 }
245 if (cfg->fast_startup) {
247 }
248 if (cfg->ldo_boost) {
250 }
251 return v;
252}
253
281{
282 uint8_t cur = *ra8_vreg_dcdcctl();
283
284 /* Step 1: enable IO buffer (STOPZA = 1).
285 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
287 *ra8_vreg_dcdcctl() = cur;
288
289 /* Step 2: turn on DCDC Vref (PD = 0).
290 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
291 cur &= (uint8_t)~k_ra8_vreg_mask_pd;
292 *ra8_vreg_dcdcctl() = cur;
293
294 if (fast) {
295 /* Fast path: jump straight to the final value with FST asserted.
296 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
298 } else {
299 /* Step 3: switch Vref to low-power.
300 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
302 /* Step 4: turn off LDO and turn on DCDC.
303 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
305 /* Step 5: enable DCDC over-current protection.
306 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
308 }
309
310 if (fast) {
312 } else {
314 }
315}
316
331RA8_INTERNAL static void internal_dcdc_disable_sequence(bool keep_lcboost)
332{
333 /* The LDO selection is "everything off" -- optionally with LCBOOST
334 * still asserted so the LDO can run at subosc-speed VDD.
335 * HUM Ch 68.2.2 "External VDD Mode" p 4033
336 *
337 * NB: do NOT touch s_state.dcdcctl here. enter_standby uses this
338 * helper transiently and relies on the cached value to restore on
339 * exit; set_mode(LDO) updates the cache itself for the permanent
340 * mode-switch path. */
341 uint8_t v = 0U;
342 if (keep_lcboost) {
344 }
345 *ra8_vreg_dcdcctl() = v;
346}
347
348/* =============================================================================
349 * Lifecycle
350 * =============================================================================
351 */
352
353[[nodiscard]] ra8_err_t ra8_vreg_init(const ra8_vreg_cfg_t* cfg)
354{
355 RA8_CHECK_NULL_PTR(cfg, s_tag, "cfg must not be nullptr");
356 const ra8_err_t verr = internal_validate_cfg(cfg);
357 if (verr != k_ra8_ok) {
358 return verr;
359 }
360
361 /* Clear LVOCR first so a stale low-voltage profile cannot affect
362 * the DCDC handshake (LV profiles widen the timing budget).
363 * HUM Ch 68.3 "Usage Notes" p 4034 */
364 *ra8_vreg_lvocr() = 0U;
365
366 /* VCCSEL biases the DCDC for the actual VCC range; program before
367 * turning DCDC on.
368 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
369 *ra8_vreg_vccsel() = (uint8_t)((uint8_t)cfg->vccsel & k_ra8_vreg_vccsel_mask);
370
371 if (cfg->mode == k_ra8_vreg_mode_dcdc) {
372 /* Use the staged handshake so the chip ends in the documented
373 * final state (STOPZA + DCDCON + OCPEN, optionally + FST). */
375 if (!cfg->ldo_boost) {
376 /* LCBOOST has no effect in DCDC mode; nothing to apply. */
377 }
378 } else {
379 /* LDO mode: write the boost / OCP / FST bits directly without
380 * staging. OCPEN has no DCDC to protect when DCDCON==0 but the
381 * caller may have asked for it so the value is restored across
382 * a future LDO->DCDC transition.
383 * HUM Ch 68.2.2 "External VDD Mode" p 4033 */
384 const uint8_t ldo = internal_pack_ldo_dcdcctl(cfg);
385 *ra8_vreg_dcdcctl() = ldo;
386 s_state.dcdcctl = ldo;
387 }
388
389 /* Apply LV profile last so the chip is in the right power mode
390 * before relaxing the timing.
391 * HUM Ch 68.3 "Usage Notes" p 4034 */
392 const uint8_t lvocr = internal_lvocr_from_profile(cfg->lv_profile);
393 *ra8_vreg_lvocr() = lvocr;
394
395 s_state.vccsel = cfg->vccsel;
396 s_state.lvocr = lvocr;
397 s_state.ocp = cfg->ocp;
398 s_state.lv_profile = cfg->lv_profile;
399 s_state.fast_startup = cfg->fast_startup;
400 s_state.ldo_boost = cfg->ldo_boost;
402 s_state.initialized = true;
403
404 ra8_log_info(s_tag, "vreg_init");
405 return k_ra8_ok;
406}
407
408[[nodiscard]] ra8_err_t ra8_vreg_deinit(void)
409{
410 /* DCDCCTL = 0 returns to LDO with all features (OCP, fast-start,
411 * low-power Vref) disabled.
412 * HUM Ch 68.2.2 "External VDD Mode" p 4033 */
413 *ra8_vreg_dcdcctl() = 0U;
414 /* VCCSEL irrelevant in LDO; clear it.
415 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
416 *ra8_vreg_vccsel() = 0U;
417 /* LVOCR cleared so we do not silently leave a low-voltage profile
418 * set across re-init.
419 * HUM Ch 68.3 "Usage Notes" p 4034 */
420 *ra8_vreg_lvocr() = 0U;
421
422 s_state.dcdcctl = 0U;
424 s_state.lvocr = 0U;
426 s_state.lv_profile = k_ra8_vreg_lv_off;
427 s_state.fast_startup = false;
428 s_state.ldo_boost = false;
429 s_state.initialized = false;
430 return k_ra8_ok;
431}
432
433/* =============================================================================
434 * Runtime control
435 * =============================================================================
436 */
437
439{
440 if ((mode != k_ra8_vreg_mode_ldo) && (mode != k_ra8_vreg_mode_dcdc)) {
442 }
443
444 if (mode == k_ra8_vreg_mode_dcdc) {
446 } else {
448 /* Permanent mode switch: cache the LDO selection so a subsequent
449 * standby/restore cycle keeps the regulator in LDO. */
450 uint8_t cached = 0U;
451 if (s_state.ldo_boost) {
453 }
454 s_state.dcdcctl = cached;
455 }
456 return k_ra8_ok;
457}
458
460{
461 if ((uint8_t)sel > k_ra8_vreg_vccsel_3v0_to_3v6) {
463 }
464 /* VCCSEL[1:0] biases the DCDC for the supply-voltage window.
465 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
466 *ra8_vreg_vccsel() = (uint8_t)((uint8_t)sel & k_ra8_vreg_vccsel_mask);
467 s_state.vccsel = sel;
468 return k_ra8_ok;
469}
470
472{
473 if ((uint8_t)level > k_ra8_vreg_ocp_high) {
475 }
476 /* Read-modify-write DCDCCTL.OCPEN.
477 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
478 uint8_t cur = *ra8_vreg_dcdcctl();
479 if (level == k_ra8_vreg_ocp_off) {
480 cur &= (uint8_t)~k_ra8_vreg_mask_ocpen;
481 } else {
483 }
484 *ra8_vreg_dcdcctl() = cur;
485 s_state.dcdcctl = cur;
486 s_state.ocp = level;
487 return k_ra8_ok;
488}
489
490[[nodiscard]] ra8_err_t ra8_vreg_set_fast_startup(bool enable)
491{
492 /* DCDCCTL.FST controls whether subsequent LDO->DCDC transitions
493 * skip the long Vref soak.
494 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
495 uint8_t cur = *ra8_vreg_dcdcctl();
496 if (enable) {
497 cur |= k_ra8_vreg_mask_fst;
498 } else {
499 cur &= (uint8_t)~k_ra8_vreg_mask_fst;
500 }
501 *ra8_vreg_dcdcctl() = cur;
502 s_state.dcdcctl = cur;
503 s_state.fast_startup = enable;
504 return k_ra8_ok;
505}
506
507[[nodiscard]] ra8_err_t ra8_vreg_set_ldo_boost(bool enable)
508{
509 /* DCDCCTL.LCBOOST keeps the LDO regulating into subosc-speed VDD.
510 * HUM Ch 68.2.2 "External VDD Mode" p 4033 */
511 uint8_t cur = *ra8_vreg_dcdcctl();
512 if (enable) {
514 } else {
515 cur &= (uint8_t)~k_ra8_vreg_mask_lcboost;
516 }
517 *ra8_vreg_dcdcctl() = cur;
518 s_state.dcdcctl = cur;
519 s_state.ldo_boost = enable;
520 return k_ra8_ok;
521}
522
524{
525 if ((uint8_t)profile > k_ra8_vreg_lv_p1) {
527 }
528 /* LVOCR enforces mutual exclusion of LVO0E / LVO1E in software --
529 * the silicon allows both bits to be set but the result is
530 * undefined.
531 * HUM Ch 68.3 "Usage Notes" p 4034 */
532 const uint8_t v = internal_lvocr_from_profile(profile);
533 *ra8_vreg_lvocr() = v;
534 s_state.lvocr = v;
535 s_state.lv_profile = profile;
536 return k_ra8_ok;
537}
538
539/* =============================================================================
540 * Status
541 * =============================================================================
542 */
543
545{
546 RA8_CHECK_NULL_PTR(out, s_tag, "out must not be nullptr");
547 /* DCDCCTL is the main status word.
548 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
549 const uint8_t dcdcctl = *ra8_vreg_dcdcctl();
550 /* VCCSEL is read-back-able.
551 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
552 const uint8_t vccsel = *ra8_vreg_vccsel();
553 /* LVOCR holds the low-voltage profile bit.
554 * HUM Ch 68.3 "Usage Notes" p 4034 */
555 const uint8_t lvocr = *ra8_vreg_lvocr();
556
557 out->dcdcctl = dcdcctl;
558 out->vccsel = vccsel;
559 out->lvocr = lvocr;
560 out->mode =
564 out->ocp = internal_ocp_from_dcdcctl(dcdcctl);
565 const bool dcdcon_set = (dcdcctl & k_ra8_vreg_mask_dcdcon) != 0U;
566 const bool pd_clear = (dcdcctl & k_ra8_vreg_mask_pd) == 0U;
567 out->dcdc_ready = false;
568 if (dcdcon_set && pd_clear) {
569 out->dcdc_ready = true;
570 }
571 out->fast_startup = ((dcdcctl & k_ra8_vreg_mask_fst) != 0U);
572 out->ldo_boost = ((dcdcctl & k_ra8_vreg_mask_lcboost) != 0U);
573 out->io_buf_on = ((dcdcctl & k_ra8_vreg_mask_stopza) != 0U);
574 return k_ra8_ok;
575}
576
577[[nodiscard]] ra8_err_t ra8_vreg_clear_status(uint8_t mask)
578{
579 /* Reject any bit outside the documented writable mask -- writing a
580 * reserved bit is a programmer error.
581 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
582 if ((mask & (uint8_t)~k_ra8_vreg_mask_dcdcctl_all) != 0U) {
584 }
585
586 /* Read-modify-write DCDCCTL to clear the requested control bits
587 * without touching the rest.
588 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
589 const uint8_t cur = *ra8_vreg_dcdcctl();
590 const uint8_t next = (uint8_t)(cur & (uint8_t)~mask);
591 *ra8_vreg_dcdcctl() = next;
592 s_state.dcdcctl = next;
593 return k_ra8_ok;
594}
595
596[[nodiscard]] ra8_err_t ra8_vreg_reset(void)
597{
598 const ra8_err_t err = ra8_vreg_deinit();
599 /* Wipe the standby cache too -- a recoverable fault may invalidate
600 * the previously cached "desired" state. */
602 return err;
603}
604
605/* =============================================================================
606 * Power transition
607 * =============================================================================
608 */
609
611{
612 if ((uint8_t)variant > k_ra8_vreg_standby_battery_backup) {
614 }
615 s_state.last_standby = variant;
616
617 /* Software Standby (and every Deep variant + Battery Backup) is
618 * not supported in DCDC mode, so park the regulator in LDO before
619 * standby. The cached state lets us restore DCDC on exit.
620 * HUM Ch 68.2.2 "External VDD Mode" p 4033 */
622 return k_ra8_ok;
623}
624
629
631{
632 if (!s_state.initialized) {
633 return k_ra8_ok;
634 }
635 /* Restore VCCSEL before re-enabling DCDC.
636 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
637 *ra8_vreg_vccsel() = (uint8_t)((uint8_t)s_state.vccsel & k_ra8_vreg_vccsel_mask);
638 /* Restore the cached DCDCCTL value.
639 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
640 *ra8_vreg_dcdcctl() = s_state.dcdcctl;
641 /* Restore low-voltage profile bit.
642 * HUM Ch 68.3 "Usage Notes" p 4034 */
643 *ra8_vreg_lvocr() = s_state.lvocr;
644 return k_ra8_ok;
645}
646
647[[nodiscard]] ra8_err_t ra8_vreg_exit_stop(void)
648{
649 return ra8_vreg_exit_standby();
650}
651
652/* =============================================================================
653 * IRQ hook
654 * =============================================================================
655 */
656
658{
659 s_vreg_fn = fn;
660 s_vreg_ctx = ctx;
661 return k_ra8_ok;
662}
663
665{
667 void* const ctx = s_vreg_ctx;
668 if (fn != nullptr) {
669 /* Forward the live DCDCCTL value so the callback can decide
670 * whether the fault was DCDC-related.
671 * HUM Ch 68.2.1 "DCDC Mode" p 4032 */
672 const uint8_t live = *ra8_vreg_dcdcctl();
673 fn(ctx, live);
674 }
675}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
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.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info(tag, message)
RA8 log info.
Definition ra8_log.h:364
static uint32_t s_state
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.
Definition ra8_vreg.c:157
ra8_err_t ra8_vreg_get_status(ra8_vreg_status_t *out)
Read the regulator status into a caller-supplied snapshot.
Definition ra8_vreg.c:544
ra8_err_t ra8_vreg_set_ldo_boost(bool enable)
Enable / disable the LDO charge-pump boost.
Definition ra8_vreg.c:507
ra8_err_t ra8_vreg_init(const ra8_vreg_cfg_t *cfg)
Initialise the internal voltage regulator from a config descriptor.
Definition ra8_vreg.c:353
static ra8_err_t internal_validate_cfg(const ra8_vreg_cfg_t *cfg)
Validate every field of a ra8_vreg_cfg_t snapshot.
Definition ra8_vreg.c:125
ra8_err_t ra8_vreg_set_mode(ra8_vreg_mode_t mode)
Switch between LDO and DCDC at runtime.
Definition ra8_vreg.c:438
static ra8_vreg_event_fn_t s_vreg_fn
Registered fault callback.
Definition ra8_vreg.c:98
void ra8_vreg_dispatch(void)
Fire the registered fault callback with the current DCDCCTL value.
Definition ra8_vreg.c:664
ra8_err_t ra8_vreg_set_lv_profile(ra8_vreg_lv_profile_t profile)
Select a low-voltage operation profile.
Definition ra8_vreg.c:523
ra8_err_t ra8_vreg_clear_status(uint8_t mask)
Clear the bits in DCDCCTL named by mask.
Definition ra8_vreg.c:577
ra8_err_t ra8_vreg_exit_stop(void)
Legacy alias for ra8_vreg_exit_standby().
Definition ra8_vreg.c:647
ra8_err_t ra8_vreg_enter_standby(ra8_vreg_standby_t variant)
Park the regulator for one of the Software Standby variants.
Definition ra8_vreg.c:610
static void * s_vreg_ctx
Context forwarded to the registered callback.
Definition ra8_vreg.c:101
ra8_err_t ra8_vreg_exit_standby(void)
Restore the regulator after Software Standby exit.
Definition ra8_vreg.c:630
ra8_err_t ra8_vreg_deinit(void)
Tear down the regulator – return DCDCCTL/VCCSEL/LVOCR to reset state.
Definition ra8_vreg.c:408
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.
Definition ra8_vreg.c:239
ra8_err_t ra8_vreg_set_vccsel(ra8_vreg_vccsel_t sel)
Set the DCDC supply-voltage-range select.
Definition ra8_vreg.c:459
ra8_err_t ra8_vreg_enter_stop(void)
Legacy alias for ra8_vreg_enter_standby(k_ra8_vreg_standby_software).
Definition ra8_vreg.c:625
static void internal_dcdc_enable_sequence(bool fast)
Run the FSP-style LDO->DCDC handshake (writes only – caller owns the inter-step delays).
Definition ra8_vreg.c:280
ra8_err_t ra8_vreg_attach_handler(ra8_vreg_event_fn_t fn, void *ctx)
Attach a fault callback (LVD / over-current dispatch hook).
Definition ra8_vreg.c:657
ra8_err_t ra8_vreg_set_ocp(ra8_vreg_ocp_t level)
Program the DCDC over-current-protection level.
Definition ra8_vreg.c:471
ra8_err_t ra8_vreg_reset(void)
Reset the regulator to its OFS-byte default state.
Definition ra8_vreg.c:596
ra8_err_t ra8_vreg_set_fast_startup(bool enable)
Enable / disable the DCDC fast-startup sequence.
Definition ra8_vreg.c:490
static ra8_vreg_lv_profile_t internal_profile_from_lvocr(uint8_t lvocr)
Decode an LVOCR byte back into the profile enum.
Definition ra8_vreg.c:183
static ra8_vreg_ocp_t internal_ocp_from_dcdcctl(uint8_t dcdcctl)
Decode the live DCDCCTL byte into the OCP enum.
Definition ra8_vreg.c:210
static void internal_dcdc_disable_sequence(bool keep_lcboost)
Switch DCDC -> LDO.
Definition ra8_vreg.c:331
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.
Definition ra8_vreg.h:261
ra8_vreg_lv_profile_t
Low-voltage operation profile (LVOCR).
Definition ra8_vreg.h:159
@ k_ra8_vreg_lv_off
Both LVO0E and LVO1E cleared (full-speed).
Definition ra8_vreg.h:160
@ k_ra8_vreg_lv_p1
LVO1E set, LVO0E cleared.
Definition ra8_vreg.h:162
@ k_ra8_vreg_lv_p0
LVO0E set, LVO1E cleared.
Definition ra8_vreg.h:161
ra8_vreg_ocp_t
DCDC over-current protection threshold programming.
Definition ra8_vreg.h:201
@ k_ra8_vreg_ocp_off
OCPEN cleared.
Definition ra8_vreg.h:202
@ k_ra8_vreg_ocp_normal
OCPEN set; default threshold.
Definition ra8_vreg.h:203
@ k_ra8_vreg_ocp_high
OCPEN set; reserved for future use.
Definition ra8_vreg.h:205
ra8_vreg_standby_t
Software Standby variant the caller intends to enter next.
Definition ra8_vreg.h:175
@ k_ra8_vreg_standby_software
Software Standby mode.
Definition ra8_vreg.h:176
@ k_ra8_vreg_standby_battery_backup
Battery Backup wake source.
Definition ra8_vreg.h:180
ra8_vreg_mode_t
Runtime regulator mode selection (DCDCCTL.DCDCON).
Definition ra8_vreg.h:139
@ k_ra8_vreg_mode_dcdc
Switching regulator (DCDC).
Definition ra8_vreg.h:141
@ k_ra8_vreg_mode_ldo
Low-dropout linear regulator (default at reset).
Definition ra8_vreg.h:140
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.
Definition ra8_vreg.h:216
ra8_vreg_mode_t mode
Initial regulator mode.
Definition ra8_vreg.h:217
bool ldo_boost
Enable LDO charge-pump boost (DCDCCTL.LCBOOST).
Definition ra8_vreg.h:221
ra8_vreg_ocp_t ocp
OCP threshold (DCDC mode only).
Definition ra8_vreg.h:219
ra8_vreg_vccsel_t vccsel
Supply-voltage range (used only in DCDC mode).
Definition ra8_vreg.h:218
ra8_vreg_lv_profile_t lv_profile
Low-voltage operation profile (LVOCR).
Definition ra8_vreg.h:222
bool fast_startup
Use fast-startup sequence (DCDCCTL.FST).
Definition ra8_vreg.h:220
Cached "desired" state used by the enter/exit-standby pair.
Definition ra8_vreg.c:82
uint8_t dcdcctl
Last value written to DCDCCTL.
Definition ra8_vreg.c:83
uint8_t lvocr
Last value written to LVOCR.
Definition ra8_vreg.c:85
ra8_vreg_vccsel_t vccsel
Last value written to VCCSEL.
Definition ra8_vreg.c:84
ra8_vreg_lv_profile_t lv_profile
Cached LV profile.
Definition ra8_vreg.c:87
bool ldo_boost
Cached LCBOOST bit.
Definition ra8_vreg.c:91
bool initialized
True once ra8_vreg_init ran.
Definition ra8_vreg.c:89
ra8_vreg_standby_t last_standby
Last standby variant requested.
Definition ra8_vreg.c:88
ra8_vreg_ocp_t ocp
Cached OCP level (no HW readback).
Definition ra8_vreg.c:86
bool fast_startup
Cached FST bit.
Definition ra8_vreg.c:90
Snapshot of the regulator state.
Definition ra8_vreg.h:234
ra8_vreg_mode_t mode
Decoded mode (LDO / DCDC).
Definition ra8_vreg.h:238
bool dcdc_ready
True when DCDCON=1 and PD=0.
Definition ra8_vreg.h:242
bool ldo_boost
True when DCDCCTL.LCBOOST is set.
Definition ra8_vreg.h:244
ra8_vreg_lv_profile_t lv_profile
Decoded LVOCR profile.
Definition ra8_vreg.h:240
ra8_vreg_vccsel_t vccsel_dec
Decoded VCCSEL.
Definition ra8_vreg.h:239
uint8_t lvocr
Raw LVOCR value.
Definition ra8_vreg.h:237
ra8_vreg_ocp_t ocp
Decoded OCP setting.
Definition ra8_vreg.h:241
bool fast_startup
True when DCDCCTL.FST is set.
Definition ra8_vreg.h:243
uint8_t dcdcctl
Raw DCDCCTL value.
Definition ra8_vreg.h:235
bool io_buf_on
True when DCDCCTL.STOPZA is set.
Definition ra8_vreg.h:245
uint8_t vccsel
Raw VCCSEL value.
Definition ra8_vreg.h:236