Expand description
Procedural macros
Overview
The esp-hal-procmacros
module provides procedural macros for placing
statics and functions into RAM and for marking interrupt handlers on ESP
microcontrollers.
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:
- 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. Supported options are:
rtc_fast
- Use RTC fast RAMrtc_slow
- Use RTC slow RAM (not all targets support slow RTC RAM)uninitialized
- Skip initialization of the memoryzeroed
- Initialize the memory to zero
- interrupt - Attribute macro for marking interrupt
handlers. Interrupt handlers are used to handle specific hardware
interrupts generated by peripherals.
The macro allows users to specify the interrupt name explicitly or use the function name to match the interrupt.
Examples
ram
macro
#[ram(rtc_fast)]
static mut SOME_INITED_DATA: [u8; 2] = [0xaa, 0xbb];
#[ram(rtc_fast, uninitialized)]
static mut SOME_UNINITED_DATA: [u8; 2] = [0; 2];
#[ram(rtc_fast, zeroed)]
static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8];
interrupt
macro
#[interrupt]
fn INTR_NAME() {
// Interrupt handling code here
}
Macros
- Create an enum for erased GPIO pins, using the enum-dispatch pattern
Attribute Macros
- Marks a function as an interrupt handler
- This attribute allows placing statics and functions into ram.