Skip to content

Commit

Permalink
Merge pull request stm32duino#2572 from fpistm/HT_FIX
Browse files Browse the repository at this point in the history
fix(hardwaretimer): avoid glitch when PWM configuration changed
  • Loading branch information
fpistm authored Nov 21, 2024
2 parents 339e2b9 + 6c30d95 commit 32b6654
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 100 deletions.
3 changes: 1 addition & 2 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,7 @@ GPIO_PIN_14 LITERAL1
GPIO_PIN_15 LITERAL1

# HardwareTimer
TIMER_DISABLED LITERAL1
TIMER_OUTPUT_COMPARE LITERAL1
TIMER_OUTPUT_DISABLED LITERAL1
TIMER_OUTPUT_COMPARE_ACTIVE LITERAL1
TIMER_OUTPUT_COMPARE_INACTIVE LITERAL1
TIMER_OUTPUT_COMPARE_TOGGLE LITERAL1
Expand Down
15 changes: 9 additions & 6 deletions libraries/SrcWrapper/inc/HardwareTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
#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

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

// Backward compatibility
#define TIMER_DISABLED TIMER_OUTPUT_DISABLED
#define TIMER_OUTPUT_COMPARE TIMER_OUTPUT_DISABLED

typedef enum {
TICK_FORMAT, // default
MICROSEC_FORMAT,
Expand Down Expand Up @@ -177,10 +180,10 @@ class HardwareTimer {

// The following function(s) are available for more advanced timer options
TIM_HandleTypeDef *getHandle(); // return the handle address for HAL related configuration
int getChannel(uint32_t channel);
int getLLChannel(uint32_t channel);
int getIT(uint32_t channel);
int getAssociatedChannel(uint32_t channel);
uint32_t getChannel(uint32_t channel);
uint32_t getLLChannel(uint32_t channel);
uint32_t getIT(uint32_t channel);
uint32_t getAssociatedChannel(uint32_t channel);

private:
// Store for each channel if regular, complementary or both are used
Expand Down
Loading

0 comments on commit 32b6654

Please sign in to comment.