blob: 501808bf210979a20f019ffde01143fb965add37 (
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
27
28
29
30
|
#include <msp430.h>
#include <stdint.h>
typedef counter_value_t uint16_t;
typedef counter_overflowed_t uint8_t;
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;
|