28 lines
644 B
C++
28 lines
644 B
C++
#include "stm32g4xx.h"
|
|
|
|
#include "tim.h"
|
|
|
|
static unsigned long Tick = 0;
|
|
|
|
extern "C" void SysTick_Handler()
|
|
{
|
|
Tick++;
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
|
|
void TICK_Init()
|
|
{
|
|
SysTick->LOAD = SystemCoreClock / 1000;
|
|
SysTick->VAL = 0UL;
|
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
|
|
|
|
NVIC_SetPriority(SysTick_IRQn, 0);
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
|
|
unsigned long TICK_GetCount() // ms
|
|
{
|
|
return Tick;
|
|
}
|
|
//------------------------------------------------------------------------------
|