ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_vreg.h
Go to the documentation of this file.
1
123
124#pragma once
125
126#ifdef __cplusplus
127extern "C" {
128#endif
129
130#include <stdint.h>
131
132#include "ra8_err.h"
133#include "ra8_vreg_regs.h"
134
139typedef enum : uint8_t {
143
164
182
207
224
247
261typedef void (*ra8_vreg_event_fn_t)(void* ctx, uint8_t status_word);
262
263/* =============================================================================
264 * Lifecycle
265 * =============================================================================
266 */
267
314[[nodiscard]] ra8_err_t ra8_vreg_init(const ra8_vreg_cfg_t* cfg);
315
336[[nodiscard]] ra8_err_t ra8_vreg_deinit(void);
337
338/* =============================================================================
339 * Runtime control
340 * =============================================================================
341 */
342
372
396
421[[nodiscard]] ra8_err_t ra8_vreg_set_ocp(ra8_vreg_ocp_t level);
422
445[[nodiscard]] ra8_err_t ra8_vreg_set_fast_startup(bool enable);
446
469[[nodiscard]] ra8_err_t ra8_vreg_set_ldo_boost(bool enable);
470
491
492/* =============================================================================
493 * Status
494 * =============================================================================
495 */
496
516
539[[nodiscard]] ra8_err_t ra8_vreg_clear_status(uint8_t mask);
540
560[[nodiscard]] ra8_err_t ra8_vreg_reset(void);
561
562/* =============================================================================
563 * Power transition
564 * =============================================================================
565 */
566
595
608[[nodiscard]] ra8_err_t ra8_vreg_enter_stop(void);
609
627[[nodiscard]] ra8_err_t ra8_vreg_exit_standby(void);
628
634[[nodiscard]] ra8_err_t ra8_vreg_exit_stop(void);
635
636/* =============================================================================
637 * IRQ hook
638 * =============================================================================
639 */
640
662[[nodiscard]] ra8_err_t ra8_vreg_attach_handler(ra8_vreg_event_fn_t fn, void* ctx);
663
682void ra8_vreg_dispatch(void);
683
684#ifdef __cplusplus
685}
686#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
void(* ra8_vreg_event_fn_t)(void *ctx, uint8_t status_word)
Voltage-regulator fault callback.
Definition ra8_vreg.h:261
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
ra8_err_t ra8_vreg_set_mode(ra8_vreg_mode_t mode)
Switch between LDO and DCDC at runtime.
Definition ra8_vreg.c:438
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_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_low
OCPEN set; reserved for future use.
Definition ra8_vreg.h:204
@ 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_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
ra8_vreg_standby_t
Software Standby variant the caller intends to enter next.
Definition ra8_vreg.h:175
@ k_ra8_vreg_standby_deep_software1
Deep Software Standby mode 1.
Definition ra8_vreg.h:177
@ 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
@ k_ra8_vreg_standby_deep_software3
Deep Software Standby mode 3.
Definition ra8_vreg.h:179
@ k_ra8_vreg_standby_deep_software2
Deep Software Standby mode 2.
Definition ra8_vreg.h:178
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
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
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
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.
ra8_vreg_vccsel_t
VCCSEL[1:0] supply-voltage range selection (DCDC mode only).
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
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