Skip to content

Commit 2a78661

Browse files
andyp1pertridge
authored andcommitted
AP_IOMCU: account for possibility of SBUS_OUT in PWM structures
1 parent abb94b0 commit 2a78661

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

libraries/AP_IOMCU/AP_IOMCU.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void AP_IOMCU::thread_main(void)
346346
// update failsafe pwm
347347
if (pwm_out.failsafe_pwm_set != pwm_out.failsafe_pwm_sent) {
348348
uint8_t set = pwm_out.failsafe_pwm_set;
349-
if (write_registers(PAGE_FAILSAFE_PWM, 0, IOMCU_MAX_CHANNELS, pwm_out.failsafe_pwm)) {
349+
if (write_registers(PAGE_FAILSAFE_PWM, 0, IOMCU_MAX_RC_CHANNELS, pwm_out.failsafe_pwm)) {
350350
pwm_out.failsafe_pwm_sent = set;
351351
}
352352
}
@@ -372,7 +372,7 @@ void AP_IOMCU::send_servo_out()
372372
if (rate.sbus_rate_hz == 0) {
373373
n = MIN(n, 8);
374374
} else {
375-
n = MIN(n, IOMCU_MAX_CHANNELS);
375+
n = MIN(n, IOMCU_MAX_RC_CHANNELS);
376376
}
377377
uint32_t now = AP_HAL::micros();
378378
if (now - last_servo_out_us >= 2000 || AP_BoardConfig::io_dshot()) {

libraries/AP_IOMCU/iofirmware/iofirmware.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ bool AP_IOMCU_FW::handle_code_write()
966966
}
967967
/* copy channel data */
968968
uint16_t i = 0, num_values = rx_io_packet.count;
969-
while ((i < IOMCU_MAX_CHANNELS) && (num_values > 0)) {
969+
while ((i < IOMCU_MAX_RC_CHANNELS) && (num_values > 0)) {
970970
/* XXX range-check value? */
971971
if (rx_io_packet.regs[i] != PWM_IGNORE_THIS_CHANNEL) {
972972
reg_direct_pwm.pwm[i] = rx_io_packet.regs[i];

libraries/AP_IOMCU/iofirmware/iofirmware.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ class AP_IOMCU_FW {
9393

9494
// PAGE_SERVO values
9595
struct {
96-
uint16_t pwm[IOMCU_MAX_CHANNELS];
96+
uint16_t pwm[IOMCU_MAX_RC_CHANNELS]; // size has to account for virtual channels via SBUS_OUT
9797
} reg_servo;
9898

9999
// PAGE_DIRECT_PWM values
100100
struct {
101-
uint16_t pwm[IOMCU_MAX_CHANNELS];
101+
uint16_t pwm[IOMCU_MAX_RC_CHANNELS];
102102
} reg_direct_pwm;
103103

104104
// PAGE_FAILSAFE_PWM
105105
struct {
106-
uint16_t pwm[IOMCU_MAX_CHANNELS];
106+
uint16_t pwm[IOMCU_MAX_RC_CHANNELS];
107107
} reg_failsafe_pwm;
108108

109109
// output rates

0 commit comments

Comments
 (0)