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
32#include "esp_err.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/*============================ TYPES =========================================*/
39
40struct esp_timer;
42
43typedef void (*esp_timer_cb_t)(void *arg);
44
45typedef enum {
47 /* ISR dispatch is not modeled on VSF host; falls back to TASK. */
50
51typedef struct {
53 void * arg;
55 const char * name;
58
59/*============================ PROTOTYPES ====================================*/
60
61/* Lifecycle. On VSF both are no-ops because the timer backbone comes up as
62 * part of vsf_start(); kept for API compatibility. */
65
66/* Microseconds elapsed since the systimer started. Equivalent to
67 * vsf_systimer_tick_to_us(vsf_systimer_get_tick()). */
69
70/* Time remaining until the next scheduled alarm, in microseconds. Returns
71 * INT64_MAX if no timer is armed. VSF does not expose a soonest-due query
72 * cheaply; this is a best-effort scan over the active timer list. */
74
75/* Create a one-shot or periodic timer. Stored in VSF heap; caller must
76 * release via esp_timer_delete(). */
78 esp_timer_handle_t *out_handle);
79
80/* Arm the timer for a single shot after timeout_us microseconds. */
82
83/* Arm the timer to fire every period_us microseconds. */
85
86/* Cancel a running timer. Safe to call on an unstarted timer. */
88
89/* Stop (if running) then destroy the timer. */
91
92/* Query whether the timer is currently armed. */
94
95#ifdef __cplusplus
96}
97#endif
98
99#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:86
esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period_us)
Definition esp_timer_port.c:146
esp_err_t esp_timer_delete(esp_timer_handle_t timer)
Definition esp_timer_port.c:180
esp_err_t esp_timer_init(void)
Definition esp_timer_port.c:80
void(* esp_timer_cb_t)(void *arg)
Definition esp_timer.h:43
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:103
int64_t esp_timer_get_next_alarm(void)
Definition esp_timer_port.c:96
bool esp_timer_is_active(esp_timer_handle_t timer)
Definition esp_timer_port.c:193
struct esp_timer * esp_timer_handle_t
Definition esp_timer.h:41
esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us)
Definition esp_timer_port.c:128
int64_t esp_timer_get_time(void)
Definition esp_timer_port.c:91
esp_err_t esp_timer_stop(esp_timer_handle_t timer)
Definition esp_timer_port.c:165
esp_timer_dispatch_t
Definition esp_timer.h:45
@ ESP_TIMER_TASK
Definition esp_timer.h:46
@ ESP_TIMER_ISR
Definition esp_timer.h:48
long long int64_t
Definition stdint.h:10
unsigned long long uint64_t
Definition stdint.h:11
Definition esp_timer.h:51
const char * name
Definition esp_timer.h:55
bool skip_unhandled_events
Definition esp_timer.h:56
esp_timer_dispatch_t dispatch_method
Definition esp_timer.h:54
esp_timer_cb_t callback
Definition esp_timer.h:52
void * arg
Definition esp_timer.h:53
Definition esp_timer_port.c:51
void * arg
Definition esp_timer_port.c:54
Generated from commit: vsfteam/vsf@015f4d1