Skip to content

Commit

Permalink
Complementary channels availble for more STM families
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Pluzhnikov committed May 10, 2023
1 parent 488c98d commit a149573
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/modm/platform/timer/stm32/general_purpose.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ modm::platform::Timer{{ id }}::configureOutputChannel(uint32_t channel,
}
}

%% if target.family in ["g4"] and id in [15, 16, 17]
%% if id in [15, 16, 17]
void
modm::platform::Timer{{ id }}::configureOutputChannel(uint32_t channel,
OutputCompareMode mode,
Expand All @@ -207,7 +207,7 @@ OutputComparePreload preload)
{
modm_assert(channel == 1, "Timer{{ id }}", "This timer has complementary output only on channel 1!", "{{ id }}");

channel -= 1;
channel -= 1;

// disable output
TIM{{ id }}->CCER &= ~(0xf << (channel * 4));
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/timer/stm32/general_purpose.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public:
configureOutputChannel(channel, mode, compareValue, out, enableComparePreload);
}

%% if target.family in ["g4"] and id in [15, 16, 17]
%% if id in [15, 16, 17]
static void
configureOutputChannel(uint32_t channel, OutputCompareMode mode,
PinState out, OutputComparePolarity polarity,
Expand Down
23 changes: 12 additions & 11 deletions src/modm/platform/timer/stm32/general_purpose_base.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,26 @@ protected:
signalToChannel()
{
modm::platform::detail::SignalConnection<Signal, p>{};
%% if target.family == "g4"
if constexpr (Signal::Signal == Gpio::Signal::Ch1 || Signal::Signal == Gpio::Signal::Ch1n) {
return 1;
} else if constexpr (Signal::Signal == Gpio::Signal::Ch2 || Signal::Signal == Gpio::Signal::Ch2n) {
return 2;
} else if constexpr (Signal::Signal == Gpio::Signal::Ch3 || Signal::Signal == Gpio::Signal::Ch3n) {
return 3;
} else if constexpr (Signal::Signal == Gpio::Signal::Ch4 || Signal::Signal == Gpio::Signal::Ch4n) {
return 4;
%% else
if constexpr (Signal::Signal == Gpio::Signal::Ch1) {
return 1;
} else if constexpr (Signal::Signal == Gpio::Signal::Ch2) {
return 2;
} else if constexpr (Signal::Signal == Gpio::Signal::Ch3) {
return 3;
%% if target.family != "l0" or target.pin != "d"
} else if constexpr (Signal::Signal == Gpio::Signal::Ch4) {
return 4;
%% if target.family not in ["l0","l1"]
} else if constexpr (Signal::Signal == Gpio::Signal::Ch1n) {
return 1;
%% if target.family not in ["f3"]
} else if constexpr (Signal::Signal == Gpio::Signal::Ch2n) {
return 2;
} else if constexpr (Signal::Signal == Gpio::Signal::Ch3n) {
return 3;
%% if target.family in ["g4","u5","h5"]
} else if constexpr (Signal::Signal == Gpio::Signal::Ch4n) {
return 4;
%% endif
%% endif
%% endif
} else {
Expand Down

0 comments on commit a149573

Please sign in to comment.