diff options
author | bnewbold <bnewbold@robocracy.org> | 2010-08-31 17:39:46 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2010-08-31 17:39:46 -0400 |
commit | 02d7b08f0497096f21e41922e0efb54c4ef33bab (patch) | |
tree | a7e04293efcba70f37cffcd03c0fcc4c0be7858a /libmaple/systick.h | |
parent | b2dd49c3141d8a21a4e7c7ef51dee7329f847c30 (diff) | |
parent | e03d58f4dab4176514924baa3a1ff430bf5819b8 (diff) | |
download | librambutan-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.h')
-rw-r--r-- | libmaple/systick.h | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/libmaple/systick.h b/libmaple/systick.h index d0a623f..57b724a 100644 --- a/libmaple/systick.h +++ b/libmaple/systick.h @@ -33,30 +33,23 @@ #include "libmaple.h" -/* To the ARM technical manual... there's nearly nothing on the systick - * timer in the stm32 manual */ +#define SYSTICK_CSR 0xE000E010 // Control and status register +#define SYSTICK_CNT 0xE000E018 // Current value register -#define SYSTICK_CSR 0xE000E010 // Control and status register -#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 - -/* We use the systick timer to tick once - * every millisecond */ -#define MAPLE_RELOAD_VAL 72000 +#define SYSTICK_CSR_COUNTFLAG BIT(16) #ifdef __cplusplus extern "C"{ #endif -void systick_init(void); +void systick_init(uint32 reload_val); static inline uint32 systick_get_count(void) { - return (uint32)*(volatile uint32*)SYSTICK_CNT; + return __read(SYSTICK_CNT); +} + +static inline uint32 systick_check_underflow(void) { + return (__read(SYSTICK_CSR) & SYSTICK_CSR_COUNTFLAG); } #ifdef __cplusplus |