embassy-stm32

Crates

git

Versions

stm32h7r7z8

Flavors

embassy_stm32

Trait Peripheral

Source
pub trait Peripheral: Sized {
    type P;

    // Required method
    unsafe fn clone_unchecked(&self) -> Self::P;

    // Provided method
    fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>
       where Self: 'a { ... }
}
Expand description

Trait for any type that can be used as a peripheral of type P.

This is used in driver constructors, to allow passing either owned peripherals (e.g. TWISPI0), or borrowed peripherals (e.g. &mut TWISPI0).

For example, if you have a driver with a constructor like this:

impl<'d, T: Instance> Twim<'d, T> {
    pub fn new(
        twim: impl Peripheral<P = T> + 'd,
        irq: impl Peripheral<P = T::Interrupt> + 'd,
        sda: impl Peripheral<P = impl GpioPin> + 'd,
        scl: impl Peripheral<P = impl GpioPin> + 'd,
        config: Config,
    ) -> Self { .. }
}

You may call it with owned peripherals, which yields an instance that can live forever ('static):

let mut twi: Twim<'static, ...> = Twim::new(p.TWISPI0, irq, p.P0_03, p.P0_04, config);

Or you may call it with borrowed peripherals, which yields an instance that can only live for as long as the borrows last:

let mut twi: Twim<'_, ...> = Twim::new(&mut p.TWISPI0, &mut irq, &mut p.P0_03, &mut p.P0_04, config);

§Implementation details, for HAL authors

When writing a HAL, the intended way to use this trait is to take impl Peripheral<P = ..> in the HAL’s public API (such as driver constructors), calling .into_ref() to obtain a PeripheralRef, and storing that in the driver struct.

.into_ref() on an owned T yields a PeripheralRef<'static, T>. .into_ref() on an &'a mut T yields a PeripheralRef<'a, T>.

Required Associated Types§

Source

type P

Peripheral singleton type

Required Methods§

Source

unsafe fn clone_unchecked(&self) -> Self::P

Unsafely clone (duplicate) a peripheral singleton.

§Safety

This returns an owned clone of the peripheral. You must manually ensure only one copy of the peripheral is in use at a time. For example, don’t create two SPI drivers on SPI1, because they will “fight” each other.

You should strongly prefer using into_ref() instead. It returns a PeripheralRef, which allows the borrow checker to enforce this at compile time.

Provided Methods§

Source

fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>
where Self: 'a,

Convert a value into a PeripheralRef.

When called on an owned T, yields a PeripheralRef<'static, T>. When called on an &'a mut T, yields a PeripheralRef<'a, T>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Peripheral for embassy_stm32::dma::AnyChannel

Source§

impl Peripheral for NoDma

Source§

impl Peripheral for embassy_stm32::exti::AnyChannel

Source§

impl Peripheral for AnyPin

Source§

impl Peripheral for ADC12_COMMON

Source§

impl Peripheral for CEC

Source§

type P = CEC

Source§

impl Peripheral for CORDIC

Source§

impl Peripheral for CRC

Source§

type P = CRC

Source§

impl Peripheral for CRS

Source§

type P = CRS

Source§

impl Peripheral for DBGMCU

Source§

impl Peripheral for DMA2D

Source§

impl Peripheral for DTS

Source§

type P = DTS

Source§

impl Peripheral for ETH

Source§

type P = ETH

Source§

impl Peripheral for EXTI0

Source§

impl Peripheral for EXTI1

Source§

impl Peripheral for EXTI2

Source§

impl Peripheral for EXTI3

Source§

impl Peripheral for EXTI4

Source§

impl Peripheral for EXTI5

Source§

impl Peripheral for EXTI6

Source§

impl Peripheral for EXTI7

Source§

impl Peripheral for EXTI8

Source§

impl Peripheral for EXTI9

Source§

impl Peripheral for EXTI10

Source§

impl Peripheral for EXTI11

Source§

impl Peripheral for EXTI12

Source§

impl Peripheral for EXTI13

Source§

impl Peripheral for EXTI14

Source§

impl Peripheral for EXTI15

Source§

impl Peripheral for FDCAN1

Source§

impl Peripheral for FDCAN2

Source§

impl Peripheral for FDCANRAM

Source§

impl Peripheral for FLASH

Source§

impl Peripheral for FMC

Source§

type P = FMC

Source§

impl Peripheral for GPDMA1

Source§

impl Peripheral for GPDMA1_CH0

Source§

impl Peripheral for GPDMA1_CH1

Source§

impl Peripheral for GPDMA1_CH2

Source§

impl Peripheral for GPDMA1_CH3

Source§

impl Peripheral for GPDMA1_CH4

Source§

impl Peripheral for GPDMA1_CH5

Source§

impl Peripheral for GPDMA1_CH6

Source§

impl Peripheral for GPDMA1_CH7

Source§

impl Peripheral for GPDMA1_CH8

Source§

impl Peripheral for GPDMA1_CH9

Source§

impl Peripheral for GPDMA1_CH10

Source§

impl Peripheral for GPDMA1_CH11

Source§

impl Peripheral for GPDMA1_CH12

Source§

impl Peripheral for GPDMA1_CH13

Source§

impl Peripheral for GPDMA1_CH14

Source§

impl Peripheral for GPDMA1_CH15

Source§

impl Peripheral for HASH

Source§

impl Peripheral for HPDMA1

Source§

impl Peripheral for HPDMA1_CH0

Source§

impl Peripheral for HPDMA1_CH1

Source§

impl Peripheral for HPDMA1_CH2

Source§

impl Peripheral for HPDMA1_CH3

Source§

impl Peripheral for HPDMA1_CH4

Source§

impl Peripheral for HPDMA1_CH5

Source§

impl Peripheral for HPDMA1_CH6

Source§

impl Peripheral for HPDMA1_CH7

Source§

impl Peripheral for HPDMA1_CH8

Source§

impl Peripheral for HPDMA1_CH9

Source§

impl Peripheral for HPDMA1_CH10

Source§

impl Peripheral for HPDMA1_CH11

Source§

impl Peripheral for HPDMA1_CH12

Source§

impl Peripheral for HPDMA1_CH13

Source§

impl Peripheral for HPDMA1_CH14

Source§

impl Peripheral for HPDMA1_CH15

Source§

impl Peripheral for I2C1

Source§

impl Peripheral for I2C2

Source§

impl Peripheral for I2C3

Source§

impl Peripheral for IWDG

Source§

impl Peripheral for JPEG

Source§

impl Peripheral for LPTIM2

Source§

impl Peripheral for LPTIM3

Source§

impl Peripheral for LPTIM4

Source§

impl Peripheral for LPTIM5

Source§

impl Peripheral for LPUART1

Source§

impl Peripheral for LTDC

Source§

impl Peripheral for MCO1

Source§

impl Peripheral for MCO2

Source§

impl Peripheral for MDIOS

Source§

impl Peripheral for PA0

Source§

type P = PA0

Source§

impl Peripheral for PA1

Source§

type P = PA1

Source§

impl Peripheral for PA2

Source§

type P = PA2

Source§

impl Peripheral for PA3

Source§

type P = PA3

Source§

impl Peripheral for PA4

Source§

type P = PA4

Source§

impl Peripheral for PA5

Source§

type P = PA5

Source§

impl Peripheral for PA6

Source§

type P = PA6

Source§

impl Peripheral for PA7

Source§

type P = PA7

Source§

impl Peripheral for PA8

Source§

type P = PA8

Source§

impl Peripheral for PA9

Source§

type P = PA9

Source§

impl Peripheral for PA10

Source§

impl Peripheral for PA11

Source§

impl Peripheral for PA12

Source§

impl Peripheral for PA13

Source§

impl Peripheral for PA14

Source§

impl Peripheral for PA15

Source§

impl Peripheral for PB0

Source§

type P = PB0

Source§

impl Peripheral for PB1

Source§

type P = PB1

Source§

impl Peripheral for PB2

Source§

type P = PB2

Source§

impl Peripheral for PB3

Source§

type P = PB3

Source§

impl Peripheral for PB4

Source§

type P = PB4

Source§

impl Peripheral for PB5

Source§

type P = PB5

Source§

impl Peripheral for PB6

Source§

type P = PB6

Source§

impl Peripheral for PB7

Source§

type P = PB7

Source§

impl Peripheral for PB8

Source§

type P = PB8

Source§

impl Peripheral for PB9

Source§

type P = PB9

Source§

impl Peripheral for PB10

Source§

impl Peripheral for PB11

Source§

impl Peripheral for PB12

Source§

impl Peripheral for PB13

Source§

impl Peripheral for PB14

Source§

impl Peripheral for PB15

Source§

impl Peripheral for PC0

Source§

type P = PC0

Source§

impl Peripheral for PC1

Source§

type P = PC1

Source§

impl Peripheral for PC2

Source§

type P = PC2

Source§

impl Peripheral for PC3

Source§

type P = PC3

Source§

impl Peripheral for PC4

Source§

type P = PC4

Source§

impl Peripheral for PC5

Source§

type P = PC5

Source§

impl Peripheral for PC6

Source§

type P = PC6

Source§

impl Peripheral for PC7

Source§

type P = PC7

Source§

impl Peripheral for PC8

Source§

type P = PC8

Source§

impl Peripheral for PC9

Source§

type P = PC9

Source§

impl Peripheral for PC10

Source§

impl Peripheral for PC11

Source§

impl Peripheral for PC12

Source§

impl Peripheral for PC13

Source§

impl Peripheral for PC14

Source§

impl Peripheral for PC15

Source§

impl Peripheral for PD0

Source§

type P = PD0

Source§

impl Peripheral for PD1

Source§

type P = PD1

Source§

impl Peripheral for PD2

Source§

type P = PD2

Source§

impl Peripheral for PD3

Source§

type P = PD3

Source§

impl Peripheral for PD4

Source§

type P = PD4

Source§

impl Peripheral for PD5

Source§

type P = PD5

Source§

impl Peripheral for PD6

Source§

type P = PD6

Source§

impl Peripheral for PD7

Source§

type P = PD7

Source§

impl Peripheral for PD8

Source§

type P = PD8

Source§

impl Peripheral for PD9

Source§

type P = PD9

Source§

impl Peripheral for PD10

Source§

impl Peripheral for PD11

Source§

impl Peripheral for PD12

Source§

impl Peripheral for PD13

Source§

impl Peripheral for PD14

Source§

impl Peripheral for PD15

Source§

impl Peripheral for PE0

Source§

type P = PE0

Source§

impl Peripheral for PE1

Source§

type P = PE1

Source§

impl Peripheral for PE2

Source§

type P = PE2

Source§

impl Peripheral for PE3

Source§

type P = PE3

Source§

impl Peripheral for PE4

Source§

type P = PE4

Source§

impl Peripheral for PE5

Source§

type P = PE5

Source§

impl Peripheral for PE6

Source§

type P = PE6

Source§

impl Peripheral for PE7

Source§

type P = PE7

Source§

impl Peripheral for PE8

Source§

type P = PE8

Source§

impl Peripheral for PE9

Source§

type P = PE9

Source§

impl Peripheral for PE10

Source§

impl Peripheral for PE11

Source§

impl Peripheral for PE12

Source§

impl Peripheral for PE13

Source§

impl Peripheral for PE14

Source§

impl Peripheral for PE15

Source§

impl Peripheral for PF0

Source§

type P = PF0

Source§

impl Peripheral for PF1

Source§

type P = PF1

Source§

impl Peripheral for PF2

Source§

type P = PF2

Source§

impl Peripheral for PF3

Source§

type P = PF3

Source§

impl Peripheral for PF4

Source§

type P = PF4

Source§

impl Peripheral for PF5

Source§

type P = PF5

Source§

impl Peripheral for PF6

Source§

type P = PF6

Source§

impl Peripheral for PF7

Source§

type P = PF7

Source§

impl Peripheral for PF8

Source§

type P = PF8

Source§

impl Peripheral for PF9

Source§

type P = PF9

Source§

impl Peripheral for PF10

Source§

impl Peripheral for PF11

Source§

impl Peripheral for PF12

Source§

impl Peripheral for PF13

Source§

impl Peripheral for PF14

Source§

impl Peripheral for PF15

Source§

impl Peripheral for PG0

Source§

type P = PG0

Source§

impl Peripheral for PG1

Source§

type P = PG1

Source§

impl Peripheral for PG2

Source§

type P = PG2

Source§

impl Peripheral for PG3

Source§

type P = PG3

Source§

impl Peripheral for PG4

Source§

type P = PG4

Source§

impl Peripheral for PG5

Source§

type P = PG5

Source§

impl Peripheral for PG6

Source§

type P = PG6

Source§

impl Peripheral for PG7

Source§

type P = PG7

Source§

impl Peripheral for PG8

Source§

type P = PG8

Source§

impl Peripheral for PG9

Source§

type P = PG9

Source§

impl Peripheral for PG10

Source§

impl Peripheral for PG11

Source§

impl Peripheral for PG12

Source§

impl Peripheral for PG13

Source§

impl Peripheral for PG14

Source§

impl Peripheral for PG15

Source§

impl Peripheral for PH0

Source§

type P = PH0

Source§

impl Peripheral for PH1

Source§

type P = PH1

Source§

impl Peripheral for PH2

Source§

type P = PH2

Source§

impl Peripheral for PH3

Source§

type P = PH3

Source§

impl Peripheral for PH4

Source§

type P = PH4

Source§

impl Peripheral for PH5

Source§

type P = PH5

Source§

impl Peripheral for PH6

Source§

type P = PH6

Source§

impl Peripheral for PH7

Source§

type P = PH7

Source§

impl Peripheral for PH8

Source§

type P = PH8

Source§

impl Peripheral for PH9

Source§

type P = PH9

Source§

impl Peripheral for PH10

Source§

impl Peripheral for PH11

Source§

impl Peripheral for PH12

Source§

impl Peripheral for PH13

Source§

impl Peripheral for PH14

Source§

impl Peripheral for PH15

Source§

impl Peripheral for PM0

Source§

type P = PM0

Source§

impl Peripheral for PM1

Source§

type P = PM1

Source§

impl Peripheral for PM2

Source§

type P = PM2

Source§

impl Peripheral for PM3

Source§

type P = PM3

Source§

impl Peripheral for PM4

Source§

type P = PM4

Source§

impl Peripheral for PM5

Source§

type P = PM5

Source§

impl Peripheral for PM6

Source§

type P = PM6

Source§

impl Peripheral for PM7

Source§

type P = PM7

Source§

impl Peripheral for PM8

Source§

type P = PM8

Source§

impl Peripheral for PM9

Source§

type P = PM9

Source§

impl Peripheral for PM10

Source§

impl Peripheral for PM11

Source§

impl Peripheral for PM12

Source§

impl Peripheral for PM13

Source§

impl Peripheral for PM14

Source§

impl Peripheral for PM15

Source§

impl Peripheral for PN0

Source§

type P = PN0

Source§

impl Peripheral for PN1

Source§

type P = PN1

Source§

impl Peripheral for PN2

Source§

type P = PN2

Source§

impl Peripheral for PN3

Source§

type P = PN3

Source§

impl Peripheral for PN4

Source§

type P = PN4

Source§

impl Peripheral for PN5

Source§

type P = PN5

Source§

impl Peripheral for PN6

Source§

type P = PN6

Source§

impl Peripheral for PN7

Source§

type P = PN7

Source§

impl Peripheral for PN8

Source§

type P = PN8

Source§

impl Peripheral for PN9

Source§

type P = PN9

Source§

impl Peripheral for PN10

Source§

impl Peripheral for PN11

Source§

impl Peripheral for PN12

Source§

impl Peripheral for PN13

Source§

impl Peripheral for PN14

Source§

impl Peripheral for PN15

Source§

impl Peripheral for PO0

Source§

type P = PO0

Source§

impl Peripheral for PO1

Source§

type P = PO1

Source§

impl Peripheral for PO2

Source§

type P = PO2

Source§

impl Peripheral for PO3

Source§

type P = PO3

Source§

impl Peripheral for PO4

Source§

type P = PO4

Source§

impl Peripheral for PO5

Source§

type P = PO5

Source§

impl Peripheral for PO6

Source§

type P = PO6

Source§

impl Peripheral for PO7

Source§

type P = PO7

Source§

impl Peripheral for PO8

Source§

type P = PO8

Source§

impl Peripheral for PO9

Source§

type P = PO9

Source§

impl Peripheral for PO10

Source§

impl Peripheral for PO11

Source§

impl Peripheral for PO12

Source§

impl Peripheral for PO13

Source§

impl Peripheral for PO14

Source§

impl Peripheral for PO15

Source§

impl Peripheral for PP0

Source§

type P = PP0

Source§

impl Peripheral for PP1

Source§

type P = PP1

Source§

impl Peripheral for PP2

Source§

type P = PP2

Source§

impl Peripheral for PP3

Source§

type P = PP3

Source§

impl Peripheral for PP4

Source§

type P = PP4

Source§

impl Peripheral for PP5

Source§

type P = PP5

Source§

impl Peripheral for PP6

Source§

type P = PP6

Source§

impl Peripheral for PP7

Source§

type P = PP7

Source§

impl Peripheral for PP8

Source§

type P = PP8

Source§

impl Peripheral for PP9

Source§

type P = PP9

Source§

impl Peripheral for PP10

Source§

impl Peripheral for PP11

Source§

impl Peripheral for PP12

Source§

impl Peripheral for PP13

Source§

impl Peripheral for PP14

Source§

impl Peripheral for PP15

Source§

impl Peripheral for PSSI

Source§

impl Peripheral for PWR

Source§

type P = PWR

Source§

impl Peripheral for RCC

Source§

type P = RCC

Source§

impl Peripheral for RNG

Source§

type P = RNG

Source§

impl Peripheral for RTC

Source§

type P = RTC

Source§

impl Peripheral for SAI1

Source§

impl Peripheral for SAI2

Source§

impl Peripheral for SDMMC2

Source§

impl Peripheral for SPDIFRX1

Source§

impl Peripheral for SPI1

Source§

impl Peripheral for SPI2

Source§

impl Peripheral for SPI3

Source§

impl Peripheral for SPI4

Source§

impl Peripheral for SPI5

Source§

impl Peripheral for SPI6

Source§

impl Peripheral for SYSCFG

Source§

impl Peripheral for TIM1

Source§

impl Peripheral for TIM2

Source§

impl Peripheral for TIM3

Source§

impl Peripheral for TIM5

Source§

impl Peripheral for TIM6

Source§

impl Peripheral for TIM7

Source§

impl Peripheral for TIM12

Source§

impl Peripheral for TIM13

Source§

impl Peripheral for TIM14

Source§

impl Peripheral for TIM15

Source§

impl Peripheral for TIM16

Source§

impl Peripheral for TIM17

Source§

impl Peripheral for UART4

Source§

impl Peripheral for UART5

Source§

impl Peripheral for UART7

Source§

impl Peripheral for UID

Source§

type P = UID

Source§

impl Peripheral for USART1

Source§

impl Peripheral for USART2

Source§

impl Peripheral for USART3

Source§

impl Peripheral for USB_OTG_FS

Source§

impl Peripheral for VREFBUF

Source§

impl Peripheral for WWDG

Source§

impl<'b, T> Peripheral for PeripheralRef<'_, T>
where T: Peripheral,

Source§

type P = <T as Peripheral>::P

Source§

impl<'b, T> Peripheral for T
where T: DerefMut, <T as Deref>::Target: Peripheral,

Source§

type P = <<T as Deref>::Target as Peripheral>::P