Skip to main content

Pin

Struct Pin 

Source
pub struct Pin<const P: u8, const N: u8, MODE = Floating> { /* private fields */ }

Implementations§

Source§

impl<const P: u8, const N: u8, MODE> Pin<P, N, MODE>

Source

pub const fn new() -> Self

Examples found in repository?
examples/serial.rs (line 26)
15pub extern "C" fn main() -> ! {
16    let peripherals = Peripherals::take().unwrap();
17
18    let rcc_config = RCC::default();
19    RCC::init(&rcc_config);
20
21    peripherals
22        .pm
23        .clk_apb_m_set()
24        .modify(|_, w| w.pad_config().enable().pm().enable());
25
26    let rx = Pin08::new().into_serial_port();
27    let tx = Pin09::new().into_serial_port();
28
29    let serial = Serial::new(peripherals.usart_1, (tx, rx), Config::default()).unwrap();
30    let (mut tx, _rx) = serial.split();
31
32    loop {
33        let _ = writeln!(tx, "Hello from MIK32 USART1");
34        delay(MESSAGE_DELAY_SPINS);
35    }
36}
More examples
Hide additional examples
examples/gpio.rs (line 24)
14pub extern "C" fn main() -> ! {
15    let p = Peripherals::take().unwrap();
16
17    let rcc_config = RCC::default();
18    RCC::init(&rcc_config);
19
20    p.pm.clk_apb_p_set().modify(|_, w| w.gpio_0().enable());
21    p.pm.clk_apb_m_set()
22        .modify(|_, w| w.pad_config().enable().pm().enable());
23
24    let mut led_pin = Pin09::new().into_output();
25    let mut button_pin = Pin10::new().into_pull_down_input();
26
27    loop {
28        if button_pin.is_high().unwrap() {
29            let _ = led_pin.set_high();
30        } else {
31            let _ = led_pin.set_low();
32        }
33
34        for _ in 0..1000 {
35            core::hint::spin_loop();
36        }
37    }
38}
Source§

impl<const P: u8, const N: u8, MODE> Pin<P, N, MODE>

Source

pub fn into_output(self) -> Pin<P, N, Output>
where Pin<P, N>: OutputPermitted,

Examples found in repository?
examples/gpio.rs (line 24)
14pub extern "C" fn main() -> ! {
15    let p = Peripherals::take().unwrap();
16
17    let rcc_config = RCC::default();
18    RCC::init(&rcc_config);
19
20    p.pm.clk_apb_p_set().modify(|_, w| w.gpio_0().enable());
21    p.pm.clk_apb_m_set()
22        .modify(|_, w| w.pad_config().enable().pm().enable());
23
24    let mut led_pin = Pin09::new().into_output();
25    let mut button_pin = Pin10::new().into_pull_down_input();
26
27    loop {
28        if button_pin.is_high().unwrap() {
29            let _ = led_pin.set_high();
30        } else {
31            let _ = led_pin.set_low();
32        }
33
34        for _ in 0..1000 {
35            core::hint::spin_loop();
36        }
37    }
38}
Source

pub fn into_floating_input(self) -> Pin<P, N, Floating>

Source

pub fn into_pull_up_input(self) -> Pin<P, N, PullUp>

Source

pub fn into_pull_down_input(self) -> Pin<P, N, PullDown>

Examples found in repository?
examples/gpio.rs (line 25)
14pub extern "C" fn main() -> ! {
15    let p = Peripherals::take().unwrap();
16
17    let rcc_config = RCC::default();
18    RCC::init(&rcc_config);
19
20    p.pm.clk_apb_p_set().modify(|_, w| w.gpio_0().enable());
21    p.pm.clk_apb_m_set()
22        .modify(|_, w| w.pad_config().enable().pm().enable());
23
24    let mut led_pin = Pin09::new().into_output();
25    let mut button_pin = Pin10::new().into_pull_down_input();
26
27    loop {
28        if button_pin.is_high().unwrap() {
29            let _ = led_pin.set_high();
30        } else {
31            let _ = led_pin.set_low();
32        }
33
34        for _ in 0..1000 {
35            core::hint::spin_loop();
36        }
37    }
38}
Source

