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.
This commit is contained in:
Andrzej Kaczmarek
2019-06-14 09:02:13 +09:00
parent d5ede9c755
commit d6dfb6ceb0
3 changed files with 47 additions and 0 deletions
+26
View File
@@ -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);
+13
View File
@@ -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
+8
View File
@@ -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