diff --git a/hal/mcu/at90can128_tqfp64/hal/mcu_timers.h b/hal/mcu/at90can128_tqfp64/hal/mcu_timers.h index 21f78b9..8fa6987 100644 --- a/hal/mcu/at90can128_tqfp64/hal/mcu_timers.h +++ b/hal/mcu/at90can128_tqfp64/hal/mcu_timers.h @@ -27,8 +27,8 @@ class Timer0 { }; static void init(Prescaler prescaler, Mode mode) { - TCCR0A = (static_cast(mode) & 0b01 << WGM00) | - (static_cast(mode) & 0b10 << WGM01) | + TCCR0A = (hal::libs::read_bit<0>(static_cast(mode)) << WGM00) | + (hal::libs::read_bit<1>(static_cast(mode)) << WGM01) | static_cast(prescaler); } diff --git a/hal/mcu/atmega128_tqfp64/hal/mcu_timers.h b/hal/mcu/atmega128_tqfp64/hal/mcu_timers.h index b123b3e..729faa8 100644 --- a/hal/mcu/atmega128_tqfp64/hal/mcu_timers.h +++ b/hal/mcu/atmega128_tqfp64/hal/mcu_timers.h @@ -27,8 +27,8 @@ class Timer0 { }; static void init(Prescaler prescaler, Mode mode) { - TCCR0 = (static_cast(mode) & 0b01 << WGM00) | - (static_cast(mode) & 0b10 << WGM01) | + TCCR0 = (hal::libs::read_bit<0>(static_cast(mode)) << WGM00) | + (hal::libs::read_bit<1>(static_cast(mode)) << WGM01) | static_cast(prescaler); } @@ -198,8 +198,8 @@ class Timer2 { }; static void init(Prescaler prescaler, Mode mode) { - TCCR2 = (static_cast(mode) & 0b01 << WGM20) | - (static_cast(mode) & 0b10 << WGM21) | + TCCR2 = (hal::libs::read_bit<0>(static_cast(mode)) << WGM20) | + (hal::libs::read_bit<1>(static_cast(mode)) << WGM21) | static_cast(prescaler); } diff --git a/hal/mcu/atmega328p_tqfp32/hal/mcu_timers.h b/hal/mcu/atmega328p_tqfp32/hal/mcu_timers.h index 989d9fc..711c598 100644 --- a/hal/mcu/atmega328p_tqfp32/hal/mcu_timers.h +++ b/hal/mcu/atmega328p_tqfp32/hal/mcu_timers.h @@ -22,9 +22,9 @@ class Timer0 { enum class Mode : uint8_t { Normal = 0 }; static void init(Prescaler prescaler, Mode mode) { - TCCR0A = (static_cast(mode) & 0b001 << WGM00) | - (static_cast(mode) & 0b010 << WGM01); - TCCR0B = (static_cast(mode) & 0b100 << WGM02) | + TCCR0A = (hal::libs::read_bit<0>(static_cast(mode)) << WGM00) | + (hal::libs::read_bit<1>(static_cast(mode)) << WGM01); + TCCR0B = (hal::libs::read_bit<2>(static_cast(mode)) << WGM02) | static_cast(prescaler); }