From 2a786616b11811f92a047000f17db67db514b0a4 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Tue, 16 Apr 2024 17:56:58 +0100 Subject: [PATCH] AP_IOMCU: account for possibility of SBUS_OUT in PWM structures --- libraries/AP_IOMCU/AP_IOMCU.cpp | 4 ++-- libraries/AP_IOMCU/iofirmware/iofirmware.cpp | 2 +- libraries/AP_IOMCU/iofirmware/iofirmware.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/AP_IOMCU/AP_IOMCU.cpp b/libraries/AP_IOMCU/AP_IOMCU.cpp index fefa91ebf0..73f283532f 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.cpp +++ b/libraries/AP_IOMCU/AP_IOMCU.cpp @@ -346,7 +346,7 @@ void AP_IOMCU::thread_main(void) // update failsafe pwm if (pwm_out.failsafe_pwm_set != pwm_out.failsafe_pwm_sent) { uint8_t set = pwm_out.failsafe_pwm_set; - if (write_registers(PAGE_FAILSAFE_PWM, 0, IOMCU_MAX_CHANNELS, pwm_out.failsafe_pwm)) { + if (write_registers(PAGE_FAILSAFE_PWM, 0, IOMCU_MAX_RC_CHANNELS, pwm_out.failsafe_pwm)) { pwm_out.failsafe_pwm_sent = set; } } @@ -372,7 +372,7 @@ void AP_IOMCU::send_servo_out() if (rate.sbus_rate_hz == 0) { n = MIN(n, 8); } else { - n = MIN(n, IOMCU_MAX_CHANNELS); + n = MIN(n, IOMCU_MAX_RC_CHANNELS); } uint32_t now = AP_HAL::micros(); if (now - last_servo_out_us >= 2000 || AP_BoardConfig::io_dshot()) { diff --git a/libraries/AP_IOMCU/iofirmware/iofirmware.cpp b/libraries/AP_IOMCU/iofirmware/iofirmware.cpp index 6e97fa4cf2..545dfad9aa 100644 --- a/libraries/AP_IOMCU/iofirmware/iofirmware.cpp +++ b/libraries/AP_IOMCU/iofirmware/iofirmware.cpp @@ -966,7 +966,7 @@ bool AP_IOMCU_FW::handle_code_write() } /* copy channel data */ uint16_t i = 0, num_values = rx_io_packet.count; - while ((i < IOMCU_MAX_CHANNELS) && (num_values > 0)) { + while ((i < IOMCU_MAX_RC_CHANNELS) && (num_values > 0)) { /* XXX range-check value? */ if (rx_io_packet.regs[i] != PWM_IGNORE_THIS_CHANNEL) { reg_direct_pwm.pwm[i] = rx_io_packet.regs[i]; diff --git a/libraries/AP_IOMCU/iofirmware/iofirmware.h b/libraries/AP_IOMCU/iofirmware/iofirmware.h index 824a2238e4..6069b3cf2a 100644 --- a/libraries/AP_IOMCU/iofirmware/iofirmware.h +++ b/libraries/AP_IOMCU/iofirmware/iofirmware.h @@ -93,17 +93,17 @@ public: // PAGE_SERVO values struct { - uint16_t pwm[IOMCU_MAX_CHANNELS]; + uint16_t pwm[IOMCU_MAX_RC_CHANNELS]; // size has to account for virtual channels via SBUS_OUT } reg_servo; // PAGE_DIRECT_PWM values struct { - uint16_t pwm[IOMCU_MAX_CHANNELS]; + uint16_t pwm[IOMCU_MAX_RC_CHANNELS]; } reg_direct_pwm; // PAGE_FAILSAFE_PWM struct { - uint16_t pwm[IOMCU_MAX_CHANNELS]; + uint16_t pwm[IOMCU_MAX_RC_CHANNELS]; } reg_failsafe_pwm; // output rates