diff --git a/bsp/es32f0334/drivers/drv_pm.c b/bsp/es32f0334/drivers/drv_pm.c index f9324d7208..1841ce2050 100644 --- a/bsp/es32f0334/drivers/drv_pm.c +++ b/bsp/es32f0334/drivers/drv_pm.c @@ -16,54 +16,28 @@ #ifdef RT_USING_PM -static void _drv_pm_enter(struct rt_pm *pm) +static void _drv_pm_enter(struct rt_pm *pm, uint8_t mode) { - rt_uint32_t mode; - - mode = pm->current_mode; - switch (mode) { - case PM_RUN_MODE_NORMAL: + case PM_SLEEP_MODE_NONE: break; - case PM_SLEEP_MODE_SLEEP: + case PM_SLEEP_MODE_IDLE: __WFI(); break; - case PM_SLEEP_MODE_TIMER: + case PM_SLEEP_MODE_LIGHT: + break; + + case PM_SLEEP_MODE_DEEP: pmu_stop2_enter(); break; - case PM_SLEEP_MODE_SHUTDOWN: + case PM_SLEEP_MODE_STANDBY: pmu_standby_enter(PMU_STANDBY_PORT_NONE); break; - default: - RT_ASSERT(0); - break; - } -} - -static void _drv_pm_exit(struct rt_pm *pm) -{ - rt_uint32_t mode; - - RT_ASSERT(pm != RT_NULL); - - mode = pm->current_mode; - - switch (mode) - { - case PM_RUN_MODE_NORMAL: - break; - - case PM_SLEEP_MODE_SLEEP: - break; - - case PM_SLEEP_MODE_TIMER: - break; - case PM_SLEEP_MODE_SHUTDOWN: break; @@ -73,32 +47,21 @@ static void _drv_pm_exit(struct rt_pm *pm) } } -#if PM_RUN_MODE_COUNT > 1 -static void _drv_pm_frequency_change(struct rt_pm *pm, rt_uint32_t frequency) -{ - return; -} -#endif - static int drv_hw_pm_init(void) { static const struct rt_pm_ops _ops = { _drv_pm_enter, - _drv_pm_exit, - -#if PM_RUN_MODE_COUNT > 1 - _drv_pm_frequency_change, -#endif + RT_NULL, RT_NULL, RT_NULL, RT_NULL }; - rt_uint8_t timer_mask; + rt_uint8_t timer_mask = 0; - /* initialize timer mask */ - timer_mask = 1UL << PM_SLEEP_MODE_TIMER; + /* initialize timer mask(no need tickless) */ + // timer_mask = 1UL << PM_SLEEP_MODE_DEEP; /* initialize system pm module */ rt_system_pm_init(&_ops, timer_mask, RT_NULL); diff --git a/bsp/es32f0654/drivers/drv_pm.c b/bsp/es32f0654/drivers/drv_pm.c index 256634b81d..926ffc05c0 100644 --- a/bsp/es32f0654/drivers/drv_pm.c +++ b/bsp/es32f0654/drivers/drv_pm.c @@ -16,54 +16,28 @@ #ifdef RT_USING_PM -static void _drv_pm_enter(struct rt_pm *pm) +static void _drv_pm_enter(struct rt_pm *pm, uint8_t mode) { - rt_uint32_t mode; - - mode = pm->current_mode; - switch (mode) { - case PM_RUN_MODE_NORMAL: + case PM_SLEEP_MODE_NONE: break; - case PM_SLEEP_MODE_SLEEP: + case PM_SLEEP_MODE_IDLE: __WFI(); break; - case PM_SLEEP_MODE_TIMER: + case PM_SLEEP_MODE_LIGHT: + break; + + case PM_SLEEP_MODE_DEEP: pmu_stop2_enter(); break; - case PM_SLEEP_MODE_SHUTDOWN: + case PM_SLEEP_MODE_STANDBY: pmu_standby_enter(PMU_STANDBY_PORT_NONE); break; - default: - RT_ASSERT(0); - break; - } -} - -static void _drv_pm_exit(struct rt_pm *pm) -{ - rt_uint32_t mode; - - RT_ASSERT(pm != RT_NULL); - - mode = pm->current_mode; - - switch (mode) - { - case PM_RUN_MODE_NORMAL: - break; - - case PM_SLEEP_MODE_SLEEP: - break; - - case PM_SLEEP_MODE_TIMER: - break; - case PM_SLEEP_MODE_SHUTDOWN: break; @@ -73,32 +47,21 @@ static void _drv_pm_exit(struct rt_pm *pm) } } -#if PM_RUN_MODE_COUNT > 1 -static void _drv_pm_frequency_change(struct rt_pm *pm, rt_uint32_t frequency) -{ - return; -} -#endif - static int drv_hw_pm_init(void) { static const struct rt_pm_ops _ops = { _drv_pm_enter, - _drv_pm_exit, - -#if PM_RUN_MODE_COUNT > 1 - _drv_pm_frequency_change, -#endif + RT_NULL, RT_NULL, RT_NULL, RT_NULL }; - rt_uint8_t timer_mask; + rt_uint8_t timer_mask = 0; - /* initialize timer mask */ - timer_mask = 1UL << PM_SLEEP_MODE_TIMER; + /* initialize timer mask(no need tickless) */ + timer_mask = 1UL << PM_SLEEP_MODE_DEEP; /* initialize system pm module */ rt_system_pm_init(&_ops, timer_mask, RT_NULL); diff --git a/examples/pm/timer_app.c b/examples/pm/timer_app.c index 5c20d0f690..66f4c8d4d2 100644 --- a/examples/pm/timer_app.c +++ b/examples/pm/timer_app.c @@ -39,7 +39,7 @@ static int timer_app_init(void) rt_timer_start(timer1); /* keep in timer mode */ - rt_pm_request(PM_SLEEP_MODE_TIMER); + rt_pm_request(PM_SLEEP_MODE_DEEP); return 0; }