osal_cbtimer.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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_cbtimer.h
  30. Revised:
  31. Revision:
  32. Description: This file contains the Callback Timer definitions.
  33. **************************************************************************************************/
  34. #ifndef OSAL_CBTIMER_H
  35. #define OSAL_CBTIMER_H
  36. #ifdef __cplusplus
  37. extern "C"
  38. {
  39. #endif
  40. /*********************************************************************
  41. * INCLUDES
  42. */
  43. /*********************************************************************
  44. * CONSTANTS
  45. */
  46. // Invalid timer id
  47. #define INVALID_TIMER_ID 0xFF
  48. // Timed out timer
  49. #define TIMEOUT_TIMER_ID 0xFE
  50. /*********************************************************************
  51. * VARIABLES
  52. */
  53. /*********************************************************************
  54. * MACROS
  55. */
  56. #define OSAL_CBTIMER_NUM_TASKS 1 // set by HZF, align to project setting
  57. #if ( OSAL_CBTIMER_NUM_TASKS == 0 )
  58. #error Callback Timer module shouldn't be included (no callback timer is needed)!
  59. #elif ( OSAL_CBTIMER_NUM_TASKS == 1 )
  60. #define OSAL_CBTIMER_PROCESS_EVENT( a ) ( a )
  61. #elif ( OSAL_CBTIMER_NUM_TASKS == 2 )
  62. #define OSAL_CBTIMER_PROCESS_EVENT( a ) ( a ), ( a )
  63. #else
  64. #error Maximum of 2 callback timer tasks are supported! Modify it here.
  65. #endif
  66. /*********************************************************************
  67. * TYPEDEFS
  68. */
  69. // Callback Timer function prototype. Callback function will be called
  70. // when the associated timer expires.
  71. //
  72. // pData - pointer to data registered with timer
  73. //
  74. typedef void (*pfnCbTimer_t)( uint8 *pData );
  75. /*********************************************************************
  76. * VARIABLES
  77. */
  78. /*********************************************************************
  79. * FUNCTIONS
  80. */
  81. /*
  82. * Callback Timer task initialization function.
  83. */
  84. extern void osal_CbTimerInit( uint8 taskId );
  85. /*
  86. * Callback Timer task event processing function.
  87. */
  88. extern uint16 osal_CbTimerProcessEvent( uint8 taskId, uint16 events );
  89. /*
  90. * Function to start a timer to expire in n mSecs.
  91. */
  92. extern Status_t osal_CbTimerStart( pfnCbTimer_t pfnCbTimer, uint8 *pData,
  93. uint16 timeout, uint8 *pTimerId );
  94. /*
  95. * Function to update a timer that has already been started.
  96. */
  97. extern Status_t osal_CbTimerUpdate( uint8 timerId, uint16 timeout );
  98. /*
  99. * Function to stop a timer that has already been started.
  100. */
  101. extern Status_t osal_CbTimerStop( uint8 timerId );
  102. /*********************************************************************
  103. *********************************************************************/
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif /* OSAL_CBTIMER_H */