Skip to content

Commit 32b6654

Browse files
authored
Merge pull request stm32duino#2572 from fpistm/HT_FIX
fix(hardwaretimer): avoid glitch when PWM configuration changed
2 parents 339e2b9 + 6c30d95 commit 32b6654

File tree

3 files changed

+96
-100
lines changed

3 files changed

+96
-100
lines changed

Diff for: keywords.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,7 @@ GPIO_PIN_14 LITERAL1
862862
GPIO_PIN_15 LITERAL1
863863

864864
# HardwareTimer
865-
TIMER_DISABLED LITERAL1
866-
TIMER_OUTPUT_COMPARE LITERAL1
865+
TIMER_OUTPUT_DISABLED LITERAL1
867866
TIMER_OUTPUT_COMPARE_ACTIVE LITERAL1
868867
TIMER_OUTPUT_COMPARE_INACTIVE LITERAL1
869868
TIMER_OUTPUT_COMPARE_TOGGLE LITERAL1

Diff for: libraries/SrcWrapper/inc/HardwareTimer.h

+9-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@
3636
#define TIMER_CHANNELS 4 // channel5 and channel 6 are not considered here has they don't have gpio output and they don't have interrupt
3737

3838
typedef enum {
39-
TIMER_DISABLED, // == TIM_OCMODE_TIMING no output, useful for only-interrupt
39+
TIMER_OUTPUT_DISABLED, // == TIM_OCMODE_TIMING no output, useful for only-interrupt
4040
// Output Compare
41-
TIMER_OUTPUT_COMPARE, // == Obsolete, use TIMER_DISABLED instead. Kept for compatibility reason
4241
TIMER_OUTPUT_COMPARE_ACTIVE, // == TIM_OCMODE_ACTIVE pin is set high when counter == channel compare
4342
TIMER_OUTPUT_COMPARE_INACTIVE, // == TIM_OCMODE_INACTIVE pin is set low when counter == channel compare
4443
TIMER_OUTPUT_COMPARE_TOGGLE, // == TIM_OCMODE_TOGGLE pin toggles when counter == channel compare
@@ -60,6 +59,10 @@ typedef enum {
6059
TIMER_NOT_USED = 0xFFFF // This must be the last item of this enum
6160
} TimerModes_t;
6261

62+
// Backward compatibility
63+
#define TIMER_DISABLED TIMER_OUTPUT_DISABLED
64+
#define TIMER_OUTPUT_COMPARE TIMER_OUTPUT_DISABLED
65+
6366
typedef enum {
6467
TICK_FORMAT, // default
6568
MICROSEC_FORMAT,
@@ -177,10 +180,10 @@ class HardwareTimer {
177180

178181
// The following function(s) are available for more advanced timer options
179182
TIM_HandleTypeDef *getHandle(); // return the handle address for HAL related configuration
180-
int getChannel(uint32_t channel);
181-
int getLLChannel(uint32_t channel);
182-
int getIT(uint32_t channel);
183-
int getAssociatedChannel(uint32_t channel);
183+
uint32_t getChannel(uint32_t channel);
184+
uint32_t getLLChannel(uint32_t channel);
185+
uint32_t getIT(uint32_t channel);
186+
uint32_t getAssociatedChannel(uint32_t channel);
184187

185188
private:
186189
// Store for each channel if regular, complementary or both are used

0 commit comments

Comments
 (0)