VSF Documented
esp_timer.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * Clean-room re-implementation of ESP-IDF public API "esp_timer.h".
20 *
21 * Authored from ESP-IDF v5.x public API only. No code copied from the
22 * ESP-IDF source tree. The VSF port bridges to vsf_callback_timer.
23 */
24
25#ifndef __VSF_ESPIDF_ESP_TIMER_H__
26#define __VSF_ESPIDF_ESP_TIMER_H__
27
28#include <stdint.h>
29#include <stdbool.h>
30#include <stddef.h>
31#include <stdio.h>
32
33#include "esp_err.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*============================ TYPES =========================================*/
40
41struct esp_timer;
43
44typedef void (*esp_timer_cb_t)(void *arg);
45
46typedef enum {
48 /* ISR dispatch is not modeled on VSF host; falls back to TASK. */
51
52typedef struct {
54 void * arg;
56 const char * name;
59
60/*============================ PROTOTYPES ====================================*/
61
62/* Lifecycle. On VSF both are no-ops because the timer backbone comes up as
63 * part of vsf_start(); kept for API compatibility. */
66
67/* Microseconds elapsed since the systimer started. Equivalent to
68 * vsf_systimer_tick_to_us(vsf_systimer_get_tick()). */
70
71/* Time remaining until the next scheduled alarm, in microseconds. Returns
72 * INT64_MAX if no timer is armed. VSF does not expose a soonest-due query
73 * cheaply; this is a best-effort scan over the active timer list. */
75
76/* Create a one-shot or periodic timer. Stored in VSF heap; caller must
77 * release via esp_timer_delete(). */
79 esp_timer_handle_t *out_handle);
80
81/* Arm the timer for a single shot after timeout_us microseconds. */
83
84/* Arm the timer to fire every period_us microseconds. */
86
87/* Cancel a running timer. Safe to call on an unstarted timer. */
89
90/* Stop (if running) then destroy the timer. */
92
93/* Query whether the timer is currently armed. */
95
96/* Arm the periodic timer to fire every period_us starting at absolute
97 * time start_at_us (microseconds since boot). */
99
100/* Arm the one-shot timer to fire at absolute time timeout_at_us. */
102
103/* Stop the periodic timer (if running), update its period, and re-arm
104 * to fire at absolute time start_at_us. */
105esp_err_t esp_timer_restart_at(esp_timer_handle_t timer, uint64_t new_period_us, uint64_t start_at_us);
106
107/* Dump all active timers to the given FILE stream (mainly for debugging). */
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif // __VSF_ESPIDF_ESP_TIMER_H__
int esp_err_t
Definition esp_err.h:41
esp_err_t esp_timer_deinit(void)
Definition esp_timer_port.c:88
esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period_us)
Definition esp_timer_port.c:148
esp_err_t esp_timer_start_once_at(esp_timer_handle_t timer, uint64_t timeout_at_us)
Definition esp_timer_port.c:233
esp_err_t esp_timer_delete(esp_timer_handle_t timer)
Definition esp_timer_port.c:182
esp_err_t esp_timer_start_periodic_at(esp_timer_handle_t timer, uint64_t period_us, uint64_t start_at_us)
Definition esp_timer_port.c:220
esp_err_t esp_timer_init(void)
Definition esp_timer_port.c:82
void(* esp_timer_cb_t)(void *arg)
Definition esp_timer.h:44
esp_err_t esp_timer_dump(FILE *stream)
Definition esp_timer_port.c:264
esp_err_t esp_timer_create(const esp_timer_create_args_t *create_args, esp_timer_handle_t *out_handle)
Definition esp_timer_port.c:105
int64_t esp_timer_get_next_alarm(void)
Definition esp_timer_port.c:98
bool esp_timer_is_active(esp_timer_handle_t timer)
Definition esp_timer_port.c:195
struct esp_timer * esp_timer_handle_t
Definition esp_timer.h:42
esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us)
Definition esp_timer_port.c:130
int64_t esp_timer_get_time(void)
Definition esp_timer_port.c:93
esp_err_t esp_timer_stop(esp_timer_handle_t timer)
Definition esp_timer_port.c:167
esp_err_t esp_timer_restart_at(esp_timer_handle_t timer, uint64_t new_period_us, uint64_t start_at_us)
Definition esp_timer_port.c:245
esp_timer_dispatch_t
Definition esp_timer.h:46
@ ESP_TIMER_TASK
Definition esp_timer.h:47
@ ESP_TIMER_ISR
Definition esp_timer.h:49
long long int64_t
Definition stdint.h:10
unsigned long long uint64_t
Definition stdint.h:11
Definition stdio.h:145
Definition esp_timer.h:52
const char * name
Definition esp_timer.h:56
bool skip_unhandled_events
Definition esp_timer.h:57
esp_timer_dispatch_t dispatch_method
Definition esp_timer.h:55
esp_timer_cb_t callback
Definition esp_timer.h:53
void * arg
Definition esp_timer.h:54
Definition esp_timer_port.c:53
void * arg
Definition esp_timer_port.c:56
Generated from commit: vsfteam/vsf@c3767bf