Add a delay function
This commit is contained in:
@@ -3,9 +3,15 @@
|
||||
|
||||
static volatile uint32_t CurrentTime;
|
||||
|
||||
static volatile uint32_t delayLength;
|
||||
|
||||
void PIT_TIMER_HANDLER(void)
|
||||
{
|
||||
CurrentTime++;
|
||||
|
||||
if (delayLength) {
|
||||
--delayLength;
|
||||
}
|
||||
PIT_ClearStatusFlags(PIT, PIT_TIMER_CHANNEL, PIT_TFLG_TIF_MASK);
|
||||
}
|
||||
|
||||
@@ -45,3 +51,11 @@ uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time)
|
||||
*time = CurrentTime;
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
void Timer_Delay(uint32_t length)
|
||||
{
|
||||
delayLength = length;
|
||||
while (delayLength) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@
|
||||
void Timer_SetCurrentTime(uint32_t *time);
|
||||
uint32_t Timer_GetElapsedTime(uint32_t *time);
|
||||
uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time);
|
||||
void Timer_Delay(uint32_t length);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user