Skip to content

Add std::function to Timer HAL  #8427

Open
@SuGlider

Description

@SuGlider
          >Is it possible to have the same functionality with timerAttachInterrupt()? It doesn't seem as though there's an equivalent method for setting the callback arguments for that function. Also, could you please clarify the difference between the functions in esp-hal-timer.h [(here)](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-timer.h) and esp_timer.h [(here)](https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/esp32/include/esp_timer/include/esp_timer.h)? Why are there two different groups of functions to use the ESP32's hardware timers?

The esp32-hal-timer layer has been refactored for the next Arduino Core 3.0.0 version.
It has some breaking changes that can be seen in the header file
We think that it makes the whole API simpler. Please let me know your opinion.

Anyway, I agree that we can add std::function to it and make it closer to the GPIO Interrupt API for C++.

Regarding the difference of the 2 layers, the esp32-hal layer is the interface from Arduino API to the IDF layer. By other hand the sdk esp32 files are just pure IDF header files, meaning that those are the IDF functions. esp32-hal calls functions from the IDF sdk and exposes an API closer to Arduino, whenever possible.
Both layer are in C. Your project can use any of them, one or the other.
Mixing both may require reading the code and avoiding conflicts, therefore, maybe not so simple.

Originally posted by @SuGlider in #8422 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Selected for Development

Relationships

None yet

Development

No branches or pull requests

Issue actions