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 <i.abdalkader@gmail.com>
pull/11234/head
iabdalkader 2023-04-10 18:16:38 +02:00 zatwierdzone przez Damien George
rodzic 6abe3e1714
commit 1976781d33
1 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -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();