Go to the source code of this file.
Data Structures | |
struct | misc_para_t |
deepsleep wakeup by external xtal More... | |
struct | pm_para_t |
deepsleep wakeup status More... | |
Macros | |
#define | PM_LONG_SUSPEND_EN 1 |
#define | PM_TIM_RECOVER_MODE 0 |
#define | PM_XTAL_DELAY_DURATION 500 |
#define | EARLYWAKEUP_TIME_US_DEEP 1100 |
#define | EARLYWAKEUP_TIME_US_SUSPEND 1250 |
#define | EMPTYRUN_TIME_US 1500 |
#define | PM_DCDC_DELAY_DURATION 1000 |
#define | PM_LONG_SLEEP_WAKEUP_EN 0 |
#define | SYS_CLK_48MRC_EN 0 |
#define | DEEP_ANA_REG0 0x3a |
analog register below can store infomation when MCU in deepsleep mode store your information in these ana_regs before deepsleep by calling analog_write function when MCU wakeup from deepsleep, read the information by by calling analog_read function Reset these analog registers only by power cycle More... | |
#define | DEEP_ANA_REG1 0x3b |
#define | DEEP_ANA_REG2 0x3c |
#define | DEEP_ANA_REG6 0x35 |
these analog register can store data in deepsleep mode or deepsleep with SRAM retention mode. Reset these analog registers by watchdog, chip reset, RESET Pin, power cycle More... | |
#define | DEEP_ANA_REG7 0x36 |
#define | DEEP_ANA_REG8 0x37 |
#define | DEEP_ANA_REG9 0x38 |
#define | DEEP_ANA_REG10 0x39 |
#define | SYS_NEED_REINIT_EXT32K BIT(0) |
#define | SYS_DEEP_ANA_REG DEEP_ANA_REG2 |
#define | WAKEUP_STATUS_TIMER_CORE ( WAKEUP_STATUS_TIMER | WAKEUP_STATUS_CORE) |
#define | WAKEUP_STATUS_TIMER_PAD ( WAKEUP_STATUS_TIMER | WAKEUP_STATUS_PAD) |
Typedefs | |
typedef int(* | suspend_handler_t) (void) |
typedef unsigned int(* | pm_tim_recover_handler_t) (unsigned int) |
typedef int(* | cpu_pm_handler_t) (SleepMode_TypeDef sleep_mode, SleepWakeupSrc_TypeDef wakeup_src, unsigned int wakeup_tick) |
Enumerations | |
enum | SleepMode_TypeDef { SUSPEND_MODE = 0, DEEPSLEEP_MODE = 0x80, DEEPSLEEP_MODE_RET_SRAM_LOW8K = 0x61, DEEPSLEEP_MODE_RET_SRAM_LOW16K = 0x43, DEEPSLEEP_MODE_RET_SRAM_LOW32K = 0x07, SHUTDOWN_MODE = 0xFF, DEEPSLEEP_RETENTION_FLAG = 0x7F } |
sleep mode. More... | |
enum | SleepWakeupSrc_TypeDef { PM_WAKEUP_PAD = BIT(4), PM_WAKEUP_CORE = BIT(5), PM_WAKEUP_TIMER = BIT(6), PM_WAKEUP_COMPARATOR = BIT(7), PM_TIM_RECOVER_START = BIT(14), PM_TIM_RECOVER_END = BIT(15) } |
wakeup source More... | |
enum | { WAKEUP_STATUS_COMPARATOR = BIT(0), WAKEUP_STATUS_TIMER = BIT(1), WAKEUP_STATUS_CORE = BIT(2), WAKEUP_STATUS_PAD = BIT(3), WAKEUP_STATUS_WD = BIT(6), STATUS_GPIO_ERR_NO_ENTER_PM = BIT(7), STATUS_ENTER_SUSPEND = BIT(30) } |
wakeup status More... | |
Functions | |
void | bls_pm_registerFuncBeforeSuspend (suspend_handler_t func) |
static int | pm_is_MCU_deepRetentionWakeup (void) |
This function serves to determine whether mcu is waked up from deep retention. More... | |
static int | pm_is_deepPadWakeup (void) |
This function serves to determine whether mcu is waked up by pad. More... | |
static int | pm_get_wakeup_src (void) |
This function serves to get the source of wake-up. More... | |
void | cpu_stall_wakeup_by_timer0 (unsigned int tick) |
This function serves to wake up cpu from stall mode by timer0. More... | |
void | cpu_stall_wakeup_by_timer1 (unsigned int tick) |
This function serves to wake up cpu from stall mode by timer1. More... | |
void | cpu_stall_wakeup_by_timer2 (unsigned int tick) |
This function serves to wake up cpu from stall mode by timer2. More... | |
unsigned int | cpu_stall (int WakeupSrc, unsigned int IntervalUs, unsigned int sysclktick) |
This function serves to wake up cpu from stall mode by timer1 or RF TX done irq. More... | |
void | cpu_set_gpio_wakeup (GPIO_PinTypeDef pin, GPIO_LevelTypeDef pol, int en) |
This function configures a GPIO pin as the wakeup pin. More... | |
void | start_reboot (void) |
This function serves to reboot chip. More... | |
unsigned int | pm_get_32k_tick (void) |
This function serves to get the 32k tick. More... | |
void | cpu_wakeup_init (void) |
This function serves to initialize MCU. More... | |
unsigned int | pm_tim_recover_32k_rc (unsigned int now_tick_32k) |
This function serves to recover system timer from tick of internal 32k RC. More... | |
unsigned int | pm_tim_recover_32k_xtal (unsigned int now_tick_32k) |
This function serves to recover system timer from tick of external 32k crystal. More... | |
int | cpu_sleep_wakeup_32k_rc (SleepMode_TypeDef sleep_mode, SleepWakeupSrc_TypeDef wakeup_src, unsigned int wakeup_tick) |
This function serves to set the working mode of MCU based on 32k crystal,e.g. suspend mode, deepsleep mode, deepsleep with SRAM retention mode and shutdown mode. More... | |
int | cpu_sleep_wakeup_32k_xtal (SleepMode_TypeDef sleep_mode, SleepWakeupSrc_TypeDef wakeup_src, unsigned int wakeup_tick) |
This function serves to set the working mode of MCU based on 32k crystal,e.g. suspend mode, deepsleep mode, deepsleep with SRAM retention mode and shutdown mode. More... | |
static void | blc_pm_select_internal_32k_crystal (void) |
This function serves to determine whether wake up source is internal 32k RC. More... | |
static void | blc_pm_select_external_32k_crystal (void) |
This function serves to determine whether wake up source is external 32k RC. More... | |
void | sleep_start (void) |
unsigned int | pm_get_info0 (void) |
unsigned int | pm_get_info1 (void) |
unsigned int | cpu_get_32k_tick (void) |
void | soft_reboot_dly13ms_use24mRC (void) |
void | check_32k_clk_stable (void) |
Variables | |
misc_para_t | blt_miscParam |
pm_para_t | pmParam |
suspend_handler_t | func_before_suspend |
pm_tim_recover_handler_t | pm_tim_recover |
cpu_pm_handler_t | cpu_sleep_wakeup |
unsigned char | tl_multi_addr |
unsigned char | tl_24mrc_cal |
unsigned short | tick_32k_calib |
unsigned int | tick_cur |
unsigned int | tick_32k_cur |
#define PM_LONG_SUSPEND_EN 1 |
#define PM_TIM_RECOVER_MODE 0 |
#define PM_XTAL_DELAY_DURATION 500 |
#define EARLYWAKEUP_TIME_US_DEEP 1100 |
#define EARLYWAKEUP_TIME_US_SUSPEND 1250 |
#define EMPTYRUN_TIME_US 1500 |
#define PM_DCDC_DELAY_DURATION 1000 |
#define PM_LONG_SLEEP_WAKEUP_EN 0 |
#define SYS_CLK_48MRC_EN 0 |
#define DEEP_ANA_REG0 0x3a |
analog register below can store infomation when MCU in deepsleep mode store your information in these ana_regs before deepsleep by calling analog_write function when MCU wakeup from deepsleep, read the information by by calling analog_read function Reset these analog registers only by power cycle
#define DEEP_ANA_REG1 0x3b |
#define DEEP_ANA_REG2 0x3c |
#define DEEP_ANA_REG6 0x35 |
these analog register can store data in deepsleep mode or deepsleep with SRAM retention mode. Reset these analog registers by watchdog, chip reset, RESET Pin, power cycle
#define DEEP_ANA_REG7 0x36 |
#define DEEP_ANA_REG8 0x37 |
#define DEEP_ANA_REG9 0x38 |
#define DEEP_ANA_REG10 0x39 |
#define SYS_NEED_REINIT_EXT32K BIT(0) |
#define SYS_DEEP_ANA_REG DEEP_ANA_REG2 |
#define WAKEUP_STATUS_TIMER_CORE ( WAKEUP_STATUS_TIMER | WAKEUP_STATUS_CORE) |
#define WAKEUP_STATUS_TIMER_PAD ( WAKEUP_STATUS_TIMER | WAKEUP_STATUS_PAD) |
typedef int(* suspend_handler_t) (void) |
typedef unsigned int(* pm_tim_recover_handler_t) (unsigned int) |
typedef int(* cpu_pm_handler_t) (SleepMode_TypeDef sleep_mode, SleepWakeupSrc_TypeDef wakeup_src, unsigned int wakeup_tick) |
enum SleepMode_TypeDef |
anonymous enum |
void bls_pm_registerFuncBeforeSuspend | ( | suspend_handler_t | func | ) |
|
inlinestatic |
This function serves to determine whether mcu is waked up from deep retention.
[in] | none. |
|
inlinestatic |
This function serves to determine whether mcu is waked up by pad.
[in] | none. |
|
inlinestatic |
This function serves to get the source of wake-up.
[in] | none. |
void cpu_stall_wakeup_by_timer0 | ( | unsigned int | tick | ) |
This function serves to wake up cpu from stall mode by timer0.
tick | - capture value of timer0. |
void cpu_stall_wakeup_by_timer1 | ( | unsigned int | tick | ) |
This function serves to wake up cpu from stall mode by timer1.
tick | - capture value of timer1. |
void cpu_stall_wakeup_by_timer2 | ( | unsigned int | tick | ) |
This function serves to wake up cpu from stall mode by timer2.
tick | - capture value of timer2. |
unsigned int cpu_stall | ( | int | WakeupSrc, |
unsigned int | IntervalUs, | ||
unsigned int | sysclktick | ||
) |
This function serves to wake up cpu from stall mode by timer1 or RF TX done irq.
WakeupSrc | - timer1. |
IntervalUs | - capture value of timer1. |
sysclktick | - tick value of per us based on system clock. |
void cpu_set_gpio_wakeup | ( | GPIO_PinTypeDef | pin, |
GPIO_LevelTypeDef | pol, | ||
int | en | ||
) |
This function configures a GPIO pin as the wakeup pin.
[in] | pin | - the pin needs to be configured as wakeup pin |
[in] | pol | - the wakeup polarity of the pad pin(0: low-level wakeup, 1: high-level wakeup) |
[in] | en | - enable or disable the wakeup function for the pan pin(1: Enable, 0: Disable) |
void start_reboot | ( | void | ) |
This function serves to reboot chip.
none. |
unsigned int pm_get_32k_tick | ( | void | ) |
This function serves to get the 32k tick.
none |
void cpu_wakeup_init | ( | void | ) |
This function serves to initialize MCU.
none |
unsigned int pm_tim_recover_32k_rc | ( | unsigned int | now_tick_32k | ) |
This function serves to recover system timer from tick of internal 32k RC.
none. |
unsigned int pm_tim_recover_32k_xtal | ( | unsigned int | now_tick_32k | ) |
This function serves to recover system timer from tick of external 32k crystal.
none. |
int cpu_sleep_wakeup_32k_rc | ( | SleepMode_TypeDef | sleep_mode, |
SleepWakeupSrc_TypeDef | wakeup_src, | ||
unsigned int | wakeup_tick | ||
) |
This function serves to set the working mode of MCU based on 32k crystal,e.g. suspend mode, deepsleep mode, deepsleep with SRAM retention mode and shutdown mode.
[in] | sleep_mode | - sleep mode type select. |
[in] | wakeup_src | - wake up source select. |
[in] | wakeup_tick | - the time of short sleep, which means MCU can sleep for less than 5 minutes. |
int cpu_sleep_wakeup_32k_xtal | ( | SleepMode_TypeDef | sleep_mode, |
SleepWakeupSrc_TypeDef | wakeup_src, | ||
unsigned int | wakeup_tick | ||
) |
This function serves to set the working mode of MCU based on 32k crystal,e.g. suspend mode, deepsleep mode, deepsleep with SRAM retention mode and shutdown mode.
[in] | sleep_mode | - sleep mode type select. |
[in] | wakeup_src | - wake up source select. |
[in] | wakeup_tick | - the time of short sleep, which means MCU can sleep for less than 5 minutes. |
|
inlinestatic |
This function serves to determine whether wake up source is internal 32k RC.
[in] | none. |
|
inlinestatic |
This function serves to determine whether wake up source is external 32k RC.
[in] | none. |
void sleep_start | ( | void | ) |
unsigned int pm_get_info0 | ( | void | ) |
unsigned int pm_get_info1 | ( | void | ) |
unsigned int cpu_get_32k_tick | ( | void | ) |
void soft_reboot_dly13ms_use24mRC | ( | void | ) |
void check_32k_clk_stable | ( | void | ) |
misc_para_t blt_miscParam |
pm_para_t pmParam |
suspend_handler_t func_before_suspend |
pm_tim_recover_handler_t pm_tim_recover |
cpu_pm_handler_t cpu_sleep_wakeup |
unsigned char tl_multi_addr |
unsigned char tl_24mrc_cal |
unsigned short tick_32k_calib |
unsigned int tick_cur |
unsigned int tick_32k_cur |