gl_timer.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef __GL_TIMER_H__
  2. #define __GL_TIMER_H__
  3. #include "gl_types.h"
  4. #undef TIMER_METHOD_SIG
  5. #define TIMER_METHOD_SIG 0
  6. GL_UINT32 GL_GetRtc32(void);
  7. /******************************************************************************/
  8. /*!
  9. * @brief To create a one-shot or periodic timer.
  10. *
  11. * @param szName String identifier for the timer. Limit to 16 characters. Used wherever supported.
  12. * @param pTimerFunction Function to run when the timer fires.
  13. * @param pTimerArg parameter passed to timer_function
  14. * @param fTimerStart If DTV_TRUE, adds timer to system queue immediately. If DTV_FALSE, timer must be explicitly added to system queue using GL_TimerSchedule().
  15. * @param dInterval Timeout interval for firing either one-shot or periodic timer. Measured in milliseconds. The timeout value is relative, i.e., it is the delta from the current time. This parameter is valid only if fTimerStart=DTV_TRUE.
  16. * @param fPeriodic If DTV_TRUE, periodic timer will be created. If DTV_FALSE, one-shot timer will be created.
  17. * @param pTimerId Timer object identifier retuned by the API (on success)
  18. *
  19. * @return @a GL_SUCCESS on success
  20. * @return @a GL_FAILURE on failure
  21. *
  22. * @note Cannot be used from ISR/DSR.
  23. *******************************************************************************/
  24. GL_Status_t GL_TimerCreate(char *szName, void (*pTimerFunction)(void *pArg),
  25. void *pTimerArg, GL_BOOL fTimerStart, GL_UINT32 dInterval, GL_BOOL fPeriodic,
  26. GL_Timer_t *pTimerId);
  27. /******************************************************************************/
  28. /*!
  29. * @brief To delete a timer. Firing (or expiry) of timer simply removes it from the system queue; the timer still needs to be explicitly deleted. However, timer deletion automatically removes it from system queue (if the timer hasnt fired yet).
  30. *
  31. * @param timerId Timer object identifier
  32. *
  33. * @return @a GL_SUCCESS on success
  34. * @return @a GL_FAILURE on failure
  35. *
  36. * @note Cannot be used from ISR/DSR.
  37. *******************************************************************************/
  38. GL_Status_t GL_TimerDelete(GL_Timer_t timerId);
  39. /******************************************************************************/
  40. /*!
  41. * @brief To disable a timer.
  42. *
  43. * @param timerId Timer object identifier
  44. *
  45. * @return @a GL_SUCCESS on success
  46. * @return @a GL_FAILURE on failure
  47. *
  48. * @note Cannot be used from ISR/DSR.
  49. *******************************************************************************/
  50. GL_Status_t GL_TimerDisable(GL_Timer_t timerId);
  51. /******************************************************************************/
  52. /*!
  53. * @brief Modifies the timeout value of an existing timer and adds it to system queue immediately. It can be used within the timer function to add the timer back to the queue.
  54. *
  55. * @param timerId Timer object identifier
  56. * @param dNewInterval Specifies new timeout interval. Measured in milliseconds. The timeout value is relative, i.e., it is the delta from the current time.
  57. *
  58. * @return @a GL_SUCCESS on success
  59. * @return @a GL_FAILURE on failure
  60. *
  61. * @note None
  62. *******************************************************************************/
  63. GL_Status_t GL_TimerSchedule(GL_Timer_t timerId, GL_UINT32 dNewInterval);
  64. /******************************************************************************/
  65. /*!
  66. * @brief It returns a 32-bit timestamp that equals the current value of the hardware counter. The hardware counter is updated every [TBD] (minimum resolution), i.e., the counter will wrap around every [TBD] interval.
  67. *
  68. * @param void
  69. *
  70. * @return 32-bit timestamp of the hardware counter.
  71. *
  72. * @note Since the hardware timer service exists in kernel space, the API may lose resolution when used from user space because of the user-kernel transition (if any).
  73. *******************************************************************************/
  74. GL_UINT32 GL_GetTimestamp(void);
  75. /******************************************************************************/
  76. /*!
  77. * @brief To enable a timer.
  78. *
  79. * @param pTimerId Timer object identifier
  80. *
  81. * @return @a GL_SUCCESS on success
  82. * @return @a GL_FAILURE on failure
  83. *
  84. * @note Since the hardware timer service exists in kernel space, the API may lose resolution when used from user space because of the user-kernel transition (if any).
  85. *******************************************************************************/
  86. GL_Status_t GL_TimerEnable(GL_Timer_t timerId);
  87. GL_Status_t GL_TimerInit(void);//[20131024,shiangting]
  88. GL_Status_t GL_TimerGetReserveTime(GL_Timer_t timerId, sw_timespec *ptime);
  89. #if SW_TIMER_METHOD
  90. GL_Status_t GL_GetCurrTime(sw_timespec *pcur_time);
  91. #endif
  92. #endif // __GL_TIMER_H__