From 1976781d33547d32c72971e8a9d6bb598d6fa93e Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Mon, 10 Apr 2023 18:16:38 +0200 Subject: [PATCH] rp2/mpbthciport: Fix HCI UART config. Fixes are: - The baudrate argument is a keyword arg, it was passed before as a positional arg. - Use the port and baudrate arguments passed from higher level code instead of the hard-coded port ID and baudrate, which would allow HCI drivers to change baudrates. - Increase UART char timeout and RX buffer size. Signed-off-by: iabdalkader --- ports/rp2/mpbthciport.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ports/rp2/mpbthciport.c b/ports/rp2/mpbthciport.c index 9a24ebdc32..7722360920 100644 --- a/ports/rp2/mpbthciport.c +++ b/ports/rp2/mpbthciport.c @@ -87,16 +87,18 @@ int mp_bluetooth_hci_uart_init(uint32_t port, uint32_t baudrate) { debug_printf("mp_bluetooth_hci_uart_init\n"); mp_obj_t args[] = { - MP_OBJ_NEW_SMALL_INT(MICROPY_HW_BLE_UART_ID), - MP_OBJ_NEW_SMALL_INT(MICROPY_HW_BLE_UART_BAUDRATE), + MP_OBJ_NEW_SMALL_INT(port), + MP_OBJ_NEW_QSTR(MP_QSTR_baudrate), MP_OBJ_NEW_SMALL_INT(baudrate), MP_OBJ_NEW_QSTR(MP_QSTR_flow), MP_OBJ_NEW_SMALL_INT((1 | 2)), MP_OBJ_NEW_QSTR(MP_QSTR_timeout), MP_OBJ_NEW_SMALL_INT(1000), + MP_OBJ_NEW_QSTR(MP_QSTR_timeout_char), MP_OBJ_NEW_SMALL_INT(200), + MP_OBJ_NEW_QSTR(MP_QSTR_rxbuf), MP_OBJ_NEW_SMALL_INT(768), }; // This is a statically-allocated UART (see machine_uart.c), and doesn't // contain any heap pointers other than the ringbufs (which are already // root pointers), so no need to track this as a root pointer. - mp_bthci_uart = MP_OBJ_TYPE_GET_SLOT(&machine_uart_type, make_new)((mp_obj_t)&machine_uart_type, 2, 2, args); + mp_bthci_uart = MP_OBJ_TYPE_GET_SLOT(&machine_uart_type, make_new)((mp_obj_t)&machine_uart_type, 1, 5, args); // Start the HCI polling to process any initial events/packets. mp_bluetooth_hci_start_polling();