pub fn into_serial_port(self) -> Pin<P, N, Func2Mode>
where Pin<P, N>: SerialPermitted,

Examples found in repository?
examples/serial.rs (line 26)
15pub extern "C" fn main() -> ! {
16    let peripherals = Peripherals::take().unwrap();
17
18    let rcc_config = RCC::default();
19    RCC::init(&rcc_config);
20
21    peripherals
22        .pm
23        .clk_apb_m_set()
24        .modify(|_, w| w.pad_config().enable().pm().enable());
25
26    let rx = Pin08::new().into_serial_port();
27    let tx = Pin09::new().into_serial_port();
28
29    let serial = Serial::new(peripherals.usart_1, (tx, rx), Config::default()).unwrap();
30    let (mut tx, _rx) = serial.split();
31
32    loop {
33        let _ = writeln!(tx, "Hello from MIK32 USART1");
34        delay(MESSAGE_DELAY_SPINS);
35    }
36}
Source

pub fn into_timer_serial_port(self) -> Pin<P, N, Func3Mode>

Trait Implementations§

Source§

impl ClockPin<Usart0> for Pin<1, 5, Func3Mode>

Source§

impl ClockPin<Usart1> for Pin<2, 6, Func3Mode>

Source§

impl CtsPin<Usart0> for Pin<0, 7, Func2Mode>

Source§

impl CtsPin<Usart1> for Pin<1, 10, Func2Mode>

Source§

impl DcdPin<Usart0> for Pin<1, 13, Func3Mode>

Source§

impl DcdPin<Usart1> for Pin<2, 1, Func3Mode>

Source§

impl DdisPin<Usart0> for Pin<1, 6, Func3Mode>

Source§

impl DdisPin<Usart1> for Pin<2, 7, Func3Mode>

Source§

impl DsrPin<Usart0> for Pin<1, 14, Func3Mode>

Source§

impl DsrPin<Usart1> for Pin<2, 2, Func3Mode>

Source§

impl DtrPin<Usart0> for Pin<1, 12, Func3Mode>

Source§

impl DtrPin<Usart1> for Pin<2, 0, Func3Mode>

Source§

impl<const P: u8, const N: u8, MODE> ErrorType for Pin<P, N, MODE>

Source§

type Error = Infallible

Error type
Source§

impl HalfDuplexPin<Usart0> for Pin<0, 6, Func2Mode>

Source§

impl HalfDuplexPin<Usart1> for Pin<1, 9, Func2Mode>

Source§

impl<const P: u8, const N: u8, MODE> InputPin for Pin<P, N, MODE>
where MODE: InputMode,

Source§

fn is_high(&mut self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&mut self) -> Result<bool, Self::Error>

Is the input pin low?
Source§

impl OutputPermitted for Pin<0, 0>

Source§

impl OutputPermitted for Pin<0, 1>

Source§

impl OutputPermitted for Pin<0, 2>

Source§

impl OutputPermitted for Pin<0, 3>

Source§

impl OutputPermitted for Pin<0, 4>

Source§

impl OutputPermitted for Pin<0, 5>

Source§

impl OutputPermitted for Pin<0, 6>

Source§

impl OutputPermitted for Pin<0, 7>

Source§

impl OutputPermitted for Pin<0, 8>

Source§

impl OutputPermitted for Pin<0, 9>

Source§

impl OutputPermitted for Pin<0, 10>

Source§

impl OutputPermitted for Pin<0, 11>

Source§

impl OutputPermitted for Pin<0, 12>

Source§

impl OutputPermitted for Pin<0, 13>

Source§

impl OutputPermitted for Pin<0, 14>

Source§

impl OutputPermitted for Pin<0, 15>

Source§

impl OutputPermitted for Pin<1, 0>

Source§

impl OutputPermitted for Pin<1, 1>

Source§

impl OutputPermitted for Pin<1, 2>

Source§

impl OutputPermitted for Pin<1, 3>

Source§

impl OutputPermitted for Pin<1, 4>

Source§

impl OutputPermitted for Pin<1, 5>

Source§

impl OutputPermitted for Pin<1, 6>

Source§

impl OutputPermitted for Pin<1, 7>

Source§

impl OutputPermitted for Pin<1, 8>

Source§

