📄 timer.h
字号:
// and then stops. -
// -TIMER_AUTORELOAD_MODE => the timer restarts when it passes through zero -
//
// -TimerScaler => TIMER_PRE_SCALE_2
// TIMER_PRE_SCALE_4
// TIMER_PRE_SCALE_8
// TIMER_PRE_SCALE_16
// TIMER_PRE_SCALE_32
// TIMER_PRE_SCALE_64
// TIMER_PRE_SCALE_128
// TIMER_PRE_SCALE_256
// -
//-for watchdog timer------------------------------------------------------------
//-------------------------------------------------------------------------------
// TimerScaler = Prescale value used to define the interrupt period Tint: -
// Tint = Tclk *(LoadValue+1) * 2**(TimerScaler+1) -
// Fclk=928 Khz => Tclk=1/Fclk=1.08 Us -
// |--------------------------------------------------| -
// | LoadValue | ClockScale = 0 | ClockScale = 7 | -
// |------------|------------------|------------------| -
// | 0000 | 2.156 us | 275.8 us | -
// | FFFF | 141.2 ms | 18.078 s | -
// |--------------------------------------------------| -
// -
//-for OS timers-----------------------------------------------------------------
//-------------------------------------------------------------------------------
// TimerScaler = Prescale value used to define the interrupt period Tint: -
// Tint = Tclk *(LoadValue+1) * 2**(TimerScaler+1) -
// Fclk=100 Mhz => Tclk=1/Fclk=10 ns -
// |-------------------------------------------------------|
// | LoadValue | ClockScale = 0 | ClockScale = 7 |
// |-----------------|------------------|------------------|
// | 0000:0000 | 20 ns | 2.56 us |
// | FFFF:FFFF | 85.9 s | 11000 s |<=> 3h3'20''
// |-------------------------------------------------------|
//--------------------------------------------------------------------------------
// -
// RETURN VALUE: OK or NOT_OK if problem -
// LIMITATIONS : To prevent from some undefined results, must not be called -
// when the timer is running -
//-------------------------------------------------------------------------------
BOOL TIME_SetupTimer(TIMER_NAME_t TimerName, UWORD32 LoadValue, TIMER_MODE_t TimerMode, TIMER_SCALER_t TimerScale) ;
//---------------------------------------------------------------------
// NAME : TIME_LoadTimerValue -
// DESCRIPTION : Write the Setup Counter value into Load Register -
// SYNOPSYS : void TIME_LoadTimerValue(TIMER_NAME_t WhichTimer,
// UNSIGNED32 CounterValue); -
// PARAMETERS :
// WhichTimer = Timer name to load -
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
//
// CountValue = Timer setup value ti load
// -
// RETURN VALUE: OK or NOT_OK
// -
// LIMITATIONS : To prevent from some undefined results, must not be -
// called when the timer is running -
// The new value from the Load Register is written into -
// the Timer when passing through zero or when starting -
//---------------------------------------------------------------------
BOOL TIME_LoadTimerValue(TIMER_NAME_t WhichTimer, UWORD32 CounterValue) ;
//---------------------------------------------------------------------
// NAME : TIME_ReadLoadTimerValue -
// DESCRIPTION : Read the Setup Counter value into Load Register -
// SYNOPSYS : UWORD32 TIME_ReadTimerValue(TIMER_NAME_t WhichTimer); -
// PARAMETERS :
// WhichTimer = Timer name to read -
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
// -
// RETURN VALUE: Value of the register
// -
//---------------------------------------------------------------------
UWORD32 TIME_ReadLoadTimerValue(TIMER_NAME_t WhichTimer) ;
//---------------------------------------------------------------------
// NAME : TIME_ReadTimerValue -
// DESCRIPTION : Read the value into the timer Register -
// SYNOPSYS : UWORD32 TIME_ReadTimerValue(TIMER_NAME_t WhichTimer); -
// PARAMETERS :
// WhichTimer = Timer name to read -
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
// -
// RETURN VALUE: Value of the register
// -
//---------------------------------------------------------------------
UWORD32 TIME_ReadTimerValue(TIMER_NAME_t WhichTimer) ;
//---------------------------------------------------------------------
// NAME : TIME_ReadPtv
// DESCRIPTION : Read the PTV value in cntl register
// SYNOPSYS : UWORD32 TIME_ReadPtv(TIMER_NAME_t WhichTimer); -
// PARAMETERS :
// WhichTimer = Timer name to read -
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
// -
// RETURN VALUE: Value of the PTV
// -
//---------------------------------------------------------------------
UWORD32 TIME_ReadPtv(TIMER_NAME_t WhichTimer);
//------------------------------------------------
// NAME : TIME_StartTimer -
// TIME_StopTimer
// DESCRIPTION : Start and Stop the timer -
// SYNOPSYS : void TIME_StartTimer(void); -
// void TIME_StopTimer (void); -
// PARAMETERS : TIMER_NAME_t TimerName -
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
// RETURN VALUE: None -
// LIMITATIONS : None -
//------------------------------------------------
BOOL TIME_StartTimer(TIMER_NAME_t TimerName);
BOOL TIME_StopTimer(TIMER_NAME_t TimerName);
//--------------------------------------------------------------
// NAME : TIME_ReadCntlTimer -
// DESCRIPTION : Read the Cnt Timer value -
// SYNOPSYS : UWORD32 TIME_ReadCntlTimer(TIMER_NAME_t TimerName) -
// PARAMETERS : -
// TimerName = Name of the timer requested -
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
// RETURN VALUE: UWORD32 -
// LIMITATIONS : None -
//--------------------------------------------------------------
UWORD32 TIME_ReadCntlTimer(TIMER_NAME_t TimerName );
//----------------------------------------------------------
// NAME : TIME_IsTimerRunning -
// DESCRIPTION : Check whether the timer is running or not -
// PARAMETERS : TimerName -
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
// RETURN VALUE: True if it's running otherwise False -
// LIMITATIONS : None -
//----------------------------------------------------------
BOOL TIME_IsTimerRunning(TIMER_NAME_t TimerName);
//-------------------------------------------------------
//---------------------------------------------------------
// Wdg Functions
//---------------------------------------------------------
//---------------------------------------------------------
//----------------------------------------------------------
// NAME : TIME_WdgDisable -
// DESCRIPTION : Writting a predefined sequence
// 0xF5 followed by 0xA0 in the 8 lsb bits
// to disable the watchdog
// PARAMETERS : None -
// RETURN VALUE: IS_OK if the watchdog has stopped
// NOT_OK if not -
// LIMITATIONS : None -
// ----------------------------------------------------------
BOOL TIME_WdgDisable(void);
//----------------------------------------------------------
// NAME : TIME_EnableInputClock
// DESCRIPTION : Enable the input clock from the CLKM and in
// the timer for the OSTIMERs
// PARAMETERS : TimerName
// OSTIMER1
// OSTIMER2
// OSTIMER3
// WDGTIMER
//
// RETURN VALUE: IS_OK if the operation succeed
// NOT_OK if not -
// LIMITATIONS : None -
// ----------------------------------------------------------
BOOL TIME_EnableInputClock(TIMER_NAME_t TimerName);
//----------------------------------------------------------
// NAME : TIME_WdgEnable -
// DESCRIPTION : Set the wdg timer in Watchdog mode
//
// PARAMETERS : None
// RETURN VALUE: IS_OK if the watchdog run
// NOT_OK if not
// LIMITATIONS : None -
// ----------------------------------------------------------
BOOL TIME_WdgEnable(void);
//----------------------------------------------------------
// NAME : TIME_TestWdgMode -
// DESCRIPTION : Test the wdg timer mode
//
// PARAMETERS : None
// RETURN VALUE: WDG_MODE if the watchdog run
// TIMER_MODE if not
// LIMITATIONS : None -
// ----------------------------------------------------------
BOOL TIME_TestWdgMode(void);
//----------------------------------------------------------
// NAME : TIME_ResetIsCorrect
// DESCRIPTION : Test the reset value of timer's registers
//
// PARAMETERS : Timer name
// RETURN VALUE: TRUE if succeed, FALSE if not
//
// LIMITATIONS : Do use only when .result has been initialiazed (RES_SetLocation)
// -------------------------------------------------------------------------------
// 1 Word stored for ostimer
// 3 Words stored for wdg timer
//-------------------------------------------------------------------
BOOL TIME_ResetIsCorrect(TIMER_NAME_t TimerName);
//----------------------------------------------------------
// NAME : TIME_WdgReffresh -
// DESCRIPTION : Load a value in the watchdog to avoid a watchdog reset
//
// PARAMETERS : None
// RETURN VALUE: IS_OK if succeed NOT_OK if not
//
// LIMITATIONS : None -
// ----------------------------------------------------------
BOOL TIME_WdgReffresh(void);
//----------------------------------------------------------
// NAME : TIME_WaitUs -
// DESCRIPTION : Wait the time specified in parameter,
// - by pooling the timer when BlockOrNotMode == POLLING_MODE
// - by generating an interrupt when BlockOrNotMode == NOTPOLLING_MODE
// PARAMETERS : TimerName -
// OSTIMER1
// OSTIMER2
// OSTIMER3
//
// BlockOrNotMode POLLING_MODE or NOTPOLLING_MODE
//
// ValueInUs
//
// PARAMETERS : None
// RETURN VALUE: IS_OK if succeed NOT_OK if not
//
// LIMITATIONS : None -
// ----------------------------------------------------------
BOOL TIME_WaitUs(TIMER_NAME_t TimerName,BOOL BlockOrNotMode,UWORD16 ValueInUs);
#define POLLING_MODE TRUE
#define NOTPOLLING_MODE FALSE
//----------------------------------------------------------
// NAME : TIME_WaitMs -
// DESCRIPTION : Wait the time specified in parameter
// PARAMETERS : time_in_ms
//
// PARAMETERS : None
// RETURN VALUE: None
//
// LIMITATIONS : ARM clock frequency : +/- 250 MHz -
// ----------------------------------------------------------
void TIME_WaitMs(UWORD32 time_in_ms);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -