mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 16:53:30 +08:00
[components][pm]add check for pm initialize.
This commit is contained in:
parent
2bf9ba0675
commit
42a32fd473
@ -19,6 +19,7 @@
|
|||||||
static struct rt_pm _pm;
|
static struct rt_pm _pm;
|
||||||
static uint8_t _pm_default_sleep = RT_PM_DEFAULT_SLEEP_MODE;
|
static uint8_t _pm_default_sleep = RT_PM_DEFAULT_SLEEP_MODE;
|
||||||
static struct rt_pm_notify _pm_notify;
|
static struct rt_pm_notify _pm_notify;
|
||||||
|
static uint8_t _pm_init_flag = 0;
|
||||||
|
|
||||||
#define RT_PM_TICKLESS_THRESH (2)
|
#define RT_PM_TICKLESS_THRESH (2)
|
||||||
|
|
||||||
@ -215,6 +216,9 @@ void rt_system_power_manager(void)
|
|||||||
{
|
{
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
|
|
||||||
|
if (_pm_init_flag == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
/* CPU frequency scaling according to the runing mode settings */
|
/* CPU frequency scaling according to the runing mode settings */
|
||||||
_pm_frequency_scaling(&_pm);
|
_pm_frequency_scaling(&_pm);
|
||||||
|
|
||||||
@ -234,6 +238,9 @@ void rt_pm_request(uint8_t mode)
|
|||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
struct rt_pm *pm;
|
struct rt_pm *pm;
|
||||||
|
|
||||||
|
if (_pm_init_flag == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (mode > (PM_SLEEP_MODE_MAX - 1))
|
if (mode > (PM_SLEEP_MODE_MAX - 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -256,6 +263,9 @@ void rt_pm_release(uint8_t mode)
|
|||||||
rt_ubase_t level;
|
rt_ubase_t level;
|
||||||
struct rt_pm *pm;
|
struct rt_pm *pm;
|
||||||
|
|
||||||
|
if (_pm_init_flag == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (mode > (PM_SLEEP_MODE_MAX - 1))
|
if (mode > (PM_SLEEP_MODE_MAX - 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -423,6 +433,9 @@ int rt_pm_run_enter(uint8_t mode)
|
|||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
struct rt_pm *pm;
|
struct rt_pm *pm;
|
||||||
|
|
||||||
|
if (_pm_init_flag == 0)
|
||||||
|
return -RT_EIO;
|
||||||
|
|
||||||
if (mode > PM_RUN_MODE_MAX)
|
if (mode > PM_RUN_MODE_MAX)
|
||||||
return -RT_EINVAL;
|
return -RT_EINVAL;
|
||||||
|
|
||||||
@ -486,6 +499,8 @@ void rt_system_pm_init(const struct rt_pm_ops *ops,
|
|||||||
|
|
||||||
pm->device_pm = RT_NULL;
|
pm->device_pm = RT_NULL;
|
||||||
pm->device_pm_number = 0;
|
pm->device_pm_number = 0;
|
||||||
|
|
||||||
|
_pm_init_flag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RT_USING_FINSH
|
#ifdef RT_USING_FINSH
|
||||||
|
Loading…
x
Reference in New Issue
Block a user