Skip to content

Commit 9dc4f19

Browse files
author
Sergey Pluzhnikov
committed
STM32 Timers: Add hasAdvancedPwmControl() function
1 parent 04b105a commit 9dc4f19

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

src/modm/platform/timer/stm32/advanced.hpp.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ public:
234234
TIM{{ id }}->CNT = value;
235235
}
236236

237+
static constexpr bool
238+
hasAdvancedPwmControl()
239+
{
240+
return true;
241+
}
242+
237243
static inline void
238244
enableOutput()
239245
{

src/modm/platform/timer/stm32/basic.hpp.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ public:
175175
TIM{{ id }}->CNT = value;
176176
}
177177

178+
static constexpr bool
179+
hasAdvancedPwmControl()
180+
{
181+
return false;
182+
}
183+
178184
static void
179185
enableInterruptVector(bool enable, uint32_t priority);
180186

src/modm/platform/timer/stm32/basic_base.hpp.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ public:
209209
static inline void
210210
setValue(Value value);
211211

212+
/**
213+
* Allows to check, whether the timer has BDTR and DTR2 registers
214+
* for PWM deadtime, break and output enable control.
215+
*/
216+
static constexpr bool
217+
hasAdvancedPwmControl();
218+
212219
/**
213220
* Enables or disables the Interrupt Vector.
214221
*

src/modm/platform/timer/stm32/general_purpose.hpp.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Copyright (c) 2013-2014, 2016, Kevin Läufer
77
* Copyright (c) 2014, 2022, Sascha Schade
88
* Copyright (c) 2022, Christopher Durand
9+
* Copyright (c) 2023, Sergey Pluzhnikov
910
*
1011
* This file is part of the modm project.
1112
*
@@ -258,6 +259,12 @@ public:
258259

259260

260261
%% if target.family not in ["l0", "l1"] and id in [15, 16, 17]
262+
static constexpr bool
263+
hasAdvancedPwmControl()
264+
{
265+
return true;
266+
}
267+
261268
static inline void
262269
enableOutput()
263270
{
@@ -343,6 +350,12 @@ public:
343350
flags |= (deadTime & bitmask) | static_cast<uint32_t>(resolution);
344351
TIM{{ id }}->BDTR = flags;
345352
}
353+
%% else
354+
static constexpr bool
355+
hasAdvancedPwmControl()
356+
{
357+
return false;
358+
}
346359
%% endif
347360

348361

src/modm/platform/timer/stm32/general_purpose_base.hpp.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2014, Fabian Greif
44
* Copyright (c) 2014-2017, Niklas Hauser
55
* Copyright (c) 2022-2023, Christopher Durand
6+
* Copyright (c) 2023, Sergey Pluzhnikov
67
*
78
* This file is part of the modm project.
89
*
@@ -283,7 +284,7 @@ public:
283284
return true;
284285
%% endif
285286
%% if loop.last and loop.length > 0
286-
}
287+
}
287288
%% endif
288289
%% endfor
289290
return false;

0 commit comments

Comments
 (0)