This is an automated email from the ASF dual-hosted git repository.
ncasaril pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 4051488 hw/ipc_nrf5340: Fix enabling multiple GPIOs passed to network
core #2623
new 8ca13c5 Merge pull request #2629 from ncasaril/nc_nrf5340_net_gpio
4051488 is described below
commit 4051488297c84bf45d494ecd00275d69fe376c36
Author: Niklas Casaril <[email protected]>
AuthorDate: Thu Jun 24 10:29:54 2021 +1000
hw/ipc_nrf5340: Fix enabling multiple GPIOs passed to network core #2623
---
hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c | 15 +++++++++------
hw/drivers/ipc_nrf5340/syscfg.yml | 11 ++++++-----
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
index 786a85a..e1c1df4 100644
--- a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
+++ b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
@@ -162,7 +162,7 @@ ipc_nrf5340_init(void)
#if MYNEWT_VAL(MCU_APP_CORE)
#if MYNEWT_VAL(IPC_NRF5340_NET_GPIO)
- unsigned int gpios[] = { MYNEWT_VAL(IPC_NRF5340_NET_GPIO) };
+ uint64_t gpios = MYNEWT_VAL(IPC_NRF5340_NET_GPIO);
NRF_GPIO_Type *nrf_gpio;
#endif
@@ -183,11 +183,14 @@ ipc_nrf5340_init(void)
memset(shms, 0, sizeof(shms));
#if MYNEWT_VAL(IPC_NRF5340_NET_GPIO)
- /* Configure GPIOs for Networking Core */
- for (i = 0; i < ARRAY_SIZE(gpios); i++) {
- nrf_gpio = HAL_GPIO_PORT(gpios[i]);
- nrf_gpio->PIN_CNF[HAL_GPIO_INDEX(gpios[i])] =
- GPIO_PIN_CNF_MCUSEL_NetworkMCU << GPIO_PIN_CNF_MCUSEL_Pos;
+ /* Configure GPIOs for Networking Core, nrf5340 has 48 GPIOs */
+ for (i = 0; i < 48; i++) {
+ if (gpios & 0x1) {
+ nrf_gpio = HAL_GPIO_PORT(i);
+ nrf_gpio->PIN_CNF[HAL_GPIO_INDEX(i)] =
+ GPIO_PIN_CNF_MCUSEL_NetworkMCU << GPIO_PIN_CNF_MCUSEL_Pos;
+ }
+ gpios >>= 1;
}
#endif
#endif
diff --git a/hw/drivers/ipc_nrf5340/syscfg.yml
b/hw/drivers/ipc_nrf5340/syscfg.yml
index c92518a..c5acaf2 100644
--- a/hw/drivers/ipc_nrf5340/syscfg.yml
+++ b/hw/drivers/ipc_nrf5340/syscfg.yml
@@ -43,11 +43,12 @@ syscfg.defs:
IPC_NRF5340_NET_GPIO:
description: >
- List of comma separated GPIO that should be configured for Network
- Core usage. Can be define numeric or with constants from bsp.h
- eg "LED_1, LED_2" or "1, 2". Further GPIO configuration should be
- done by Network Core.
- value: ""
+ Bitfield with 1s for each GPIO that should be configured for
Network
+ Core usage. Can be defined with numeric or with constants from
bsp.h
+ eg "(1ULL << LED_1 | 1ULL << LED_2)" or "(1 << 1 | 1ULL << 34)".
+ The "ULL" qualifier is needed for pins > 31.
+ Further GPIO configuration should be done by Network Core.
+ value: 0
syscfg.restrictions:
- "!BSP_NRF5340 || BSP_NRF5340_NET_ENABLE"