Loading include/arch/msp430fr5994lp/driver/counter.h +6 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ class Counter { public: uint16_t value; uint8_t overflow; volatile uint8_t overflow; Counter() : overflow(0) {} Loading @@ -21,12 +21,16 @@ class Counter { overflow = 0; TA2CTL = TASSEL__SMCLK | ID__1 | MC__CONTINUOUS; TA2EX0 = 0; TA2CTL |= TACLR; TA2CTL |= TACLR | TAIE; asm volatile("nop"); __eint(); asm volatile("nop"); } inline void stop() { TA2CTL = 0; value = TA2R; __dint(); } }; Loading src/arch/msp430fr5994lp/driver/counter.cc +11 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,14 @@ #endif Counter counter; #ifndef __acweaving __attribute__((interrupt(TIMER2_A1_VECTOR))) void handle_timer2_overflow() { if (TA2IV == 0x0e) { if (counter.overflow < 255) { counter.overflow++; } } } #endif Loading
include/arch/msp430fr5994lp/driver/counter.h +6 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ class Counter { public: uint16_t value; uint8_t overflow; volatile uint8_t overflow; Counter() : overflow(0) {} Loading @@ -21,12 +21,16 @@ class Counter { overflow = 0; TA2CTL = TASSEL__SMCLK | ID__1 | MC__CONTINUOUS; TA2EX0 = 0; TA2CTL |= TACLR; TA2CTL |= TACLR | TAIE; asm volatile("nop"); __eint(); asm volatile("nop"); } inline void stop() { TA2CTL = 0; value = TA2R; __dint(); } }; Loading
src/arch/msp430fr5994lp/driver/counter.cc +11 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,14 @@ #endif Counter counter; #ifndef __acweaving __attribute__((interrupt(TIMER2_A1_VECTOR))) void handle_timer2_overflow() { if (TA2IV == 0x0e) { if (counter.overflow < 255) { counter.overflow++; } } } #endif