Skip to content

Commit

Permalink
nimble/transport/nrf53: Move RX from interrupt to task
Browse files Browse the repository at this point in the history
This fixes monitor usage.
  • Loading branch information
andrzej-kaczmarek committed Oct 23, 2023
1 parent ddc64fb commit b776c84
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions nimble/transport/nrf5340/src/nrf5340_ble_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -95,22 +109,16 @@ 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
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);
}

Expand Down

0 comments on commit b776c84

Please sign in to comment.