You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2020/09/25 08:20:17 UTC

[mynewt-core] branch master updated: hw/ipc_nrf5340: Add support for passing GPIO control

This is an automated email from the ASF dual-hosted git repository.

janc 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 5044524  hw/ipc_nrf5340: Add support for passing GPIO control
5044524 is described below

commit 50445247dfa76e242163a3108c24642ac8b3f149
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Mon Sep 21 17:00:23 2020 +0200

    hw/ipc_nrf5340: Add support for passing GPIO control
    
    This allows to configure GPIOs that should be controlled by Network
    Core. For race-free execution GPIOs are configured from IPC subsystem
    when Networking Core is force-off.
---
 hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c | 24 ++++++++++++++++++++----
 hw/drivers/ipc_nrf5340/syscfg.yml        |  8 ++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
index a2416ce..ec78250 100644
--- a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
+++ b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
@@ -21,6 +21,8 @@
 #include <os/os.h>
 #include <ipc_nrf5340/ipc_nrf5340.h>
 #include <nrfx.h>
+#include <mcu/nrf5340_hal.h>
+#include <bsp/bsp.h>
 
 /* Currently this allows only for 1-1 connection. */
 
@@ -148,17 +150,31 @@ ipc_nrf5340_isr(void)
 void
 ipc_nrf5340_init(void)
 {
-    int channel;
+    int i;
 
 #if MYNEWT_VAL(BSP_NRF5340)
+#if MYNEWT_VAL(IPC_NRF5340_NET_GPIO)
+    unsigned int gpios[] = { MYNEWT_VAL(IPC_NRF5340_NET_GPIO) };
+    NRF_GPIO_Type *nrf_gpio;
+#endif
+
     /* Make sure network core if off when we set up IPC */
-    NRF_RESET_S->NETWORK.FORCEOFF  = RESET_NETWORK_FORCEOFF_FORCEOFF_Hold;
+    NRF_RESET_S->NETWORK.FORCEOFF = RESET_NETWORK_FORCEOFF_FORCEOFF_Hold;
     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;
+    }
+#endif
 #endif
 
     /* Enable IPC channels */
-    for (channel = 0; channel < IPC_MAX_CHANS; channel++) {
-        NRF_IPC->SEND_CNF[channel] = (0x01UL << channel);
+    for (i = 0; i < IPC_MAX_CHANS; i++) {
+        NRF_IPC->SEND_CNF[i] = (0x01UL << i);
     }
 
     NVIC_SetVector(IPC_IRQn, (uint32_t)ipc_nrf5340_isr);
diff --git a/hw/drivers/ipc_nrf5340/syscfg.yml b/hw/drivers/ipc_nrf5340/syscfg.yml
index 6977a26..3820223 100644
--- a/hw/drivers/ipc_nrf5340/syscfg.yml
+++ b/hw/drivers/ipc_nrf5340/syscfg.yml
@@ -40,5 +40,13 @@ syscfg.defs:
             Sysinit stage for nRF53 IPC
         value: 10
 
+    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: ""
+
 syscfg.restrictions:
     - "!BSP_NRF5340 || BSP_NRF5340_NET_ENABLE"