1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Dshot commands via MSP

This commit is contained in:
limonspb 2020-11-27 22:35:58 -06:00
parent 79c2f79919
commit fecf19b0d7
2 changed files with 31 additions and 0 deletions

View file

@ -55,6 +55,7 @@
#include "drivers/compass/compass.h"
#include "drivers/display.h"
#include "drivers/dshot.h"
#include "drivers/dshot_command.h"
#include "drivers/flash.h"
#include "drivers/io.h"
#include "drivers/motor.h"
@ -3002,6 +3003,34 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
}
break;
#ifdef USE_DSHOT
case MSP2_SEND_DSHOT_COMMAND:
{
const bool armed = ARMING_FLAG(ARMED);
if (!armed) {
const uint8_t commandType = sbufReadU8(src);
const uint8_t motorIndex = sbufReadU8(src);
const uint8_t commandCount = sbufReadU8(src);
if (DSHOT_CMD_TYPE_BLOCKING == commandType) {
motorDisable();
}
for (uint8_t i = 0; i < commandCount; i++) {
const uint8_t commandIndex = sbufReadU8(src);
dshotCommandWrite(motorIndex, getMotorCount(), commandIndex, commandType);
delay(1);
}
if (DSHOT_CMD_TYPE_BLOCKING == commandType) {
motorEnable();
}
}
}
break;
#endif
#ifdef USE_CAMERA_CONTROL
case MSP_CAMERA_CONTROL:
{

View file

@ -21,3 +21,5 @@
#define MSP2_BETAFLIGHT_BIND 0x3000
#define MSP2_MOTOR_OUTPUT_REORDERING 0x3001
#define MSP2_SET_MOTOR_OUTPUT_REORDERING 0x3002
#define MSP2_SEND_DSHOT_COMMAND 0x3003