Initialize the beeper before setting up LEDs - #98
Open
Michael-ango wants to merge 1 commit into
Open
Conversation
beeper_init() configures VESC_PIN_PPM as a GPIO output, which is the same pad as LED_PIN_B6. Since d31ce1d moved the leds_setup() call into data_init(), beeper_init() runs afterwards and takes the pad back from the LED timer, silently disabling LEDs configured on B6. Move the beeper initialization into data_init(), after the config is read and before leds_setup(), restoring the previous ordering. It cannot go earlier, as the condition reads the configuration. Fix: Fix LEDs configured on pin B6 not working
Author
|
Additionally, a check could be implemented that checks if the LEDs and beeper are configured on the same pin and output a log_error() to avoid silent failures like this in the future. The reordering I'm proposing would flip the conflict silence if a user accidentally configures both the beeper and led at the same time. The beeper would fail with no clear reason why. Currently this commit is the simplest approach to clearing the unavoidable conflict, an additional check is just a quality of life improvement. A beeper/led conflict after this would require negligent configuration. |
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.
LEDs configured on pin B6 stopped working for me after upgrading from 1.2.1.
leds_setup()configures B6 asPAL_MODE_ALTERNATE(2)so TIM4 CH1 drives the pad.beeper_init()then callsio_set_mode(VESC_PIN_PPM, VESC_PIN_MODE_OUTPUT)on thesame pad, which switches MODER to general-purpose output and disconnects the
alternate-function mux. The timer and DMA keep running and
led_driver_paint()keepswriting frames, but nothing reaches the pin, and nothing is logged.
Confirmed
VESC_PIN_PPMandLED_PIN_B6are the same pad: with the pin held low,evaluating
(gpio-configure 'pin-ppm 'pin-mode-in-pu)released it to 5 V.Note that disabling the beeper doesn't avoid this, since the guard is an OR, it runs
regardless unless
inputtilt_remote_typehappens to be PPM.Tested: built unmodified from source and reproduced the fault, then confirmed this patch
fixes it on hardware.