@@ -50,16 +50,20 @@ volatile uint32_t timerb3_overflow_count = 0;
50
50
volatile uint32_t timerb3_millis = 0 ;
51
51
static uint16_t timerb3_fract = 0 ;
52
52
53
- inline uint16_t clockCyclesPerMicrosecond (uint32_t clk ){
53
+ inline uint16_t clockCyclesPerMicrosecondComp (uint32_t clk ){
54
54
return ( (clk ) / 1000000L );
55
55
}
56
56
57
- inline uint16_t clockCyclesToMicroseconds ( uint16_t cycles , uint32_t clk ){
58
- return ( cycles / clockCyclesPerMicrosecond ( clk ) );
57
+ inline uint16_t clockCyclesPerMicrosecond ( ){
58
+ return clockCyclesPerMicrosecondComp ( F_CPU_CORRECTED );
59
59
}
60
60
61
- inline uint32_t microsecondsToClockCycles (uint16_t cycles , uint32_t clk ){
62
- return ( cycles * clockCyclesPerMicrosecond (clk ) );
61
+ inline uint16_t clockCyclesToMicroseconds (uint16_t cycles ){
62
+ return ( cycles / clockCyclesPerMicrosecond () );
63
+ }
64
+
65
+ inline uint32_t microsecondsToClockCycles (uint16_t microseconds ){
66
+ return ( microseconds * clockCyclesPerMicrosecond () );
63
67
}
64
68
65
69
ISR (TCB3_INT_vect )
@@ -545,7 +549,7 @@ void init()
545
549
/********************* TCB3 for system time tracking **************************/
546
550
547
551
/* Calculate relevant time tracking values */
548
- microseconds_per_timerb3_overflow = clockCyclesToMicroseconds (TIME_TRACKING_CYCLES_PER_OVF , F_CPU_CORRECTED );
552
+ microseconds_per_timerb3_overflow = clockCyclesToMicroseconds (TIME_TRACKING_CYCLES_PER_OVF );
549
553
microseconds_per_timerb3_tick = microseconds_per_timerb3_overflow /TIME_TRACKING_TIMER_PERIOD ;
550
554
551
555
millis_inc = microseconds_per_timerb3_overflow / 1000 ;
0 commit comments