mirror of
https://github.com/espressif/esp-idf
synced 2025-03-08 15:49:08 -05:00
fix(ble/bluedroid): Support SPI log output options for HCI
This commit is contained in:
parent
e59cc9822c
commit
3cebdc731a
@ -11,6 +11,13 @@ config BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
help
|
||||
Output ble logs to SPI bus
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
bool "Enable HCI log output to SPI"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable logging of HCI packets to the SPI bus when BLE SPI log output is enabled.
|
||||
|
||||
config BT_BLE_LOG_SPI_OUT_QUEUE_SIZE
|
||||
int "Number of ble log async SPI output queues"
|
||||
depends on BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -84,6 +84,13 @@
|
||||
#define BT_HCI_LOG_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
// HCI LOG TO SPI
|
||||
#if UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#define BT_BLE_LOG_SPI_OUT_HCI_ENABLED UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#else
|
||||
#define BT_BLE_LOG_SPI_OUT_HCI_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define HCI_LOG_DATA_BUFFER_SIZE UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -120,6 +120,13 @@
|
||||
#define UC_BT_HCI_LOG_DEBUG_EN FALSE
|
||||
#endif
|
||||
|
||||
//HCI LOG TO SPI
|
||||
#ifdef CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#define UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED TRUE
|
||||
#else
|
||||
#define UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define UC_BT_HCI_LOG_DATA_BUFFER_SIZE CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
|
@ -41,6 +41,14 @@
|
||||
#include "stack/hcimsgs.h"
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
|
||||
#define HCI_BLE_EVENT 0x3e
|
||||
#define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
|
||||
#define PACKET_TYPE_TO_INDEX(type) ((type) - 1)
|
||||
@ -214,6 +222,9 @@ static uint16_t transmit_data(serial_data_type_t type,
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(data[0], &data[1], length - 1);
|
||||
#endif
|
||||
#if (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
ble_log_spi_out_write_with_ts(BLE_LOG_SPI_OUT_SOURCE_NIMBLE, data, length);
|
||||
#endif // (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
// TX Data to target
|
||||
esp_vhci_host_send_packet(data, length);
|
||||
|
||||
@ -561,6 +572,9 @@ void bt_record_hci_data(uint8_t *data, uint16_t len)
|
||||
|
||||
static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
{
|
||||
#if (BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
ble_log_spi_out_write_with_ts(BLE_LOG_SPI_OUT_SOURCE_HCI_UPSTREAM, data, len);
|
||||
#endif // (BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
//Target has packet to host, malloc new buffer for packet
|
||||
BT_HDR *pkt = NULL;
|
||||
pkt_linked_item_t *linked_pkt = NULL;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -22,6 +22,10 @@
|
||||
#include "bt_common.h"
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
|
||||
|
||||
#define NIMBLE_VHCI_TIMEOUT_MS 2000
|
||||
#define BLE_HCI_EVENT_HDR_LEN (2)
|
||||
#define BLE_HCI_CMD_HDR_LEN (3)
|
||||
@ -77,6 +81,9 @@ void esp_vhci_host_send_packet_wrapper(uint8_t *data, uint16_t len)
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(data[0], &data[1], len - 1);
|
||||
#endif
|
||||
#if (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
ble_log_spi_out_write_with_ts(BLE_LOG_SPI_OUT_SOURCE_HCI_DOWNSTREAM, data, len);
|
||||
#endif // (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
esp_vhci_host_send_packet(data, len);
|
||||
}
|
||||
|
||||
@ -362,6 +369,10 @@ void bt_record_hci_data(uint8_t *data, uint16_t len)
|
||||
*/
|
||||
static int host_rcv_pkt(uint8_t *data, uint16_t len)
|
||||
{
|
||||
#if (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
ble_log_spi_out_write_with_ts(BLE_LOG_SPI_OUT_SOURCE_HCI_UPSTREAM, data, len);
|
||||
#endif // (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
|
||||
|
||||
bt_record_hci_data(data, len);
|
||||
|
||||
if(!ble_hs_enabled_state) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user