blob: f328ae0cc30be313261ccff72c5b6b4113a52dac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "systick.h"
#define MILLIS_INC 1
volatile uint32_t systick_timer_overflow_count = 0;
volatile uint32_t systick_timer_millis = 0;
static uint8_t systick_timer_fract = 0;
void systick_init(void) {
/* Set the reload counter to tick every 1ms */
SYSTICK_RELOAD = MAPLE_RELOAD_VAL;
/* Clock the system timer with the core clock
* and turn it on, interrrupt every 1ms to keep track of millis()*/
SYSTICK_CSR = SYSTICK_SRC_HCLK |
SYSTICK_ENABLE |
SYSTICK_TICKINT;
}
void SysTickHandler(void)
{
uint32_t m = systick_timer_millis;
uint8_t f = systick_timer_fract;
m += MILLIS_INC;
systick_timer_millis = m;
systick_timer_overflow_count++;
}
|