mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-27 04:10:25 +00:00
add the possibility to document bind_interrupts
struct
s
the `bind_interrupts` macro creates a `struct` for the interrupts. it was so far not possible to document those (except for STM32) and there was no generic documentation being generated/added either, thus the `missing_docs` lint was triggered for consumers which enabled it. with this change it is now possible to manually add a comment on the `struct` being defined in the macro invocation. to show that this works one RP example has been modified accordingly.
This commit is contained in:
parent
d1c2ce927a
commit
117eb45fa0
@ -54,16 +54,20 @@ pub use crate::pac::NVIC_PRIO_BITS;
|
||||
/// ```rust,ignore
|
||||
/// use embassy_imxrt::{bind_interrupts, flexspi, peripherals};
|
||||
///
|
||||
/// bind_interrupts!(struct Irqs {
|
||||
/// FLEXSPI_IRQ => flexspi::InterruptHandler<peripherals::FLEXSPI>;
|
||||
/// });
|
||||
/// bind_interrupts!(
|
||||
/// /// Binds the FLEXSPI interrupt.
|
||||
/// struct Irqs {
|
||||
/// FLEXSPI_IRQ => flexspi::InterruptHandler<peripherals::FLEXSPI>;
|
||||
/// }
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
// developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`.
|
||||
#[macro_export]
|
||||
macro_rules! bind_interrupts {
|
||||
($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => {
|
||||
($(#[$attr:meta])* $vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => {
|
||||
#[derive(Copy, Clone)]
|
||||
$(#[$attr])*
|
||||
$vis struct $name;
|
||||
|
||||
$(
|
||||
|
@ -200,9 +200,12 @@ mod chip;
|
||||
/// ```rust,ignore
|
||||
/// use embassy_nrf::{bind_interrupts, spim, peripherals};
|
||||
///
|
||||
/// bind_interrupts!(struct Irqs {
|
||||
/// SPIM3 => spim::InterruptHandler<peripherals::SPI3>;
|
||||
/// });
|
||||
/// bind_interrupts!(
|
||||
/// /// Binds the SPIM3 interrupt.
|
||||
/// struct Irqs {
|
||||
/// SPIM3 => spim::InterruptHandler<peripherals::SPI3>;
|
||||
/// }
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
/// Example of how to bind multiple interrupts in a single macro invocation:
|
||||
@ -219,7 +222,7 @@ mod chip;
|
||||
// developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`.
|
||||
#[macro_export]
|
||||
macro_rules! bind_interrupts {
|
||||
($vis:vis struct $name:ident {
|
||||
($(#[$attr:meta])* $vis:vis struct $name:ident {
|
||||
$(
|
||||
$(#[cfg($cond_irq:meta)])?
|
||||
$irq:ident => $(
|
||||
@ -229,6 +232,7 @@ macro_rules! bind_interrupts {
|
||||
)*
|
||||
}) => {
|
||||
#[derive(Copy, Clone)]
|
||||
$(#[$attr])*
|
||||
$vis struct $name;
|
||||
|
||||
$(
|
||||
|
@ -160,15 +160,18 @@ embassy_hal_internal::interrupt_mod!(
|
||||
/// ```rust,ignore
|
||||
/// use embassy_rp::{bind_interrupts, usb, peripherals};
|
||||
///
|
||||
/// bind_interrupts!(struct Irqs {
|
||||
/// USBCTRL_IRQ => usb::InterruptHandler<peripherals::USB>;
|
||||
/// });
|
||||
/// bind_interrupts!(
|
||||
/// /// Binds the USB Interrupts.
|
||||
/// struct Irqs {
|
||||
/// USBCTRL_IRQ => usb::InterruptHandler<peripherals::USB>;
|
||||
/// }
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
// developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`.
|
||||
#[macro_export]
|
||||
macro_rules! bind_interrupts {
|
||||
($vis:vis struct $name:ident {
|
||||
($(#[$attr:meta])* $vis:vis struct $name:ident {
|
||||
$(
|
||||
$(#[cfg($cond_irq:meta)])?
|
||||
$irq:ident => $(
|
||||
@ -178,6 +181,7 @@ macro_rules! bind_interrupts {
|
||||
)*
|
||||
}) => {
|
||||
#[derive(Copy, Clone)]
|
||||
$(#[$attr])*
|
||||
$vis struct $name;
|
||||
|
||||
$(
|
||||
|
@ -163,11 +163,14 @@ pub use crate::_generated::interrupt;
|
||||
/// ```rust,ignore
|
||||
/// use embassy_stm32::{bind_interrupts, i2c, peripherals};
|
||||
///
|
||||
/// bind_interrupts!(struct Irqs {
|
||||
/// I2C1 => i2c::EventInterruptHandler<peripherals::I2C1>, i2c::ErrorInterruptHandler<peripherals::I2C1>;
|
||||
/// I2C2_3 => i2c::EventInterruptHandler<peripherals::I2C2>, i2c::ErrorInterruptHandler<peripherals::I2C2>,
|
||||
/// i2c::EventInterruptHandler<peripherals::I2C3>, i2c::ErrorInterruptHandler<peripherals::I2C3>;
|
||||
/// });
|
||||
/// bind_interrupts!(
|
||||
/// /// Binds the I2C interrupts.
|
||||
/// struct Irqs {
|
||||
/// I2C1 => i2c::EventInterruptHandler<peripherals::I2C1>, i2c::ErrorInterruptHandler<peripherals::I2C1>;
|
||||
/// I2C2_3 => i2c::EventInterruptHandler<peripherals::I2C2>, i2c::ErrorInterruptHandler<peripherals::I2C2>,
|
||||
/// i2c::EventInterruptHandler<peripherals::I2C3>, i2c::ErrorInterruptHandler<peripherals::I2C3>;
|
||||
/// }
|
||||
/// );
|
||||
/// ```
|
||||
|
||||
// developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`.
|
||||
|
@ -12,9 +12,12 @@ use embassy_rp::gpio::Pull;
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
ADC_IRQ_FIFO => InterruptHandler;
|
||||
});
|
||||
bind_interrupts!(
|
||||
/// Binds the ADC interrupts.
|
||||
struct Irqs {
|
||||
ADC_IRQ_FIFO => InterruptHandler;
|
||||
}
|
||||
);
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user