From 6a58ebee1fee196d92775262b877decdeb1ea428 Mon Sep 17 00:00:00 2001 From: "sc943313837@gmail.com" Date: Sat, 15 Sep 2012 12:34:15 +0000 Subject: 添加PM头文件 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2289 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/drivers/include/drivers/pm.h | 80 +++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 components/drivers/include/drivers/pm.h (limited to 'components') 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 + +#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 -- cgit v1.3.1