Skip to content

Commit 543851d

Browse files
dakejahljulianoesAlexKlimaj
authored
[Sponsored by ARK] Bidirectional DShot (#23863)
* Bidirectional DShot Co-authored-by: Julian Oes <[email protected]> * f4/f1 support, not supported * fix f1 build target * sanity check timer_channel value, fix CCxNP ifdef, debug stuff * removed debug code, added define for H7 HAVE_GTIM_CCXNP * round robin sampling for less than 4 DMA * unlimited esc_status logging * dshot: fix formatting * dshot: add define for number of DMA channels to use This allows individual boards to override the number of DShot channels and hence avoid round robin capture of the RPM feedback. * ARK: enable 4 DMA channels for DShot on 6X * dshot: publish when all channels are updated This slows down the ESC_STATUS publication in the case of round robin capture. E.g. for 800 Hz output with one DMA channel, the ESC_STATUS is now published at 200 Hz. * dshot: avoid duplicate publications for bidir and telem Instead of publishing both bidirectional dshot updates as well as telemetry updates, we now combine the data from both streams, and publish whenever we get RPM updates, as the latter arrives with higher rate, e.g. 200 Hz with round robin, or faster otherwise. When combining the data, we take RPM from bidirectional dshot, and the rest from telemetry. When we have only one of the two, either telemetry or bidirectional dshot, we just publish that one. * boards: add ark fpv and pi6x BOARD_DMA_NUM_DSHOT_CHANNELS * dshot: turn off debug build --------- Co-authored-by: Julian Oes <[email protected]> Co-authored-by: alexklimaj <[email protected]>
1 parent 2280e94 commit 543851d

File tree

25 files changed

+1348
-254
lines changed

25 files changed

+1348
-254
lines changed

boards/ark/fmu-v6x/src/board_config.h

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@
420420
/* This board provides a DMA pool and APIs */
421421
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
422422

423+
/* This board has 4 DMA channels available for bidirectional dshot */
424+
#define BOARD_DMA_NUM_DSHOT_CHANNELS 4
425+
423426
/* This board provides the board_on_reset interface */
424427

425428
#define BOARD_HAS_ON_RESET 1

boards/ark/fpv/src/board_config.h

+3
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@
307307
/* This board provides a DMA pool and APIs */
308308
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
309309

310+
/* This board has 3 DMA channels available for bidirectional dshot */
311+
#define BOARD_DMA_NUM_DSHOT_CHANNELS 3
312+
310313
/* This board provides the board_on_reset interface */
311314

312315
#define BOARD_HAS_ON_RESET 1

boards/ark/fpv/src/timer_config.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
constexpr io_timers_t io_timers[MAX_IO_TIMERS] = {
5959
initIOTimer(Timer::Timer5, DMA{DMA::Index1}),
6060
initIOTimer(Timer::Timer8, DMA{DMA::Index1}),
61-
initIOTimer(Timer::Timer4, DMA{DMA::Index1}),
61+
initIOTimer(Timer::Timer4),
6262
};
6363

6464
constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = {

boards/ark/pi6x/src/board_config.h

+3
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@
309309
/* This board provides a DMA pool and APIs */
310310
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
311311

312+
/* This board has 4 DMA channels available for bidirectional dshot */
313+
#define BOARD_DMA_NUM_DSHOT_CHANNELS 4
314+
312315
/* This board provides the board_on_reset interface */
313316

314317
#define BOARD_HAS_ON_RESET 1

boards/holybro/kakutef7/default.px4board

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ CONFIG_DRIVERS_IMU_INVENSENSE_MPU6000=y
1717
CONFIG_DRIVERS_OSD_ATXXXX=y
1818
CONFIG_DRIVERS_PWM_OUT=y
1919
CONFIG_DRIVERS_RC_INPUT=y
20-
CONFIG_DRIVERS_TELEMETRY_FRSKY_TELEMETRY=y
2120
CONFIG_MODULES_BATTERY_STATUS=y
2221
CONFIG_MODULES_COMMANDER=y
2322
CONFIG_MODULES_CONTROL_ALLOCATOR=y
@@ -47,6 +46,6 @@ CONFIG_MODULES_SENSORS=y
4746
# CONFIG_SENSORS_VEHICLE_AIRSPEED is not set
4847
# CONFIG_SENSORS_VEHICLE_MAGNETOMETER is not set
4948
# CONFIG_SENSORS_VEHICLE_OPTICAL_FLOW is not set
50-
CONFIG_SYSTEMCMDS_DMESG=y
49+
# CONFIG_SYSTEMCMDS_DMESG is not set
5150
CONFIG_SYSTEMCMDS_PARAM=y
52-
CONFIG_SYSTEMCMDS_TOP=y
51+
# CONFIG_SYSTEMCMDS_TOP is not set

platforms/nuttx/src/px4/nxp/imxrt/dshot/dshot.c

+15
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,21 @@ void up_bdshot_erpm(void)
418418
}
419419

420420

421+
int up_bdshot_num_erpm_ready(void)
422+
{
423+
int num_ready = 0;
424+
425+
for (unsigned i = 0; i < DSHOT_TIMERS; ++i) {
426+
// We only check that data has been received, rather than if it's valid.
427+
// This ensures data is published even if one channel has bit errors.
428+
if (bdshot_recv_mask & (1 << i)) {
429+
++num_ready;
430+
}
431+
}
432+
433+
return num_ready;
434+
}
435+
421436

422437
int up_bdshot_get_erpm(uint8_t channel, int *erpm)
423438
{

platforms/nuttx/src/px4/rpi/rpi_common/include/px4_arch/io_timer.h

-3
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ __EXPORT int io_timer_free_channel(unsigned channel);
151151
__EXPORT int io_timer_get_channel_mode(unsigned channel);
152152
__EXPORT int io_timer_get_mode_channels(io_timer_channel_mode_t mode);
153153
__EXPORT extern void io_timer_trigger(void);
154-
__EXPORT void io_timer_update_dma_req(uint8_t timer, bool enable);
155-
156-
__EXPORT extern int io_timer_set_dshot_mode(uint8_t timer, unsigned dshot_pwm_rate, uint8_t dma_burst_length);
157154

158155
/**
159156
* Returns the pin configuration for a specific channel, to be used as GPIO output.

0 commit comments

Comments
 (0)