diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-12-08 21:26:28 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-12-08 21:26:28 +0100 |
| commit | 6c746dcf3944fdd2901697c2bab107033458e22c (patch) | |
| tree | b54ff7b6feab720e2ffca7e91e5eee099a0a4cf8 | |
| parent | 3ef18ec133b681d0ad3d25c050b5b960483c444e (diff) | |
Document how to bind multiple interrupts and handlers in `bind_interrupts!`.
| -rw-r--r-- | embassy-nrf/src/lib.rs | 22 | ||||
| -rw-r--r-- | embassy-rp/src/lib.rs | 11 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 23 |
3 files changed, 56 insertions, 0 deletions
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; | |||
| 97 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | 97 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) |
| 98 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | 98 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to |
| 99 | /// prove at compile-time that the right interrupts have been bound. | 99 | /// prove at compile-time that the right interrupts have been bound. |
| 100 | /// | ||
| 101 | /// Example of how to bind one interrupt: | ||
| 102 | /// | ||
| 103 | /// ```rust,ignore | ||
| 104 | /// use embassy_nrf::{bind_interrupts, spim, peripherals}; | ||
| 105 | /// | ||
| 106 | /// bind_interrupts!(struct Irqs { | ||
| 107 | /// SPIM3 => spim::InterruptHandler<peripherals::SPI3>; | ||
| 108 | /// }); | ||
| 109 | /// ``` | ||
| 110 | /// | ||
| 111 | /// Example of how to bind multiple interrupts in a single macro invocation: | ||
| 112 | /// | ||
| 113 | /// ```rust,ignore | ||
| 114 | /// use embassy_nrf::{bind_interrupts, spim, twim, peripherals}; | ||
| 115 | /// | ||
| 116 | /// bind_interrupts!(struct Irqs { | ||
| 117 | /// SPIM3 => spim::InterruptHandler<peripherals::SPI3>; | ||
| 118 | /// SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 => twim::InterruptHandler<peripherals::TWISPI0>; | ||
| 119 | /// }); | ||
| 120 | /// ``` | ||
| 121 | |||
| 100 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. | 122 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. |
| 101 | #[macro_export] | 123 | #[macro_export] |
| 102 | macro_rules! bind_interrupts { | 124 | 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!( | |||
| 86 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | 86 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) |
| 87 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | 87 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to |
| 88 | /// prove at compile-time that the right interrupts have been bound. | 88 | /// prove at compile-time that the right interrupts have been bound. |
| 89 | /// | ||
| 90 | /// Example of how to bind one interrupt: | ||
| 91 | /// | ||
| 92 | /// ```rust,ignore | ||
| 93 | /// use embassy_rp::{bind_interrupts, usb, peripherals}; | ||
| 94 | /// | ||
| 95 | /// bind_interrupts!(struct Irqs { | ||
| 96 | /// USBCTRL_IRQ => usb::InterruptHandler<peripherals::USB>; | ||
| 97 | /// }); | ||
| 98 | /// ``` | ||
| 99 | /// | ||
| 89 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. | 100 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. |
| 90 | #[macro_export] | 101 | #[macro_export] |
| 91 | macro_rules! bind_interrupts { | 102 | 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; | |||
| 90 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | 90 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) |
| 91 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | 91 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to |
| 92 | /// prove at compile-time that the right interrupts have been bound. | 92 | /// prove at compile-time that the right interrupts have been bound. |
| 93 | /// | ||
| 94 | /// Example of how to bind one interrupt: | ||
| 95 | /// | ||
| 96 | /// ```rust,ignore | ||
| 97 | /// use embassy_stm32::{bind_interrupts, usb_otg, peripherals}; | ||
| 98 | /// | ||
| 99 | /// bind_interrupts!(struct Irqs { | ||
| 100 | /// OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | ||
| 101 | /// }); | ||
| 102 | /// ``` | ||
| 103 | /// | ||
| 104 | /// Example of how to bind multiple interrupts, and multiple handlers to each interrupt, in a single macro invocation: | ||
| 105 | /// | ||
| 106 | /// ```rust,ignore | ||
| 107 | /// use embassy_stm32::{bind_interrupts, i2c, peripherals}; | ||
| 108 | /// | ||
| 109 | /// bind_interrupts!(struct Irqs { | ||
| 110 | /// I2C1 => i2c::EventInterruptHandler<peripherals::I2C1>, i2c::ErrorInterruptHandler<peripherals::I2C1>; | ||
| 111 | /// I2C2_3 => i2c::EventInterruptHandler<peripherals::I2C2>, i2c::ErrorInterruptHandler<peripherals::I2C2>, | ||
| 112 | /// i2c::EventInterruptHandler<peripherals::I2C3>, i2c::ErrorInterruptHandler<peripherals::I2C3>; | ||
| 113 | /// }); | ||
| 114 | /// ``` | ||
| 115 | |||
| 93 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. | 116 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. |
| 94 | #[macro_export] | 117 | #[macro_export] |
| 95 | macro_rules! bind_interrupts { | 118 | macro_rules! bind_interrupts { |
