OSAL_PwrMgr.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**************************************************************************************************
  2. Filename: OSAL_PwrMgr.h
  3. Revised: $Date: 2007-10-28 18:41:49 -0700 (Sun, 28 Oct 2007) $
  4. Revision: $Revision: 15799 $
  5. Description: This file contains the OSAL Power Management API.
  6. Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef OSAL_PWRMGR_H
  34. #define OSAL_PWRMGR_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /*********************************************************************
  40. * INCLUDES
  41. */
  42. /*********************************************************************
  43. * MACROS
  44. */
  45. /*********************************************************************
  46. * TYPEDEFS
  47. */
  48. /* These attributes define sleep beheaver. The attributes can be changed
  49. * for each sleep cycle or when the device characteristic change.
  50. */
  51. typedef struct
  52. {
  53. uint16 pwrmgr_task_state;
  54. uint16 pwrmgr_next_timeout;
  55. uint16 accumulated_sleep_time;
  56. uint8 pwrmgr_device;
  57. } pwrmgr_attribute_t;
  58. /* With PWRMGR_ALWAYS_ON selection, there is no power savings and the
  59. * device is most likely on mains power. The PWRMGR_BATTERY selection allows
  60. * the HAL sleep manager to enter SLEEP LITE state or SLEEP DEEP state.
  61. */
  62. #define PWRMGR_ALWAYS_ON 0
  63. #define PWRMGR_BATTERY 1
  64. /* The PWRMGR_CONSERVE selection turns power savings on, all tasks have to
  65. * agree. The PWRMGR_HOLD selection turns power savings off.
  66. */
  67. #define PWRMGR_CONSERVE 0
  68. #define PWRMGR_HOLD 1
  69. /*********************************************************************
  70. * GLOBAL VARIABLES
  71. */
  72. /* This global variable stores the power management attributes.
  73. */
  74. extern pwrmgr_attribute_t pwrmgr_attribute;
  75. /*********************************************************************
  76. * FUNCTIONS
  77. */
  78. /*
  79. * Initialize the power management system.
  80. * This function is called from OSAL.
  81. *
  82. */
  83. extern void osal_pwrmgr_init( void );
  84. /*
  85. * This function is called by each task to state whether or not this
  86. * task wants to conserve power. The task will call this function to
  87. * vote whether it wants the OSAL to conserve power or it wants to
  88. * hold off on the power savings. By default, when a task is created,
  89. * its own power state is set to conserve. If the task always wants
  90. * to converse power, it doesn't need to call this function at all.
  91. * It is important for the task that changed the power manager task
  92. * state to PWRMGR_HOLD to switch back to PWRMGR_CONSERVE when the
  93. * hold period ends.
  94. */
  95. extern uint8 osal_pwrmgr_task_state( uint8 task_id, uint8 state );
  96. /*
  97. * This function is called on power-up, whenever the device characteristic
  98. * change (ex. Battery backed coordinator). This function works with the timer
  99. * to set HAL's power manager sleep state when power saving is entered.
  100. * This function should be called form HAL initialization. After power up
  101. * initialization, it should only be called from NWK or ZDO.
  102. */
  103. extern void osal_pwrmgr_device( uint8 pwrmgr_device );
  104. /*
  105. * This function is called from the main OSAL loop when there are
  106. * no events scheduled and shouldn't be called from anywhere else.
  107. */
  108. extern void osal_pwrmgr_powerconserve( void );
  109. /*********************************************************************
  110. *********************************************************************/
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif /* OSAL_PWRMGR_H */