Skip to content

Commit

Permalink
[stm32] Fix Rcc::disable() erroneously disabling unrelated clocks
Browse files Browse the repository at this point in the history
Due to missing curly braces certain statements are not guarded by an if
condition and will always be executed. This causes some ethernet clocks
to always be disabled regardless of specified parameters.
  • Loading branch information
chris-durand committed Jul 10, 2022
1 parent 5c47e72 commit 7aed364
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/modm/platform/clock/stm32/rcc_impl.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ Rcc::disable()

__DSB();
%% for peripheral, (st_per, bus) in rcc_enable.items() | sort
if constexpr (peripheral == Peripheral::{{ peripheral }})
if constexpr (peripheral == Peripheral::{{ peripheral }}) {
RCC->{{bus}} &= ~RCC_{{bus}}_{{st_per}}EN;{% if peripheral == "Eth" %} __DSB();
RCC->{{bus}} &= ~RCC_{{bus}}_{{st_per}}RXEN; __DSB();
RCC->{{bus}} &= ~RCC_{{bus}}_{{st_per}}TXEN;{% elif peripheral == "Usbotghs" %} __DSB();
RCC->{{bus}} &= ~RCC_{{bus}}_{{st_per}}ULPIEN;{% endif %}
}
%% endfor
__DSB();
}
Expand Down

0 comments on commit 7aed364

Please sign in to comment.