summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/arch/msp430fr5969lp/driver/counter.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/arch/msp430fr5969lp/driver/counter.h b/include/arch/msp430fr5969lp/driver/counter.h
new file mode 100644
index 0000000..851c32d
--- /dev/null
+++ b/include/arch/msp430fr5969lp/driver/counter.h
@@ -0,0 +1,26 @@
+#include <msp430.h>
+#include <stdint.h>
+
+class Counter {
+ private:
+ Counter(const Counter &copy);
+
+ public:
+ uint8_t overflowed;
+
+ Counter() : overflowed(0) {}
+
+ inline void start() {
+ overflowed = 0;
+ TA2CTL = TASSEL__SMCLK | ID__1 | MC__CONTINUOUS;
+ TA2EX0 = 0;
+ TA2CTL |= TACLR;
+ }
+
+ inline uint16_t stop() {
+ TA2CTL = 0;
+ return TA2R;
+ }
+};
+
+extern Counter counter;