impl OutputPermitted for Pin<1, 9>

Source§

impl OutputPermitted for Pin<1, 10>

Source§

impl OutputPermitted for Pin<1, 11>

Source§

impl OutputPermitted for Pin<1, 12>

Source§

impl OutputPermitted for Pin<1, 13>

Source§

impl OutputPermitted for Pin<1, 14>

Source§

impl OutputPermitted for Pin<1, 15>

Source§

impl OutputPermitted for Pin<2, 0>

Source§

impl OutputPermitted for Pin<2, 1>

Source§

impl OutputPermitted for Pin<2, 2>

Source§

impl OutputPermitted for Pin<2, 3>

Source§

impl OutputPermitted for Pin<2, 4>

Source§

impl OutputPermitted for Pin<2, 5>

Source§

impl OutputPermitted for Pin<2, 6>

Source§

impl OutputPermitted for Pin<2, 7>

Source§

impl<const P: u8, const N: u8> OutputPin for Pin<P, N, Output>

Single digital push-pull output pin.

Source§

fn set_high(&mut self) -> Result<(), Self::Error>

Drives the pin high.

Source§

fn set_low(&mut self) -> Result<(), Self::Error>

Drives the pin low.

Source§

fn set_state(&mut self, state: PinState) -> Result<(), Self::Error>

Drives the pin high or low depending on the provided value. Read more
Source§

impl RiPin<Usart0> for Pin<1, 15, Func3Mode>

Source§

impl RiPin<Usart1> for Pin<2, 3, Func3Mode>

Source§

impl RtsPin<Usart0> for Pin<0, 8, Func2Mode>

Source§

impl RtsPin<Usart1> for Pin<1, 11, Func2Mode>

Source§

impl RxPin<Usart0> for Pin<0, 5, Func2Mode>

Source§

impl RxPin<Usart1> for Pin<1, 8, Func2Mode>

Source§

impl SerialPermitted for Pin<0, 5>

Source§

impl SerialPermitted for Pin<0, 6>

Source§

impl SerialPermitted for Pin<0, 7>

Source§

impl SerialPermitted for Pin<0, 8>

Source§

impl SerialPermitted for Pin<1, 8>

Source§

impl SerialPermitted for Pin<1, 9>

Source§

impl SerialPermitted for Pin<1, 10>

Source§

impl SerialPermitted for Pin<1, 11>

Source§

impl TimerSerialPermitted for Pin<1, 5>

Source§

impl TimerSerialPermitted for Pin<1, 6>

Source§

impl TimerSerialPermitted for Pin<1, 12>

Source§

impl TimerSerialPermitted for Pin<1, 13>

Source§

impl TimerSerialPermitted for Pin<1, 14>

Source§

impl TimerSerialPermitted for Pin<1, 15>

Source§

impl TimerSerialPermitted for Pin<2, 0>

Source§

impl TimerSerialPermitted for Pin<2, 1>

Source§

impl TimerSerialPermitted for Pin<2, 2>

Source§

impl TimerSerialPermitted for Pin<2, 3>

Source§

impl TimerSerialPermitted for Pin<2, 6>

Source§

impl TimerSerialPermitted for Pin<2, 7>

Source§

impl TxPin<Usart0> for Pin<0, 6, Func2Mode>

Source§

impl TxPin<Usart1> for Pin<1, 9, Func2Mode>

Auto Trait Implementations§

§

impl<const P: u8, const N: u8, MODE> Freeze for Pin<P, N, MODE>

§

impl<const P: u8, const N: u8, MODE> RefUnwindSafe for Pin<P, N, MODE>
where MODE: RefUnwindSafe,

§

impl<const P: u8, const N: u8, MODE> Send for Pin<P, N, MODE>
where MODE: Send,

§

impl<const P: u8, const N: u8, MODE> Sync for Pin<P, N, MODE>
where MODE: Sync,

§

impl<const P: u8, const N: u8, MODE> Unpin for Pin<P, N, MODE>
where MODE: Unpin,

§

impl<const P: u8, const N: u8, MODE> UnsafeUnpin for Pin<P, N, MODE>

§

impl<const P: u8, const N: u8, MODE> UnwindSafe for Pin<P, N, MODE>
where MODE: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.