mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 05:45:31 +03:00
Dshot commands via MSP
This commit is contained in:
parent
79c2f79919
commit
fecf19b0d7
2 changed files with 31 additions and 0 deletions
|
@ -55,6 +55,7 @@
|
||||||
#include "drivers/compass/compass.h"
|
#include "drivers/compass/compass.h"
|
||||||
#include "drivers/display.h"
|
#include "drivers/display.h"
|
||||||
#include "drivers/dshot.h"
|
#include "drivers/dshot.h"
|
||||||
|
#include "drivers/dshot_command.h"
|
||||||
#include "drivers/flash.h"
|
#include "drivers/flash.h"
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "drivers/motor.h"
|
#include "drivers/motor.h"
|
||||||
|
@ -3002,6 +3003,34 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
|
||||||
}
|
}
|
||||||
break;
|
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
|
#ifdef USE_CAMERA_CONTROL
|
||||||
case MSP_CAMERA_CONTROL:
|
case MSP_CAMERA_CONTROL:
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,3 +21,5 @@
|
||||||
#define MSP2_BETAFLIGHT_BIND 0x3000
|
#define MSP2_BETAFLIGHT_BIND 0x3000
|
||||||
#define MSP2_MOTOR_OUTPUT_REORDERING 0x3001
|
#define MSP2_MOTOR_OUTPUT_REORDERING 0x3001
|
||||||
#define MSP2_SET_MOTOR_OUTPUT_REORDERING 0x3002
|
#define MSP2_SET_MOTOR_OUTPUT_REORDERING 0x3002
|
||||||
|
#define MSP2_SEND_DSHOT_COMMAND 0x3003
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue