diff options
author | Perry Hung <iperry@alum.mit.edu> | 2010-08-04 08:52:30 -0400 |
---|---|---|
committer | Perry Hung <iperry@alum.mit.edu> | 2010-08-04 08:52:30 -0400 |
commit | d2494611156c4ba477a1bbd1b07ba0cfc14b29e4 (patch) | |
tree | 48782014152efa392ac0689c4098e089da52c82c /libmaple/systick.h | |
parent | 2b7a1b40c96525cd4c6324f6e9d53845fb07a55f (diff) | |
download | librambutan-d2494611156c4ba477a1bbd1b07ba0cfc14b29e4.tar.gz librambutan-d2494611156c4ba477a1bbd1b07ba0cfc14b29e4.zip |
Cleaned up wirish/time, some interrupt handling refactoring:
Fixed millis(), it was just wrong, before.
Added micros(), not extensively tested.
New implementation of delayMicroseconds(). Should be more consistent
now.
Added a handful of nvic routines to enable/disable interrupts.
Cleaned up systick
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 |