diff --git a/include/arch/arduino-nano/driver/counter.h b/include/arch/arduino-nano/driver/counter.h index 43ddd153e40cb6b5f9b391f2f040c14ba1ae3300..5685136c96dcced25e9b9a8fbf4da2d2d97eb35e 100644 --- a/include/arch/arduino-nano/driver/counter.h +++ b/include/arch/arduino-nano/driver/counter.h @@ -2,7 +2,7 @@ #include typedef counter_value_t uint16_t; -typedef counter_overflowed_t uint8_t; +typedef counter_overflow_t uint8_t; class Counter { private: @@ -10,12 +10,12 @@ class Counter { public: uint16_t value; - volatile uint8_t overflowed; + volatile uint8_t overflow; - Counter() : overflowed(0) {} + Counter() : overflow(0) {} inline void start() { - overflowed = 0; + overflow = 0; TCNT1 = 0; TCCR1A = 0; TCCR1B = _BV(CS10); // no prescaler diff --git a/include/arch/esp8266/driver/counter.h b/include/arch/esp8266/driver/counter.h index 42f6f1401de0de7fc4ce2b32b728cad2933bc246..0b50c8eadf8cad57a7680322262d590c109fca71 100644 --- a/include/arch/esp8266/driver/counter.h +++ b/include/arch/esp8266/driver/counter.h @@ -8,7 +8,7 @@ extern "C" { #include "c_types.h" typedef counter_value_t uint32_t; -typedef counter_overflowed_t uint32_t; +typedef counter_overflow_t uint32_t; class Counter { private: @@ -17,9 +17,9 @@ class Counter { public: uint32_t value; - uint32_t overflowed; + uint32_t overflow; - Counter() : start_cycles(0), value(0), overflowed(0) {} + Counter() : start_cycles(0), value(0), overflow(0) {} inline void start() { asm volatile ("esync; rsr %0,ccount":"=a" (start_cycles)); @@ -31,7 +31,7 @@ class Counter { if (stop_cycles > start_cycles) { value = stop_cycles - start_cycles; } else { - overflowed = 1; + overflow = 1; } } }; diff --git a/include/arch/msp430fr5969lp/driver/counter.h b/include/arch/msp430fr5969lp/driver/counter.h index 501808bf210979a20f019ffde01143fb965add37..b95aba112a69e59692e2620dda18bbb933abe6f1 100644 --- a/include/arch/msp430fr5969lp/driver/counter.h +++ b/include/arch/msp430fr5969lp/driver/counter.h @@ -1,8 +1,11 @@ +#ifndef COUNTER_H +#define COUNTER_H + #include #include -typedef counter_value_t uint16_t; -typedef counter_overflowed_t uint8_t; +typedef uint16_t counter_value_t; +typedef uint8_t counter_overflow_t; class Counter { private: @@ -10,12 +13,12 @@ class Counter { public: uint16_t value; - uint8_t overflowed; + uint8_t overflow; - Counter() : overflowed(0) {} + Counter() : overflow(0) {} inline void start() { - overflowed = 0; + overflow = 0; TA2CTL = TASSEL__SMCLK | ID__1 | MC__CONTINUOUS; TA2EX0 = 0; TA2CTL |= TACLR; @@ -28,3 +31,5 @@ class Counter { }; extern Counter counter; + +#endif diff --git a/include/arch/msp430fr5994lp/driver/counter.h b/include/arch/msp430fr5994lp/driver/counter.h index 21c5ec523eda3feb63b6e4e3629f4206542a52ab..61f0ec17921a8171ae46256d5534a16b021fc0fd 100644 --- a/include/arch/msp430fr5994lp/driver/counter.h +++ b/include/arch/msp430fr5994lp/driver/counter.h @@ -2,7 +2,7 @@ #include typedef uint16_t counter_value_t; -typedef uint8_t counter_overflowed_t; +typedef uint8_t counter_overflow_t; class Counter { private: @@ -10,12 +10,12 @@ class Counter { public: uint16_t value; - uint8_t overflowed; + uint8_t overflow; - Counter() : overflowed(0) {} + Counter() : overflow(0) {} inline void start() { - overflowed = 0; + overflow = 0; TA2CTL = TASSEL__SMCLK | ID__1 | MC__CONTINUOUS; TA2EX0 = 0; TA2CTL |= TACLR; diff --git a/include/arch/posix/driver/counter.h b/include/arch/posix/driver/counter.h index 4f575a8de03bb219cc46028ccda6da124c8cd521..88cb0cc005edcb49591567b6696c071e144eaf64 100644 --- a/include/arch/posix/driver/counter.h +++ b/include/arch/posix/driver/counter.h @@ -2,7 +2,7 @@ #include typedef uint64_t counter_value_t; -typedef uint8_t counter_overflowed_t; +typedef uint8_t counter_overflow_t; class Counter { private: @@ -11,9 +11,9 @@ class Counter { public: uint64_t value; - volatile uint8_t overflowed; + volatile uint8_t overflow; - Counter() : overflowed(0) {} + Counter() : overflow(0) {} inline void start() { struct timespec ts; diff --git a/include/object/ptalog.h b/include/object/ptalog.h index 21aaa9131b041ad5f04250d7746cae421c22c2ec..14ff2fdfb1fb26b02a858cd2c454061d165feb88 100644 --- a/include/object/ptalog.h +++ b/include/object/ptalog.h @@ -41,6 +41,13 @@ class PTALog { } } +#ifdef PTALOG_TIMING + inline void passNop(Counter& counter) + { + kout << "[PTA] nop=" << counter.value << "/" << counter.overflow << endl; + } +#endif + inline void reset() { log_index = 0; @@ -64,7 +71,8 @@ class PTALog { kout << "[PTA] trace, count=" << dec << log_index << endl; for (uint8_t i = 0; i < log_index; i++) { #ifdef PTALOG_TIMING - kout << "[PTA] transition=" << log[i].transition_id << endl; + kout << "[PTA] transition=" << log[i].transition_id; + kout << " cycles=" << log[i].timer << "/" << log[i].overflow << endl; #else kout << "[PTA] transition=" << log[i].transition_id << endl; #endif diff --git a/src/arch/arduino-nano/driver/counter.cc b/src/arch/arduino-nano/driver/counter.cc index 894a882b5b74df4b7a6b5239cae0ce7318439b56..2529b0e1f32e0166df443a53a872602c3984569f 100644 --- a/src/arch/arduino-nano/driver/counter.cc +++ b/src/arch/arduino-nano/driver/counter.cc @@ -8,7 +8,7 @@ Counter counter; ISR(TIMER1_OVF_vect) { - if (counter.overflowed < 255) { - counter.overflowed++; + if (counter.overflow < 255) { + counter.overflow++; } }