@@ -50,16 +50,20 @@ volatile uint32_t timerb3_overflow_count = 0;
5050volatile uint32_t timerb3_millis = 0 ;
5151static uint16_t timerb3_fract = 0 ;
5252
53- inline uint16_t clockCyclesPerMicrosecond (uint32_t clk ){
53+ inline uint16_t clockCyclesPerMicrosecondComp (uint32_t clk ){
5454 return ( (clk ) / 1000000L );
5555}
5656
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 );
5959}
6060
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 () );
6367}
6468
6569ISR (TCB3_INT_vect )
@@ -545,7 +549,7 @@ void init()
545549/********************* TCB3 for system time tracking **************************/
546550
547551 /* 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 );
549553 microseconds_per_timerb3_tick = microseconds_per_timerb3_overflow /TIME_TRACKING_TIMER_PERIOD ;
550554
551555 millis_inc = microseconds_per_timerb3_overflow / 1000 ;
0 commit comments