Repository navigation
feat(pwmout/gpioout/pca9685): add possibility to configure pwm-channels as gpios - #29409
marinauterion wants to merge 3 commits into
Conversation
🔎 Flash and RAM Analysis
px4_io-v2 firmware image, which an FMU flashes to its IO at boot: 🔴 changed. px4_fmu-v2 — Bloaty section/symbol breakdownpx4_fmu-v5x — Bloaty section/symbol breakdownpx4_fmu-v6x — Bloaty section/symbol breakdownpx4_io-v2 — Bloaty section/symbol breakdownUpdated: 2026-11-26T02:20:12 |
|
No broken links found in changed files. |
7591dd5 to
580fbf4
Compare
|
Claude review on behalf of @dakejahl Merge after fixes: with any GPIO_EN bit set, gpio_out takes Must-fix
Optional
|
1bec3f6 to
3a3ced1
Compare
3a3ced1 to
671ca4e
Compare
…ls as plain gpios feat(Tools/module_config/generate_actuators_metadata): implement TODO to skip custom params that are notdefined by any module Signed-off-by: Marin Doetterer <marin@auterion.com>
- start gpio_out after dshot/pwm_out to keep the existing actuator_outputs instances - pwm_out and dshot mask out <prefix>_GPIO_EN channels instead of relying on claim order - reject GPIO channels on DShot timers and bits beyond the board's channel count - hide the GPIO column in QGC for DShot timers (same show_if as DIS/MIN/MAX) - report 0 on non-GPIO channels in gpio_out's actuator_outputs - gpio_out depends on DRIVERS_PWM_OUT - drop the unused GPIO channel mode on RP2040/ESP32 and the PARAM_INVALID guard in pwm_out - docs: DShot limitation and boot behaviour Signed-off-by: Marin Doetterer <marin@auterion.com>
671ca4e to
cafc5bb
Compare
|
@hamishwillee: Could you please check the docs part of the change? Thanks a lot. |
Review follow-up for the new GPIO Outputs section: add a version badge, state that dshot does not drive a DShot-timer output selected as GPIO, say that most firmware lacks gpio_out and how to enable it, note that PCA9685 changes need no reboot, and link the new parameters and modules. Also clarify that PWM MAIN holds the FMU outputs on boards without an I/O board, and use consistent output/checkbox wording. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
There was a problem hiding this comment.
@marinauterion @alexcekay Apologies for the delay. I'm swamped and I missed this. I've improved my tracking which is how I found this, but please ping me again if you don't get a response.
If something has to go in urgently and I am the blocker, send me a message in slack.
Firstly, despite all the comments, this is great. Most of it is spotted by my Claude instance, which is set up to check things no one would think of, such as "Does the yaml long descrption repeat the short description and how can I minimise it". So most of this is minor consistency fixes.
I pushed f3dd207 with docs tidy-ups to the GPIO Outputs section:
- version badge
- "output"/"checkbox" wording
- info box rewrite:
gpio_outmust be in firmware and how to enable it, anddshotdoesn't drive a DShot output selected as GPIO - PCA9685 changes need no reboot
- links to the new parameters and modules
- PWM MAIN tab description
Inline, there's a question on the pin state before gpio_out starts, and suggestions for the parameter descriptions.
Outside this PR's lines:
- The
PCA9685_DUTY_ENlong description has grammar errors ("Other standard params follows", "12bits"). docs/en/flight_modes_fw/hold.mdL64 linksboards/auterion/fmu-v6s/default.px4board#L46forCONFIG_FIGURE_OF_EIGHT. That setting is at L50 after this PR (L49 before it).
| The output keeps its reset level until `gpio_out` starts, which happens after the other output drivers during boot. | ||
| It is then set to the level of its disarmed value. |
There was a problem hiding this comment.
What is the pin state before gpio_out starts: floating, or set by the board? If it depends on the board.
Claude suggests this. Push back if it makes no sense on any of this.
| The output keeps its reset level until `gpio_out` starts, which happens after the other output drivers during boot. | |
| It is then set to the level of its disarmed value. | |
| Until `gpio_out` starts, which happens after the other output drivers during boot, the pin is in its power-on state (which depends on the board). | |
| It is then set to the level of its disarmed value. |
| long: | | ||
| Selecting which channels are driven as plain digital (on/off) outputs. |
There was a problem hiding this comment.
Say how the level is chosen and that DShot timers aren't supported; don't duplicate the short description in the long description.
| long: | | |
| Selecting which channels are driven as plain digital (on/off) outputs. | |
| long: High if the output is above the midpoint of PWM_MAIN_MINn and PWM_MAIN_MAXn, otherwise low. Not supported on DShot timers. |
| long: | | ||
| Selecting which channels are driven as plain digital (on/off) outputs. |
There was a problem hiding this comment.
Say how the level is chosen and that DShot timers aren't supported; don't duplicate the short description in the long description.
| long: | | |
| Selecting which channels are driven as plain digital (on/off) outputs. | |
| long: High if the output is above the midpoint of PWM_AUX_MINn and PWM_AUX_MAXn, otherwise low. Not supported on DShot timers. |
| long: | | ||
| Selecting which channels are driven as plain digital (on/off) outputs. |
There was a problem hiding this comment.
Say how the level is chosen; don't duplicate the short description in the long description.
| long: | | |
| Selecting which channels are driven as plain digital (on/off) outputs. | |
| long: On if the output is above the midpoint of PCA9685_MINn and PCA9685_MAXn, otherwise off. Overrides PCA9685_DUTY_EN. |
| 0: Put CH1 into GPIO mode | ||
| 1: Put CH2 into GPIO mode | ||
| 2: Put CH3 into GPIO mode | ||
| 3: Put CH4 into GPIO mode | ||
| 4: Put CH5 into GPIO mode | ||
| 5: Put CH6 into GPIO mode | ||
| 6: Put CH7 into GPIO mode | ||
| 7: Put CH8 into GPIO mode | ||
| 8: Put CH9 into GPIO mode | ||
| 9: Put CH10 into GPIO mode | ||
| 10: Put CH11 into GPIO mode | ||
| 11: Put CH12 into GPIO mode | ||
| 12: Put CH13 into GPIO mode | ||
| 13: Put CH14 into GPIO mode | ||
| 14: Put CH15 into GPIO mode | ||
| 15: Put CH16 into GPIO mode |
There was a problem hiding this comment.
Match the gpio_out bit labels ("in GPIO mode").
| 0: Put CH1 into GPIO mode | |
| 1: Put CH2 into GPIO mode | |
| 2: Put CH3 into GPIO mode | |
| 3: Put CH4 into GPIO mode | |
| 4: Put CH5 into GPIO mode | |
| 5: Put CH6 into GPIO mode | |
| 6: Put CH7 into GPIO mode | |
| 7: Put CH8 into GPIO mode | |
| 8: Put CH9 into GPIO mode | |
| 9: Put CH10 into GPIO mode | |
| 10: Put CH11 into GPIO mode | |
| 11: Put CH12 into GPIO mode | |
| 12: Put CH13 into GPIO mode | |
| 13: Put CH14 into GPIO mode | |
| 14: Put CH15 into GPIO mode | |
| 15: Put CH16 into GPIO mode | |
| 0: Put CH1 in GPIO mode | |
| 1: Put CH2 in GPIO mode | |
| 2: Put CH3 in GPIO mode | |
| 3: Put CH4 in GPIO mode | |
| 4: Put CH5 in GPIO mode | |
| 5: Put CH6 in GPIO mode | |
| 6: Put CH7 in GPIO mode | |
| 7: Put CH8 in GPIO mode | |
| 8: Put CH9 in GPIO mode | |
| 9: Put CH10 in GPIO mode | |
| 10: Put CH11 in GPIO mode | |
| 11: Put CH12 in GPIO mode | |
| 12: Put CH13 in GPIO mode | |
| 13: Put CH14 in GPIO mode | |
| 14: Put CH15 in GPIO mode | |
| 15: Put CH16 in GPIO mode |
| show_as: bitset | ||
| advanced: true | ||
| - name: 'GPIO_EN' | ||
| label: "GPIO\n Mode" |
There was a problem hiding this comment.
Should this match the PWM tab's "GPIO Output" label? (If so, the docs line and screenshot need updating too.)
|
Also, could you please add a release note update in https://docs.px4.io/main/en/releases/main. I'd love to link this from other places to increase visibility. Perhaps a comment in the intro https://docs.px4.io/main/en/getting_started/px4_basic_concepts#outputs-motors-servos-actuators that links to your new section? This is "at your discretion" - but IMO it certainly wouldn't hurt. |
Solved Problem
Implement the ability to control PWM outputs as GPIO (ON/OFF) within PX4. This is required to enable toggling peripherals, such as the airspeed sensor, on and off.
Currently, these pins are directly driven by timers (TIMs) and lack the option for direct GPIO control.
Solution
gpio_outdrives the FMU channels selected inPWM_MAIN_GPIO_EN/PWM_AUX_GPIO_ENas GPIOs: HIGH ifoutput > (MIN + MAX) / 2, else LOW.pwm_outanddshotskip these channels;gpio_outstarts last, so existingactuator_outputsinstances are unchanged.gpio_out, hidden in QGC).pca9685_pwm_out: same feature viaPCA9685_GPIO_EN.Tests
While PCA can be changed on the fly, changes for PWM_MAIN need a reboot
PWM MAIN
PCA9685 OUTPUT
Testing
2026-10-15-13.32.27.423262484.mp4