diff --git a/nimble/transport/nrf5340/src/nrf5340_ble_hci.c b/nimble/transport/nrf5340/src/nrf5340_ble_hci.c index 7f3c5efe27..c6e69f4062 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,13 @@ 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; + assert(channel == IPC_RX_CHANNEL); - 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); - } +#if MYNEWT_VAL(BLE_TRANSPORT_NRF5340_RX_TASK) + ble_transport_rx(); +#else + rx_func(NULL); +#endif } static void @@ -111,6 +123,9 @@ nrf5340_ble_hci_init(void) { SYSINIT_ASSERT_ACTIVE(); +#if MYNEWT_VAL(BLE_TRANSPORT_NRF5340_RX_TASK) + ble_transport_rx_register(rx_func, NULL); +#endif ipc_nrf5340_recv(IPC_RX_CHANNEL, nrf5340_ble_hci_trans_rx, NULL); } diff --git a/nimble/transport/nrf5340/syscfg.yml b/nimble/transport/nrf5340/syscfg.yml new file mode 100644 index 0000000000..2b05734078 --- /dev/null +++ b/nimble/transport/nrf5340/syscfg.yml @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +syscfg.defs: + BLE_TRANSPORT_NRF5340_RX_TASK: + description: > + Use separate task for RX. This is required and enabled by default + if monitor is used, optional otherwise. + value: 0 + +syscfg.vals.BLE_MONITOR: + BLE_TRANSPORT_NRF5340_RX_TASK: 1 + BLE_TRANSPORT_RX_PRIO: 1 + BLE_TRANSPORT_RX_STACK_SIZE: 120