/**
 * @file hv_drvl_Timer.c
 * @brief timer driver driver abstract layer file.
 * @details This file provides the following functions: \n
 *          (1) system timer init/cleanup, start/stop\n
 *          (2) system timer set/read counter \n
 *          (3) system timer set/cleanup irq, set irq handler \n
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-06-12
 * @copyright Copyright(c),2023-6, Hiview Software. All rights reserved.
 * @par History:
 * <table>
 * <tr><th>Author       <th>Date            <th>Change Description
 * </table>
 */

#include "hv_vos_Comm.h"
#include "hv_chip_Config.h"
#include "hv_comm_Assert.h"
#include "hv_comm_Define.h"
#include "hv_drv_Timer.h"

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

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

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

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

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

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

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

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

/**@brief read system timer counter
 *  @param[in] self HwTmr structure pointer
 *  @param[out] read counter values
 */
UINT32 Hv_Drv_Tmr_ReadCounter(HwTmr *pstTmr)
{
    return Hv_Cal_Tmr_ReadCounter(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)
{
    Hv_Cal_Tmr_SetCounter(pstTmr, uiCount);
}

