diff --git a/nimble/transport/nrf5340/src/nrf5340_ble_hci.c b/nimble/transport/nrf5340/src/nrf5340_ble_hci.c index 7f3c5efe27..700532abcb 100644 --- a/nimble/transport/nrf5340/src/nrf5340_ble_hci.c +++ b/nimble/transport/nrf5340/src/nrf5340_ble_hci.c @@ -36,6 +36,20 @@ static struct hci_ipc_sm g_hci_ipc_sm; +static void +rx_func(void *arg) +{ + uint8_t *buf; + int len; + + len = ipc_nrf5340_available_buf(IPC_RX_CHANNEL, (void **)&buf); + while (len > 0) { + len = hci_ipc_rx(&g_hci_ipc_sm, buf, len); + ipc_nrf5340_consume(IPC_RX_CHANNEL, len); + len = ipc_nrf5340_available_buf(IPC_RX_CHANNEL, (void **)&buf); + } +} + static int nrf5340_ble_hci_acl_tx(struct os_mbuf *om) { @@ -95,15 +109,8 @@ nrf5340_ble_hci_iso_tx(struct os_mbuf *om) static void nrf5340_ble_hci_trans_rx(int channel, void *user_data) { - uint8_t *buf; - int len; - - len = ipc_nrf5340_available_buf(channel, (void **)&buf); - while (len > 0) { - len = hci_ipc_rx(&g_hci_ipc_sm, buf, len); - ipc_nrf5340_consume(channel, len); - len = ipc_nrf5340_available_buf(channel, (void **)&buf); - } + assert(channel == IPC_RX_CHANNEL); + ble_transport_rx(); } static void @@ -111,6 +118,7 @@ nrf5340_ble_hci_init(void) { SYSINIT_ASSERT_ACTIVE(); + ble_transport_rx_register(rx_func, NULL); ipc_nrf5340_recv(IPC_RX_CHANNEL, nrf5340_ble_hci_trans_rx, NULL); }