embassy_stm32_plus/traits/gpio/
mod.rs1#[cfg(feature = "exti")]
2use embassy_stm32::exti::ExtiInput;
3use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed};
4#[cfg(feature = "exti")]
5use embassy_stm32::Peripheral;
6
7pub trait GpioTrait: Pin {
9 #[inline]
12 fn input(self) -> Input<'static> {
13 self.input_with_pull(Pull::Up)
14 }
15
16 #[inline]
18 fn input_with_pull(self, pull: Pull) -> Input<'static> {
19 Input::new(self, pull)
20 }
21
22 #[inline]
25 fn output(self) -> Output<'static> {
26 self.output_with_level_speed(Level::High, Speed::Low)
27 }
28
29 #[inline]
31 fn output_with_level_speed(self, level: Level, speed: Speed) -> Output<'static> {
32 Output::new(self, level, speed)
33 }
34
35 #[cfg(feature = "exti")]
38 #[inline]
39 fn exti_input(self, exti: impl Peripheral<P=Self::ExtiChannel> + 'static) -> ExtiInput<'static> {
40 self.exti_input_with_pull(exti, Pull::Up)
41 }
42
43 #[cfg(feature = "exti")]
45 #[inline]
46 fn exti_input_with_pull(self, exti: impl Peripheral<P=Self::ExtiChannel> + 'static, pull: Pull) -> ExtiInput<'static> {
47 ExtiInput::new(self, exti, pull)
48 }
49}
50
51impl<T: Pin> GpioTrait for T {}