summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-05-10 09:30:21 +0800
committerGitHub <[email protected]>2019-05-10 09:30:21 +0800
commit1dd364b45a907935a7b67a2199e83dae582fd85b (patch)
treeacfe83b9630cdac82f4944c233d727a2cdef4d1f /components
parentc4cd2a1cc1d21d764487759f4b1438d86b9cad29 (diff)
parent598f2d360b3d93e4a074fce390621a8979cc5fe1 (diff)
Merge pull request #2666 from Zero-Free/pm_dev
[pm]add pm example and support for stm32l475-atk-pandora
Diffstat (limited to 'components')
-rw-r--r--components/drivers/pm/pm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/components/drivers/pm/pm.c b/components/drivers/pm/pm.c
index 98a993b526..3e9cf56c76 100644
--- a/components/drivers/pm/pm.c
+++ b/components/drivers/pm/pm.c
@@ -19,6 +19,7 @@
static struct rt_pm _pm;
static uint8_t _pm_default_sleep = RT_PM_DEFAULT_SLEEP_MODE;
static struct rt_pm_notify _pm_notify;
+static uint8_t _pm_init_flag = 0;
#define RT_PM_TICKLESS_THRESH (2)
@@ -215,6 +216,9 @@ void rt_system_power_manager(void)
{
uint8_t mode;
+ if (_pm_init_flag == 0)
+ return;
+
/* CPU frequency scaling according to the runing mode settings */
_pm_frequency_scaling(&_pm);
@@ -234,6 +238,9 @@ void rt_pm_request(uint8_t mode)
rt_base_t level;
struct rt_pm *pm;
+ if (_pm_init_flag == 0)
+ return;
+
if (mode > (PM_SLEEP_MODE_MAX - 1))
return;
@@ -256,6 +263,9 @@ void rt_pm_release(uint8_t mode)
rt_ubase_t level;
struct rt_pm *pm;
+ if (_pm_init_flag == 0)
+ return;
+
if (mode > (PM_SLEEP_MODE_MAX - 1))
return;
@@ -423,6 +433,9 @@ int rt_pm_run_enter(uint8_t mode)
rt_base_t level;
struct rt_pm *pm;
+ if (_pm_init_flag == 0)
+ return -RT_EIO;
+
if (mode > PM_RUN_MODE_MAX)
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_number = 0;
+
+ _pm_init_flag = 1;
}
#ifdef RT_USING_FINSH