diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2020-08-16 08:30:19 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-09-08 12:53:24 +1000 |
commit | 6077c63a450d7c2ab5e31e5845ecb5f1a4634b26 (patch) | |
tree | 98421822c08f263f97580d29489ae2265642622a | |
parent | 8b00aeab8fd20f8b8920cf322b5cfb7021ef1504 (diff) | |
download | micropython-6077c63a450d7c2ab5e31e5845ecb5f1a4634b26.tar.gz micropython-6077c63a450d7c2ab5e31e5845ecb5f1a4634b26.zip |
stm32/mpbthciport: Increase char timeout of BT HCI UART.
The 2ms used previously was not long enough and it could lose HCI sync.
Also print error on tx failure to make this more obvious in the future.
-rw-r--r-- | ports/stm32/mpbthciport.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ports/stm32/mpbthciport.c b/ports/stm32/mpbthciport.c index 71a9e4fc7f..a5977ff12c 100644 --- a/ports/stm32/mpbthciport.c +++ b/ports/stm32/mpbthciport.c @@ -142,8 +142,9 @@ int mp_bluetooth_hci_uart_init(uint32_t port, uint32_t baudrate) { mp_bluetooth_hci_uart_obj.base.type = &pyb_uart_type; mp_bluetooth_hci_uart_obj.uart_id = port; mp_bluetooth_hci_uart_obj.is_static = true; - mp_bluetooth_hci_uart_obj.timeout = 2; - mp_bluetooth_hci_uart_obj.timeout_char = 2; + // We don't want to block indefinitely, but expect flow control is doing its job. + mp_bluetooth_hci_uart_obj.timeout = 200; + mp_bluetooth_hci_uart_obj.timeout_char = 200; MP_STATE_PORT(pyb_uart_obj_all)[mp_bluetooth_hci_uart_obj.uart_id - 1] = &mp_bluetooth_hci_uart_obj; // This also initialises the UART. @@ -184,7 +185,11 @@ int mp_bluetooth_hci_uart_write(const uint8_t *buf, size_t len) { // DEBUG_printf("mp_bluetooth_hci_uart_write (stm32)\n"); mp_bluetooth_hci_controller_wakeup(); - uart_tx_strn(&mp_bluetooth_hci_uart_obj, (void *)buf, len); + int errcode; + uart_tx_data(&mp_bluetooth_hci_uart_obj, (void *)buf, len, &errcode); + if (errcode != 0) { + printf("\nmp_bluetooth_hci_uart_write: failed to write to UART %d\n", errcode); + } return 0; } |