hv_vos_Timer.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * @file hv_vos_Timer.h
  3. * @brief Header file of timer.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. * (+) Use ()
  10. *
  11. * @endverbatim
  12. * @author HiView SoC Software Team
  13. * @version 1.0.0
  14. * @date 2023-03-01
  15. */
  16. #ifndef _HV_VOS_TIMER_H
  17. #define _HV_VOS_TIMER_H
  18. #include "hv_vos_Types.h"
  19. VOS_EXTERN_C_BEGIN
  20. #define TIMER_NUM 70
  21. #define TIMER_ID_BEGIN 0x4000
  22. #define TIMER_ID_END (TIMER_ID_BEGIN + TIMER_NUM)
  23. typedef struct _HV_TIMER_S HV_TIMER_S;
  24. /// Timer callback function.
  25. typedef void (*osTimerFunc_t) (void *argument, USHORT16 usTimerId);
  26. /* Timer callback information structure definition */
  27. typedef struct {
  28. osTimerFunc_t func;
  29. void *arg;
  30. USHORT16 usTimerEvent;
  31. }TimerCallback_t;
  32. typedef struct _HV_TIMER_INIT_PARAMS{
  33. const CHAR8 * name; /* Software timer name for debug */
  34. UINT32 periodMs; /* Software timer period */
  35. BOOL reload; /* Software timer flase:one-shot; true:auto-reload */
  36. void *callbackArg; /* Software timer callback function argument */
  37. osTimerFunc_t callbackFn; /* Software timer callback function */
  38. USHORT16 usTimerEvent; /* Software timer eventID that send to conrresponding task */
  39. } HV_TIMER_INIT_PARAMS;
  40. /**
  41. * @brief Update software timer instance.
  42. * @param[in] void.
  43. * @return void.
  44. */
  45. VOID Hv_Vos_Timer_Update();
  46. /**
  47. * @brief Create software timer instance.
  48. * @param[in] timer init struct parm.
  49. * @return malloc timer instance.
  50. */
  51. HV_TIMER_S* Hv_Vos_Timer_Create(HV_TIMER_INIT_PARAMS *param);
  52. /**
  53. * @brief Delete software timer instance.
  54. * @param[in] Timer instance.
  55. * @return None.
  56. */
  57. void Hv_Vos_Timer_Delete(HV_TIMER_S *pstTimer);
  58. /**
  59. * @brief Start software timer instance.
  60. * @param[in] Timer instance.
  61. * @return None.
  62. */
  63. BOOL Hv_Vos_Timer_Start(HV_TIMER_S *pstTimer);
  64. /**
  65. * @brief Stop software timer instance.
  66. * @param[in] Timer instance.
  67. * @return None.
  68. */
  69. BOOL Hv_Vos_Timer_Stop(HV_TIMER_S *pstTimer);
  70. /**
  71. * @brief Queries a timer to see if it is active or dormant.
  72. * @param xTimer The timer being queried.
  73. * @return HV_FALSE will be returned if the timer is dormant. A value other than
  74. * pdHV_FALSE will be returned if the timer is active.
  75. * */
  76. BOOL Hv_Vos_Timer_IsTimerActive(HV_TIMER_S *pstTimer);
  77. /**
  78. * @brief Change software timer period.
  79. * @param[in] Timer instance.
  80. * @return None.
  81. */
  82. BOOL Hv_Vos_Timer_ChangePeriod(HV_TIMER_S *pstTimer, UINT32 uiPeriodMs);
  83. BOOL Hv_Vos_Timer_Rstart(HV_TIMER_S *pstTimer, UINT32 uiPeriodMs);
  84. BOOL Hv_Vos_Timer_Rstop(HV_TIMER_S *pstTimer);
  85. VOS_EXTERN_C_END
  86. #endif