diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.cpp b/libraries/AP_HAL_ChibiOS/RCOutput.cpp index 4b223a2ab1..5339019e9d 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput.cpp @@ -1073,6 +1073,7 @@ void RCOutput::dshot_send(pwm_group &group, bool blocking) } else if (!group.dma_handle->lock_nonblock()) { return; } + #ifdef HAL_WITH_BIDIR_DSHOT // assume that we won't be able to get the input capture lock group.bdshot.enabled = false; @@ -1316,6 +1317,9 @@ bool RCOutput::serial_setup_output(uint8_t chan, uint32_t baudrate, uint16_t cha return false; } + // stop further dshot output before we reconfigure the DMA + serial_group = new_serial_group; + // setup the groups for serial output. We ask for a bit width of 1, which gets modified by the // we setup all groups so they all are setup with the right polarity, and to make switching between // channels in blheli pass-thru fast @@ -1328,8 +1332,6 @@ bool RCOutput::serial_setup_output(uint8_t chan, uint32_t baudrate, uint16_t cha } } - serial_group = new_serial_group; - // run the thread doing serial IO at highest priority. This is needed to ensure we don't // lose bytes when we switch between output and input serial_thread = chThdGetSelfX(); diff --git a/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp b/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp index ccc224cbe0..f570b85910 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp @@ -466,7 +466,7 @@ void RCOutput::dma_up_irq_callback(void *p, uint32_t flags) if (group->in_serial_dma && irq.waiter) { // tell the waiting process we've done the DMA chEvtSignalI(irq.waiter, serial_event_mask); - } else if (group->bdshot.enabled) { + } else if (!group->in_serial_dma && group->bdshot.enabled) { group->dshot_state = DshotState::SEND_COMPLETE; // sending is done, in 30us the ESC will send telemetry TOGGLE_PIN_DEBUG(55);