Skip to content

fix(hardwaretimer): avoid glitch when PWM configuration changed #2572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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