Adds configurable I2C address for PCA9685 PWM driver (#26051)

* Adds configurable I2C address for PCA9685 PWM driver

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.

* Update src/drivers/pca9685_pwm_out/module.yaml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/drivers/pca9685_pwm_out/module.yaml

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
Alex Klimaj
2025-12-12 09:31:19 -09:00
committed by GitHub
co-authored by Copilot Jacob Dahl
parent c25fcabcc6
commit 12745baf6c
13 changed files with 74 additions and 4 deletions
+25 -2
View File
@@ -47,6 +47,7 @@
#include <drivers/drv_hrt.h>
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/sem.hpp>
#include <lib/parameters/param.h>
#include "PCA9685.h"
@@ -356,8 +357,30 @@ int PCA9685Wrapper::custom_command(int argc, char **argv) {
int PCA9685Wrapper::task_spawn(int argc, char **argv) {
int ch;
int address=PCA9685_DEFAULT_ADDRESS;
int iicbus=PCA9685_DEFAULT_IICBUS;
int address = PCA9685_DEFAULT_ADDRESS;
int iicbus = PCA9685_DEFAULT_IICBUS;
int32_t en_bus = 0;
param_t param_handle = param_find("PCA9685_EN_BUS");
if (param_handle != PARAM_INVALID) {
param_get(param_handle, &en_bus);
if (en_bus > 0) {
iicbus = en_bus;
}
}
int32_t i2c_addr = 0;
param_handle = param_find("PCA9685_I2C_ADDR");
if (param_handle != PARAM_INVALID) {
param_get(param_handle, &i2c_addr);
if (i2c_addr > 0) {
address = i2c_addr;
}
}
int myoptind = 1;
const char *myoptarg = nullptr;
+10
View File
@@ -29,6 +29,16 @@ parameters:
min: 0
max: 10
default: 0
PCA9685_I2C_ADDR:
description:
short: I2C address of PCA9685
long: |
I2C address of PCA9685.
The default address is 0x40 (64).
type: int32
min: 1
max: 127
default: 64
PCA9685_SCHD_HZ:
description:
short: PWM update rate