Fix BEEPER timer sibling pad mislabeling and expose them as PINIO#11686
Open
sensei-hacker wants to merge 2 commits into
Open
Fix BEEPER timer sibling pad mislabeling and expose them as PINIO#11686sensei-hacker wants to merge 2 commits into
sensei-hacker wants to merge 2 commits into
Conversation
timerHardwareOverride() applied TIM_USE_BEEPER to every pad sharing a timer set to OUTPUT_MODE_BEEPER, but beeperInit() only ever wires up the first matching pad — all channels of one timer share a single period register, so only one can actually be the buzzer. This caused sibling pads (e.g. S4-S6 on a 4-channel timer with S3 as buzzer) to be reported as "Buzzer" over MSP and shown as such in the configurator while being functionally dead. Confirmed on hardware: oscilloscope showed a real waveform only on the first pad of the timer. Track which pad is canonical (first-encountered, matching the same scan order beeperInit() uses) per physical timer; only that pad gets TIM_USE_BEEPER, siblings get no output-group flags at all since their timer's period is already claimed by the buzzer.
Sibling channels on a BEEPER-mode timer can't do PWM (the timer's period is fixed for an audible tone), but they can still be driven as simple on/off GPIO outputs. Flag them TIM_USE_PINIO instead of leaving them unusable, and add a GPIO fallback to pinioInit()'s Pass 2 for pads that fail PWM setup for this reason.
Contributor
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Test firmware build ready — commit Download firmware for PR #11686 240 targets built. Find your board's
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follows up on #11675 (unified buzzer output). When a timer is set to BEEPER output mode, only the timer's first channel is actually wired up as the beeper (
beeperInit()picks the first match); the other channels on that same physical timer share its period register and can't independently do anything else. Previously those sibling channels kept whatever usage flags they already had, so the Configurator's Mixer tab labeled every pad on that timer "Buzzer" even though only one pad actually functioned as one.Changes
pwm_mapping.c:timerHardwareOverride()now only appliesTIM_USE_BEEPERto the canonical (first-match) pad on a BEEPER-mode timer. Sibling pads get their motor/servo/LED/beeper flags cleared so they're no longer mislabeled.pinio.c/pwm_mapping.c: since sibling pads can't do PWM (the timer's period is fixed for an audible tone) but can still be driven as simple on/off outputs, they're now flaggedTIM_USE_PINIOinstead of being left completely unusable. Added a GPIO-only fallback topinioInit()'s Pass 2 (mirroring the existing fallback in Pass 1) for pads that fail PWM setup for this reason.PINIO_COUNT(4) and MSP labeling caps are respected automatically — on boards that already have 4 target-defined PINIO pins, the new sibling pads are correctly inert with no phantom labels in the Configurator.Testing
TIM_USE_BEEPER/BEEPER label, and manually confirmed the buzzer works correctly when moved to different pads on the same timer bank.Related Issues
Follow-up to #11675