diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.cpp b/libraries/AP_HAL_ChibiOS/RCOutput.cpp index ca8858870e..c24f79ccda 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput.cpp @@ -471,6 +471,28 @@ void RCOutput::set_dshot_rate(uint8_t dshot_rate, uint16_t loop_rate_hz) _dshot_period_us = 1000000UL / drate; } +#ifndef DISABLE_DSHOT +/* + Set/get the dshot esc_type + */ +void RCOutput::set_dshot_esc_type(DshotEscType dshot_esc_type) +{ + _dshot_esc_type = dshot_esc_type; + switch (_dshot_esc_type) { + case DSHOT_ESC_BLHELI_S: + DSHOT_BIT_WIDTH_TICKS = DSHOT_BIT_WIDTH_TICKS_S; + DSHOT_BIT_0_TICKS = DSHOT_BIT_0_TICKS_S; + DSHOT_BIT_1_TICKS = DSHOT_BIT_1_TICKS_S; + break; + default: + DSHOT_BIT_WIDTH_TICKS = DSHOT_BIT_WIDTH_TICKS_DEFAULT; + DSHOT_BIT_0_TICKS = DSHOT_BIT_0_TICKS_DEFAULT; + DSHOT_BIT_1_TICKS = DSHOT_BIT_1_TICKS_DEFAULT; + break; + } +} +#endif + /* find pwm_group and index in group given a channel number */ diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.h b/libraries/AP_HAL_ChibiOS/RCOutput.h index e830831fed..6e3be9dc90 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.h +++ b/libraries/AP_HAL_ChibiOS/RCOutput.h @@ -172,7 +172,7 @@ public: /* Set/get the dshot esc_type */ - void set_dshot_esc_type(DshotEscType dshot_esc_type) override { _dshot_esc_type = dshot_esc_type; } + void set_dshot_esc_type(DshotEscType dshot_esc_type) override; DshotEscType get_dshot_esc_type() const override { return _dshot_esc_type; } #endif diff --git a/libraries/AP_HAL_ChibiOS/RCOutput_serial.cpp b/libraries/AP_HAL_ChibiOS/RCOutput_serial.cpp index c81159f1f9..67a162fb87 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput_serial.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput_serial.cpp @@ -146,6 +146,7 @@ void RCOutput::update_channel_masks() { for (uint8_t i=0; i