AP_HAL_Linux: RCOutput_Navio: allow to have other offset

This commit is contained in:
Lucas De Marchi 2015-08-25 16:06:10 -03:00 committed by Andrew Tridgell
parent 3beaf34aa1
commit 6c042b6666
3 changed files with 9 additions and 4 deletions

View File

@ -94,7 +94,7 @@ static LinuxRCOutput_AioPRU rcoutDriver;
use the PCA9685 based RCOutput driver on Navio
*/
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
static LinuxRCOutput_Navio rcoutDriver(RPI_GPIO_27);
static LinuxRCOutput_Navio rcoutDriver(3, RPI_GPIO_27);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ
static LinuxRCOutput_ZYNQ rcoutDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP

View File

@ -50,11 +50,13 @@ using namespace Linux;
static const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;
LinuxRCOutput_Navio::LinuxRCOutput_Navio(uint8_t oe_pin_number) :
LinuxRCOutput_Navio::LinuxRCOutput_Navio(uint8_t channel_offset,
uint8_t oe_pin_number) :
_i2c_sem(NULL),
_enable_pin(NULL),
_frequency(50),
_pulses_buffer(new uint16_t[PWM_CHAN_COUNT]),
_channel_offset(channel_offset),
_oe_pin_number(oe_pin_number)
{
}
@ -169,7 +171,7 @@ void LinuxRCOutput_Navio::write(uint8_t ch, uint16_t period_us)
uint8_t data[2] = {length & 0xFF, length >> 8};
uint8_t status = hal.i2c->writeRegisters(PCA9685_ADDRESS,
PCA9685_RA_LED0_OFF_L + 4 * (ch + 3),
PCA9685_RA_LED0_OFF_L + 4 * (ch + _channel_offset),
2,
data);

View File

@ -6,7 +6,8 @@
class Linux::LinuxRCOutput_Navio : public AP_HAL::RCOutput {
public:
LinuxRCOutput_Navio(uint8_t oe_pin_number);
LinuxRCOutput_Navio(uint8_t channel_offset,
uint8_t oe_pin_number);
~LinuxRCOutput_Navio();
void init(void* machtnichts);
void reset_all_channels();
@ -27,6 +28,8 @@ private:
uint16_t _frequency;
uint16_t *_pulses_buffer;
uint8_t _channel_offset;
uint8_t _oe_pin_number;
};