aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-06-24 14:38:35 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-06-24 14:38:35 -0400
commitb08c0f74786fe871e7c64a77d19d2a66329f62a4 (patch)
treece8ba7985fd93ad8910f8c0313722815137cabbd /libmaple
parent22b9ffc1a7b77cab2a55c4c9ebf9c9abdc6c790e (diff)
parent1a825f8a475f0b10c5c528cedd6c930a2f248255 (diff)
downloadlibrambutan-b08c0f74786fe871e7c64a77d19d2a66329f62a4.tar.gz
librambutan-b08c0f74786fe871e7c64a77d19d2a66329f62a4.zip
Merge branch 'freertos'
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/systick.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libmaple/systick.c b/libmaple/systick.c
index 5a94d81..5025328 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,22 @@ void systick_enable() {
SYSTICK_CSR_TICKINT_PEND);
}
+/**
+ * @brief Attach a callback to be called from the SysTick exception handler.
+ *
+ * To detach a callback, call this function again with a null argument.
+ */
+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++;
}