C+
Packages · View as Markdown

espidf

C+ bindings for ESP-IDF on the esp32-xtensa target: just enough of the platform for a control loop to drive pins, read the clock, sleep, and print. See Embedded & ESP32 for the bigger picture.

Four modules:

  • espidf/gpioreset, set_direction, set_level, get_level, and the mode values.
  • espidf/timernow_us, the esp_timer clock as i64 microseconds since boot.
  • espidf/taskdelay_ms / delay_us (newlib usleep, so they are tick-rate independent).
  • espidf/logprint_line / print_i32 / print_i64 over the UART.

The gpio and timer externs are #[no_alloc] + #[no_block] leaves, so a #[realtime] control loop can call them and keep its contract. The bindings themselves stay on i32 / u32 / *u8 and #str_ptr literals so they are usable from #[no_alloc] code, while Text / Vec remain available on the chip's newlib heap when you do want them.

Building and entry point

A consuming package declares espidf = "*" and builds as a [lib] staticlib:

cpc build --target esp32-xtensa

cpc stops at the archive; the ESP-IDF / CMake build links the firmware (the bound symbols live in IDF's driver, esp_timer, and newlib components). The app exports cplus_app_main, and IDF's main component keeps a two-line C shim that calls it from app_main. The full entry convention is on the Embedded & ESP32 page.