AP_HAL: move is_dshot_protocol to AP_HAL

This commit is contained in:
Iampete1 2021-09-22 23:56:09 +01:00 committed by Andrew Tridgell
parent 9751cb5b24
commit 3b8b90d170
2 changed files with 20 additions and 0 deletions

View File

@ -52,3 +52,19 @@ void AP_HAL::RCOutput::append_to_banner(char banner_msg[], uint8_t banner_msg_le
hal.util->snprintf(banner_msg, banner_msg_len, "%s %s:%u-%u", banner_msg_temp, mode_str, (unsigned)low_ch, (unsigned)high_ch);
}
}
/*
true when the output mode is of type dshot
*/
bool AP_HAL::RCOutput::is_dshot_protocol(const enum output_mode mode)
{
switch (mode) {
case MODE_PWM_DSHOT150:
case MODE_PWM_DSHOT300:
case MODE_PWM_DSHOT600:
case MODE_PWM_DSHOT1200:
return true;
default:
return false;
}
}

View File

@ -202,6 +202,10 @@ public:
MODE_NEOPIXEL, // same as MODE_PWM_DSHOT at 800kHz but it's an LED
MODE_PROFILED, // same as MODE_PWM_DSHOT using separate clock and data
};
// true when the output mode is of type dshot
// static to allow use in the ChibiOS thread stuff
static bool is_dshot_protocol(const enum output_mode mode);
// https://github.com/bitdump/BLHeli/blob/master/BLHeli_32%20ARM/BLHeli_32%20Firmware%20specs/Digital_Cmd_Spec.txt
enum BLHeliDshotCommand : uint8_t {