📄 msapi_timer.c
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2007 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (¨MStar Confidential Information〃) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
/// @file msAPI_Timer.h
/// @brief API for Timer functions
/// @author MStar Semiconductor, Inc.
//
////////////////////////////////////////////////////////////////////////////////
#define MSAPI_TIMER_C
/******************************************************************************/
/* Header Files */
/******************************************************************************/
#include "DataType.h"
#include "drvtimer.h"
#include "msAPI_Timer.h"
#include "drvsys.h"
/********************************************************************************/
/* Functions */
/********************************************************************************/
static BIT fSetSystemTime = 1;
/********************************************************************************/
/* Functions */
/********************************************************************************/
/******************************************************************************/
/// API for Get system time ticks
/// @return -Current system time counts, the unit is system default.
/******************************************************************************/
U32 msAPI_Timer_GetTime0(void)
{
return MDrv_Timer_GetTime0();
}
/******************************************************************************/
/// API for Get system down timer ticks
/// @return -Current system time counts, the unit is system default.
/******************************************************************************/
U32 msAPI_Timer_GetDownTimer0(void)
{
return MDrv_Timer_GetDownTimer0();
}
U32 msAPI_Timer_GetDownTimer1(void)
{
return MDrv_Timer_GetDownTimer1();
}
/******************************************************************************/
/// API for Set system down timer ticks
/// @return -Current system time counts, the unit is system default.
/******************************************************************************/
void msAPI_Timer_SetDownTimer0(U32 u32Timer)
{
MDrv_Timer_SetDownTimer0(u32Timer);
}
void msAPI_Timer_SetDownTimer1(U32 u32Timer)
{
MDrv_Timer_SetDownTimer1(u32Timer);
}
/******************************************************************************/
/// API for Calculate the difference of two time values. This function will handle overflow problem.
/// @param -u32Timer \b IN First time value to calculate
/// @param -u32TaskTimer \b IN 2nd time value to calculate
/// @return -Time difference of 2 time values.
/******************************************************************************/
U32 msAPI_Timer_TimeDifference(U32 u32Timer, U32 u32TaskTimer) //unit = ms
{
if (u32TaskTimer >= u32Timer)
return 0;
else
return MDrv_Timer_TimeDifference(u32Timer, u32TaskTimer);
}
/******************************************************************************/
/// API for Calculating the difference between time in parameter and current time.
/// @param -u32TaskTimer \b IN 2nd time value to calculate
/// @return -Time difference between current time and task time
/******************************************************************************/
U32 msAPI_Timer_TimeDifferenceFromCurrent(U32 u32TaskTimer) //unit = ms
{
return (MDrv_Timer_GetTime0() - u32TaskTimer);
}
/********************************************************************************/
/// API for Delay function
/// @param -u32DelayTime \b IN required time period to delay.
/********************************************************************************/
void msAPI_Timer_Delayms(U32 u32DelayTime) //unit = ms
{
MDrv_Timer_Delayms(u32DelayTime);
}
/******************************************************************************/
/// API for Get system time.
/// @return -Current system time counts
///
/// The unit depends on the "period" which is setting by USER_TIMER_PERIOD
/******************************************************************************/
U32 msAPI_Timer_GetSystemTime(void) //unit = sec
{
return MDrv_Timer_GetSystemTime0();
}
/******************************************************************************/
/// API for Get Wakeup time.
/// @return -User setting wake up time
/******************************************************************************/
U32 msAPI_Timer_GetWakeupTime(void)
{
return MDrv_Timer_GetWakeupTime();
}
/******************************************************************************/
/// API for Set system time.
/// @param -u32SystemTime \b IN System time to set
///
/// The unit is depends on the "period" which is setting by USER_TIMER_PERIOD
/******************************************************************************/
void msAPI_Timer_SetSystemTime(U32 u32SystemTime) //unit = sec
{
MDrv_Timer_SetSystemTime0(u32SystemTime);
fSetSystemTime = 1;
}
/******************************************************************************/
/// API for check if system time has been set
/******************************************************************************/
BOOLEAN msAPI_Timer_IsSystemTimeValid(void)
{
return (BOOLEAN)(fSetSystemTime);
}
/******************************************************************************/
/// API for Set Wakeup time.
/// @param -u32Time \b IN Wake up time to set
/******************************************************************************/
void msAPI_Timer_SetWakeupTime(U32 u32Time) //unit = sec
{
MDrv_Timer_SetWakeupTime(u32Time);
}
/******************************************************************************/
void msAPI_Timer_ResetWDT(void)
{
MDrv_Sys_ClearWatchDog();
}
/********************************************************************************/
void msAPI_Timer_DisableSystemTime()
{
MDrv_Timer_SetSystemTime0(0);
fSetSystemTime = 0;
}
#undef MSAPI_TIMER_C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -