diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-11-15 16:06:11 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-11-15 16:06:11 +0100 |
commit | d0400d63dfca33d3839fafc1553357150cd19eca (patch) | |
tree | f5066fb691e21cf0f9f72b56a4486468f56c0086 /include | |
parent | a923400805d41fc57c760d72588ab88485005690 (diff) |
MSP430: Add "counter" driver
Diffstat (limited to 'include')
-rw-r--r-- | include/arch/msp430fr5969lp/driver/counter.h | 26 |
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 ©); + + 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; |