diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 3274dafb1..9093ad919 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -97,6 +97,28 @@ mod chip; /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to /// prove at compile-time that the right interrupts have been bound. +/// +/// Example of how to bind one interrupt: +/// +/// ```rust,ignore +/// use embassy_nrf::{bind_interrupts, spim, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// SPIM3 => spim::InterruptHandler; +/// }); +/// ``` +/// +/// Example of how to bind multiple interrupts in a single macro invocation: +/// +/// ```rust,ignore +/// use embassy_nrf::{bind_interrupts, spim, twim, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// SPIM3 => spim::InterruptHandler; +/// SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 => twim::InterruptHandler; +/// }); +/// ``` + // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. #[macro_export] macro_rules! bind_interrupts { diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 66e4cfdcf..5151323a9 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -86,6 +86,17 @@ embassy_hal_internal::interrupt_mod!( /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to /// prove at compile-time that the right interrupts have been bound. +/// +/// Example of how to bind one interrupt: +/// +/// ```rust,ignore +/// use embassy_rp::{bind_interrupts, usb, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// USBCTRL_IRQ => usb::InterruptHandler; +/// }); +/// ``` +/// // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. #[macro_export] macro_rules! bind_interrupts { diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 13e189da6..5d9b4e6a0 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -90,6 +90,29 @@ pub use crate::_generated::interrupt; /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to /// prove at compile-time that the right interrupts have been bound. +/// +/// Example of how to bind one interrupt: +/// +/// ```rust,ignore +/// use embassy_stm32::{bind_interrupts, usb_otg, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// OTG_FS => usb_otg::InterruptHandler; +/// }); +/// ``` +/// +/// Example of how to bind multiple interrupts, and multiple handlers to each interrupt, in a single macro invocation: +/// +/// ```rust,ignore +/// use embassy_stm32::{bind_interrupts, i2c, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// I2C1 => i2c::EventInterruptHandler, i2c::ErrorInterruptHandler; +/// I2C2_3 => i2c::EventInterruptHandler, i2c::ErrorInterruptHandler, +/// i2c::EventInterruptHandler, i2c::ErrorInterruptHandler; +/// }); +/// ``` + // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. #[macro_export] macro_rules! bind_interrupts {