mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 10:40:47 +03:00
Merge branch 'chore/ble-log-unused-code' into 'master'
chore: BLE Log Unused Code Cleanup See merge request espressif/esp-idf!51910
This commit is contained in:
@@ -143,7 +143,9 @@ if BLE_LOG_ENABLED
|
||||
bool "Enable BLE Log Timestamp Synchronization (TS)"
|
||||
default n
|
||||
help
|
||||
Enable BLE Log TS with external logging module
|
||||
Enable BLE Log TS with external logging module. Synchronization is
|
||||
triggered periodically by an ESP Timer using task dispatch. The
|
||||
timer does not wake the system from light sleep.
|
||||
|
||||
if BLE_LOG_TS_ENABLED
|
||||
config BLE_LOG_SYNC_IO_NUM
|
||||
@@ -152,38 +154,6 @@ if BLE_LOG_ENABLED
|
||||
default 0
|
||||
help
|
||||
GPIO number for TS toggle output
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_TIMEOUT_MS
|
||||
int "Timeout (ms) for Timestamp Synchronization toggle"
|
||||
default 1000
|
||||
help
|
||||
Timeout (ms) for Timestamp Synchronization toggle
|
||||
|
||||
choice BLE_LOG_TS_TRIGGER_CHOICE
|
||||
prompt "BLE Log Timestamp Synchronization trigger choice"
|
||||
default BLE_LOG_TS_TRIGGER_TASK_EVENT
|
||||
help
|
||||
Choose BLE Log Timestamp Synchronization trigger
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_ESP_TIMER
|
||||
bool "BLE Log Timestamp Synchronization trigger - ESP Timer"
|
||||
help
|
||||
ESP Timer based periodic TS trigger
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_TASK_EVENT
|
||||
bool "BLE Log Timestamp Synchronization trigger - Task Event"
|
||||
help
|
||||
Task Event based TS trigger (Light Sleep Test Compatibility)
|
||||
endchoice
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD
|
||||
bool "Utilize ISR dispatch method for ESP Timer as Timestamp Synchronization trigger"
|
||||
default n
|
||||
select ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
|
||||
select GPIO_CTRL_FUNC_IN_IRAM
|
||||
depends on BLE_LOG_TS_TRIGGER_ESP_TIMER
|
||||
help
|
||||
Utilize ISR dispatch method for ESP Timer as Timestamp Synchronization trigger
|
||||
endif
|
||||
|
||||
choice BLE_LOG_PRPH_CHOICE
|
||||
@@ -288,6 +258,31 @@ if BLE_LOG_ENABLED
|
||||
config BLE_LOG_LBM_LL_TRANS_SIZE
|
||||
int
|
||||
default 512
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_TIMEOUT_MS
|
||||
int
|
||||
depends on BLE_LOG_TS_ENABLED
|
||||
default 1000
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_CHOICE
|
||||
bool
|
||||
depends on BLE_LOG_TS_ENABLED
|
||||
default y
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_ESP_TIMER
|
||||
bool
|
||||
depends on BLE_LOG_TS_ENABLED
|
||||
default y
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_TASK_EVENT
|
||||
bool
|
||||
depends on BLE_LOG_TS_ENABLED
|
||||
default n
|
||||
|
||||
config BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD
|
||||
bool
|
||||
depends on BLE_LOG_TS_ENABLED
|
||||
default n
|
||||
endif
|
||||
|
||||
menu "Legacy SPI Log Output (Deprecated - use BT Log Async Output instead)"
|
||||
|
||||
@@ -25,9 +25,7 @@ BLE_LOG_STATIC TaskHandle_t rt_task_handle = NULL;
|
||||
BLE_LOG_STATIC BLE_LOG_DRAM_ATTR QueueHandle_t rt_queue_handle = NULL;
|
||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||
BLE_LOG_STATIC BLE_LOG_DRAM_ATTR uint32_t rt_ts_enabled = 0;
|
||||
#if CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER
|
||||
BLE_LOG_STATIC esp_timer_handle_t rt_ts_timer = NULL;
|
||||
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER */
|
||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||
|
||||
/* PRIVATE FUNCTION DECLARATION */
|
||||
@@ -43,9 +41,7 @@ BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters)
|
||||
ble_log_prph_trans_t *trans = NULL;
|
||||
uint32_t curr_os_ts = 0;
|
||||
uint32_t last_hook_os_ts = 0;
|
||||
#ifndef UNIT_TEST
|
||||
while (1)
|
||||
#endif /* !UNIT_TEST */
|
||||
{
|
||||
/* CRITICAL:
|
||||
* Blocking queue receive is mandatory for light sleep support */
|
||||
@@ -55,12 +51,8 @@ BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters)
|
||||
|
||||
/* Task hook */
|
||||
curr_os_ts = pdTICKS_TO_MS(xTaskGetTickCount());
|
||||
if ((curr_os_ts - last_hook_os_ts) < BLE_LOG_TASK_HOOK_TIMEOUT_MS) {
|
||||
#ifndef UNIT_TEST
|
||||
if ((curr_os_ts - last_hook_os_ts) < BLE_LOG_TS_TRIGGER_TIMEOUT_MS) {
|
||||
continue;
|
||||
#else /* UNIT_TEST */
|
||||
return;
|
||||
#endif /* !UNIT_TEST */
|
||||
}
|
||||
last_hook_os_ts = curr_os_ts;
|
||||
|
||||
@@ -71,19 +63,12 @@ BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters)
|
||||
};
|
||||
ble_log_write_hex(BLE_LOG_SRC_INTERNAL, (const uint8_t *)&ble_log_info, sizeof(ble_log_info_t));
|
||||
|
||||
#if CONFIG_BLE_LOG_TS_TRIGGER_TASK_EVENT
|
||||
ble_log_rt_ts_trigger(NULL);
|
||||
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_TASK_EVENT */
|
||||
|
||||
ble_log_write_enh_stat();
|
||||
ble_log_write_buf_util();
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||
#if CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD
|
||||
BLE_LOG_IRAM_ATTR
|
||||
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD */
|
||||
BLE_LOG_STATIC void ble_log_rt_ts_trigger(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
@@ -121,23 +106,19 @@ bool ble_log_rt_init(void)
|
||||
|
||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||
BLE_LOG_ATOMIC_STORE_RELAXED(rt_ts_enabled, false);
|
||||
#if CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER
|
||||
/* Initialize ESP Timer Trigger */
|
||||
esp_timer_create_args_t ts_timer_args = {
|
||||
.callback = ble_log_rt_ts_trigger,
|
||||
.arg = NULL,
|
||||
#if CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD
|
||||
.dispatch_method = ESP_TIMER_ISR,
|
||||
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD */
|
||||
.name = "ble_log_ts_timer",
|
||||
.skip_unhandled_events = true,
|
||||
};
|
||||
if (esp_timer_create(&ts_timer_args, &rt_ts_timer) != ESP_OK) {
|
||||
goto exit;
|
||||
}
|
||||
if (esp_timer_start_periodic(rt_ts_timer, BLE_LOG_TS_TRIGGER_TIMEOUT_US) != ESP_OK) {
|
||||
if (esp_timer_start_periodic(rt_ts_timer, BLE_LOG_TS_TRIGGER_TIMEOUT_MS * 1000) != ESP_OK) {
|
||||
goto exit;
|
||||
}
|
||||
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER */
|
||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||
|
||||
BLE_LOG_ATOMIC_STORE_RELEASE(rt_inited, true);
|
||||
@@ -160,13 +141,11 @@ void ble_log_rt_deinit(void)
|
||||
}
|
||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||
BLE_LOG_ATOMIC_STORE_RELEASE(rt_ts_enabled, false);
|
||||
#if CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER
|
||||
if (rt_ts_timer) {
|
||||
esp_timer_stop_blocking(rt_ts_timer, portMAX_DELAY);
|
||||
esp_timer_delete(rt_ts_timer);
|
||||
rt_ts_timer = NULL;
|
||||
}
|
||||
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER */
|
||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||
|
||||
/* CRITICAL:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -61,9 +61,6 @@ void ble_log_ts_deinit(void)
|
||||
gpio_reset_pin(CONFIG_BLE_LOG_SYNC_IO_NUM);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD
|
||||
BLE_LOG_IRAM_ATTR
|
||||
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER_ISR_DISPATCH_METHOD */
|
||||
void ble_log_ts_info_update(ble_log_ts_info_t **info)
|
||||
{
|
||||
if (!ts_inited) {
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
#define BLE_LOG_REF_COUNT_WAIT_TIMEOUT_MS (1000)
|
||||
|
||||
/* VARIABLE */
|
||||
#ifndef UNIT_TEST
|
||||
BLE_LOG_DRAM_ATTR portMUX_TYPE ble_log_spin_lock = portMUX_INITIALIZER_UNLOCKED;
|
||||
#endif /* !UNIT_TEST */
|
||||
|
||||
/* INTERNAL INTERFACE */
|
||||
#include "esp_compiler.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -22,12 +22,7 @@
|
||||
/* MACRO */
|
||||
#define BLE_LOG_TASK_PRIO (ESP_TASK_PRIO_MAX - 1)
|
||||
#define BLE_LOG_TASK_STACK_SIZE CONFIG_BLE_LOG_TASK_STACK_SIZE
|
||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||
#define BLE_LOG_TS_TRIGGER_TIMEOUT_US (CONFIG_BLE_LOG_TS_TRIGGER_TIMEOUT_MS * 1000)
|
||||
#define BLE_LOG_TASK_HOOK_TIMEOUT_MS CONFIG_BLE_LOG_TS_TRIGGER_TIMEOUT_MS
|
||||
#else /* !CONFIG_BLE_LOG_TS_ENABLED */
|
||||
#define BLE_LOG_TASK_HOOK_TIMEOUT_MS (1000)
|
||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||
#define BLE_LOG_TS_TRIGGER_TIMEOUT_MS (1000)
|
||||
|
||||
/* INTERFACE */
|
||||
bool ble_log_rt_init(void);
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
#include "esp_bit_defs.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
#ifndef UNIT_TEST
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_rom_serial_output.h"
|
||||
#endif /* !UNIT_TEST */
|
||||
|
||||
/* MACRO */
|
||||
#define BLE_LOG_ATOMIC_LOAD_ACQUIRE(VAR) __atomic_load_n(&(VAR), __ATOMIC_ACQUIRE)
|
||||
@@ -30,9 +28,6 @@
|
||||
#define BLE_LOG_ATOMIC_STORE_RELEASE(VAR, VALUE) __atomic_store_n(&(VAR), (VALUE), __ATOMIC_RELEASE)
|
||||
#define BLE_LOG_ATOMIC_STORE_RELAXED(VAR, VALUE) __atomic_store_n(&(VAR), (VALUE), __ATOMIC_RELAXED)
|
||||
|
||||
/* Unit test */
|
||||
#ifndef UNIT_TEST
|
||||
|
||||
/* Reference counting macros */
|
||||
#define BLE_LOG_REF_COUNT_ACQUIRE(VAR) __atomic_fetch_add(VAR, 1, __ATOMIC_ACQUIRE)
|
||||
#define BLE_LOG_REF_COUNT_RELEASE(VAR) __atomic_fetch_sub(VAR, 1, __ATOMIC_RELEASE)
|
||||
@@ -96,64 +91,6 @@ void ble_log_cas_release(volatile bool *cas_lock)
|
||||
__atomic_store_n(cas_lock, false, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
#else /* UNIT_TEST */
|
||||
|
||||
/* Reference counting macros */
|
||||
#define BLE_LOG_REF_COUNT_ACQUIRE(VAR) (*VAR)++
|
||||
#define BLE_LOG_REF_COUNT_RELEASE(VAR) (*VAR)--
|
||||
#define BLE_LOG_ATOMIC_LOAD_SEQ_CST(VAR) BLE_LOG_ATOMIC_LOAD_ACQUIRE(VAR)
|
||||
#define BLE_LOG_ATOMIC_STORE_SEQ_CST(VAR, VALUE) BLE_LOG_ATOMIC_STORE_RELAXED(VAR, VALUE)
|
||||
#define BLE_LOG_REF_COUNT_ACQUIRE_SEQ_CST(VAR) BLE_LOG_REF_COUNT_ACQUIRE(VAR)
|
||||
|
||||
/* Specifier*/
|
||||
#define BLE_LOG_STATIC
|
||||
#define BLE_LOG_INLINE
|
||||
|
||||
/* Section */
|
||||
#define BLE_LOG_DRAM_ATTR
|
||||
#define BLE_LOG_IRAM_ATTR
|
||||
|
||||
/* Memory operation */
|
||||
void *mocked_malloc(size_t size);
|
||||
void mocked_free(void *ptr);
|
||||
void mocked_memcpy(void *dst, const void *src, size_t len);
|
||||
void mocked_memset(void *ptr, int value, size_t len);
|
||||
#define BLE_LOG_MALLOC(size) mocked_malloc(size)
|
||||
#define BLE_LOG_FREE(ptr) mocked_free(ptr)
|
||||
#define BLE_LOG_ALIGNED_MALLOC(size) mocked_malloc(size)
|
||||
#define BLE_LOG_MEMCPY(dst, src, len) mocked_memcpy(dst, src, len)
|
||||
#define BLE_LOG_MEMSET(ptr, value, len) mocked_memset(ptr, value, len)
|
||||
|
||||
/* Critical section wrapper */
|
||||
void mocked_enter_critical(void);
|
||||
void mocked_exit_critical(void);
|
||||
#define BLE_LOG_ENTER_CRITICAL() mocked_enter_critical()
|
||||
#define BLE_LOG_EXIT_CRITICAL() mocked_exit_critical()
|
||||
|
||||
/* FreeRTOS API wrapper */
|
||||
bool mocked_in_isr(void);
|
||||
#define BLE_LOG_IN_ISR() mocked_in_isr()
|
||||
|
||||
/* Spin lock wrapper */
|
||||
void mocked_acquire_spin_lock(void *spin_lock);
|
||||
void mocked_release_spin_lock(void *spin_lock);
|
||||
#define BLE_LOG_ACQUIRE_SPIN_LOCK(spin_lock) mocked_acquire_spin_lock(spin_lock)
|
||||
#define BLE_LOG_RELEASE_SPIN_LOCK(spin_lock) mocked_release_spin_lock(spin_lock)
|
||||
|
||||
/* Printf wrapper */
|
||||
void mocked_printf(const char *fmt, ...);
|
||||
#define BLE_LOG_CONSOLE mocked_printf
|
||||
|
||||
/* Assert wrapper */
|
||||
void mocked_assert(bool expr);
|
||||
#define BLE_LOG_ASSERT(expr) mocked_assert(expr)
|
||||
|
||||
#define BLE_LOG_FEED_WDT()
|
||||
|
||||
bool ble_log_cas_acquire(volatile bool *cas_lock);
|
||||
void ble_log_cas_release(volatile bool *cas_lock);
|
||||
#endif /* UNIT_TEST */
|
||||
|
||||
#define BLE_LOG_VERSION (5)
|
||||
|
||||
/* TYPEDEF */
|
||||
|
||||
Reference in New Issue
Block a user