diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-09-01 15:09:49 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-09-01 15:09:49 +0000 |
commit | 0c65db21d1bdc2ca3419f947288e08033f890662 (patch) | |
tree | c5a3ae24fb1e857edd2ea9b40faddf11a2be7024 /nuttx/include | |
parent | 0ec4fcc28f0c8601c4205d73a7e7f93f44f3c8e3 (diff) | |
download | px4-nuttx-0c65db21d1bdc2ca3419f947288e08033f890662.tar.gz px4-nuttx-0c65db21d1bdc2ca3419f947288e08033f890662.tar.bz2 px4-nuttx-0c65db21d1bdc2ca3419f947288e08033f890662.zip |
Add NSH date command
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3932 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/nuttx/pm.h | 175 |
1 files changed, 139 insertions, 36 deletions
diff --git a/nuttx/include/nuttx/pm.h b/nuttx/include/nuttx/pm.h index f40bca61f..184f00e9c 100644 --- a/nuttx/include/nuttx/pm.h +++ b/nuttx/include/nuttx/pm.h @@ -33,6 +33,27 @@ * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ +/* Definition of terms. Various "sleep" and low power consumption states + * have various names and are sometimes used in conflicting ways. In the + * PM logic, we will use the following terminology: + * + * NORMAL - The normal, full power operating mode. + * REDUCED - This is still basically normal operational mode, but with some + * simple changes to reduce power consumption. Perhaps this just + * means just dimming the backlight. + * STANDBY - Standby is a very low power consumption mode. It is the lowest + * power from which the system can recover quickly. + * SLEEP - The lowest power consumption mode. It may require some time + * to get back to normal operation from SLEEP (some parts may + * even require going through reset). + * + * State changes always proceed from higher to lower power usage: + * + * NORMAL->REDUCED->STANDBY->SLEEP + * ^ | | | + * | V V V + * +-------+---------+--------+ + */ #ifndef __INCLUDE_NUTTX_PM_H #define __INCLUDE_NUTTX_PM_H @@ -42,11 +63,30 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <nuttx/fs.h> + +#ifdef CONFIG_PM /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ +/* Configuration ************************************************************/ +/* Time slices */ + +#ifndef CONFIG_PM_SLICEMS +# define CONFIG_PM_SLICEMS 100 /* Default is 100 msec */ +#endif + +#ifndef CONFIG_PM_NREDUCED +# define CONFIG_PM_NREDUCED 30 /* Thiry IDLE slices to enter reduced mode */ +#endif + +#ifndef CONFIG_PM_NSTANDBY +# define CONFIG_PM_NSTANDBY 80 /* Eight IDLE slices to enter standby mode */ +#endif + +#ifndef CONFIG_PM_NSLEEP +# define CONFIG_PM_NSLEEP 150 /* 150 IDLE slices to enter standby mode */ +#endif /**************************************************************************** * Public Types @@ -56,33 +96,31 @@ * state indication is the state transition event. */ -enum pm_event_e +enum pm_state_e { - PM_IDLE = 0, /* Drivers will receive periodic idle indications. The driver - * may use these IDLE indications to perform driver-specific - * power optimizations. - */ - PM_SLEEP_PREP, /* This is a warning that the system is about to enter into - * sleep mode. The driver should begin whatever operations - * that may be required to enter sleep mode. The driver - * may abort the sleep mode by returning a non-zero value - * from the callback function. - */ - PM_STOP_PREP, /* This is a warning that the system is about to enter into - * stop mode. The driver should begin whatever operations - * that may be required to enter stop mode. The driver - * may abort the stop mode by returning a non-zero value - * from the callback function. - */ - PM_SLEEP, /* The system is entering sleep mode. The driver should - * already be prepared for this mode. - */ - PM_STOP, /* The system is entering stop mode. The driver should - * already be prepared for this mode. - */ - PM_RESUME, /* The system resuming normal operation. The driver should - * reinitialize for normal operation. - */ + PM_REDUCED = 0, /* Drivers will receive periodic this indications if it is + * appropriate to enter a simple reduced power state. This + * would include simple things such as displaying display back- + * lighting. The driver should essentially be ready to resume + * normal activity instantly. + * + * PM_REDUCED may be followed by PM_STANDBY or PM_RESUME. + */ + PM_STANDBY, /* The system is entering standby mode. The driver should + * already be prepared for this mode. + * + * PM_STANDBY may be followed PM_SLEEP or by PM_RESUME + */ + PM_SLEEP, /* The system is entering deep sleep mode. The driver should + * already be prepared for this mode. + * + * PM_SLEEP may be following by PM_RESUME + */ + PM_RESUME, /* The system is resuming normal operation. The driver should + * reinitialize for normal operation. + * + * PM_RESUME may be followed by PM_REDUCED. + */ } /* This structure contain pointers callback functions in the driver. These @@ -93,7 +131,53 @@ enum pm_event_e struct pm_callback_s { struct pm_callback_s *flink; /* Supports a singly linked list */ - int (*notify)(enum pm_event_e pmevent); /* PM event callback */ + + /************************************************************************** + * Name: prepare + * + * Description: + * Notify the driver to prepare for a new power confition .This is a + * warning that the system is about to enter into a new power state. The + * driver should begin whatever operations that may be required to enter + * power state. The driver may abort the state change mode by returning + * a non-zero value from the callback function + * + * Input Parameters: + * cb - Returned to the driver. The driver version of the callback + * strucure may include additional, driver-specific state + * data at the end of the structure. + * pmstate - Idenfifies the new PM state + * + * Returned Value: + * 0 (OK) means the event was successfully processed. Non-zero means + * means that the driver is not prepared to perform the tasks needed + * achieve this power setting. + * + **************************************************************************/ + + int (*prepare)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate); + + /************************************************************************** + * Name: notify + * + * Description: + * Notify the driver of new power state. This callback is called after + * all drivers have had the opportunity to prepare for the new power + * state. + * + * Input Parameters: + * cb - Returned to the driver. The driver version of the callback + * strucure may include additional, driver-specific state + * data at the end of the structure. + * pmstate - Idenfifies the new PM state + * + * Returned Value: + * 0 (OK) means the event was successfully processed. Non-zero means + * means that the driver failed to enter the power mode. + * + **************************************************************************/ + + int (*notify)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate); } /**************************************************************************** @@ -128,29 +212,41 @@ extern "C" { * ****************************************************************************/ -EXTERN int pm_register(FAR const struct pm_callback_s *callbacks); +EXTERN int pm_register(FAR struct pm_callback_s *callbacks); /**************************************************************************** - * Name: pm_broadcast + * Name: pm_changestate * * Description: * This function is used to platform-specific power managmeent logic. It - * will announce the power management event to all drivers that have - * registered for power management event callbacks. + * will announce the power management power management state change to all + * drivers that have registered for power management event callbacks. * - * + * Input Parameters: + * pmstate - Idenfifies the new PM state + * + * Returned Value: + * 0 (OK) means that the callback function for all registered drivers + * returned OK (meaning that they accept the state change). * ****************************************************************************/ -EXTERN int pm_broadcast(enum pm_event_s pmevent); +EXTERN int pm_changestate(enum pm_event_s pmstate); /**************************************************************************** * Name: pm_activity * * Description: * This function is called by a device driver to indicate that it is - * performing meaningful activities (non-idle). This will restart a - * idle timer and prevent entering reduced power states. + * performing meaningful activities (non-idle). This increment an activty + * cound and/or will restart a idle timer and prevent entering reduced + * power states. + * + * Input Parameters: + * None + * + * Returned Value: + * The current activity count. * ****************************************************************************/ @@ -164,6 +260,12 @@ EXTERN int pm_activity(void); * was called. A count of zero will indicate that no meaningful activity * occurred since the last time this function was called. * + * Input Parameters: + * None + * + * Returned Value: + * The current activity count. + * ****************************************************************************/ EXTERN int pm_checkactivity(void); @@ -174,4 +276,5 @@ EXTERN int pm_checkactivity(void); #endif #endif /* __ASSEMBLY__ */ +#endif /* CONFIG_PM */ #endif /* __INCLUDE_NUTTX_PM_H */ |