mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 11:38:56 +08:00
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:
co-authored by
Copilot
Jacob Dahl
parent
c25fcabcc6
commit
12745baf6c
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user