mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 20:56:01 -04:00
Merge branch 'bugfix/add_esp_timer_get_expiry_time_v5.2' into 'release/v5.2'
fix(nimble): Add support for esp_timer_get_expiry_time to nimble porting layer (v5.2) See merge request espressif/esp-idf!29462
This commit is contained in:
commit
d9be451649
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* SPDX-FileContributor: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileContributor: 2019-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -842,15 +842,35 @@ ble_npl_time_t
|
|||||||
IRAM_ATTR npl_freertos_callout_get_ticks(struct ble_npl_callout *co)
|
IRAM_ATTR npl_freertos_callout_get_ticks(struct ble_npl_callout *co)
|
||||||
{
|
{
|
||||||
#if BLE_NPL_USE_ESP_TIMER
|
#if BLE_NPL_USE_ESP_TIMER
|
||||||
/* Currently, esp_timer does not support an API which gets the expiry time for
|
|
||||||
* current timer.
|
uint32_t exp = 0;
|
||||||
* Returning 0 from here should not cause any effect.
|
|
||||||
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||||
|
uint64_t expiry = 0;
|
||||||
|
esp_err_t err;
|
||||||
|
|
||||||
|
struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co;
|
||||||
|
|
||||||
|
//Fetch expiry time in microseconds
|
||||||
|
err = esp_timer_get_expiry_time((esp_timer_handle_t)(callout->handle), &expiry);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
//Error. Could not fetch the expiry time
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Convert microseconds to ticks
|
||||||
|
npl_freertos_time_ms_to_ticks((uint32_t)(expiry / 1000), &exp);
|
||||||
|
#else
|
||||||
|
//esp_timer_get_expiry_time() is only available from IDF 5.0 onwards
|
||||||
|
/* Returning 0 from here should not cause any effect.
|
||||||
* Drawback of this approach is that existing code to reset timer would be called
|
* Drawback of this approach is that existing code to reset timer would be called
|
||||||
* more often (since the if condition to invoke reset timer would always succeed if
|
* more often (since the if condition to invoke reset timer would always succeed if
|
||||||
* timer is active).
|
* timer is active).
|
||||||
*/
|
*/
|
||||||
|
exp = 0;
|
||||||
|
#endif //ESP_IDF_VERSION
|
||||||
|
|
||||||
return 0;
|
return exp;
|
||||||
#else
|
#else
|
||||||
struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co;
|
struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co;
|
||||||
return xTimerGetExpiryTime(callout->handle);
|
return xTimerGetExpiryTime(callout->handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user