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

Added support for DShot ESC settings to CLI.

This commit is contained in:
mikeller 2017-02-13 22:28:30 +13:00
parent 79b4badf62
commit 85b002bb73
7 changed files with 103 additions and 41 deletions

View file

@ -21,6 +21,7 @@
#include <math.h>
#include "platform.h"
#include "system.h"
#include "io.h"
#include "pwm_output.h"
@ -29,6 +30,8 @@
#define MULTISHOT_5US_PW (MULTISHOT_TIMER_MHZ * 5)
#define MULTISHOT_20US_MULT (MULTISHOT_TIMER_MHZ * 20 / 1000.0f)
#define DSHOT_MAX_COMMAND 47
static pwmWriteFuncPtr pwmWritePtr;
static pwmOutputPort_t motors[MAX_SUPPORTED_MOTORS];
static pwmCompleteWriteFuncPtr pwmCompleteWritePtr = NULL;
@ -315,6 +318,27 @@ uint32_t getDshotHz(motorPwmProtocolTypes_e pwmProtocolType)
return MOTOR_DSHOT150_MHZ * 1000000;
}
}
void pwmWriteDshotCommand(uint8_t index, uint8_t command)
{
if (command <= DSHOT_MAX_COMMAND) {
motorDmaOutput_t *const motor = getMotorDmaOutput(index);
unsigned repeats;
if ((command >= 7 && command <= 10) || command == 12) {
repeats = 10;
} else {
repeats = 1;
}
for (; repeats; repeats--) {
motor->requestTelemetry = true;
pwmWritePtr(index, command);
pwmCompleteMotorUpdate(0);
delay(1);
}
}
}
#endif
#ifdef USE_SERVOS