/*
 * @file hv_drv_Timer.h
 * @brief Header file of hw timer module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use Hv_Drv_Tmr_Init()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-06-12
 */

#ifndef _HV_DRV_TIMER_H
#define _HV_DRV_TIMER_H
#include "hv_cal_Timer.h"

/** @defgroup
 *  driver system timer functions
 *  @{
 */

/**@brief init tmr parameters
 *  @param params pointer to tmr configure parameters
 *  @return HwTmr structure pointer
 */
HwTmr *Hv_Drv_Tmr_Init(HwTmrConfig *pstTmrCfg);

/** @brief stop timer
 *  @param[in] self HwTmr structure pointer
 */
VOID Hv_Drv_Tmr_Stop(HwTmr *pstTmr);


/**@brief Cleanup tmr parameters
 *  @param self HwTmr structure pointer
 */
VOID Hv_Drv_Tmr_Cleanup(HwTmr *pstTmr);


/**@brief set tmr ms counter register values, use before Hv_Drv_Tmr_Start
 *  @param[in] self HwTmr structure pointer
 *  @param[in] uiMsCounts count ms time
 */
VOID Hv_Drv_Tmr_SetMsCounter(HwTmr *pstTmr, UINT32 uiMsCounts);


/**@brief set system timer ISR handler function
 *  @param irqNum interrupt Number value
 *  @param arg pointer to tmr configure parameters
 *  @return ISR HV_VOS_ISR_RESULT_E result
 */
HV_VOS_ISR_RESULT_E Hv_Drv_Tmr_IrqHandler(UINT32 uiIrqNum, VOID *pArg);

/**@brief set system timer interrupt
 *  @param self HwTmr structure pointer
 */
VOID Hv_Drv_Tmr_SetInterrupt(HwTmr *pstTmr);

/**@brief clean system timer interrupt
 *  @param self HwTmr structure pointer
 */
VOID Hv_Drv_Tmr_ClearInterrupt(HwTmr *pstTmr);

/**@brief start system timer
 *  @param self HwTmr structure pointer
 */
VOID Hv_Drv_Tmr_Start(HwTmr *pstTmr);

/**@brief read system timer counter
 *  @param[in] self HwTmr structure pointer
 *  @param[out] read counter values
 */
UINT32 Hv_Drv_Tmr_ReadCounter(HwTmr *pstTmr);

/** set system timer counter
 *  @param[in] self HwTmr structure pointer
 *  @param[in] count count values
 */
VOID Hv_Drv_Tmr_SetCounter(HwTmr *pstTmr, UINT32 uiCount);

/** @} */
#endif

