Changed CurrentTime to a static variable and added function for getting the current time instead

Global variables are really bad practice and should be avoided
This commit is contained in:
Kristian Sloth Lauszus
2018-03-11 17:59:23 +01:00
parent 8f4fc1da8e
commit 6e2eca7829
5 changed files with 10 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
#include "fsl_pit.h"
#include "timer.h"
volatile uint32_t CurrentTime;
static volatile uint32_t CurrentTime;
void PIT_TIMER_HANDLER(void)
{
@@ -24,6 +24,10 @@ void Timer_Init(void)
PIT_StartTimer(PIT, PIT_TIMER_CHANNEL);
}
uint32_t Timer_GetCurrentTime() {
return CurrentTime;
}
void Timer_SetCurrentTime(uint32_t *time)
{
*time = CurrentTime;