extmod/nimble: Make stm32 and unix NimBLE ports use synchronous events.

This changes stm32 from using PENDSV to run NimBLE to use the MicroPython
scheduler instead.  This allows Python BLE callbacks to be invoked directly
(and therefore synchronously) rather than via the ringbuffer.

The NimBLE UART HCI and event processing now happens in a scheduled task
every 128ms.  When RX IRQ idle events arrive, it will also schedule this
task to improve latency.

There is a similar change for the unix port where the background thread now
queues the scheduled task.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared
2020-11-03 23:27:47 +11:00
committed by Damien George
parent 81e92d3d6e
commit 61d1e4b01b
15 changed files with 280 additions and 157 deletions

View File

@@ -433,8 +433,8 @@ void stm32_main(uint32_t reset_mode) {
systick_enable_dispatch(SYSTICK_DISPATCH_LWIP, mod_network_lwip_poll_wrapper);
#endif
#if MICROPY_PY_BLUETOOTH
extern void mp_bluetooth_hci_poll_wrapper(uint32_t ticks_ms);
systick_enable_dispatch(SYSTICK_DISPATCH_BLUETOOTH_HCI, mp_bluetooth_hci_poll_wrapper);
extern void mp_bluetooth_hci_systick(uint32_t ticks_ms);
systick_enable_dispatch(SYSTICK_DISPATCH_BLUETOOTH_HCI, mp_bluetooth_hci_systick);
#endif
#if MICROPY_PY_NETWORK_CYW43