summaryrefslogtreecommitdiff
path: root/include/arch/msp430fr5969lp/driver/counter.h
blob: 851c32dc6ae6d62210f03cb58ca6715da96985fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;