AMTS/Mieke/SW/ODD/systick.c

28 lines
532 B
C
Raw Normal View History

2018-03-18 22:43:59 +00:00
#include "systick.h"
volatile uint32_t SysTickCnt;
void SysTick_Handler()
{
2018-04-03 15:18:28 +00:00
// SysTick_Handler increments SysTickCnt
2018-03-18 22:43:59 +00:00
SysTickCnt++;
}
void systick_init(void)
{
2018-04-03 15:18:28 +00:00
// Init the systick clocks to a T = 1 ms
2018-03-18 22:43:59 +00:00
RCC_ClocksTypeDef clocks;
RCC_GetClocksFreq(&clocks);
SysTick_Config(clocks.HCLK_Frequency/1000 - 1);
2018-04-03 15:18:28 +00:00
// Set count to 0
2018-03-18 22:43:59 +00:00
SysTickCnt = 0;
}
void Wait(uint32_t ms)
{
2018-04-03 15:18:28 +00:00
// Wait specified time in milliseconds
2018-03-18 22:43:59 +00:00
uint32_t SysTickCntHold = SysTickCnt;
2018-04-03 15:18:28 +00:00
while((SysTickCnt - SysTickCntHold) <= ms);
2018-03-18 22:43:59 +00:00
}