diff --git a/flight/pios/stm32f10x/pios_dsm.c b/flight/pios/stm32f10x/pios_dsm.c index 5fa1fb7ff..577e22949 100644 --- a/flight/pios/stm32f10x/pios_dsm.c +++ b/flight/pios/stm32f10x/pios_dsm.c @@ -213,12 +213,24 @@ static int PIOS_DSM_UnrollChannels(struct pios_dsm_dev *dsm_dev) /* extract and save the channel value */ uint8_t channel_num = (word >> resolution) & 0x0f; if (channel_num < PIOS_DSM_NUM_INPUTS) { + if (channel_log & (1 << channel_num)) { - /* Found duplicate! */ - /* Update resolution and restart processing the current frame. */ + /* Found duplicate. This should happen when in 11 bit */ + /* mode and the data is 10 bits */ + if (resolution == 10) + return -1; resolution = 10; return PIOS_DSM_UnrollChannels(dsm_dev); } + + if ((channel_log & 0xFF) == 0x55) { + /* This pattern indicates 10 bit pattern */ + if (resolution == 11) + return -1; + resolution = 11; + return PIOS_DSM_UnrollChannels(dsm_dev); + } + state->channel_data[channel_num] = (word & mask); /* keep track of this channel */ channel_log |= (1 << channel_num); diff --git a/flight/pios/stm32f4xx/pios_dsm.c b/flight/pios/stm32f4xx/pios_dsm.c index 4154f9f23..314102c0e 100644 --- a/flight/pios/stm32f4xx/pios_dsm.c +++ b/flight/pios/stm32f4xx/pios_dsm.c @@ -215,12 +215,24 @@ static int PIOS_DSM_UnrollChannels(struct pios_dsm_dev *dsm_dev) /* extract and save the channel value */ uint8_t channel_num = (word >> resolution) & 0x0f; if (channel_num < PIOS_DSM_NUM_INPUTS) { + if (channel_log & (1 << channel_num)) { - /* Found duplicate! */ - /* Update resolution and restart processing the current frame. */ + /* Found duplicate. This should happen when in 11 bit */ + /* mode and the data is 10 bits */ + if (resolution == 10) + return -1; resolution = 10; return PIOS_DSM_UnrollChannels(dsm_dev); } + + if ((channel_log & 0xFF) == 0x55) { + /* This pattern indicates 10 bit pattern */ + if (resolution == 11) + return -1; + resolution = 11; + return PIOS_DSM_UnrollChannels(dsm_dev); + } + state->channel_data[channel_num] = (word & mask); /* keep track of this channel */ channel_log |= (1 << channel_num);