osal_cbtimer.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**************************************************************************************************
  2. Filename: osal_cbtimer.h
  3. Revised:
  4. Revision:
  5. Description: This file contains the Callback Timer definitions.
  6. **************************************************************************************************/
  7. #ifndef OSAL_CBTIMER_H
  8. #define OSAL_CBTIMER_H
  9. #ifdef __cplusplus
  10. extern "C"
  11. {
  12. #endif
  13. /*********************************************************************
  14. * INCLUDES
  15. */
  16. /*********************************************************************
  17. * CONSTANTS
  18. */
  19. // Invalid timer id
  20. #define INVALID_TIMER_ID 0xFF
  21. // Timed out timer
  22. #define TIMEOUT_TIMER_ID 0xFE
  23. /*********************************************************************
  24. * VARIABLES
  25. */
  26. /*********************************************************************
  27. * MACROS
  28. */
  29. #define OSAL_CBTIMER_NUM_TASKS 2 // set by HZF, align to TI project setting
  30. #if ( OSAL_CBTIMER_NUM_TASKS == 0 )
  31. #error Callback Timer module shouldn't be included (no callback timer is needed)!
  32. #elif ( OSAL_CBTIMER_NUM_TASKS == 1 )
  33. #define OSAL_CBTIMER_PROCESS_EVENT( a ) ( a )
  34. #elif ( OSAL_CBTIMER_NUM_TASKS == 2 )
  35. #define OSAL_CBTIMER_PROCESS_EVENT( a ) ( a ), ( a )
  36. #else
  37. #error Maximum of 2 callback timer tasks are supported! Modify it here.
  38. #endif
  39. /*********************************************************************
  40. * TYPEDEFS
  41. */
  42. // Callback Timer function prototype. Callback function will be called
  43. // when the associated timer expires.
  44. //
  45. // pData - pointer to data registered with timer
  46. //
  47. typedef void (*pfnCbTimer_t)( uint8 *pData );
  48. /*********************************************************************
  49. * VARIABLES
  50. */
  51. /*********************************************************************
  52. * FUNCTIONS
  53. */
  54. /*
  55. * Callback Timer task initialization function.
  56. */
  57. extern void osal_CbTimerInit( uint8 taskId );
  58. /*
  59. * Callback Timer task event processing function.
  60. */
  61. extern uint16 osal_CbTimerProcessEvent( uint8 taskId, uint16 events );
  62. /*
  63. * Function to start a timer to expire in n mSecs.
  64. */
  65. extern Status_t osal_CbTimerStart( pfnCbTimer_t pfnCbTimer, uint8 *pData,
  66. uint16 timeout, uint8 *pTimerId );
  67. /*
  68. * Function to update a timer that has already been started.
  69. */
  70. extern Status_t osal_CbTimerUpdate( uint8 timerId, uint16 timeout );
  71. /*
  72. * Function to stop a timer that has already been started.
  73. */
  74. extern Status_t osal_CbTimerStop( uint8 timerId );
  75. /*********************************************************************
  76. *********************************************************************/
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* OSAL_CBTIMER_H */