1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

invert dshot

This commit is contained in:
Thorsten Laux 2019-04-22 11:44:39 +02:00
parent bcac7f2e0b
commit 4a7be33c25
3 changed files with 10 additions and 9 deletions

View file

@ -673,8 +673,11 @@ FAST_CODE uint16_t prepareDshotPacket(motorDmaOutput_t *const motor)
csum ^= csum_data; // xor data by nibbles csum ^= csum_data; // xor data by nibbles
csum_data >>= 4; csum_data >>= 4;
} }
csum &= 0xf;
// append checksum // append checksum
if (useDshotTelemetry) {
csum = ~csum;
}
csum &= 0xf;
packet = (packet << 4) | csum; packet = (packet << 4) | csum;
return packet; return packet;

View file

@ -269,14 +269,12 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1); const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
uint8_t pupMode = 0; uint8_t pupMode = 0;
pupMode = (output & TIMER_OUTPUT_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP;
#ifdef USE_DSHOT_TELEMETRY #ifdef USE_DSHOT_TELEMETRY
if (!useDshotTelemetry) { if (useDshotTelemetry) {
pupMode = (output & TIMER_OUTPUT_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP; output ^= TIMER_OUTPUT_INVERTED;
} else
#endif
{
pupMode = (output & TIMER_OUTPUT_INVERTED) ? GPIO_PuPd_UP : GPIO_PuPd_DOWN;
} }
#endif
IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, pupMode), timerHardware->alternateFunction); IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, pupMode), timerHardware->alternateFunction);

View file

@ -150,7 +150,7 @@ static uint16_t decodeDshotPacket(uint32_t buffer[])
csum = csum ^ (csum >> 8); // xor bytes csum = csum ^ (csum >> 8); // xor bytes
csum = csum ^ (csum >> 4); // xor nibbles csum = csum ^ (csum >> 4); // xor nibbles
if (csum & 0xf) { if ((csum & 0xf) != 0) {
return 0xffff; return 0xffff;
} }
return value >> 4; return value >> 4;
@ -176,7 +176,7 @@ static uint16_t decodeProshotPacket(uint32_t buffer[])
csum = csum ^ (csum >> 8); // xor bytes csum = csum ^ (csum >> 8); // xor bytes
csum = csum ^ (csum >> 4); // xor nibbles csum = csum ^ (csum >> 4); // xor nibbles
if (csum & 0xf) { if ((csum & 0xf) != 0) {
return 0xffff; return 0xffff;
} }
return value >> 4; return value >> 4;