Documentation improvements for esp-hal-procmacros

This commit is contained in:
Jesse Braham 2023-10-27 08:00:39 -07:00 committed by Jesse Braham
parent 8a54c8a3e3
commit 0304a10b2f
3 changed files with 55 additions and 23 deletions

View File

@ -8,14 +8,14 @@ repository = "https://github.com/esp-rs/esp-hal"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["esp32c3", "interrupt", "ram"] features = ["esp32c3", "embassy", "interrupt", "ram"]
[lib] [lib]
proc-macro = true proc-macro = true
[dependencies] [dependencies]
darling = "0.20.3" darling = "0.20.3"
litrs = "0.4.0" litrs = "0.4.1"
object = { version = "0.32.1", optional = true } object = { version = "0.32.1", optional = true }
proc-macro-crate = "2.0.0" proc-macro-crate = "2.0.0"
proc-macro-error = "1.0.4" proc-macro-error = "1.0.4"

View File

@ -5,7 +5,13 @@
![Crates.io](https://img.shields.io/crates/l/esp-hal-procmacros?labelColor=1C2C2E&style=flat-square) ![Crates.io](https://img.shields.io/crates/l/esp-hal-procmacros?labelColor=1C2C2E&style=flat-square)
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org) [![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)
Procedural macros for placing statics and functions into RAM, and for marking interrupt handlers. Procedural macros for use with the `esp-hal` family of HAL packages.
Provides macros for:
- Placing statics and functions into RAM
- Marking interrupt handlers
- Automatically creating an `embassy` executor instance and spawning the defined entry point
## [Documentation] ## [Documentation]

View File

@ -1,31 +1,65 @@
//! Procedural macros
//!
//! ## Overview //! ## Overview
//! The `esp-hal-procmacros` module provides procedural macros for placing //!
//! statics and functions into RAM and for marking interrupt handlers on ESP //! Procedural macros for use with the `esp-hal` family of HAL packages. In
//! microcontrollers. //! 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
//! - Automatically creating an `embassy` executor instance and spawning the
//! defined entry point
//! //!
//! These macros offer developers a convenient way to control memory placement //! These macros offer developers a convenient way to control memory placement
//! and define interrupt handlers in their embedded applications, allowing for //! and define interrupt handlers in their embedded applications, allowing for
//! optimized memory usage and precise handling of hardware interrupts. //! optimized memory usage and precise handling of hardware interrupts.
//! //!
//! Key Components: //! Key Components:
//! - [ram](attr.ram.html) - 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 RAM
//! - `rtc_slow` - Use RTC slow RAM (not all targets support slow RTC RAM)
//! - `uninitialized` - Skip initialization of the memory
//! - `zeroed` - Initialize the memory to zero
//! - [interrupt](attr.interrupt.html) - Attribute macro for marking interrupt //! - [interrupt](attr.interrupt.html) - Attribute macro for marking interrupt
//! handlers. Interrupt handlers are used to handle specific hardware //! handlers. Interrupt handlers are used to handle specific hardware
//! interrupts generated by peripherals.<br> The macro allows users to //! interrupts generated by peripherals.<br> The macro allows users to
//! specify the interrupt name explicitly or use the function name to match //! specify the interrupt name explicitly or use the function name to match
//! the interrupt. //! the interrupt.
//! - [main](attr.main.html) - Creates a new `executor`` instance and declares
//! an application entry point spawning the corresponding function body as an
//! async task.
//! - [ram](attr.ram.html) - 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 RAM
//! - `rtc_slow` - Use RTC slow RAM (not all targets support slow RTC RAM)
//! - `uninitialized` - Skip initialization of the memory
//! - `zeroed` - Initialize the memory to zero
//! //!
//! ## Examples //! ## Examples
//! //!
//! #### `interrupt` macro
//!
//! Requires the `interrupt` feature to be enabled.
//!
//! ```no_run
//! #[interrupt]
//! fn INTR_NAME() {
//! // Interrupt handling code here
//! }
//! ```
//!
//! #### `main` macro
//!
//! Requires the `embassy` feature to be enabled.
//!
//! ```no_run
//! #[main]
//! async fn main(spawner: Spawner) -> ! {
//! // Your application's entry point
//! }
//! ```
//!
//! #### `ram` macro //! #### `ram` macro
//!
//! Requires the `ram` feature to be enabled.
//!
//! ```no_run //! ```no_run
//! #[ram(rtc_fast)] //! #[ram(rtc_fast)]
//! static mut SOME_INITED_DATA: [u8; 2] = [0xaa, 0xbb]; //! static mut SOME_INITED_DATA: [u8; 2] = [0xaa, 0xbb];
@ -36,14 +70,6 @@
//! #[ram(rtc_fast, zeroed)] //! #[ram(rtc_fast, zeroed)]
//! static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; //! static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8];
//! ``` //! ```
//!
//! #### `interrupt` macro
//! ```no_run
//! #[interrupt]
//! fn INTR_NAME() {
//! // Interrupt handling code here
//! }
//! ```
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46717278")] #![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46717278")]