summaryrefslogtreecommitdiff
path: root/include/arch/msp430fr5969lp/driver
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-11-15 16:06:11 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-11-15 16:06:11 +0100
commitd0400d63dfca33d3839fafc1553357150cd19eca (patch)
treef5066fb691e21cf0f9f72b56a4486468f56c0086 /include/arch/msp430fr5969lp/driver
parenta923400805d41fc57c760d72588ab88485005690 (diff)
MSP430: Add "counter" driver
Diffstat (limited to 'include/arch/msp430fr5969lp/driver')
-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;