|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Low Power Mode (LPM) HAL driver – public API. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_lpm_config_t |
| Configuration descriptor for ra8_lpm_init. More... | |
| struct | ra8_lpm_ldo_cfg_t |
| LDO standby retention selection (HUM 11.2.1 p 436). More... | |
| struct | ra8_lpm_ram_retention_t |
| RAM retention configuration (HUM 11.2.16 / 11.2.17). More... | |
Enumerations | |
| enum | ra8_lpm_pd_timeout_t : uint32_t { k_ra8_lpm_pd_timeout_default = 100000U } |
| Poll bound for ra8_lpm_graphics_power_on flag waits. More... | |
| enum | ra8_lpm_clock_t : uint8_t { k_ra8_lpm_clock_moco = 0U , k_ra8_lpm_clock_hoco = 1U , k_ra8_lpm_clock_loco = 2U , k_ra8_lpm_clock_main = 3U , k_ra8_lpm_clock_sub = 4U , k_ra8_lpm_clock_count = 5U } |
| Selector for ra8_lpm_set_clock_stop / ra8_lpm_get_clock_stop. More... | |
Functions | |
| ra8_err_t | ra8_lpm_init (const ra8_lpm_config_t *cfg) |
| Initialise the LPM block from a config descriptor. | |
| ra8_err_t | ra8_lpm_deinit (void) |
| Restore SBYCR / DPSBYCR / LPSCR / SSCR1 to cold-reset defaults. | |
| ra8_err_t | ra8_lpm_prcr_unlock (void) |
| Unlock PRCR.PRC1 to permit writes to LPM control registers. | |
| ra8_err_t | ra8_lpm_prcr_relock (void) |
| Re-lock PRCR.PRC1 after protected writes. | |
| ra8_err_t | ra8_lpm_set_wakeup_sources (uint32_t wupen0, uint32_t wupen1) |
| Programme the raw WUPEN0 / WUPEN1 masks. | |
| ra8_err_t | ra8_lpm_arm_wupen0_bits (uint32_t bits) |
| OR-in additional WUPEN0 bits without disturbing other sources. | |
| ra8_err_t | ra8_lpm_clear_wupen0_bits (uint32_t bits) |
| AND-out WUPEN0 bits to disarm specific wake-up sources. | |
| ra8_err_t | ra8_lpm_arm_wupen1_bits (uint32_t bits) |
| OR-in additional WUPEN1 bits without disturbing other sources. | |
| ra8_err_t | ra8_lpm_clear_wupen1_bits (uint32_t bits) |
| AND-out WUPEN1 bits to disarm specific wake-up sources. | |
| ra8_err_t | ra8_lpm_arm_dpsier (ra8_lpm_dpsier_idx_t idx, uint8_t value) |
| Programme the per-byte DPSIER0..3 enable byte directly. | |
| ra8_err_t | ra8_lpm_clear_dpsifr (ra8_lpm_dpsier_idx_t idx) |
| Clear DPSIFR0..3 so a stale flag does not cancel deep standby. | |
| ra8_err_t | ra8_lpm_set_dpsiegr (ra8_lpm_dpsier_idx_t idx, uint8_t value) |
| Programme DPSIEGR0..2 (deep-standby IRQ edge polarity). | |
| ra8_err_t | ra8_lpm_snooze_set_request_sources (bool ulpt0_underflow, bool ulpt1_underflow, bool acmphs0) |
| Configure ULPT-driven snooze request sources. | |
| ra8_err_t | ra8_lpm_snooze_set_end_sources (bool ulpt0, bool ulpt1, bool usbfs, bool usbhs) |
| Configure end-of-snooze sources via DPSIER3 (ULPT/USB hooks). | |
| ra8_err_t | ra8_lpm_set_ram_retention (const ra8_lpm_ram_retention_t *cfg) |
| Programme PDRAMSCR0 / PDRAMSCR1 from a retention descriptor. | |
| ra8_err_t | ra8_lpm_set_ldo_standby (const ra8_lpm_ldo_cfg_t *cfg) |
| Programme PLL1LDOCR / PLL2LDOCR / HOCOLDOCR SKEEP bits. | |
| ra8_err_t | ra8_lpm_set_clock_stop (ra8_lpm_clock_t clock, bool stop) |
| Set or clear the per-oscillator stop bit before sleep entry. | |
| ra8_err_t | ra8_lpm_graphics_power_on (uint32_t timeout_iters) |
| Power the graphics domain on (DRW / GLCDC / MIPI DSI+CSI / VIN). | |
| ra8_err_t | ra8_lpm_get_clock_stop (ra8_lpm_clock_t clock, bool *stop) |
| Read the per-oscillator stop bit. | |
| ra8_err_t | ra8_lpm_get_opccr (uint8_t *opccr) |
| Read OPCCR raw byte (OPCM[1:0] + OPCMTSF). | |
| ra8_err_t | ra8_lpm_wait_for_opccr (uint32_t poll_limit) |
| Wait for OPCCR.OPCMTSF to clear (mode-transition complete). | |
| ra8_err_t | ra8_lpm_enter_sleep (ra8_sleep_mode_t mode) |
| Programme LPSCR for mode and enter the requested sleep. | |
| ra8_err_t | ra8_lpm_enter_deep_standby (void) |
| Convenience wrapper – enter Deep Software Standby mode 1. | |
| ra8_err_t | ra8_lpm_get_status (uint32_t *out) |
| Read LPM status (SBYCR | DPSBYCR | LPSCR | SSCR1) packed. | |
| ra8_err_t | ra8_lpm_get_exit_cause (uint64_t *out) |
| Snapshot WUPEN0 / WUPEN1 into a single 64-bit word. | |
| ra8_err_t | ra8_lpm_get_dpsi_state (uint8_t enables[4], uint8_t flags[4], uint8_t edges[3]) |
| Read DPSIER0..3 + DPSIFR0..3 + DPSIEGR0..2 into a buffer. | |
Low Power Mode (LPM) HAL driver – public API.
Hand-written HAL covering the entire LPM block defined in HUM Ch 11 (pages 429..497) plus the wake-up-source registers in ICU Ch 14.2.19 / 14.2.20. The driver exposes:
Definition in file ra8_lpm.h.
| enum ra8_lpm_clock_t : uint8_t |
Selector for ra8_lpm_set_clock_stop / ra8_lpm_get_clock_stop.
| enum ra8_lpm_pd_timeout_t : uint32_t |
Poll bound for ra8_lpm_graphics_power_on flag waits.
Power-gating a domain completes in microseconds (HUM Ch 11.5.1 p 480), so this bound is generous by orders of magnitude at any core clock; it exists to satisfy NASA Rule 2 rather than to encode a real deadline.
| Enumerator | |
|---|---|
| k_ra8_lpm_pd_timeout_default | Default power-gate poll bound. |
|
nodiscard |
Programme the per-byte DPSIER0..3 enable byte directly.
| [in] | idx | DPSIER selector (k_ra8_lpm_dpsier_idx_*). |
| [in] | value | 8-bit enable mask to write. |
| k_ra8_ok | Register updated. |
| k_ra8_err_invalid_arg | idx out of range. |
Definition at line 502 of file ra8_lpm.c.
References internal_dpsier_offset(), internal_dpsifr_offset(), k_ra8_err_invalid_arg, k_ra8_lpm_dpsier_idx_count, k_ra8_ok, ra8_log_error, ra8_lpm_sysc_reg8(), and s_tag.
Referenced by internal_lpm_dpsby1_arm_wake(), internal_lpm_dpsby2_arm_wake(), and internal_lpm_dpsby3_arm_wake().
|
nodiscard |
OR-in additional WUPEN0 bits without disturbing other sources.
| [in] | bits | k_ra8_lpm_wupen0_* mask to set. |
| k_ra8_ok | WUPEN0 updated. |
Definition at line 465 of file ra8_lpm.c.
References k_ra8_lpm_wupen0_off, k_ra8_ok, and ra8_lpm_icu_reg32().
Referenced by internal_lpm_dpsby1_arm_wake(), internal_lpm_dpsby2_arm_wake(), internal_lpm_dpsby3_arm_wake(), internal_lpm_swstd_arm_wake(), and internal_lpm_wake_arm0().
|
nodiscard |
OR-in additional WUPEN1 bits without disturbing other sources.
| [in] | bits | k_ra8_lpm_wupen1_* mask to set. |
| k_ra8_ok | WUPEN1 updated. |
Definition at line 481 of file ra8_lpm.c.
References k_ra8_lpm_wupen1_off, k_ra8_ok, and ra8_lpm_icu_reg32().
Referenced by internal_lpm_wake_arm1(), internal_lus_arm_wake(), and lpi_arm_wake().
|
nodiscard |
Clear DPSIFR0..3 so a stale flag does not cancel deep standby.
| [in] | idx | DPSIER selector (k_ra8_lpm_dpsier_idx_*). |
| k_ra8_ok | Flag cleared. |
| k_ra8_err_invalid_arg | idx out of range. |
Definition at line 522 of file ra8_lpm.c.
References internal_dpsifr_offset(), k_ra8_err_invalid_arg, k_ra8_lpm_dpsier_idx_count, k_ra8_ok, ra8_log_error, ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
AND-out WUPEN0 bits to disarm specific wake-up sources.
| [in] | bits | k_ra8_lpm_wupen0_* mask to clear. |
| k_ra8_ok | WUPEN0 updated. |
Definition at line 473 of file ra8_lpm.c.
References k_ra8_lpm_wupen0_off, k_ra8_ok, and ra8_lpm_icu_reg32().
Referenced by internal_lpm_wake_disarm_all().
|
nodiscard |
AND-out WUPEN1 bits to disarm specific wake-up sources.
| [in] | bits | k_ra8_lpm_wupen1_* mask to clear. |
| k_ra8_ok | WUPEN1 updated. |
Definition at line 489 of file ra8_lpm.c.
References k_ra8_lpm_wupen1_off, k_ra8_ok, and ra8_lpm_icu_reg32().
Referenced by internal_lpm_wake_disarm_all().
|
nodiscard |
Restore SBYCR / DPSBYCR / LPSCR / SSCR1 to cold-reset defaults.
Rewrites SBYCR with its reset value (OPE=1, all other bits 0), DPSBYCR with its reset value (DCSSMODE=01b), LPSCR with its reset value (System Active), SSCR1=0, all WUPEN bits=0, all DPSIER bits=0. Used during clean teardown so a stray IRQ does not bring us out of a subsequent sleep with stale wake-up arming.
| k_ra8_ok | Registers reset. |
Definition at line 394 of file ra8_lpm.c.
References k_ra8_lpm_dpsbycr_off, k_ra8_lpm_dpsbycr_reset_val, k_ra8_lpm_dpsier0_off, k_ra8_lpm_dpsier1_off, k_ra8_lpm_dpsier2_off, k_ra8_lpm_dpsier3_off, k_ra8_lpm_lpscr_off, k_ra8_lpm_sbycr_off, k_ra8_lpm_sbycr_reset_val, k_ra8_lpm_sscr1_off, k_ra8_lpm_wupen0_off, k_ra8_lpm_wupen1_off, k_ra8_ok, ra8_log_info, ra8_lpm_icu_reg32(), ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Convenience wrapper – enter Deep Software Standby mode 1.
| k_ra8_ok | WFI returned (cold path: never returns on hardware). |
Definition at line 786 of file ra8_lpm.c.
References k_ra8_sleep_mode_deep_standby_1, and ra8_lpm_enter_sleep().
|
nodiscard |
Programme LPSCR for mode and enter the requested sleep.
Maps mode to the LPSCR.LPMD encoding from HUM 11.2.20 p 457, writes the new LPSCR value, configures SCR.SLEEPDEEP for non-Sleep modes, then executes WFI. For k_ra8_sleep_mode_sleep the LPMD field is left at 0 (System Active) and a plain WFI puts only the CPU to sleep – peripherals stay clocked.
| [in] | mode | Target sleep mode (sleep / deep-sleep / software-standby / deep-standby 1..3). |
| k_ra8_ok | Mode programmed and WFI returned. |
| k_ra8_err_invalid_arg | mode was not a valid encoding. |
Definition at line 735 of file ra8_lpm.c.
References internal_set_sleepdeep(), internal_validate_mode(), internal_wait_for_interrupt(), k_ra8_lpm_lpscr_lpmd_mask, k_ra8_lpm_lpscr_off, k_ra8_ok, k_ra8_sleep_mode_deep_sleep, k_ra8_sleep_mode_deep_standby_1, k_ra8_sleep_mode_deep_standby_2, k_ra8_sleep_mode_deep_standby_3, k_ra8_sleep_mode_sleep, k_ra8_sleep_mode_software_std, ra8_log_info_val, ra8_lpm_sysc_reg8(), RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_lpm_demo_one_wake(), lpi_idle_one_period(), main(), pp_demo_cycle_modes(), and ra8_lpm_enter_deep_standby().
|
nodiscard |
Read the per-oscillator stop bit.
| [in] | clock | Oscillator selector (k_ra8_lpm_clock_*). |
| [out] | stop | Receives the current stop bit (1 = stopped). |
| k_ra8_ok | *stop populated. |
| k_ra8_err_invalid_arg | clock out of range. |
| k_ra8_err_null_ptr | stop was nullptr. |
Definition at line 688 of file ra8_lpm.c.
References internal_clock_offset(), k_ra8_err_invalid_arg, k_ra8_lpm_clock_count, k_ra8_lpm_clock_stop_mask, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Read DPSIER0..3 + DPSIFR0..3 + DPSIEGR0..2 into a buffer.
| [out] | enables | Receives DPSIER0..3 (must be 4 bytes). |
| [out] | flags | Receives DPSIFR0..3 (must be 4 bytes). |
| [out] | edges | Receives DPSIEGR0..2 (must be 3 bytes). |
| k_ra8_ok | All buffers populated. |
| k_ra8_err_null_ptr | Any of enables / flags / edges was nullptr. |
Definition at line 828 of file ra8_lpm.c.
References k_ra8_lpm_dpsiegr0_off, k_ra8_lpm_dpsiegr1_off, k_ra8_lpm_dpsiegr2_off, k_ra8_lpm_dpsier0_off, k_ra8_lpm_dpsier1_off, k_ra8_lpm_dpsier2_off, k_ra8_lpm_dpsier3_off, k_ra8_lpm_dpsifr0_off, k_ra8_lpm_dpsifr1_off, k_ra8_lpm_dpsifr2_off, k_ra8_lpm_dpsifr3_off, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Snapshot WUPEN0 / WUPEN1 into a single 64-bit word.
Returns (WUPEN1 << 32) | WUPEN0 – which sources were armed at the moment of the call. Combined with the post-wake NVIC pending mask the application can decide what woke it.
| [out] | out | Receives the packed wake-up enable snapshot. |
| k_ra8_ok | *out populated. |
| k_ra8_err_null_ptr | out was nullptr. |
Definition at line 814 of file ra8_lpm.c.
References k_ra8_lpm_cause_shift_wupen0, k_ra8_lpm_cause_shift_wupen1, k_ra8_lpm_wupen0_off, k_ra8_lpm_wupen1_off, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_lpm_icu_reg32(), and s_tag.
Referenced by internal_lpm_wake_arm0(), internal_lpm_wake_arm1(), and internal_lpm_wake_disarm_all().
|
nodiscard |
Read OPCCR raw byte (OPCM[1:0] + OPCMTSF).
| [out] | opccr | Receives the live OPCCR byte. |
| k_ra8_ok | *opccr populated. |
| k_ra8_err_null_ptr | opccr was nullptr. |
Definition at line 706 of file ra8_lpm.c.
References k_ra8_lpm_opccr_off, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Read LPM status (SBYCR | DPSBYCR | LPSCR | SSCR1) packed.
Packs four single-byte registers into a uint32:
| Byte | Source |
|---|---|
| [0] | SBYCR |
| [1] | DPSBYCR |
| [2] | LPSCR |
| [3] | SSCR1 |
Useful for telemetry: "what mode are we in, did IOKEEP latch, is fast-return enabled?".
| [out] | out | Receives the packed status word. |
| k_ra8_ok | *out populated. |
| k_ra8_err_null_ptr | out was nullptr. |
Definition at line 796 of file ra8_lpm.c.
References k_ra8_lpm_dpsbycr_off, k_ra8_lpm_lpscr_off, k_ra8_lpm_sbycr_off, k_ra8_lpm_sscr1_off, k_ra8_lpm_status_shift_dpsbycr, k_ra8_lpm_status_shift_lpscr, k_ra8_lpm_status_shift_sbycr, k_ra8_lpm_status_shift_sscr1, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Power the graphics domain on (DRW / GLCDC / MIPI DSI+CSI / VIN).
Clears PDCTRGD.PDDE so the graphics power domain leaves its gated reset state, then waits for the controller to report the transition complete. HUM Ch 11.5.1 Table 11.7 p 480 lists the domain contents: MIPI DSI, MIPI CSI, VIN, DRW and GLCDC. HUM Ch 11.2.14 p 452 gives the register a reset value of 0x81 – PDPGSF = 1 (gated off) and PDDE = 1 (power off) – so every one of those peripherals is unpowered out of reset and cancelling module-stop alone is not enough to make one respond.
This was the whole of issue #247: the D/AVE 2D engine had never rasterised a pixel on real silicon because nothing ever powered its domain. Bench evidence on an EK-RA8D2 – with PDCTRGD at its 0x81 reset value the DRW HWREVISION register reads 0x00000000; after this call it reads 0x0FBE0107.
Sequence (HUM Ch 11.2.14 p 452 + Ch 11.5.1 p 480):
Idempotent: if the domain is already powered (PDPGSF = 0) the function returns k_ra8_ok without touching the register, so several graphics drivers may each call it during their own init.
| [in] | timeout_iters | Poll-loop bound for each flag wait; must be non-zero. Bounds the loop for NASA Rule 2. |
| k_ra8_ok | Domain powered and gating complete. |
| k_ra8_err_invalid_arg | timeout_iters was 0. |
| k_ra8_err_hw_timeout | A status flag never reached its target state within timeout_iters. |
Definition at line 171 of file ra8_lpm_graphics.c.
References internal_graphics_clear_pdde(), internal_graphics_confirm_powered(), internal_graphics_confirm_ready(), internal_graphics_enable_moco(), k_ra8_err_invalid_arg, k_ra8_lpm_pdctr_pdpgsf_mask, k_ra8_lpm_pdctrgd_off, k_ra8_ok, ra8_log_error, ra8_log_info, ra8_lpm_sysc_reg8(), RA8_RETURN_ON_ERROR, and s_tag.
Referenced by ra8_drw_init().
|
nodiscard |
Initialise the LPM block from a config descriptor.
Writes SBYCR.OPE, DPSBYCR (IOKEEP + DCSSMODE), and SSCR1 (SS2FR + SS2LP) from cfg. Clears LPSCR.LPMD to System Active so the next plain WFI does an ordinary CPU sleep until the application explicitly arms a deeper mode via ra8_lpm_enter_sleep.
| [in] | cfg | Non-NULL configuration descriptor. |
| k_ra8_ok | All four registers programmed. |
| k_ra8_err_null_ptr | cfg was nullptr. |
Definition at line 358 of file ra8_lpm.c.
References ra8_lpm_config_t::dcdc_softstart, ra8_lpm_config_t::io_port_keep, k_ra8_lpm_dpsbycr_dcssmode_shift, k_ra8_lpm_dpsbycr_iokeep_mask, k_ra8_lpm_dpsbycr_off, k_ra8_lpm_lpscr_off, k_ra8_lpm_sbycr_off, k_ra8_lpm_sbycr_ope_mask, k_ra8_lpm_sscr1_off, k_ra8_lpm_sscr1_ss2fr_mask, k_ra8_lpm_sscr1_ss2lp_shift, k_ra8_ok, ra8_lpm_config_t::opa_bus_keep, RA8_CHECK_NULL_PTR, ra8_log_info, ra8_lpm_sysc_reg8(), s_tag, ra8_lpm_config_t::sscr_fast_return, and ra8_lpm_config_t::sscr_low_power.
Referenced by internal_lpm_deep_setup_or_halt(), internal_lpm_demo_setup_or_halt(), internal_lpm_dpsby1_setup_or_halt(), internal_lpm_dpsby2_setup_or_halt(), internal_lpm_dpsby3_setup_or_halt(), internal_lpm_swstd_setup_or_halt(), internal_lpm_wake_setup_or_halt(), internal_lus_setup_or_halt(), lpi_setup_or_halt(), m85_lpm_configure(), and pp_demo_modules_or_halt().
|
nodiscard |
Re-lock PRCR.PRC1 after protected writes.
| k_ra8_ok | PRC1 locked. |
Definition at line 441 of file ra8_lpm.c.
References k_lpm_byte_mask, k_ra8_lpm_prcr_key, k_ra8_lpm_prcr_off, k_ra8_lpm_prcr_prc1_msk, k_ra8_ok, and ra8_lpm_sysc_reg16().
Referenced by m85_gate_hoco(), and m85_lpm_configure().
|
nodiscard |
Unlock PRCR.PRC1 to permit writes to LPM control registers.
Writes 0xA502 to SYSTEM.PRCR (key 0xA5 + PRC1=1). The companion ra8_lpm_prcr_relock writes 0xA500 to lock the region again. Pairs with the standby/wake critical section.
| k_ra8_ok | PRC1 unlocked. |
Definition at line 430 of file ra8_lpm.c.
References k_lpm_byte_mask, k_ra8_lpm_prcr_key, k_ra8_lpm_prcr_off, k_ra8_lpm_prcr_prc1_msk, k_ra8_ok, and ra8_lpm_sysc_reg16().
Referenced by m85_gate_hoco(), and m85_lpm_configure().
|
nodiscard |
Set or clear the per-oscillator stop bit before sleep entry.
Toggles the STOP bit (bit 0) of the oscillator control register selected by clock – MOSCCR, HOCOCR, MOCOCR, LOCOCR or SOSCCR. Those registers belong to the clock-generation circuit and are PRC0-protected (HUM Ch 13.1 Table 13.1); a write issued while PRC0 is locked is discarded silently by the hardware. The read-modify-write is therefore performed inside a self-contained PRCR CGC unlock window: the caller does not unlock PRCR beforehand, and PRCR is returned to its fully-locked state before return.
| [in] | clock | Oscillator selector (k_ra8_lpm_clock_*). |
| [in] | stop | true – request stop; false – request run. |
| k_ra8_ok | Stop bit toggled. |
| k_ra8_err_invalid_arg | clock out of range. |
Definition at line 661 of file ra8_lpm.c.
References internal_clock_offset(), k_ra8_err_invalid_arg, k_ra8_lpm_clock_count, k_ra8_lpm_clock_stop_mask, k_ra8_ok, k_ra8_prcr_unlock_cgc, ra8_log_error, ra8_lpm_sysc_reg8(), RA8_PROTECTED_WRITE, and s_tag.
Referenced by internal_lus_setup_or_halt(), lpi_setup_or_halt(), and m85_gate_hoco().
|
nodiscard |
Programme DPSIEGR0..2 (deep-standby IRQ edge polarity).
| [in] | idx | DPSIEGR selector (0..2 only – DPSIEGR3 not used). |
| [in] | value | 8-bit edge mask: bit=1 selects rising edge. |
| k_ra8_ok | Register updated. |
| k_ra8_err_invalid_arg | idx out of range. |
Definition at line 535 of file ra8_lpm.c.
References internal_dpsiegr_offset(), k_ra8_err_invalid_arg, k_ra8_lpm_dpsier_idx_count, k_ra8_ok, ra8_log_error, ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Programme PLL1LDOCR / PLL2LDOCR / HOCOLDOCR SKEEP bits.
| [in] | cfg | Non-NULL LDO retention configuration. |
| k_ra8_ok | All three LDOCR bytes updated. |
| k_ra8_err_null_ptr | cfg was nullptr. |
| k_ra8_err_invalid_state | OPCCR.OPCM != 0 (writes prohibited). |
Definition at line 626 of file ra8_lpm.c.
References ra8_lpm_ldo_cfg_t::hoco, k_ra8_err_invalid_state, k_ra8_lpm_hocoldocr_off, k_ra8_lpm_ldocr_skeep_mask, k_ra8_lpm_ldocr_skeep_shift, k_ra8_lpm_opccr_off, k_ra8_lpm_opccr_opcm_mask, k_ra8_lpm_pll1ldocr_off, k_ra8_lpm_pll2ldocr_off, k_ra8_ok, ra8_lpm_ldo_cfg_t::pll1, ra8_lpm_ldo_cfg_t::pll2, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Programme PDRAMSCR0 / PDRAMSCR1 from a retention descriptor.
| [in] | cfg | Non-NULL retention configuration. |
| k_ra8_ok | Both registers programmed. |
| k_ra8_err_null_ptr | cfg was nullptr. |
Definition at line 606 of file ra8_lpm.c.
References ra8_lpm_ram_retention_t::cpu0_tcm_keep, ra8_lpm_ram_retention_t::cpu1_tcm_keep, k_ra8_lpm_pdramscr0_off, k_ra8_lpm_pdramscr0_writable, k_ra8_lpm_pdramscr1_off, k_ra8_lpm_pdramscr1_rkeep0_mask, k_ra8_lpm_pdramscr1_rkeep1_mask, k_ra8_ok, ra8_lpm_ram_retention_t::pdramscr0_bits, RA8_CHECK_NULL_PTR, ra8_lpm_sysc_reg16(), ra8_lpm_sysc_reg8(), and s_tag.
|
nodiscard |
Programme the raw WUPEN0 / WUPEN1 masks.
Writes wupen0 to ICU.WUPEN0 and wupen1 to ICU.WUPEN1 verbatim. Use the k_ra8_lpm_wupen0_* / k_ra8_lpm_wupen1_* helper enums to assemble bit patterns.
| [in] | wupen0 | Mask for WUPEN0 (IRQ0..15 + IWDT/PVD/RTC/USB...). |
| [in] | wupen1 | Mask for WUPEN1 (ULPT/I3C/SOSC/CMP). |
| k_ra8_ok | Masks written. |
Definition at line 456 of file ra8_lpm.c.
References k_ra8_lpm_wupen0_off, k_ra8_lpm_wupen1_off, k_ra8_ok, and ra8_lpm_icu_reg32().
|
nodiscard |
Configure end-of-snooze sources via DPSIER3 (ULPT/USB hooks).
Mirrors the FSP "snooze end" concept by writing the relevant DPSIER3 bits (DULPT0IE / DULPT1IE / DUSBFSIE / DUSBHSIE) so a subsequent deep-standby entry can be cancelled by the same peripheral that woke it from snooze.
| [in] | ulpt0 | Set DPSIER3.DULPT0IE. |
| [in] | ulpt1 | Set DPSIER3.DULPT1IE. |
| [in] | usbfs | Set DPSIER3.DUSBFSIE. |
| [in] | usbhs | Set DPSIER3.DUSBHSIE. |
| k_ra8_ok | DPSIER3 updated. |
Definition at line 575 of file ra8_lpm.c.
References k_ra8_lpm_dpsier3_dulpt0ie_mask, k_ra8_lpm_dpsier3_dulpt1ie_mask, k_ra8_lpm_dpsier3_dusbfsie_mask, k_ra8_lpm_dpsier3_dusbhsie_mask, k_ra8_lpm_dpsier3_off, k_ra8_lpm_dpsifr3_off, k_ra8_ok, and ra8_lpm_sysc_reg8().
|
nodiscard |
Configure ULPT-driven snooze request sources.
RA8D2 does not implement the dedicated SNZCR/SNZEDCR/SNZREQCR register block found on older RA Gen-1 parts. Instead, the chip supports a "Software Standby + ULPT wake" pattern where ULPT0 (or ULPT1) periodically wakes the MCU from Software Standby to sample an ADC channel or service an I2C transaction. This helper writes the ULPT-related bits in WUPEN1 to enable that pattern.
| [in] | ulpt0_underflow | Set to enable ULPT0 underflow wake. |
| [in] | ulpt1_underflow | Set to enable ULPT1 underflow wake. |
| [in] | acmphs0 | Set to enable ACMPHS0 comparator wake. |
| k_ra8_ok | WUPEN1 updated. |
Definition at line 553 of file ra8_lpm.c.
References k_ra8_lpm_wupen0_acmphs0, k_ra8_lpm_wupen0_off, k_ra8_lpm_wupen1_off, k_ra8_lpm_wupen1_ulpt0u, k_ra8_lpm_wupen1_ulpt1u, k_ra8_ok, and ra8_lpm_icu_reg32().
|
nodiscard |
Wait for OPCCR.OPCMTSF to clear (mode-transition complete).
| [in] | poll_limit | Maximum number of polling iterations. |
| k_ra8_ok | OPCMTSF cleared within budget. |
| k_ra8_err_hw_timeout | poll_limit exhausted with OPCMTSF=1. |
Definition at line 714 of file ra8_lpm.c.
References k_ra8_err_hw_timeout, k_ra8_err_invalid_arg, k_ra8_lpm_opccr_off, k_ra8_lpm_opccr_opcmtsf_msk, k_ra8_ok, ra8_log_error, ra8_lpm_sysc_reg8(), and s_tag.