/**
 * @file hv_vos_Time.c
 * @brief 
 * @details 
 * @author HiView SoC Software Team
 * @version 0.0.1
 * @date 20230301
 * @copyright Copyright(c),2023-3, Hiview Software. All rights reserved.
 * @par History: 
 * <table>
 * <tr><th>author                     <th>date           <th>description
 * <tr><td>HiView SoC Software Team   <td>20230301       <td>Create and first Version.
 * </table>
**/

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "hv_vos_Time.h"
#include "hv_vos_Irq.h"
#include "hv_chip_Config.h"

void Hv_Vos_InitTime(void)
{ 
    return;
}

void Hv_Vos_CleanupTime(void)
{ 
    return;
}

/* freeRTOS ticks quals  (1000/configTICK_RATE_HZ) ms. */
UINT64 Hv_Vos_GetTick(void) 
{
    return xTaskGetTickCount();
}

UINT64 Hv_Vos_MsToTick(UINT32 uiMilliseconds)
{   
    return pdMS_TO_TICKS(uiMilliseconds);
}

void Hv_Vos_MSleep(UINT32 uiMilliseconds)
{
    vTaskDelay(pdMS_TO_TICKS(uiMilliseconds));
}

void Hv_Vos_MSleepUntil(UINT32 uiMilliseconds)
{
    portTickType xNextWakeTime = Hv_Vos_GetTick();
    vTaskDelayUntil(&xNextWakeTime, uiMilliseconds);
}

/* Notice the us should not too large to hold the CPU */
void Hv_Vos_Delayus(UINT32 us)
{
    UINT32 uiCnt  = us * HV_CHIP_DELAY_CLK;
    while(uiCnt--)
    {
        asm("nop");
    }
}


