Skip to content

Conversation

@AlexKlimaj
Copy link
Member

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:

  • Added support for setting the I2C address (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]
  • Updated board configuration files (*.px4board) to enable the PCA9685 driver on additional boards (fmu-v6x, fpv, pi6x). [1] [2] [3]
  • Modified board sensor initialization scripts to start the PCA9685 driver only if the enable parameter is set, and to use parameter-based configuration rather than hardcoded command-line arguments. [1] [2] [3] [4] [5]
  • Set default values for the new parameters in relevant board default scripts, ensuring consistent startup behavior.

Documentation Updates:

  • Added documentation for the new PCA9685_I2C_ADDR parameter and clarified that both bus and address can be configured via parameters or command line. [1] [2]

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.
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

No flaws found

Copy link
Contributor

Copilot AI left a 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_ADDR parameter 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
Copy link

Copilot AI Dec 5, 2025

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
Suggested change
type: int32
type: int32
min: 0
max: 127

Copilot uses AI. Check for mistakes.
if (param_handle != PARAM_INVALID) {
param_get(param_handle, &i2c_addr);

if (i2c_addr > 0) {
Copy link

Copilot AI Dec 5, 2025

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.

Suggested change
if (i2c_addr > 0) {
if (i2c_addr >= 0) {

Copilot uses AI. Check for mistakes.
@dakejahl dakejahl self-assigned this Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants