Skip to content

Commit

Permalink
STM32 Timers: Add hasAdvancedPwmControl() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Pluzhnikov committed May 11, 2023
1 parent ac01af4 commit 8fe6fcf
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/modm/platform/timer/stm32/advanced.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ public:
TIM{{ id }}->CNT = value;
}

static constexpr bool
hasAdvancedPwmControl()
{
return true;
}

static inline void
enableOutput()
{
Expand Down
6 changes: 6 additions & 0 deletions src/modm/platform/timer/stm32/basic.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ public:
TIM{{ id }}->CNT = value;
}

static constexpr bool
hasAdvancedPwmControl()
{
return false;
}

static void
enableInterruptVector(bool enable, uint32_t priority);

Expand Down
7 changes: 7 additions & 0 deletions src/modm/platform/timer/stm32/basic_base.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ public:
static inline void
setValue(Value value);

/**
* Allows to check, whether the timer has BDTR and DTR2 registers
* for PWM deadtime, break and output enable control.
*/
static constexpr bool
hasAdvancedPwmControl();

/**
* Enables or disables the Interrupt Vector.
*
Expand Down
13 changes: 13 additions & 0 deletions src/modm/platform/timer/stm32/general_purpose.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2013-2014, 2016, Kevin Läufer
* Copyright (c) 2014, 2022, Sascha Schade
* Copyright (c) 2022, Christopher Durand
* Copyright (c) 2023, Sergey Pluzhnikov
*
* This file is part of the modm project.
*
Expand Down Expand Up @@ -258,6 +259,12 @@ public:


%% if target.family not in ["l0", "l1"] and id in [15, 16, 17]
static constexpr bool
hasAdvancedPwmControl()
{
return true;
}

static inline void
enableOutput()
{
Expand Down Expand Up @@ -343,6 +350,12 @@ public:
flags |= (deadTime & bitmask) | static_cast<uint32_t>(resolution);
TIM{{ id }}->BDTR = flags;
}
%% else
static constexpr bool
hasAdvancedPwmControl()
{
return false;
}
%% endif


Expand Down
3 changes: 2 additions & 1 deletion src/modm/platform/timer/stm32/general_purpose_base.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (c) 2014, Fabian Greif
* Copyright (c) 2014-2017, Niklas Hauser
* Copyright (c) 2022-2023, Christopher Durand
* Copyright (c) 2023, Sergey Pluzhnikov
*
* This file is part of the modm project.
*
Expand Down Expand Up @@ -283,7 +284,7 @@ public:
return true;
%% endif
%% if loop.last and loop.length > 0
}
}
%% endif
%% endfor
return false;
Expand Down

0 comments on commit 8fe6fcf

Please sign in to comment.