-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Adds configurable I2C address for PCA9685 PWM driver #26051
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
base: main
Are you sure you want to change the base?
Conversation
Introduces a parameter to set the I2C address for the PCA9685 PWM output driver, enhancing flexibility for hardware variations. Updates documentation and board initialization scripts to support the new configuration and streamline device startup.
|
No flaws found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds configurable I2C address and bus parameters for the PCA9685 PWM driver, enabling more flexible hardware configuration across different boards. The changes allow users to configure the I2C address via the PCA9685_I2C_ADDR parameter (default 0x40/64) in addition to the existing bus selection parameter, replacing hardcoded command-line arguments with parameter-driven configuration.
- Adds
PCA9685_I2C_ADDRparameter for configuring the I2C address of the PCA9685 chip - Updates driver startup logic to read both bus and address from parameters before parsing command-line arguments
- Enables PCA9685 driver support on three additional ARK boards (fmu-v6x, pi6x, fpv) and updates board initialization scripts to use parameter-based configuration
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/drivers/pca9685_pwm_out/module.yaml | Adds PCA9685_I2C_ADDR parameter definition with default value of 64 (0x40) |
| src/drivers/pca9685_pwm_out/main.cpp | Implements parameter reading for both bus and address at driver startup, includes <lib/parameters/param.h> header |
| docs/en/modules/modules_driver.md | Documents that I2C bus and address can be configured via parameters or command line |
| docs/en/advanced_config/parameter_reference.md | Adds parameter reference entry for PCA9685_I2C_ADDR with valid range 0-127 |
| boards/bluerobotics/navigator/init/rc.board_sensors | Removes hardcoded command-line arguments -a 0x40 -b 4 from driver startup |
| boards/bluerobotics/navigator/init/rc.board_defaults | Sets default parameter values for PCA9685_EN_BUS (4) and PCA9685_I2C_ADDR (64) |
| boards/auterion/fmu-v6s/init/rc.board_sensors | Removes hardcoded bus argument -b 1 from conditional driver startup |
| boards/ark/pi6x/init/rc.board_sensors | Adds conditional PCA9685 driver startup based on PCA9685_EN_BUS parameter |
| boards/ark/pi6x/default.px4board | Enables PCA9685 PWM driver in board configuration |
| boards/ark/fpv/init/rc.board_sensors | Adds conditional PCA9685 driver startup based on PCA9685_EN_BUS parameter |
| boards/ark/fpv/default.px4board | Enables PCA9685 PWM driver in board configuration |
| boards/ark/fmu-v6x/init/rc.board_sensors | Adds conditional PCA9685 driver startup based on PCA9685_EN_BUS parameter |
| boards/ark/fmu-v6x/default.px4board | Enables PCA9685 PWM driver in board configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| long: | | ||
| I2C address of PCA9685. | ||
| The default address is 0x40 (64). | ||
| type: int32 |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PCA9685_I2C_ADDR parameter definition is missing validation bounds (min and max). Valid 7-bit I2C addresses range from 0 to 127. The documentation in parameter_reference.md already includes these bounds (min: 0, max: 127), but they should also be defined here in the parameter definition to ensure proper validation at the parameter system level.
Add the following constraints:
min: 0
max: 127| type: int32 | |
| type: int32 | |
| min: 0 | |
| max: 127 |
| if (param_handle != PARAM_INVALID) { | ||
| param_get(param_handle, &i2c_addr); | ||
|
|
||
| if (i2c_addr > 0) { |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter check if (i2c_addr > 0) will incorrectly reject I2C address 0x00, which is technically a valid 7-bit I2C address (though rarely used). The check should be >= 0 or removed entirely since the parameter system should handle validation if proper min/max constraints are defined in module.yaml.
However, since 0x00 is the general call address and typically not used for device addressing, this might be intentional. If so, the parameter definition in module.yaml should have min: 1 instead of min: 0 to match this behavior.
| if (i2c_addr > 0) { | |
| if (i2c_addr >= 0) { |
This pull request adds support for configuring the I2C address and bus for the PCA9685 external PWM driver via parameters, and ensures these parameters are set and used consistently across supported boards. It also updates documentation to reflect these new configuration options and simplifies the startup logic for the driver in board initialization scripts.
PCA9685 PWM Driver Configuration Enhancements:
PCA9685_I2C_ADDR) of the PCA9685 PWM driver via a parameter, with a default value of 0x40 (64). The driver now reads both the bus (PCA9685_EN_BUS) and address parameters at startup and uses them if set. [1] [2]*.px4board) to enable the PCA9685 driver on additional boards (fmu-v6x,fpv,pi6x). [1] [2] [3]Documentation Updates:
PCA9685_I2C_ADDRparameter and clarified that both bus and address can be configured via parameters or command line. [1] [2]