@@ -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 )
@@ -400,7 +404,7 @@ void init()
400
404
/********************* TCB3 for system time tracking **************************/
401
405
402
406
/* Calculate relevant time tracking values */
403
- microseconds_per_timerb3_overflow = clockCyclesToMicroseconds (TIME_TRACKING_CYCLES_PER_OVF , F_CPU_CORRECTED );
407
+ microseconds_per_timerb3_overflow = clockCyclesToMicroseconds (TIME_TRACKING_CYCLES_PER_OVF );
404
408
microseconds_per_timerb3_tick = microseconds_per_timerb3_overflow /TIME_TRACKING_TIMER_PERIOD ;
405
409
406
410
millis_inc = microseconds_per_timerb3_overflow / 1000 ;
0 commit comments