Add a delay function

This commit is contained in:
Eric Tang
2018-06-24 20:21:01 -07:00
parent 09a58b607c
commit 04f4053bde
2 changed files with 15 additions and 0 deletions

View File

@@ -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) {
;
}
}

View File

@@ -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