From d0400d63dfca33d3839fafc1553357150cd19eca Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 15 Nov 2018 16:06:11 +0100 Subject: MSP430: Add "counter" driver --- include/arch/msp430fr5969lp/driver/counter.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 include/arch/msp430fr5969lp/driver/counter.h (limited to 'include/arch/msp430fr5969lp/driver') 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 +#include + +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; -- cgit v1.2.3