Add timer.[ch]

This commit is contained in:
László Monda
2017-11-12 04:48:06 +01:00
parent d0c689146e
commit a91f945591
6 changed files with 47 additions and 4 deletions

18
right/src/timer.c Normal file
View File

@@ -0,0 +1,18 @@
#include "fsl_pit.h"
#include "timer.h"
void Timer_Init(void)
{
pit_config_t pitConfig;
PIT_GetDefaultConfig(&pitConfig);
PIT_Init(PIT, &pitConfig);
PIT_SetTimerPeriod(PIT, PIT_TIMER_CHANNEL, USEC_TO_COUNT(TIMER_INTERVAL_USEC, PIT_SOURCE_CLOCK));
PIT_EnableInterrupts(PIT, PIT_TIMER_CHANNEL, kPIT_TimerInterruptEnable);
// EnableIRQ(PIT_TIMER_IRQ_ID);
PIT_StartTimer(PIT, PIT_TIMER_CHANNEL);
}
uint32_t Timer_GetTime(void)
{
return PIT_GetCurrentTimerCount(PIT, PIT_TIMER_CHANNEL);
}