From f1adfaacedb2f5e9b05b64f8b145297996f01de7 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Wed, 30 Jun 2021 14:51:51 +0530 Subject: [PATCH] Add esp_timer_is_active function for Nimble stack to use esp_timer instead of FreeRTOS timer --- components/bt/host/nimble/Kconfig.in | 6 ++++++ components/bt/host/nimble/nimble | 2 +- .../bt/host/nimble/port/include/esp_nimble_cfg.h | 8 ++++++++ components/esp_timer/include/esp_timer.h | 12 ++++++++++++ components/esp_timer/src/esp_timer.c | 5 +++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/components/bt/host/nimble/Kconfig.in b/components/bt/host/nimble/Kconfig.in index ff6994c4dd..b4d69a6d78 100644 --- a/components/bt/host/nimble/Kconfig.in +++ b/components/bt/host/nimble/Kconfig.in @@ -493,3 +493,9 @@ config BT_NIMBLE_MAX_PERIODIC_SYNCS Set this option to set the upper limit for number of periodic sync connections. This should be less than maximum connections allowed by controller. + +config BT_NIMBLE_USE_ESP_TIMER + bool "Enable Esp Timer for Nimble" + default y + help + Set this option to use Esp Timer which has higher priority timer instead of FreeRTOS timer diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 5bb7b40227..a90d8e46b8 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 5bb7b402275210ed6f97fe4bd6e452bf0f659452 +Subproject commit a90d8e46b87ea026182b97d8311dafc15c577714 diff --git a/components/bt/host/nimble/port/include/esp_nimble_cfg.h b/components/bt/host/nimble/port/include/esp_nimble_cfg.h index 582d4a42e1..1f4b3302b3 100644 --- a/components/bt/host/nimble/port/include/esp_nimble_cfg.h +++ b/components/bt/host/nimble/port/include/esp_nimble_cfg.h @@ -1374,4 +1374,12 @@ #define MYNEWT_VAL_NEWT_FEATURE_LOGCFG (1) #endif +#ifndef MYNEWT_VAL_BLE_USE_ESP_TIMER +#ifdef CONFIG_BT_NIMBLE_USE_ESP_TIMER +#define MYNEWT_VAL_BLE_USE_ESP_TIMER (1) +#else +#define MYNEWT_VAL_BLE_USE_ESP_TIMER (0) +#endif +#endif + #endif diff --git a/components/esp_timer/include/esp_timer.h b/components/esp_timer/include/esp_timer.h index f77222bf8e..cdf3964fec 100644 --- a/components/esp_timer/include/esp_timer.h +++ b/components/esp_timer/include/esp_timer.h @@ -228,6 +228,18 @@ int64_t esp_timer_get_next_alarm(void); */ esp_err_t esp_timer_dump(FILE* stream); +/** + * @brief Returns status of a timer, active or not + * + * This function is used to identify if the timer is still active or not. + * + * @param timer timer handle created using esp_timer_create + * @return + * - 1 if timer is still active + * - 0 if timer is not active. + */ +bool esp_timer_is_active(esp_timer_handle_t timer); + #ifdef __cplusplus } #endif diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index a636c14590..516d4f1c8d 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -530,3 +530,8 @@ uint32_t IRAM_ATTR esp_system_get_time_resolution(void) return 1000; } #endif + +bool esp_timer_is_active(esp_timer_handle_t timer) +{ + return timer_armed(timer); +}