From e965363b6b66785ff088c4e998a7e80783bdd97c Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 10 Mar 2020 01:47:16 +1100 Subject: stm32: Refactor Bluetooth HCI RX to be independent of transport layer. Now all HCI specific code (eg UART vs WB55 internal messaging) is confined to modbluetooth_hci.c. --- extmod/modbluetooth_hci.h | 1 + extmod/nimble/nimble/npl_os.c | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'extmod') diff --git a/extmod/modbluetooth_hci.h b/extmod/modbluetooth_hci.h index 6d44761a4..d6b432d22 100644 --- a/extmod/modbluetooth_hci.h +++ b/extmod/modbluetooth_hci.h @@ -50,6 +50,7 @@ extern pyb_uart_obj_t mp_bluetooth_hci_uart_obj; int mp_bluetooth_hci_uart_init(uint32_t port); int mp_bluetooth_hci_uart_activate(void); int mp_bluetooth_hci_uart_set_baudrate(uint32_t baudrate); +int mp_bluetooth_hci_uart_readchar(void); int mp_bluetooth_hci_uart_write(const uint8_t *buf, size_t len); #endif // MICROPY_INCLUDED_EXTMOD_MODBLUETOOTH_HCI_H diff --git a/extmod/nimble/nimble/npl_os.c b/extmod/nimble/nimble/npl_os.c index 57ab689e6..620dcb0ae 100644 --- a/extmod/nimble/nimble/npl_os.c +++ b/extmod/nimble/nimble/npl_os.c @@ -235,7 +235,11 @@ ble_npl_error_t ble_npl_sem_pend(struct ble_npl_sem *sem, ble_npl_time_t timeout if (sem->count == 0) { uint32_t t0 = mp_hal_ticks_ms(); while (sem->count == 0 && mp_hal_ticks_ms() - t0 < timeout) { + // This function may be called at thread-level, so execute + // mp_bluetooth_nimble_hci_uart_process at raised priority. + MICROPY_PY_BLUETOOTH_ENTER mp_bluetooth_nimble_hci_uart_process(); + MICROPY_PY_BLUETOOTH_EXIT if (sem->count != 0) { break; } -- cgit v1.2.3