diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.cpp b/libraries/AP_HAL_ChibiOS/RCOutput.cpp index 1163b903eab2a..223e5844d873f 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput.cpp @@ -1071,6 +1071,7 @@ void RCOutput::set_group_mode(pwm_group &group) #if HAL_SERIALLED_ENABLED { uint8_t bits_per_pixel = 24; + uint32_t bit_width = NEOP_BIT_WIDTH_TICKS; bool active_high = true; if (!start_led_thread()) { @@ -1080,6 +1081,7 @@ void RCOutput::set_group_mode(pwm_group &group) if (group.current_mode == MODE_PROFILED) { bits_per_pixel = 25; + bit_width = PROFI_BIT_WIDTH_TICKS; active_high = false; } @@ -1094,7 +1096,7 @@ void RCOutput::set_group_mode(pwm_group &group) // calculate min time between pulses taking into account the DMAR parallelism const uint32_t pulse_time_us = 1000000UL * bit_length / rate; - if (!setup_group_DMA(group, rate, NEOP_BIT_WIDTH_TICKS, active_high, buffer_length, pulse_time_us, false)) { + if (!setup_group_DMA(group, rate, bit_width, active_high, buffer_length, pulse_time_us, false)) { group.current_mode = MODE_PWM_NONE; break; } @@ -1698,7 +1700,8 @@ bool RCOutput::serial_led_send(pwm_group &group) } #if HAL_DSHOT_ENABLED - if (soft_serial_waiting() || (group.dshot_state != DshotState::IDLE && group.dshot_state != DshotState::RECV_COMPLETE)) { + if (soft_serial_waiting() || (group.dshot_state != DshotState::IDLE && group.dshot_state != DshotState::RECV_COMPLETE) + || AP_HAL::micros64() - group.last_dmar_send_us < (group.dshot_pulse_time_us + 50)) { // doing serial output or DMAR input, don't send DShot pulses return false; } diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.h b/libraries/AP_HAL_ChibiOS/RCOutput.h index 5dd9e84643f7c..b0984b3bfdd8f 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.h +++ b/libraries/AP_HAL_ChibiOS/RCOutput.h @@ -414,7 +414,7 @@ class ChibiOS::RCOutput : public AP_HAL::RCOutput #endif // HAL_WITH_BIDIR_DSHOT // are we safe to send another pulse? bool can_send_dshot_pulse() const { - return is_dshot_protocol(current_mode) && AP_HAL::micros() - last_dmar_send_us > (dshot_pulse_time_us + 50); + return is_dshot_protocol(current_mode) && AP_HAL::micros64() - last_dmar_send_us > (dshot_pulse_time_us + 50); } // return whether the group channel is both enabled in the group and for output