aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/systick.c
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-08-31 17:39:46 -0400
committerbnewbold <bnewbold@robocracy.org>2010-08-31 17:39:46 -0400
commit02d7b08f0497096f21e41922e0efb54c4ef33bab (patch)
treea7e04293efcba70f37cffcd03c0fcc4c0be7858a /libmaple/systick.c
parentb2dd49c3141d8a21a4e7c7ef51dee7329f847c30 (diff)
parente03d58f4dab4176514924baa3a1ff430bf5819b8 (diff)
downloadlibrambutan-02d7b08f0497096f21e41922e0efb54c4ef33bab.tar.gz
librambutan-02d7b08f0497096f21e41922e0efb54c4ef33bab.zip
Merge maple-native changes into portable
This compiles for both maple and maple_native but is untested.
Diffstat (limited to 'libmaple/systick.c')
-rw-r--r--libmaple/systick.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libmaple/systick.c b/libmaple/systick.c
index a333528..8b0d92a 100644
--- a/libmaple/systick.c
+++ b/libmaple/systick.c
@@ -31,23 +31,25 @@
#include "libmaple.h"
#include "systick.h"
-#define MILLIS_INC 1
+#define SYSTICK_RELOAD 0xE000E014 // Reload value register
+#define SYSTICK_CNT 0xE000E018 // Current value register
+#define SYSTICK_CALIB 0xE000E01C // Calibration value register
+
+#define SYSTICK_SRC_HCLK BIT(2) // Use core clock
+#define SYSTICK_TICKINT BIT(1) // Interrupt on systick countdown
+#define SYSTICK_ENABLE BIT(0) // Turn on the counter
volatile uint32 systick_timer_millis = 0;
-void systick_init(void) {
+void systick_init(uint32 reload_val) {
/* Set the reload counter to tick every 1ms */
- REG_SET_MASK(SYSTICK_RELOAD, MAPLE_RELOAD_VAL);
-// SYSTICK_RELOAD = MAPLE_RELOAD_VAL;
+ __write(SYSTICK_RELOAD, reload_val);
/* Clock the system timer with the core clock
* and turn it on, interrrupt every 1ms to keep track of millis()*/
- REG_SET(SYSTICK_CSR, SYSTICK_SRC_HCLK |
+ __write(SYSTICK_CSR, SYSTICK_SRC_HCLK |
SYSTICK_ENABLE |
SYSTICK_TICKINT);
-// SYSTICK_CSR = SYSTICK_SRC_HCLK |
-// SYSTICK_ENABLE |
-// SYSTICK_TICKINT;
}
void SysTickHandler(void) {