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 2019/06/14 00:02:18 UTC

[mynewt-nimble] branch master updated: nimble/ll: Add GPIOs for HCI debugging

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-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new d6dfb6c  nimble/ll: Add GPIOs for HCI debugging
d6dfb6c is described below

commit d6dfb6ceb0060534bda43bd2f56fc3eb06661323
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Jun 10 23:59:34 2019 +0200

    nimble/ll: Add GPIOs for HCI debugging
    
    This adds two new settings which allows to use two GPIO pins to indicate
    when command is received or event sent by controller. This can be useful
    for debugging, e.g. to check synchronization between HCI and air
    activity.
---
 nimble/controller/src/ble_ll_hci.c       | 26 ++++++++++++++++++++++++++
 nimble/controller/syscfg.yml             | 13 +++++++++++++
 porting/npl/riot/include/syscfg/syscfg.h |  8 ++++++++
 3 files changed, 47 insertions(+)

diff --git a/nimble/controller/src/ble_ll_hci.c b/nimble/controller/src/ble_ll_hci.c
index 2f158f3..18daf53 100644
--- a/nimble/controller/src/ble_ll_hci.c
+++ b/nimble/controller/src/ble_ll_hci.c
@@ -34,6 +34,9 @@
 #include "controller/ble_ll_resolv.h"
 #include "controller/ble_ll_sync.h"
 #include "ble_ll_conn_priv.h"
+#if MYNEWT_VAL(BLE_LL_DBG_HCI_CMD_PIN) >= 0 || MYNEWT_VAL(BLE_LL_DBG_HCI_EV_PIN) >= 0
+#include "hal/hal_gpio.h"
+#endif
 
 #if MYNEWT_VAL(BLE_LL_DIRECT_TEST_MODE)
 #include "ble_ll_dtm_priv.h"
@@ -97,6 +100,10 @@ ble_ll_hci_event_send(uint8_t *evbuf)
 {
     int rc;
 
+#if MYNEWT_VAL(BLE_LL_DBG_HCI_EV_PIN) >= 0
+    hal_gpio_write(MYNEWT_VAL(BLE_LL_DBG_HCI_EV_PIN), 1);
+#endif
+
     BLE_LL_ASSERT(BLE_HCI_EVENT_HDR_LEN + evbuf[1] <= BLE_LL_MAX_EVT_LEN);
 
     /* Count number of events sent */
@@ -105,6 +112,10 @@ ble_ll_hci_event_send(uint8_t *evbuf)
     /* Send the event to the host */
     rc = ble_hci_trans_ll_evt_tx(evbuf);
 
+#if MYNEWT_VAL(BLE_LL_DBG_HCI_EV_PIN) >= 0
+    hal_gpio_write(MYNEWT_VAL(BLE_LL_DBG_HCI_EV_PIN), 0);
+#endif
+
     return rc;
 }
 
@@ -1458,6 +1469,10 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
     uint16_t ocf;
     ble_ll_hci_post_cmd_complete_cb post_cb = NULL;
 
+#if MYNEWT_VAL(BLE_LL_DBG_HCI_CMD_PIN) >= 0
+    hal_gpio_write(MYNEWT_VAL(BLE_LL_DBG_HCI_CMD_PIN), 1);
+#endif
+
     /* The command buffer is the event argument */
     cmdbuf = (uint8_t *)ble_npl_event_get_arg(ev);
     BLE_LL_ASSERT(cmdbuf != NULL);
@@ -1525,6 +1540,10 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
     if (post_cb) {
         post_cb();
     }
+
+#if MYNEWT_VAL(BLE_LL_DBG_HCI_CMD_PIN) >= 0
+    hal_gpio_write(MYNEWT_VAL(BLE_LL_DBG_HCI_CMD_PIN), 0);
+#endif
 }
 
 /**
@@ -1573,6 +1592,13 @@ ble_ll_hci_acl_rx(struct os_mbuf *om, void *arg)
 void
 ble_ll_hci_init(void)
 {
+#if MYNEWT_VAL(BLE_LL_DBG_HCI_CMD_PIN) >= 0
+    hal_gpio_init_out(MYNEWT_VAL(BLE_LL_DBG_HCI_CMD_PIN), 0);
+#endif
+#if MYNEWT_VAL(BLE_LL_DBG_HCI_EV_PIN) >= 0
+    hal_gpio_init_out(MYNEWT_VAL(BLE_LL_DBG_HCI_EV_PIN), 0);
+#endif
+
     /* Set event callback for command processing */
     ble_npl_event_init(&g_ble_ll_hci_cmd_ev, ble_ll_hci_cmd_proc, NULL);
 
diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml
index 83730cc..98a0800 100644
--- a/nimble/controller/syscfg.yml
+++ b/nimble/controller/syscfg.yml
@@ -309,6 +309,19 @@ syscfg.defs:
             Sysinit stage for the NimBLE controller.
         value: 250
 
+    BLE_LL_DBG_HCI_CMD_PIN:
+        description: >
+            When set to proper GPIO pin number, this pin will be set to high
+            state when HCI command is received and being processed and back
+            to low state when it was processed.
+        value: -1
+    BLE_LL_DBG_HCI_EV_PIN:
+        description: >
+            When set to proper GPIO pin number, this pin will be set to high
+            state when HCI event is being sent and back to low state when event
+            was sent from controller.
+        value: -1
+
 # defunct settings (to be removed eventually)
     BLE_DEVICE:
         description: Superseded by BLE_CONTROLLER
diff --git a/porting/npl/riot/include/syscfg/syscfg.h b/porting/npl/riot/include/syscfg/syscfg.h
index 1ed4446..5b0987b 100644
--- a/porting/npl/riot/include/syscfg/syscfg.h
+++ b/porting/npl/riot/include/syscfg/syscfg.h
@@ -509,6 +509,14 @@
 #define MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS (4)
 #endif
 
+#ifndef MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN
+#define MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN (-1)
+#endif
+
+#ifndef MYNEWT_VAL_BLE_LL_DBG_HCI_EV_PIN
+#define MYNEWT_VAL_BLE_LL_DBG_HCI_EV_PIN (-1)
+#endif
+
 #ifndef MYNEWT_VAL_BLE_LL_DIRECT_TEST_MODE
 #define MYNEWT_VAL_BLE_LL_DIRECT_TEST_MODE (0)
 #endif