OSAL_PwrMgr.h 5.3 KB

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