AP_RCProtocol: improve s-bus parsing

This relax s-bus timing requirement to allow not so perfect signals.
Fixes s-bus on s-bus pin in matekf405-wing
Also fixed comment a bit
This commit is contained in:
Alexander Malishev 2018-06-27 01:44:58 +04:00 committed by Andrew Tridgell
parent 49d08ba72a
commit 14db344c12
2 changed files with 4 additions and 4 deletions

View File

@ -34,7 +34,7 @@ extern const AP_HAL::HAL& hal;
void AP_RCProtocol_DSM::process_pulse(uint32_t width_s0, uint32_t width_s1)
{
// convert to bit widths, allowing for up to 1usec error, assuming 115200 bps
// convert to bit widths, allowing for up to about 4usec error, assuming 115200 bps
uint16_t bits_s0 = ((width_s0+4)*(uint32_t)115200) / 1000000;
uint16_t bits_s1 = ((width_s1+4)*(uint32_t)115200) / 1000000;
uint8_t bit_ofs, byte_ofs;

View File

@ -204,9 +204,9 @@ bool AP_RCProtocol_SBUS::sbus_decode(const uint8_t frame[25], uint16_t *values,
*/
void AP_RCProtocol_SBUS::process_pulse(uint32_t width_s0, uint32_t width_s1)
{
// convert to bit widths, allowing for up to 1usec error, assuming 100000 bps
uint16_t bits_s0 = (width_s0+1) / 10;
uint16_t bits_s1 = (width_s1+1) / 10;
// convert to bit widths, allowing for up to 4usec error, assuming 100000 bps
uint16_t bits_s0 = (width_s0+4) / 10;
uint16_t bits_s1 = (width_s1+4) / 10;
uint16_t nlow;
uint8_t byte_ofs = sbus_state.bit_ofs/12;