mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-14 04:56:47 +03:00
feat(esp_timer): Support absolute timing APIs
Merges https://github.com/espressif/esp-idf/pull/17807
This commit is contained in:
committed by
Konstantin Kondrashov
parent
d18019de5b
commit
b3ccc1316d
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -157,6 +157,23 @@ esp_err_t esp_timer_create(const esp_timer_create_args_t* create_args,
|
||||
*/
|
||||
esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us);
|
||||
|
||||
/**
|
||||
* @brief Start a one-shot timer with absolute alarm time
|
||||
*
|
||||
* This function starts a one-shot timer that will trigger once at the specified absolute time.
|
||||
* To start a timer relative to the current time, see esp_timer_start_once().
|
||||
* Timer represented by `timer` should not be running when this function is
|
||||
* called.
|
||||
*
|
||||
* @param timer timer handle created using esp_timer_create()
|
||||
* @param alarm_us timer alarm time, in absolute microseconds (as returned by esp_timer_get_time())
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the timer is already running or in the past
|
||||
*/
|
||||
esp_err_t esp_timer_start_once_at(esp_timer_handle_t timer, uint64_t alarm_us);
|
||||
|
||||
/**
|
||||
* @brief Start a periodic timer
|
||||
*
|
||||
@@ -172,6 +189,24 @@ esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us);
|
||||
*/
|
||||
esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period);
|
||||
|
||||
/**
|
||||
* @brief Start a periodic timer with absolute alarm time
|
||||
*
|
||||
* Timer represented by `timer` should not be running when this function is called.
|
||||
* This function starts the timer which will trigger every `period` microseconds.
|
||||
* The first alarm will be triggered at `first_alarm_us` time.
|
||||
* To start a periodic timer relative to the current time, see esp_timer_start_periodic().
|
||||
*
|
||||
* @param timer timer handle created using esp_timer_create()
|
||||
* @param period_us timer period, in microseconds
|
||||
* @param first_alarm_us timer first alarm time, in absolute microseconds (as returned by esp_timer_get_time())
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the timer is already running or in the past
|
||||
*/
|
||||
esp_err_t esp_timer_start_periodic_at(esp_timer_handle_t timer, uint64_t period_us, uint64_t first_alarm_us);
|
||||
|
||||
/**
|
||||
* @brief Restart a currently running timer
|
||||
*
|
||||
@@ -190,6 +225,24 @@ esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period);
|
||||
*/
|
||||
esp_err_t esp_timer_restart(esp_timer_handle_t timer, uint64_t timeout_us);
|
||||
|
||||
/**
|
||||
* @brief Restart a currently running timer with absolute alarm time
|
||||
*
|
||||
* Type of `timer` | Action
|
||||
* --------------- | ------
|
||||
* One-shot timer | Restarted immediately and times out once at `alarm_us` microseconds
|
||||
* Periodic timer | Restarted immediately with a new period of `period_us` microseconds. Next alarm is at `first_alarm_us` microseconds
|
||||
*
|
||||
* @param timer timer handle created using esp_timer_create()
|
||||
* @param period_us In case of a periodic timer, represents the new period.
|
||||
* @param first_alarm_us timer alarm time, in absolute microseconds (as returned by esp_timer_get_time())
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the timer is not running or in the past
|
||||
*/
|
||||
esp_err_t esp_timer_restart_at(esp_timer_handle_t timer, uint64_t period_us, uint64_t first_alarm_us);
|
||||
|
||||
/**
|
||||
* @brief Stop a running timer
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user