diff options
| author | [email protected] <[email protected]> | 2012-09-15 12:34:15 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-09-15 12:34:15 +0000 |
| commit | 6a58ebee1fee196d92775262b877decdeb1ea428 (patch) | |
| tree | 01658e3b9fae8cd412ad4140306b495b7a742c36 /components/drivers/include | |
| parent | a1519350a4caa3b5d081f254398cf9a2655c6f85 (diff) | |
添加PM头文件
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2289 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/drivers/include')
| -rw-r--r-- | components/drivers/include/drivers/pm.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/components/drivers/include/drivers/pm.h b/components/drivers/include/drivers/pm.h new file mode 100644 index 0000000000..042acb2be4 --- /dev/null +++ b/components/drivers/include/drivers/pm.h @@ -0,0 +1,80 @@ +/* + * File : pm.h + * COPYRIGHT (C) 2012, Shanghai Real-Thread Technology Co., Ltd + * + * All rights reserved. + * + * Change Logs: + * Date Author Notes + * 2012-06-02 Bernard the first version + */ + +#ifndef __PM_H__ +#define __PM_H__ + +#include <rtthread.h> + +#ifdef RT_USING_PM +enum +{ + PM_HIGHSPEED_MODE = 0, /* mode 0 */ + PM_RUNNING_MODE, /* mode 1 */ + PM_SLEEP_MODE, /* mode 2 */ + PM_DEEPSLEEP_MODE, /* mode 3 */ + PM_TIMER_MODE, /* mode 4 */ + PM_DEEPTIMER_MODE, /* mode 5 */ + PM_SHUTDOWN_MODE, /* mode 6 */ + PM_DEEPSHUTDOWN_MODE, /* mode 7 */ + PM_MODE_MAX = PM_DEEPSHUTDOWN_MODE, +}; + +#define RT_PM_DEVICE(device) (struct rt_pm*)(device) + +/** + * device control flag to request or release power + */ +#define RT_PM_DEVICE_CTRL_REQUEST 0x01 +#define RT_PM_DEVICE_CTRL_RELEASE 0x02 + +struct rt_pm; +/** + * low power mode operations + */ +struct rt_pm_ops +{ + void (*enter)(struct rt_pm *pm); + void (*exit)(struct rt_pm *pm); + + void (*timer_start)(struct rt_pm *pm, rt_uint32_t timeout); + void (*timer_stop)(struct rt_pm *pm); + rt_uint32_t (*timer_get_tick)(struct rt_pm *pm); +}; + +/** + * power management + */ +struct rt_pm +{ + struct rt_device parent; + rt_uint8_t mode[PM_MODE_MAX + 1]; + rt_uint8_t pm_mode; /* current pm mode */ + rt_uint8_t timer_mask; + + rt_uint32_t pm_tick; + + const struct rt_pm_ops *ops; +};
+
+ + +void rt_pm_enter(void); +void rt_pm_exit(void); +void rt_pm_request(rt_ubase_t mode); +void rt_pm_release(rt_ubase_t mode); + +void rt_system_pm_init(const struct rt_pm_ops *ops, rt_uint8_t timer_mask, + void *user_data); + +#endif + +#endif |
