mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(ble): add esp timer trigger back for timestamp synchronization
(cherry picked from commit d1a5804de9)
Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
This commit is contained in:
@@ -110,12 +110,38 @@ if BLE_LOG_ENABLED
|
|||||||
help
|
help
|
||||||
Enable BLE Log TS with external logging module
|
Enable BLE Log TS with external logging module
|
||||||
|
|
||||||
config BLE_LOG_SYNC_IO_NUM
|
if BLE_LOG_TS_ENABLED
|
||||||
int "GPIO number for Timestamp Synchronization (TS) toggle output"
|
config BLE_LOG_SYNC_IO_NUM
|
||||||
depends on BLE_LOG_TS_ENABLED
|
int "GPIO number for Timestamp Synchronization (TS) toggle output"
|
||||||
default 0
|
depends on BLE_LOG_TS_ENABLED
|
||||||
help
|
default 0
|
||||||
GPIO number for TS toggle output
|
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"
|
||||||
|
select ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
|
||||||
|
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
|
||||||
|
endif
|
||||||
|
|
||||||
choice BLE_LOG_PRPH_CHOICE
|
choice BLE_LOG_PRPH_CHOICE
|
||||||
prompt "BLE Log peripheral choice"
|
prompt "BLE Log peripheral choice"
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ BLE_LOG_STATIC TaskHandle_t rt_task_handle = NULL;
|
|||||||
BLE_LOG_STATIC QueueHandle_t rt_queue_handle = NULL;
|
BLE_LOG_STATIC QueueHandle_t rt_queue_handle = NULL;
|
||||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||||
BLE_LOG_STATIC bool rt_ts_enabled = false;
|
BLE_LOG_STATIC bool rt_ts_enabled = false;
|
||||||
|
#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 */
|
||||||
|
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||||
|
BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters);
|
||||||
|
BLE_LOG_STATIC void ble_log_rt_ts_trigger(void *arg);
|
||||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||||
|
|
||||||
/* PRIVATE FUNCTION */
|
/* PRIVATE FUNCTION */
|
||||||
@@ -56,15 +65,9 @@ BLE_LOG_IRAM_ATTR 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));
|
ble_log_write_hex(BLE_LOG_SRC_INTERNAL, (const uint8_t *)&ble_log_info, sizeof(ble_log_info_t));
|
||||||
|
|
||||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
#if CONFIG_BLE_LOG_TS_TRIGGER_TASK_EVENT
|
||||||
if (rt_ts_enabled) {
|
ble_log_rt_ts_trigger(NULL);
|
||||||
ble_log_ts_info_t *ts_info = NULL;
|
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_TASK_EVENT */
|
||||||
ble_log_ts_info_update(&ts_info);
|
|
||||||
if (ts_info) {
|
|
||||||
ble_log_write_hex(BLE_LOG_SRC_INTERNAL, (const uint8_t *)ts_info, sizeof(ble_log_ts_info_t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
|
||||||
|
|
||||||
#if CONFIG_BLE_LOG_ENH_STAT_ENABLED
|
#if CONFIG_BLE_LOG_ENH_STAT_ENABLED
|
||||||
ble_log_write_enh_stat();
|
ble_log_write_enh_stat();
|
||||||
@@ -72,6 +75,21 @@ BLE_LOG_IRAM_ATTR BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||||
|
BLE_LOG_STATIC void ble_log_rt_ts_trigger(void *arg)
|
||||||
|
{
|
||||||
|
(void)arg;
|
||||||
|
if (!rt_inited || !rt_ts_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ble_log_ts_info_t *ts_info = NULL;
|
||||||
|
ble_log_ts_info_update(&ts_info);
|
||||||
|
if (ts_info) {
|
||||||
|
ble_log_write_hex(BLE_LOG_SRC_INTERNAL, (const uint8_t *)ts_info, sizeof(ble_log_ts_info_t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||||
|
|
||||||
/* INTERFACE */
|
/* INTERFACE */
|
||||||
bool ble_log_rt_init(void)
|
bool ble_log_rt_init(void)
|
||||||
{
|
{
|
||||||
@@ -92,10 +110,26 @@ bool ble_log_rt_init(void)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_inited = true;
|
|
||||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||||
rt_ts_enabled = false;
|
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,
|
||||||
|
.dispatch_method = ESP_TIMER_ISR,
|
||||||
|
.name = "ble_log_ts_timer",
|
||||||
|
};
|
||||||
|
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) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER */
|
||||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||||
|
|
||||||
|
rt_inited = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@@ -108,6 +142,13 @@ void ble_log_rt_deinit(void)
|
|||||||
rt_inited = false;
|
rt_inited = false;
|
||||||
#if CONFIG_BLE_LOG_TS_ENABLED
|
#if CONFIG_BLE_LOG_TS_ENABLED
|
||||||
rt_ts_enabled = false;
|
rt_ts_enabled = false;
|
||||||
|
#if CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER
|
||||||
|
if (rt_ts_timer) {
|
||||||
|
esp_timer_stop(rt_ts_timer);
|
||||||
|
esp_timer_delete(rt_ts_timer);
|
||||||
|
rt_ts_timer = NULL;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_BLE_LOG_TS_TRIGGER_ESP_TIMER */
|
||||||
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||||
|
|
||||||
/* CRITICAL:
|
/* CRITICAL:
|
||||||
|
|||||||
@@ -22,7 +22,12 @@
|
|||||||
/* MACRO */
|
/* MACRO */
|
||||||
#define BLE_LOG_TASK_PRIO (ESP_TASK_PRIO_MAX - 1)
|
#define BLE_LOG_TASK_PRIO (ESP_TASK_PRIO_MAX - 1)
|
||||||
#define BLE_LOG_TASK_STACK_SIZE CONFIG_BLE_LOG_TASK_STACK_SIZE
|
#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)
|
#define BLE_LOG_TASK_HOOK_TIMEOUT_MS (1000)
|
||||||
|
#endif /* CONFIG_BLE_LOG_TS_ENABLED */
|
||||||
|
|
||||||
/* INTERFACE */
|
/* INTERFACE */
|
||||||
bool ble_log_rt_init();
|
bool ble_log_rt_init();
|
||||||
|
|||||||
Reference in New Issue
Block a user