36 lines
		
	
	
		
			621 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			621 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <systick.h>
 | |
| #include <stm32f0xx.h>
 | |
| 
 | |
| static volatile uint32_t global_systick = 0;
 | |
| static volatile uint32_t systick_wait_counter;
 | |
| static volatile uint32_t blink_cntr = 0;
 | |
| static volatile bool blink_state = false;
 | |
| 
 | |
| void systick_wait_ms(uint32_t ms)
 | |
| {
 | |
| 	systick_wait_counter = ms;
 | |
| 	
 | |
| 	while (systick_wait_counter > 0)
 | |
| 		__WFI();
 | |
| }
 | |
| 
 | |
| bool systick_get_blink_state(void)
 | |
| {
 | |
| 	return blink_state;
 | |
| }
 | |
| 
 | |
| uint32_t systick_get_global_tick(void)
 | |
| {
 | |
| 	return global_systick;
 | |
| }
 | |
| 
 | |
| void SysTick_Handler(void)
 | |
| {
 | |
| 	global_systick++;
 | |
| 	systick_wait_counter--;
 | |
| 	if (++blink_cntr > 250ul) {
 | |
| 		blink_cntr = 0ul;
 | |
| 		blink_state = !blink_state;
 | |
| 	}
 | |
| }
 |