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