/*
 * @file hv_vos_Timer.h
 * @brief Header file of timer.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-03-01
 */



#ifndef _HV_VOS_TIMER_H
#define _HV_VOS_TIMER_H

#include "hv_vos_Types.h"


VOS_EXTERN_C_BEGIN

#define TIMER_NUM           70
#define TIMER_ID_BEGIN      0x4000
#define TIMER_ID_END        (TIMER_ID_BEGIN + TIMER_NUM)

typedef struct _HV_TIMER_S HV_TIMER_S;

/// Timer callback function.
typedef void (*osTimerFunc_t) (void *argument, USHORT16 usTimerId);
/* Timer callback information structure definition */
typedef struct {
  osTimerFunc_t func;
  void         *arg;
  USHORT16     usTimerEvent;
}TimerCallback_t;

typedef struct _HV_TIMER_INIT_PARAMS{
    const CHAR8 * name;              /* Software timer name for debug */
    UINT32 periodMs;                 /* Software timer period */
    BOOL reload;                     /* Software timer flase:one-shot; true:auto-reload */
    void *callbackArg;               /* Software timer callback function argument */
    osTimerFunc_t callbackFn;        /* Software timer callback function */
    USHORT16  usTimerEvent;          /* Software timer eventID that send to conrresponding task */
} HV_TIMER_INIT_PARAMS;

/**
 * @brief Update software timer instance.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Vos_Timer_Update();

/**
 * @brief Create software timer instance.
 * @param[in] timer init struct parm.
 * @return malloc timer instance.
 */
HV_TIMER_S* Hv_Vos_Timer_Create(HV_TIMER_INIT_PARAMS *param);

/**
 * @brief Delete software timer instance.
 * @param[in] Timer instance.
 * @return None.
 */
void Hv_Vos_Timer_Delete(HV_TIMER_S *pstTimer);

/**
 * @brief Start software timer instance.
 * @param[in] Timer instance.
 * @return None.
 */
BOOL Hv_Vos_Timer_Start(HV_TIMER_S *pstTimer);

/**
 * @brief Stop software timer instance.
 * @param[in] Timer instance.
 * @return None.
 */
BOOL Hv_Vos_Timer_Stop(HV_TIMER_S *pstTimer);

/**

 * @brief Queries a timer to see if it is active or dormant.
 * @param xTimer The timer being queried.
 * @return HV_FALSE will be returned if the timer is dormant.  A value other than
 * pdHV_FALSE will be returned if the timer is active.
 * */
BOOL Hv_Vos_Timer_IsTimerActive(HV_TIMER_S *pstTimer);

/**
 * @brief Change software timer period.
 * @param[in] Timer instance.
 * @return None.
 */
BOOL Hv_Vos_Timer_ChangePeriod(HV_TIMER_S *pstTimer, UINT32 uiPeriodMs);


BOOL Hv_Vos_Timer_Rstart(HV_TIMER_S *pstTimer, UINT32 uiPeriodMs);

BOOL Hv_Vos_Timer_Rstop(HV_TIMER_S *pstTimer);


VOS_EXTERN_C_END


#endif



