a periodic usart reset works much better

tying the usart buffer clear to the 25*5 ms system tick makes sense
This commit is contained in:
Elliot Williams
2019-12-18 15:42:51 +01:00
parent 976ba2d44a
commit c3fbbab485

View File

@ -225,8 +225,11 @@ int main(void) {
cmd1 = CLAMP((int16_t)command.steer, -1000, 1000);
cmd2 = CLAMP((int16_t)command.speed, -1000, 1000);
} else { // restart DMA to hopefully get back in sync
HAL_UART_DMAStop(&huart2);
HAL_UART_Receive_DMA(&huart2, (uint8_t *)&command, sizeof(command));
// Try a periodic reset
if (main_loop_counter % 25 == 0) {
HAL_UART_DMAStop(&huart2);
HAL_UART_Receive_DMA(&huart2, (uint8_t *)&command, sizeof(command));
}
}
timeout = 0;
#endif