RCOutput_PCA9685: allow different external clock frequencies

The PCA9685 may use an external clock 0~50MHz
Specify the external clock frequency in constructor arguments for each board HAL
This commit is contained in:
Jacob Walser 2020-11-17 13:25:14 -05:00 committed by Lucas De Marchi
parent 8561f5239d
commit e64d9816ce
2 changed files with 7 additions and 7 deletions

View File

@ -48,7 +48,6 @@
* and https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library/issues/11
*/
#define PCA9685_INTERNAL_CLOCK (1.04f * 25000000.f)
#define PCA9685_EXTERNAL_CLOCK 24576000.f
using namespace Linux;
@ -57,7 +56,7 @@ using namespace Linux;
extern const AP_HAL::HAL& hal;
RCOutput_PCA9685::RCOutput_PCA9685(AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev,
bool external_clock,
uint32_t external_clock,
uint8_t channel_offset,
int16_t oe_pin_number) :
_dev(std::move(dev)),
@ -68,10 +67,11 @@ RCOutput_PCA9685::RCOutput_PCA9685(AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev,
_channel_offset(channel_offset),
_oe_pin_number(oe_pin_number)
{
if (_external_clock)
_osc_clock = PCA9685_EXTERNAL_CLOCK;
else
if (_external_clock > 0) {
_osc_clock = _external_clock;
} else {
_osc_clock = PCA9685_INTERNAL_CLOCK;
}
}
RCOutput_PCA9685::~RCOutput_PCA9685()

View File

@ -15,7 +15,7 @@ namespace Linux {
class RCOutput_PCA9685 : public AP_HAL::RCOutput {
public:
RCOutput_PCA9685(AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev,
bool external_clock,
uint32_t external_clock,
uint8_t channel_offset,
int16_t oe_pin_number);
@ -42,7 +42,7 @@ private:
uint16_t *_pulses_buffer;
bool _external_clock;
uint32_t _external_clock;
bool _corking = false;
uint8_t _channel_offset;
int16_t _oe_pin_number;