Crate esp_hal_procmacros

Source
Expand description

§Overview

Procedural macros for use with the esp-hal family of HAL packages. In general, you should not need to depend on this package directly, as the relevant procmacros are re-exported by the various HAL packages.

Provides macros for:

  • Placing statics and functions into RAM
  • Marking interrupt handlers
  • Blocking and Async #[main] macros

These macros offer developers a convenient way to control memory placement and define interrupt handlers in their embedded applications, allowing for optimized memory usage and precise handling of hardware interrupts.

Key Components:

  • handler - Attribute macro for marking interrupt handlers. Interrupt handlers are used to handle specific hardware interrupts generated by peripherals.

  • ram - Attribute macro for placing statics and functions into specific memory sections, such as SRAM or RTC RAM (slow or fast) with different initialization options. See its documentation for details.

  • embassy::main - Creates a new executor instance and declares an application entry point spawning the corresponding function body as an async task.

§Examples

§main macro

Requires the embassy feature to be enabled.

#[main]
async fn main(spawner: Spawner) {
    // Your application's entry point
}

§Feature Flags

  • embassy — Provide a #[main] procmacro to mark the entry point for Embassy applications.
  • rtc-slow — Indicates the target device has RTC slow memory available.

§Low-power Core Feature Flags

  • has-lp-core — Indicate that the SoC contains an LP core.
  • has-ulp-core — Indicate that the SoC contains a ULP core.
  • is-lp-core — Provide an #[entry] macro for running applications on the ESP32-C6’s LP core.
  • is-ulp-core — Provide an #[entry] macro for running applications on the ESP32-S2/S3’s ULP core.

Attribute Macros§

blocking_main
Attribute to declare the entry point of the program
embassy_main
Creates a new executor instance and declares an application entry point spawning the corresponding function body as an async task.
handler
Mark a function as an interrupt handler.
ram
Sets which segment of RAM to use for a function or static and how it should be initialized.

Derive Macros§

BuilderLite
Automatically implement the Builder Lite pattern for a struct.