aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/systick.h
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:43:27 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:49:08 -0400
commit19ea6ba4ea3f1ecb9830cf4d3e1366513f4f96e3 (patch)
treea43f7e0fb3650ca54f245b750a078a0e8c356504 /libmaple/systick.h
parent868fb1c273e562a1140abfa948022c9d4f55bccf (diff)
parent1e2e177f6dae62e040c674b617744c73be187062 (diff)
downloadlibrambutan-19ea6ba4ea3f1ecb9830cf4d3e1366513f4f96e3.tar.gz
librambutan-19ea6ba4ea3f1ecb9830cf4d3e1366513f4f96e3.zip
Merge branch 'refactor'
This merges the libmaple refactor work into master. The contents of libmaple proper (/libmaple/) are almost completely incompatible with previous APIs in master. See /docs/source/libmaple/overview.rst for more information on the new design. Wirish incompatibilities are limited to the HardwareTimer class; however, there are several new deprecations, most likely to be removed in 0.1.0.
Diffstat (limited to 'libmaple/systick.h')
-rw-r--r--libmaple/systick.h46
1 files changed, 38 insertions, 8 deletions
diff --git a/libmaple/systick.h b/libmaple/systick.h
index 33a3cf8..35b4cb9 100644
--- a/libmaple/systick.h
+++ b/libmaple/systick.h
@@ -31,30 +31,60 @@
#ifndef _SYSTICK_H_
#define _SYSTICK_H_
-#include "libmaple.h"
+#include "libmaple_types.h"
+#include "util.h"
#ifdef __cplusplus
extern "C"{
#endif
-#define SYSTICK_CSR 0xE000E010 // Control and status register
-#define SYSTICK_CNT 0xE000E018 // Current value register
+/** SysTick register map type */
+typedef struct systick_reg_map {
+ __io uint32 CSR; /**< Control and status register */
+ __io uint32 RVR; /**< Reload value register */
+ __io uint32 CNT; /**< Current value register ("count") */
+ __io uint32 CVR; /**< Calibration value register */
+} systick_reg_map;
-#define SYSTICK_CSR_COUNTFLAG BIT(16)
+/** SysTick register map base pointer */
+#define SYSTICK_BASE ((struct systick_reg_map*)0xE000E010)
-/** System elapsed time in milliseconds */
+/*
+ * Register bit definitions.
+ */
+
+/* Control and status register */
+
+#define SYSTICK_CSR_COUNTFLAG BIT(16)
+#define SYSTICK_CSR_CLKSOURCE BIT(2)
+#define SYSTICK_CSR_CLKSOURCE_EXTERNAL 0
+#define SYSTICK_CSR_CLKSOURCE_CORE BIT(2)
+#define SYSTICK_CSR_TICKINT BIT(1)
+#define SYSTICK_CSR_TICKINT_PEND BIT(1)
+#define SYSTICK_CSR_TICKINT_NO_PEND 0
+#define SYSTICK_CSR_ENABLE BIT(0)
+#define SYSTICK_CSR_ENABLE_MULTISHOT BIT(0)
+#define SYSTICK_CSR_ENABLE_DISABLED 0
+
+/* Calibration value register */
+
+#define SYSTICK_CVR_NOREF BIT(31)
+#define SYSTICK_CVR_SKEW BIT(30)
+#define SYSTICK_CVR_TENMS 0xFFFFFF
+
+/** System elapsed time, in milliseconds */
extern volatile uint32 systick_timer_millis;
void systick_init(uint32 reload_val);
void systick_disable();
-void systick_resume();
+void systick_enable();
static inline uint32 systick_get_count(void) {
- return __read(SYSTICK_CNT);
+ return SYSTICK_BASE->CNT;
}
static inline uint32 systick_check_underflow(void) {
- return (__read(SYSTICK_CSR) & SYSTICK_CSR_COUNTFLAG);
+ return SYSTICK_BASE->CSR & SYSTICK_CSR_COUNTFLAG;
}
#ifdef __cplusplus