AP_Bootloader: support changing baudrates on UARTs

This commit is contained in:
Andrew Tridgell 2018-06-25 14:10:21 +10:00
parent e40457d98f
commit 0ebd05aa1a
2 changed files with 9 additions and 4 deletions

View File

@ -733,9 +733,14 @@ bootloader(unsigned timeout)
// send the sync response for this command // send the sync response for this command
sync_response(); sync_response();
delay(5);
// set the baudrate // set the baudrate
port_setbaud(baud); port_setbaud(baud);
lock_bl_port();
timeout = 0;
// this is different to what every other case in this // this is different to what every other case in this
// switch does! Most go through sync_response down the // switch does! Most go through sync_response down the
// bottom, but we need to undertake an action after // bottom, but we need to undertake an action after

View File

@ -29,7 +29,7 @@ int16_t cin(unsigned timeout_ms)
} }
} }
} }
chThdSleepMicroseconds(100); chThdSleepMicroseconds(500);
return -1; return -1;
} }
@ -43,7 +43,7 @@ int cin_word(uint32_t *wp, unsigned timeout_ms)
} }
} }
} }
chThdSleepMicroseconds(100); chThdSleepMicroseconds(500);
return -1; return -1;
} }
@ -346,14 +346,14 @@ void init_uarts(void)
*/ */
void port_setbaud(uint32_t baudrate) void port_setbaud(uint32_t baudrate)
{ {
sercfg.speed = baudrate;
#ifdef HAL_USE_SERIAL_USB #ifdef HAL_USE_SERIAL_USB
if (uarts[last_uart] == (BaseChannel *)&SDU1) { if (uarts[last_uart] == (BaseChannel *)&SDU1) {
// can't set baudrate on USB // can't set baudrate on USB
return; return;
} }
#endif #endif
sdStop((SerialDriver *)uarts[last_uart]); memset(&sercfg, 0, sizeof(sercfg));
sercfg.speed = baudrate;
sdStart((SerialDriver *)uarts[last_uart], &sercfg); sdStart((SerialDriver *)uarts[last_uart], &sercfg);
} }