mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Add dshot_telemetry_start_margin setting (#12912)
This commit is contained in:
parent
acb52cba56
commit
be9652923a
4 changed files with 21 additions and 4 deletions
|
@ -854,6 +854,7 @@ const clivalue_t valueTable[] = {
|
|||
#ifdef USE_DSHOT_BITBANG
|
||||
{ "dshot_bitbang", VAR_UINT8 | HARDWARE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON_AUTO }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotBitbang) },
|
||||
{ "dshot_bitbang_timer", VAR_UINT8 | HARDWARE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DSHOT_BITBANGED_TIMER }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotBitbangedTimer) },
|
||||
{ "dshot_telemetry_start_margin", VAR_UINT8 | HARDWARE_VALUE , .config.minmaxUnsigned = { 0, 100 }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.telemetryStartMargin) },
|
||||
#endif
|
||||
#endif
|
||||
{ PARAM_NAME_USE_UNSYNCED_PWM, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useUnsyncedPwm) },
|
||||
|
|
|
@ -49,8 +49,6 @@ uint16_t bbBuffer[134];
|
|||
#define BITBAND_SRAM_BASE 0x22000000
|
||||
#define BITBAND_SRAM(a,b) ((BITBAND_SRAM_BASE + (((a)-BITBAND_SRAM_REF)<<5) + ((b)<<2))) // Convert SRAM address
|
||||
|
||||
#define DSHOT_TELEMETRY_START_MARGIN 10
|
||||
|
||||
static uint8_t preambleSkip = 0;
|
||||
|
||||
typedef struct bitBandWord_s {
|
||||
|
@ -217,7 +215,13 @@ uint32_t decode_bb_bitband( uint16_t buffer[], uint32_t count, uint32_t bit)
|
|||
#endif
|
||||
|
||||
// The anticipated edges were observed
|
||||
preambleSkip = startMargin - DSHOT_TELEMETRY_START_MARGIN;
|
||||
|
||||
// Attempt to skip the preamble ahead of the telemetry to save CPU
|
||||
if (startMargin > motorConfig()->dev.telemetryStartMargin) {
|
||||
preambleSkip = startMargin - motorConfig()->dev.telemetryStartMargin;
|
||||
} else {
|
||||
preambleSkip = 0;
|
||||
}
|
||||
|
||||
if (nlen > 0) {
|
||||
value <<= nlen;
|
||||
|
@ -325,7 +329,13 @@ FAST_CODE uint32_t decode_bb( uint16_t buffer[], uint32_t count, uint32_t bit)
|
|||
}
|
||||
|
||||
// The anticipated edges were observed
|
||||
preambleSkip = startMargin - DSHOT_TELEMETRY_START_MARGIN;
|
||||
|
||||
// Attempt to skip the preamble ahead of the telemetry to save CPU
|
||||
if (startMargin > motorConfig()->dev.telemetryStartMargin) {
|
||||
preambleSkip = startMargin - motorConfig()->dev.telemetryStartMargin;
|
||||
} else {
|
||||
preambleSkip = 0;
|
||||
}
|
||||
|
||||
if (nlen > 0) {
|
||||
value <<= nlen;
|
||||
|
|
|
@ -44,6 +44,10 @@
|
|||
#define DEFAULT_DSHOT_BURST DSHOT_DMAR_OFF
|
||||
#endif
|
||||
|
||||
#if !defined(DSHOT_TELEMETRY_START_MARGIN)
|
||||
#define DSHOT_TELEMETRY_START_MARGIN 10
|
||||
#endif
|
||||
|
||||
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 2);
|
||||
|
||||
void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
||||
|
@ -110,6 +114,7 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
|||
#ifdef USE_DSHOT_BITBANG
|
||||
motorConfig->dev.useDshotBitbang = DEFAULT_DSHOT_BITBANG;
|
||||
motorConfig->dev.useDshotBitbangedTimer = DSHOT_BITBANGED_TIMER_DEFAULT;
|
||||
motorConfig->dev.telemetryStartMargin = DSHOT_TELEMETRY_START_MARGIN;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef struct motorDevConfig_s {
|
|||
uint8_t useDshotBitbang;
|
||||
uint8_t useDshotBitbangedTimer;
|
||||
uint8_t motorOutputReordering[MAX_SUPPORTED_MOTORS]; // Reindexing motors for "remap motors" feature in Configurator
|
||||
uint8_t telemetryStartMargin;
|
||||
} motorDevConfig_t;
|
||||
|
||||
typedef struct motorConfig_s {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue