Driver for the BPM (Backup Power Manager).
This driver provides access to the main features of the BPM controller. It provides functions for different power mode management.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the BPM - Backup Power Manager. | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the BPM - Backup Power Manager. | |
Macros | |
#define | BPM_UNLOCK(reg) |
BPM unlock macro. More... | |
Sleep mode definitions | |
#define | BPM_SM_ACTIVE 0 |
Active mode. More... | |
#define | BPM_SM_SLEEP_0 1 |
Sleep mode 0. More... | |
#define | BPM_SM_SLEEP_1 2 |
Sleep mode 1. More... | |
#define | BPM_SM_SLEEP_2 3 |
Sleep mode 2. More... | |
#define | BPM_SM_SLEEP_3 4 |
Sleep mode 3. More... | |
#define | BPM_SM_WAIT 5 |
Wait mode. More... | |
#define | BPM_SM_RET 6 |
Retention mode. More... | |
#define | BPM_SM_BACKUP 7 |
Backup mode. More... | |
Power scaling change mode | |
#define | BPM_PSCM_CPU_HALT 0 |
Power scaling change mode: halting the CPU execution. More... | |
#define | BPM_PSCM_CPU_NOT_HALT 1 |
Power scaling change mode: CPU execution not halted. More... | |
Power scaling mode value | |
#define | BPM_PS_0 0 |
Power scaling mode 0. More... | |
#define | BPM_PS_1 1 |
Power scaling mode 1. More... | |
#define | BPM_PS_2 2 |
Power scaling mode 2. More... | |
CLK32 32Khz-1Khz clock source selection | |
#define | BPM_CLK32_SOURCE_OSC32K 0 |
OSC32K : Low frequency crystal oscillator. More... | |
#define | BPM_CLK32_SOURCE_RC32K 1 |
RC32K : Internal Low frequency RC oscillator. More... | |
Backup wake up sources | |
#define | BPM_BKUP_WAKEUP_SRC_EIC (1UL << BPM_BKUPWEN_EIC) |
EIC wake up. More... | |
#define | BPM_BKUP_WAKEUP_SRC_AST (1UL << BPM_BKUPWEN_AST) |
AST wake up. More... | |
#define | BPM_BKUP_WAKEUP_SRC_WDT (1UL << BPM_BKUPWEN_WDT) |
WDT wake up. More... | |
#define | BPM_BKUP_WAKEUP_SRC_BOD33 (1UL << BPM_BKUPWEN_BOD33) |
BOD33 wake up. More... | |
#define | BPM_BKUP_WAKEUP_SRC_BOD18 (1UL << BPM_BKUPWEN_BOD18) |
BOD18 wake up. More... | |
#define | BPM_BKUP_WAKEUP_SRC_PICOUART (1UL << BPM_BKUPWEN_PICOUART) |
PICOUART wake up. More... | |
Backup pin muxing | |
#define | BPM_BKUP_PIN_PB01_EIC0 BPM_BKUPPMUX_BKUPPMUX(0) |
#define | BPM_BKUP_PIN_PA06_EIC1 BPM_BKUPPMUX_BKUPPMUX(1) |
#define | BPM_BKUP_PIN_PA04_EIC2 BPM_BKUPPMUX_BKUPPMUX(2) |
#define | BPM_BKUP_PIN_PA05_EIC3 BPM_BKUPPMUX_BKUPPMUX(3) |
#define | BPM_BKUP_PIN_PA07_EIC4 BPM_BKUPPMUX_BKUPPMUX(4) |
#define | BPM_BKUP_PIN_PC03_EIC5 BPM_BKUPPMUX_BKUPPMUX(5) |
#define | BPM_BKUP_PIN_PC04_EIC6 BPM_BKUPPMUX_BKUPPMUX(6) |
#define | BPM_BKUP_PIN_PC05_EIC7 BPM_BKUPPMUX_BKUPPMUX(7) |
#define | BPM_BKUP_PIN_PC06_EIC8 BPM_BKUPPMUX_BKUPPMUX(8) |
Power management | |
void | bpm_sleep (Bpm *bpm, uint32_t sleep_mode) |
Enter sleep mode. More... | |
void | bpm_power_scaling_cpu (Bpm *bpm, uint32_t ps_value) |
Change Power Scaling mode. More... | |
bool | bpm_power_scaling_cpu_failsafe (Bpm *bpm, uint32_t ps_value, uint32_t timeout) |
Change Power Scaling mode and check results. More... | |
static __always_inline bool | bpm_configure_power_scaling (Bpm *bpm, uint32_t ps_value, uint32_t no_halt) |
Configure power scaling mode. More... | |
void | bpm_enable_fast_wakeup (Bpm *bpm) |
Enable fast wakeup for analog modules. More... | |
void | bpm_disable_fast_wakeup (Bpm *bpm) |
Disable fast wakeup for analog modules. More... | |
void | bpm_set_clk32_source (Bpm *bpm, uint32_t source) |
Set clock source for 32KHz clock. More... | |
uint32_t | bpm_get_backup_wakeup_cause (Bpm *bpm) |
Get wakeup cause from backup mode. More... | |
void | bpm_enable_wakeup_source (Bpm *bpm, uint32_t sources) |
Enable wakeup source. More... | |
void | bpm_disable_wakeup_source (Bpm *bpm, uint32_t sources) |
Disable wakeup source. More... | |
void | bpm_enable_backup_pin (Bpm *bpm, uint32_t backup_pins) |
Enable backup pin for wakeup. More... | |
void | bpm_disable_backup_pin (Bpm *bpm, uint32_t backup_pins) |
Disable backup pin for wakeup. More... | |
void | bpm_enable_io_retention (Bpm *bpm) |
Enable IO retention for backup mode. More... | |
void | bpm_disable_io_retention (Bpm *bpm) |
Disable IO retention for backup mode. More... | |
Interrupt and status management | |
void | bpm_enable_interrupt (Bpm *bpm, uint32_t sources) |
Enable interrupt with given sources mask. More... | |
void | bpm_disable_interrupt (Bpm *bpm, uint32_t sources) |
Disable interrupt with given sources mask. More... | |
uint32_t | bpm_get_interrupt_mask (Bpm *bpm) |
Get BPM interrupt mask. More... | |
uint32_t | bpm_get_interrupt_status (Bpm *bpm) |
Get BPM interrupt status. More... | |
void | bpm_clear_interrupt (Bpm *bpm, uint32_t sources) |
Clear BPM interrupt. More... | |
uint32_t | bpm_get_status (Bpm *bpm) |
Get BPM status. More... | |
uint32_t | bpm_get_version (Bpm *bpm) |
Get version of BPM module. More... | |
#define BPM_BKUP_PIN_PA04_EIC2 BPM_BKUPPMUX_BKUPPMUX(2) |
#define BPM_BKUP_PIN_PA05_EIC3 BPM_BKUPPMUX_BKUPPMUX(3) |
#define BPM_BKUP_PIN_PA06_EIC1 BPM_BKUPPMUX_BKUPPMUX(1) |
#define BPM_BKUP_PIN_PA07_EIC4 BPM_BKUPPMUX_BKUPPMUX(4) |
#define BPM_BKUP_PIN_PB01_EIC0 BPM_BKUPPMUX_BKUPPMUX(0) |
#define BPM_BKUP_PIN_PC03_EIC5 BPM_BKUPPMUX_BKUPPMUX(5) |
#define BPM_BKUP_PIN_PC04_EIC6 BPM_BKUPPMUX_BKUPPMUX(6) |
#define BPM_BKUP_PIN_PC05_EIC7 BPM_BKUPPMUX_BKUPPMUX(7) |
#define BPM_BKUP_PIN_PC06_EIC8 BPM_BKUPPMUX_BKUPPMUX(8) |
#define BPM_BKUP_WAKEUP_SRC_AST (1UL << BPM_BKUPWEN_AST) |
AST wake up.
Referenced by event_button_init().
#define BPM_BKUP_WAKEUP_SRC_BOD18 (1UL << BPM_BKUPWEN_BOD18) |
BOD18 wake up.
#define BPM_BKUP_WAKEUP_SRC_BOD33 (1UL << BPM_BKUPWEN_BOD33) |
BOD33 wake up.
#define BPM_BKUP_WAKEUP_SRC_EIC (1UL << BPM_BKUPWEN_EIC) |
EIC wake up.
Referenced by event_button_init().
#define BPM_BKUP_WAKEUP_SRC_PICOUART (1UL << BPM_BKUPWEN_PICOUART) |
PICOUART wake up.
#define BPM_BKUP_WAKEUP_SRC_WDT (1UL << BPM_BKUPWEN_WDT) |
WDT wake up.
#define BPM_CLK32_SOURCE_OSC32K 0 |
OSC32K : Low frequency crystal oscillator.
Referenced by bpm_set_clk32_source(), and lcdca_clk_init().
#define BPM_CLK32_SOURCE_RC32K 1 |
RC32K : Internal Low frequency RC oscillator.
Referenced by lcdca_clk_init().
#define BPM_PS_0 0 |
Power scaling mode 0.
Referenced by app_switch_power_scaling(), main(), run_ps_test(), sysclk_init(), and test_core().
#define BPM_PS_1 1 |
Power scaling mode 1.
Referenced by app_switch_power_scaling(), main(), run_ps_test(), sysclk_init(), and test_core().
#define BPM_PS_2 2 |
Power scaling mode 2.
Referenced by app_switch_power_scaling(), and sysclk_init().
#define BPM_PSCM_CPU_HALT 0 |
Power scaling change mode: halting the CPU execution.
#define BPM_PSCM_CPU_NOT_HALT 1 |
Power scaling change mode: CPU execution not halted.
Referenced by main(), and sysclk_init().
#define BPM_SM_ACTIVE 0 |
Active mode.
#define BPM_SM_BACKUP 7 |
Backup mode.
Referenced by bpm_sleep(), main(), and run_backup_test().
#define BPM_SM_RET 6 |
Retention mode.
Referenced by bpm_sleep(), main(), run_picouart_test(), and run_ret_test().
#define BPM_SM_SLEEP_0 1 |
Sleep mode 0.
Referenced by bpm_sleep(), main(), and run_sleep_0_test().
#define BPM_SM_SLEEP_1 2 |
Sleep mode 1.
Referenced by bpm_sleep(), main(), run_picouart_test(), and run_sleep_1_test().
#define BPM_SM_SLEEP_2 3 |
Sleep mode 2.
Referenced by bpm_sleep(), main(), and run_sleep_2_test().
#define BPM_SM_SLEEP_3 4 |
Sleep mode 3.
Referenced by bpm_sleep(), main(), run_picouart_test(), and run_sleep_3_test().
#define BPM_SM_WAIT 5 |
Wait mode.
Referenced by bpm_sleep(), main(), run_alarm_test(), run_periodic_test(), run_picouart_test(), and run_wait_test().
#define BPM_UNLOCK | ( | reg | ) |
BPM unlock macro.
Referenced by bpm_disable_fast_wakeup(), bpm_enable_fast_wakeup(), bpm_power_scaling_cpu(), bpm_ps_no_halt_exec(), bpm_set_clk32_source(), and bpm_sleep().
void bpm_clear_interrupt | ( | Bpm * | bpm, |
uint32_t | sources | ||
) |
Clear BPM interrupt.
bpm | Base address of the BPM instance. |
sources | BPM interrupt source mask. |
Referenced by BPM_Handler().
|
static |
Configure power scaling mode.
While checking PSOK in power safe (no halt) mode, timeout is set to 240000 by default, which takes 20ms when 12MHz clock is used.
bpm | Base address of the BPM instance. |
ps_value | Power scaling value, see power_scaling_mode_value. |
no_halt | No halt or Fail safe, see bpm_power_scaling_cpu() and bpm_power_scaling_cpu_failsafe() |
References bpm_power_scaling_cpu(), and bpm_power_scaling_cpu_failsafe().
Referenced by app_switch_power_scaling(), main(), sysclk_init(), and test_core().
void bpm_disable_backup_pin | ( | Bpm * | bpm, |
uint32_t | backup_pins | ||
) |
Disable backup pin for wakeup.
bpm | Base address of the BPM instance. |
backup_pins | Backup pin mask, see backup_pin_muxing. |
void bpm_disable_fast_wakeup | ( | Bpm * | bpm | ) |
Disable fast wakeup for analog modules.
bpm | Base address of the BPM instance. |
References BPM_UNLOCK.
void bpm_disable_interrupt | ( | Bpm * | bpm, |
uint32_t | sources | ||
) |
Disable interrupt with given sources mask.
bpm | Base address of the BPM instance. |
sources | BPM interrupt source mask. |
Referenced by BPM_Handler().
void bpm_disable_io_retention | ( | Bpm * | bpm | ) |
Disable IO retention for backup mode.
bpm | Base address of the BPM instance. |
Referenced by config_backup_wakeup(), event_button_init(), and main().
void bpm_disable_wakeup_source | ( | Bpm * | bpm, |
uint32_t | sources | ||
) |
Disable wakeup source.
bpm | Base address of the BPM instance. |
sources | Wakeup source mask, see backup_wake_up_sources. |
void bpm_enable_backup_pin | ( | Bpm * | bpm, |
uint32_t | backup_pins | ||
) |
Enable backup pin for wakeup.
bpm | Base address of the BPM instance. |
backup_pins | Backup pin mask, see backup_pin_muxing. |
Referenced by config_backup_wakeup(), config_wakeup(), and event_button_init().
void bpm_enable_fast_wakeup | ( | Bpm * | bpm | ) |
Enable fast wakeup for analog modules.
bpm | Base address of the BPM instance. |
References BPM_UNLOCK.
Referenced by config_backup_wakeup(), event_button_init(), main(), sysclk_init(), and udd_enable().
void bpm_enable_interrupt | ( | Bpm * | bpm, |
uint32_t | sources | ||
) |
Enable interrupt with given sources mask.
bpm | Base address of the BPM instance. |
sources | BPM interrupt source mask. |
void bpm_enable_io_retention | ( | Bpm * | bpm | ) |
Enable IO retention for backup mode.
bpm | Base address of the BPM instance. |
Referenced by config_backup_wakeup(), event_button_init(), and main().
void bpm_enable_wakeup_source | ( | Bpm * | bpm, |
uint32_t | sources | ||
) |
Enable wakeup source.
bpm | Base address of the BPM instance. |
sources | Wakeup source mask, see backup_wake_up_sources. |
Referenced by config_backup_wakeup(), config_wakeup(), event_button_init(), main(), run_alarm_test(), run_periodic_test(), and run_picouart_test().
uint32_t bpm_get_backup_wakeup_cause | ( | Bpm * | bpm | ) |
Get wakeup cause from backup mode.
bpm | Base address of the BPM instance. |
Referenced by run_backup_test().
uint32_t bpm_get_interrupt_mask | ( | Bpm * | bpm | ) |
Get BPM interrupt mask.
bpm | Base address of the BPM instance. |
uint32_t bpm_get_interrupt_status | ( | Bpm * | bpm | ) |
Get BPM interrupt status.
bpm | Base address of the BPM instance. |
Referenced by BPM_Handler().
uint32_t bpm_get_status | ( | Bpm * | bpm | ) |
Get BPM status.
bpm | Base address of the BPM instance. |
Referenced by app_switch_power_scaling(), main(), sysclk_init(), and test_core().
uint32_t bpm_get_version | ( | Bpm * | bpm | ) |
Get version of BPM module.
bpm | Base address of the BPM instance. |
void bpm_power_scaling_cpu | ( | Bpm * | bpm, |
uint32_t | ps_value | ||
) |
Change Power Scaling mode.
PSOK is not checked while switching PS mode.
bpm | Base address of the BPM instance. |
ps_value | Power scaling value, see power_scaling_mode_value. |
References BPM_UNLOCK.
Referenced by bpm_configure_power_scaling().
bool bpm_power_scaling_cpu_failsafe | ( | Bpm * | bpm, |
uint32_t | ps_value, | ||
uint32_t | timeout | ||
) |
Change Power Scaling mode and check results.
Wait for a while to check if PSOK is ready.
bpm | Base address of the BPM instance. |
ps_value | Power scaling value, see power_scaling_mode_value. |
timeout | Timeout, in number of processor clocks, max 0xFFFFFF. |
References bpm_ps_no_halt_exec(), cpu_irq_restore(), and cpu_irq_save().
Referenced by bpm_configure_power_scaling(), and run_ps_test().
void bpm_set_clk32_source | ( | Bpm * | bpm, |
uint32_t | source | ||
) |
Set clock source for 32KHz clock.
bpm | Base address of the BPM instance. |
source | Clock source, see CLK32_32Khz_1Khz. |
References BPM_CLK32_SOURCE_OSC32K, and BPM_UNLOCK.
Referenced by lcdca_clk_init().
void bpm_sleep | ( | Bpm * | bpm, |
uint32_t | sleep_mode | ||
) |
Enter sleep mode.
bpm | Base address of the BPM instance. |
sleep_mode | Expected sleep mode (active case not included). |
References BPM_SM_BACKUP, BPM_SM_RET, BPM_SM_SLEEP_0, BPM_SM_SLEEP_1, BPM_SM_SLEEP_2, BPM_SM_SLEEP_3, BPM_SM_WAIT, BPM_UNLOCK, and cpu_irq_enable.
Referenced by main(), run_alarm_test(), run_backup_test(), run_periodic_test(), run_picouart_test(), run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), run_wait_test(), and sleepmgr_sleep().