first commit for opensource
first commit for opensource
This commit is contained in:
85
kernel/pm/include/tos_pm.h
Normal file
85
kernel/pm/include/tos_pm.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef _TOS_PM_H_
|
||||
#define _TOS_PM_H_
|
||||
|
||||
#if TOS_CFG_PWR_MGR_EN > 0u
|
||||
|
||||
#define K_PM_DEVICE_MAX_COUNT 10u
|
||||
|
||||
typedef enum idle_power_manager_mode_en {
|
||||
IDLE_POWER_MANAGER_MODE_SLEEP,
|
||||
IDLE_POWER_MANAGER_MODE_TICKLESS,
|
||||
} idle_pwrmgr_mode_t;
|
||||
|
||||
/*
|
||||
Low-power mode summary
|
||||
|-------------------------------------------------------------------------------------------------------------------|
|
||||
| Mode name | Entry | Wakeup | Effect on 1.8V | Effect on VDD | Voltage regulator |
|
||||
| | | | domain clocks | domain clocks | |
|
||||
|----------------|------------------|--------------------|--------------------|-----------------|-------------------|
|
||||
| Sleep | WFI | Any interrupt | CPU clock OFF | | |
|
||||
| (Sleep now or |------------------|--------------------| no effect on other | None | ON |
|
||||
| Sleep-on-exit) | WFE | Wakeup event | clocks or analog | | |
|
||||
| | | | clock sources | | |
|
||||
|----------------|------------------|--------------------|--------------------|-----------------|-------------------|
|
||||
| | | | | | ON or in |
|
||||
| Stop | PDDS and LPDS | Any EXTI line | | | low-power mode |
|
||||
| | bits + SLEEPDEEP | (configured in the | | | (depends on Power |
|
||||
| | bit + WFI or WFE | EXTI registers | | | control register |
|
||||
| | | | | | (PWR_CR) |
|
||||
|----------------|------------------|--------------------| All 1.8V domain | HSI and HSE |-------------------|
|
||||
| | | WKUP pin rising | clocks OFF | oscillators OFF | |
|
||||
| Standby | PDDS bit + | edge, RTC alarm, | | | |
|
||||
| | SLEEPDEEP bit + | external reset in | | | OFF |
|
||||
| | WFI or WFE | NRST pin, | | | |
|
||||
| | | IWDG reset | | | |
|
||||
| | | | | | |
|
||||
|-------------------------------------------------------------------------------------------------------------------|
|
||||
*/
|
||||
typedef enum k_cpu_low_power_mode_en {
|
||||
TOS_LOW_POWER_MODE_SLEEP = 0, /* wakeup source: systick/tim/rtc */
|
||||
TOS_LOW_POWER_MODE_STOP, /* wakeup source: rtc wakeup/alarm */
|
||||
TOS_LOW_POWER_MODE_STANDBY, /* wakeup source: rtc alarm */
|
||||
__LOW_POWER_MODE_DUMMY,
|
||||
} k_cpu_lpwr_mode_t;
|
||||
|
||||
typedef struct k_pm_device_st {
|
||||
char *name;
|
||||
|
||||
int (*init)(void);
|
||||
int (*suspend)(void);
|
||||
int (*resume)(void);
|
||||
} k_pm_device_t;
|
||||
|
||||
typedef struct pm_device_control_st {
|
||||
uint8_t count;
|
||||
k_pm_device_t *mgr[K_PM_DEVICE_MAX_COUNT];
|
||||
} pm_device_ctl_t;
|
||||
|
||||
#if TOS_CFG_TICKLESS_EN > 0u
|
||||
__API__ k_err_t tos_pm_cpu_lpwr_mode_set(k_cpu_lpwr_mode_t cpu_lpwr_mode);
|
||||
#endif
|
||||
|
||||
__API__ k_err_t tos_pm_device_register(k_pm_device_t *device);
|
||||
|
||||
__KERNEL__ void pm_init(void);
|
||||
|
||||
__KERNEL__ void pm_cpu_lpwr_mode_enter(k_cpu_lpwr_mode_t lpwr_mode);
|
||||
|
||||
__KERNEL__ k_cpu_lpwr_mode_t pm_cpu_lpwr_mode_get(void);
|
||||
|
||||
__KERNEL__ void pm_idle_pwr_mgr_mode_set(idle_pwrmgr_mode_t idle_pwrmgr_mode);
|
||||
|
||||
__KERNEL__ int pm_idle_pwr_mgr_mode_is_sleep(void);
|
||||
|
||||
__KERNEL__ int pm_idle_pwr_mgr_mode_is_tickless(void);
|
||||
|
||||
__KERNEL__ void pm_power_manager(void);
|
||||
|
||||
__KERNEL__ int pm_device_suspend(void);
|
||||
|
||||
__KERNEL__ int pm_device_resume(void);
|
||||
|
||||
#endif /* TOS_CFG_PWR_MGR_EN */
|
||||
|
||||
#endif /* _TOS_PM_H_ */
|
||||
|
28
kernel/pm/include/tos_tickless.h
Normal file
28
kernel/pm/include/tos_tickless.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _TOS_TICKLESS_H_
|
||||
#define _TOS_TICKLESS_H_
|
||||
|
||||
#if TOS_CFG_TICKLESS_EN > 0u
|
||||
|
||||
typedef struct k_tickless_wakeup_alarm_st {
|
||||
int (*init)(void);
|
||||
int (*setup)(k_time_t millisecond);
|
||||
int (*dismiss)(void);
|
||||
k_time_t (*max_delay)(void); /* in millisecond */
|
||||
} k_tickless_wkup_alarm_t;
|
||||
|
||||
__API__ void tos_tickless_wkup_alarm_install(k_cpu_lpwr_mode_t mode, k_tickless_wkup_alarm_t *wkup_alarm);
|
||||
|
||||
__API__ k_err_t tos_tickless_wkup_alarm_init(k_cpu_lpwr_mode_t mode);
|
||||
|
||||
__HOOK__ int tos_bsp_tickless_setup(void);
|
||||
|
||||
__KERNEL__ int tickless_wkup_alarm_is_installed(k_cpu_lpwr_mode_t mode);
|
||||
|
||||
__KERNEL__ void tickless_init(void);
|
||||
|
||||
__KERNEL__ void tickless_proc(void);
|
||||
|
||||
#endif /* TOS_CFG_TICKLESS_EN */
|
||||
|
||||
#endif /* _TOS_TICKLESS_H_ */
|
||||
|
Reference in New Issue
Block a user