OSAL_Timers.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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_Timers.h
  30. Revised:
  31. Revision:
  32. Description: This file contains the OSAL Timer definition and manipulation functions.
  33. **************************************************************************************************/
  34. #ifndef OSAL_TIMERS_H
  35. #define OSAL_TIMERS_H
  36. #ifdef __cplusplus
  37. extern "C"
  38. {
  39. #endif
  40. /*********************************************************************
  41. * INCLUDES
  42. */
  43. /*********************************************************************
  44. * MACROS
  45. */
  46. /*********************************************************************
  47. * CONSTANTS
  48. * the unit is chosen such that the 320us tick equivalent can fit in
  49. * 32 bits.
  50. */
  51. #define OSAL_TIMERS_MAX_TIMEOUT 0x28f5c28e /* unit is ms*/
  52. /*********************************************************************
  53. * TYPEDEFS
  54. */
  55. /*********************************************************************
  56. * GLOBAL VARIABLES
  57. */
  58. /*********************************************************************
  59. * FUNCTIONS
  60. */
  61. /*
  62. * Initialization for the OSAL Timer System.
  63. */
  64. extern void osalTimerInit( void );
  65. /*
  66. * Set a Timer
  67. */
  68. extern uint8 osal_start_timerEx( uint8 task_id, uint16 event_id, uint32 timeout_value );
  69. /*
  70. * Set a timer that reloads itself.
  71. */
  72. extern uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32 timeout_value );
  73. /*
  74. * Stop a Timer
  75. */
  76. extern uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id );
  77. /*
  78. * Get the tick count of a Timer.
  79. */
  80. extern uint32 osal_get_timeoutEx( uint8 task_id, uint16 event_id );
  81. /*
  82. * Simulated Timer Interrupt Service Routine
  83. */
  84. extern void osal_timer_ISR( void );
  85. /*
  86. * Adjust timer tables
  87. */
  88. extern void osal_adjust_timers( void );
  89. /*
  90. * Update timer tables
  91. */
  92. extern void osalTimerUpdate( uint32 updateTime );
  93. /*
  94. * Count active timers
  95. */
  96. extern uint8 osal_timer_num_active( void );
  97. /*
  98. * Set the hardware timer interrupts for sleep mode.
  99. * These functions should only be called in OSAL_PwrMgr.c
  100. */
  101. extern void osal_sleep_timers( void );
  102. extern void osal_unsleep_timers( void );
  103. /*
  104. * Read the system clock - returns milliseconds
  105. */
  106. extern uint32 osal_GetSystemClock( void );
  107. /*
  108. * Get the next OSAL timer expiration.
  109. * This function should only be called in OSAL_PwrMgr.c
  110. */
  111. extern uint32 osal_next_timeout( void );
  112. /*********************************************************************
  113. *********************************************************************/
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif /* OSAL_TIMERS_H */