diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index 2f9931e95a..441f64835e 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -673,8 +673,11 @@ FAST_CODE uint16_t prepareDshotPacket(motorDmaOutput_t *const motor) csum ^= csum_data; // xor data by nibbles csum_data >>= 4; } - csum &= 0xf; // append checksum + if (useDshotTelemetry) { + csum = ~csum; + } + csum &= 0xf; packet = (packet << 4) | csum; return packet; diff --git a/src/main/drivers/pwm_output_dshot.c b/src/main/drivers/pwm_output_dshot.c index b68e359607..6a23638a89 100644 --- a/src/main/drivers/pwm_output_dshot.c +++ b/src/main/drivers/pwm_output_dshot.c @@ -269,14 +269,12 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m const bool configureTimer = (timerIndex == dmaMotorTimerCount-1); uint8_t pupMode = 0; + pupMode = (output & TIMER_OUTPUT_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP; #ifdef USE_DSHOT_TELEMETRY - if (!useDshotTelemetry) { - pupMode = (output & TIMER_OUTPUT_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP; - } else -#endif - { - pupMode = (output & TIMER_OUTPUT_INVERTED) ? GPIO_PuPd_UP : GPIO_PuPd_DOWN; + if (useDshotTelemetry) { + output ^= TIMER_OUTPUT_INVERTED; } +#endif IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, pupMode), timerHardware->alternateFunction); diff --git a/src/main/drivers/pwm_output_dshot_shared.c b/src/main/drivers/pwm_output_dshot_shared.c index 0f6f4bbe66..4510767bb4 100644 --- a/src/main/drivers/pwm_output_dshot_shared.c +++ b/src/main/drivers/pwm_output_dshot_shared.c @@ -150,7 +150,7 @@ static uint16_t decodeDshotPacket(uint32_t buffer[]) csum = csum ^ (csum >> 8); // xor bytes csum = csum ^ (csum >> 4); // xor nibbles - if (csum & 0xf) { + if ((csum & 0xf) != 0) { return 0xffff; } return value >> 4; @@ -176,7 +176,7 @@ static uint16_t decodeProshotPacket(uint32_t buffer[]) csum = csum ^ (csum >> 8); // xor bytes csum = csum ^ (csum >> 4); // xor nibbles - if (csum & 0xf) { + if ((csum & 0xf) != 0) { return 0xffff; } return value >> 4;