mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +03:00
DSHOT - Use cycle counting instead of recording timestamp in dshot motor_DMA_IRQHandler.
It turns out that two calls to micros() and the calculation of directionChangeDurationUs took 581 cycles, vs 396 cycles without the calls to micros() and deferred calculation of the duration which is only needed in the CLI. This brings the time down from around 7 microseconds to 5.5 microseconds on an F3 at 72Mhz. This makes the difference between 100% invalid telemetry and 4% invalid telemetry on the first motor on the F3. Squashed commits: * Remove the forward declaration for `pwmDshotSetDirectionInput` and make it static. * Remove unneeded forward declaration of `motor_DMA_IRQHandler`. * Remove duplication in DMA IRQ Handler. Doesn't affect resulting code but improves readability. * Use an inline function to read DWT->CYCCNT. * Remove unneeded forward declarations from cli.c now that the correct header is included. * Update DWT unlock method.
This commit is contained in:
parent
6f4c2bb48c
commit
d016aa2fc4
8 changed files with 76 additions and 33 deletions
|
@ -66,6 +66,7 @@ bool cliMode = false;
|
|||
#include "drivers/dshot.h"
|
||||
#include "drivers/dshot_command.h"
|
||||
#include "drivers/dshot_dpwm.h"
|
||||
#include "drivers/pwm_output_dshot_shared.h"
|
||||
#include "drivers/camera_control.h"
|
||||
#include "drivers/compass/compass.h"
|
||||
#include "drivers/display.h"
|
||||
|
@ -274,12 +275,6 @@ static const char * const *sensorHardwareNames[] = {
|
|||
};
|
||||
#endif // USE_SENSOR_NAMES
|
||||
|
||||
#if defined(USE_DSHOT) && defined(USE_DSHOT_TELEMETRY)
|
||||
extern uint32_t readDoneCount;
|
||||
extern uint32_t inputBuffer[GCR_TELEMETRY_INPUT_LEN];
|
||||
extern uint32_t setDirectionMicros;
|
||||
#endif
|
||||
|
||||
typedef enum dumpFlags_e {
|
||||
DUMP_MASTER = (1 << 0),
|
||||
DUMP_PROFILE = (1 << 1),
|
||||
|
@ -5840,8 +5835,10 @@ static void cliDshotTelemetryInfo(char *cmdline)
|
|||
if (useDshotTelemetry) {
|
||||
cliPrintLinef("Dshot reads: %u", readDoneCount);
|
||||
cliPrintLinef("Dshot invalid pkts: %u", dshotInvalidPacketCount);
|
||||
extern uint32_t setDirectionMicros;
|
||||
cliPrintLinef("Dshot irq micros: %u", setDirectionMicros);
|
||||
uint32_t directionChangeCycles = dshotDMAHandlerCycleCounters.changeDirectionCompletedAt - dshotDMAHandlerCycleCounters.irqAt;
|
||||
uint32_t directionChangeDurationUs = clockCyclesToMicros(directionChangeCycles);
|
||||
cliPrintLinef("Dshot directionChange cycles: %u, micros: %u", directionChangeCycles, directionChangeDurationUs);
|
||||
cliPrintLinef("Dshot packet decode micros: %u", decodePacketDurationUs);
|
||||
cliPrintLinefeed();
|
||||
|
||||
#ifdef USE_DSHOT_TELEMETRY_STATS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue