mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
Merge branch 'fix/add_esp_timer_trigger_back_v6.0' into 'release/v6.0'
fix(ble): add esp timer trigger back for timestamp synchronization (v6.0) See merge request espressif/esp-idf!44694
This commit is contained in:
@@ -110,12 +110,46 @@ 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"
|
||||||
|
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
|
choice BLE_LOG_PRPH_CHOICE
|
||||||
prompt "BLE Log peripheral choice"
|
prompt "BLE Log peripheral choice"
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ void ble_log_lbm_write_trans(ble_log_prph_trans_t **trans, ble_log_src_t src_cod
|
|||||||
}
|
}
|
||||||
if (len_append) {
|
if (len_append) {
|
||||||
#if CONFIG_SOC_ESP_NIMBLE_CONTROLLER
|
#if CONFIG_SOC_ESP_NIMBLE_CONTROLLER
|
||||||
if (omdata) {
|
if (omdata && !BLE_LOG_IN_ISR()) {
|
||||||
|
/* os_mbuf_copydata is in flash and not safe to call from ISR */
|
||||||
os_mbuf_copydata((struct os_mbuf *)addr_append, 0,
|
os_mbuf_copydata((struct os_mbuf *)addr_append, 0,
|
||||||
len_append, buf + BLE_LOG_FRAME_HEAD_LEN + len);
|
len_append, buf + BLE_LOG_FRAME_HEAD_LEN + len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,24 @@ BLE_LOG_IRAM_ATTR BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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;
|
||||||
|
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 +113,28 @@ 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,
|
||||||
|
#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",
|
||||||
|
};
|
||||||
|
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 +147,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:
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ void ble_log_ts_deinit(void)
|
|||||||
gpio_reset_pin(CONFIG_BLE_LOG_SYNC_IO_NUM);
|
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)
|
void ble_log_ts_info_update(ble_log_ts_info_t **info)
|
||||||
{
|
{
|
||||||
if (!ts_inited) {
|
if (!ts_inited) {
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ portMUX_TYPE ble_log_spin_lock = portMUX_INITIALIZER_UNLOCKED;
|
|||||||
#if CONFIG_BLE_LOG_XOR_CHECKSUM_ENABLED
|
#if CONFIG_BLE_LOG_XOR_CHECKSUM_ENABLED
|
||||||
#include "esp_compiler.h"
|
#include "esp_compiler.h"
|
||||||
|
|
||||||
static inline uint32_t ror32(uint32_t word, uint32_t shift)
|
BLE_LOG_IRAM_ATTR BLE_LOG_STATIC BLE_LOG_INLINE
|
||||||
|
uint32_t ror32(uint32_t word, uint32_t shift)
|
||||||
{
|
{
|
||||||
if (unlikely(shift == 0)) {
|
if (unlikely(shift == 0)) {
|
||||||
return word;
|
return word;
|
||||||
|
|||||||
@@ -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