diff options
Diffstat (limited to 'include/arch/msp430fr5994lp/driver/counter.h')
-rw-r--r-- | include/arch/msp430fr5994lp/driver/counter.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/arch/msp430fr5994lp/driver/counter.h b/include/arch/msp430fr5994lp/driver/counter.h new file mode 100644 index 0000000..e7f0507 --- /dev/null +++ b/include/arch/msp430fr5994lp/driver/counter.h @@ -0,0 +1,27 @@ +#include <msp430.h> +#include <stdint.h> + +class Counter { + private: + Counter(const Counter ©); + + public: + uint16_t value; + uint8_t overflowed; + + Counter() : overflowed(0) {} + + inline void start() { + overflowed = 0; + TA2CTL = TASSEL__SMCLK | ID__1 | MC__CONTINUOUS; + TA2EX0 = 0; + TA2CTL |= TACLR; + } + + inline void stop() { + TA2CTL = 0; + value = TA2R; + } +}; + +extern Counter counter; |