APM:Libraries
systick.h
Go to the documentation of this file.
1 #ifndef _SYSTICK_H
2 #define _SYSTICK_H
3 
4 #include <stm32f4xx.h>
5 #include <hal_types.h>
6 #include <hal.h>
7 
8 
9 #ifdef __cplusplus
10  extern "C" {
11 #endif
12 
14 extern volatile uint64_t systick_uptime_millis;
16 extern void emerg_delay(uint32_t);
17 
18 
27 void systick_init(uint32_t reload_val);
28 
33 static inline void systick_enable() { SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; }
34 
39 static inline void systick_disable() { SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk; }
40 
44 static inline uint64_t systick_uptime(void) { return systick_uptime_millis; }
48 static inline uint32_t systick_get_count(void) { return SysTick->VAL; }
49 
59 static inline uint32_t systick_check_underflow(void) { return SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk; }
60 
66 void systick_attach_callback(Handler callback);
67 void systick_detach_callback(Handler callback);
68 
69 uint32_t systick_micros(void);
70 
71 void SysTick_Handler(void);
72 
73 
74 /*
75 void HardFault_Handler(void);
76 void MemManage_Handler(void);
77 void BusFault_Handler(void);
78 void UsageFault_Handler(void);
79 */
80 void __attribute__((noreturn)) __error(uint32_t pc, uint32_t num, uint32_t lr, uint32_t flag);
81 void __attribute__((noreturn)) error_throb(uint32_t num);
82 
83 
84 #ifdef __cplusplus
85  }
86 #endif
87 
88 #endif
void(* voidFuncPtr)(void)
Definition: hal_types.h:16
void SysTick_Handler(void)
Definition: systick.c:63
void systick_init(uint32_t reload_val)
Initialize and enable SysTick.
Definition: systick.c:50
static uint64_t systick_uptime(void)
Returns the system uptime, in milliseconds.
Definition: systick.h:44
void systick_attach_callback(Handler callback)
Attach a callback to be called from the SysTick exception handler.
Definition: systick.c:28
static uint32_t systick_get_count(void)
Returns the current value of the SysTick counter.
Definition: systick.h:48
voidFuncPtr boardEmergencyHandler
void systick_detach_callback(Handler callback)
Definition: systick.c:34
void __error(uint32_t num, uint32_t pc, uint32_t lr, uint32_t flag)
void uint32_t uint32_t lr
Definition: systick.h:80
void emerg_delay(uint32_t)
Definition: boards.cpp:257
volatile uint64_t systick_uptime_millis
void uint32_t uint32_t uint32_t flag
Definition: systick.h:80
uint64_t Handler
Definition: hal_types.h:19
static uint32_t systick_check_underflow(void)
Check for underflow.
Definition: systick.h:59
void uint32_t num
Definition: systick.h:80
uint32_t systick_micros(void)
static void systick_enable()
Definition: systick.h:33
static void systick_disable()
Definition: systick.h:39
void __attribute__((noreturn)) __error(uint32_t pc