Skip to content

Fix BEEPER timer sibling pad mislabeling and expose them as PINIO#11686

Open
sensei-hacker wants to merge 2 commits into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix/beeper-timer-sibling-pad-flags
Open

Fix BEEPER timer sibling pad mislabeling and expose them as PINIO#11686
sensei-hacker wants to merge 2 commits into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix/beeper-timer-sibling-pad-flags

Conversation

@sensei-hacker

Copy link
Copy Markdown
Member

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 applies TIM_USE_BEEPER to 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 flagged TIM_USE_PINIO instead of being left completely unusable. Added a GPIO-only fallback to pinioInit()'s Pass 2 (mirroring the existing fallback in Pass 1) for pads that fail PWM setup for this reason.
  • Existing 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

  • Build-verified (BROTHERHOBBYH743, KAKUTEF7): clean compile and link, no new warnings.
  • Hardware-verified on a BrotherHobby H743: confirmed via MSP that only the canonical beeper pad reports TIM_USE_BEEPER/BEEPER label, and manually confirmed the buzzer works correctly when moved to different pads on the same timer bank.
  • Code-reviewed (embedded-C correctness, IO ownership/resource-index correctness, struct-field parity with the existing Pass 1 GPIO fallback pattern): approved.

Related Issues

Follow-up to #11675

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.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Test firmware build ready — commit 31bb99e

Download firmware for PR #11686

240 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant