aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/systick.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libmaple/systick.c b/libmaple/systick.c
index 5a94d81..388f7aa 100644
--- a/libmaple/systick.c
+++ b/libmaple/systick.c
@@ -31,6 +31,7 @@
#include "systick.h"
volatile uint32 systick_uptime_millis;
+static void (*systick_user_callback)(void);
/**
* @brief Initialize and enable SysTick.
@@ -64,10 +65,20 @@ void systick_enable() {
SYSTICK_CSR_TICKINT_PEND);
}
+/**
+ * Attach a callback called each ms.
+ */
+void systick_attach_callback(void (*callback)(void)) {
+ systick_user_callback = callback;
+}
+
/*
* SysTick ISR
*/
void __exc_systick(void) {
+ if (systick_user_callback) {
+ systick_user_callback();
+ }
systick_uptime_millis++;
}