You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/03/17 12:35:44 UTC
[mynewt-core] 02/04: hw/ipc_nrf5340: Add support for HCI transport flow control
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit f194570f32220b53fed361711f63b2601bc5db56
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Wed Mar 9 22:59:40 2022 +0100
hw/ipc_nrf5340: Add support for HCI transport flow control
---
.../include/ipc_nrf5340/ipc_nrf5340_priv.h | 3 ++
hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c | 45 ++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h b/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h
index a869a14..9fa2023 100644
--- a/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h
+++ b/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h
@@ -46,6 +46,9 @@ struct ipc_shared {
APP_AND_NET_RUNNING,
NET_RESTARTED,
} ipc_state;
+#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
+ uint8_t acl_from_ll_count;
+#endif
};
#ifdef __cplusplus
diff --git a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
index 8eb741f..9168dd4 100644
--- a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
+++ b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
@@ -25,6 +25,9 @@
#include <hal/hal_gpio.h>
#include <bsp.h>
#include <nrf_mutex.h>
+#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
+#include <nimble/transport.h>
+#endif
#if MYNEWT_VAL(IPC_NRF5340_NET_GPIO)
#include <mcu/nrf5340_hal.h>
@@ -268,6 +271,10 @@ ipc_nrf5340_init(void)
ipc_shared->ipc_shms = shms;
ipc_shared->ipc_state = APP_WAITS_FOR_NET;
+#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
+ ipc_shared->acl_from_ll_count = MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT);
+#endif
+
if (MYNEWT_VAL(MCU_APP_SECURE) && !MYNEWT_VAL(IPC_NRF5340_PRE_TRUSTZONE_NETCORE_BOOT)) {
/*
* When bootloader is secure and application is not all peripherals are
@@ -452,3 +459,41 @@ ipc_nrf5340_consume(int channel, uint16_t len)
return ipc_nrf5340_shm_read(&shms[channel], NULL, NULL, len);
}
+
+#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
+int
+ble_transport_int_flow_ctl_get(void)
+{
+ int ret;
+
+ __asm__ volatile (".syntax unified \n"
+ "1: ldrexb r1, [%[addr]] \n"
+ " mov %[ret], r1 \n"
+ " cmp r1, #0 \n"
+ " itte ne \n"
+ " subne r2, r1, #1 \n"
+ " strexbne r1, r2, [%[addr]] \n"
+ " clrexeq \n"
+ " cmp r1, #0 \n"
+ " bne 1b \n"
+ : [ret] "=&r" (ret)
+ : [addr] "r"(&ipc_shared->acl_from_ll_count)
+ : "r1", "r2", "memory");
+
+ return ret;
+}
+
+void
+ble_transport_int_flow_ctl_put(void)
+{
+ __asm__ volatile (".syntax unified \n"
+ "1: ldrexb r1, [%[addr]] \n"
+ " add r1, r1, #1 \n"
+ " strexb r2, r1, [%[addr]] \n"
+ " cmp r2, #0 \n"
+ " bne 1b \n"
+ :
+ : [addr] "r"(&ipc_shared->acl_from_ll_count)
+ : "r1", "r2", "memory");
+}
+#endif