File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1919static struct rt_pm _pm ;
2020static uint8_t _pm_default_sleep = RT_PM_DEFAULT_SLEEP_MODE ;
2121static struct rt_pm_notify _pm_notify ;
22+ static uint8_t _pm_init_flag = 0 ;
2223
2324#define RT_PM_TICKLESS_THRESH (2)
2425
@@ -215,6 +216,9 @@ void rt_system_power_manager(void)
215216{
216217 uint8_t mode ;
217218
219+ if (_pm_init_flag == 0 )
220+ return ;
221+
218222 /* CPU frequency scaling according to the runing mode settings */
219223 _pm_frequency_scaling (& _pm );
220224
@@ -234,6 +238,9 @@ void rt_pm_request(uint8_t mode)
234238 rt_base_t level ;
235239 struct rt_pm * pm ;
236240
241+ if (_pm_init_flag == 0 )
242+ return ;
243+
237244 if (mode > (PM_SLEEP_MODE_MAX - 1 ))
238245 return ;
239246
@@ -256,6 +263,9 @@ void rt_pm_release(uint8_t mode)
256263 rt_ubase_t level ;
257264 struct rt_pm * pm ;
258265
266+ if (_pm_init_flag == 0 )
267+ return ;
268+
259269 if (mode > (PM_SLEEP_MODE_MAX - 1 ))
260270 return ;
261271
@@ -423,6 +433,9 @@ int rt_pm_run_enter(uint8_t mode)
423433 rt_base_t level ;
424434 struct rt_pm * pm ;
425435
436+ if (_pm_init_flag == 0 )
437+ return - RT_EIO ;
438+
426439 if (mode > PM_RUN_MODE_MAX )
427440 return - RT_EINVAL ;
428441
@@ -486,6 +499,8 @@ void rt_system_pm_init(const struct rt_pm_ops *ops,
486499
487500 pm -> device_pm = RT_NULL ;
488501 pm -> device_pm_number = 0 ;
502+
503+ _pm_init_flag = 1 ;
489504}
490505
491506#ifdef RT_USING_FINSH
You can’t perform that action at this time.
0 commit comments