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>
impl<const P: u8, const N: u8, MODE> Pin<P, N, MODE>
Sourcepub const fn new() -> Self
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());
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
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>
impl<const P: u8, const N: u8, MODE> Pin<P, N, MODE>
Sourcepub fn into_output(self) -> Pin<P, N, Output>where
Pin<P, N>: OutputPermitted,
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}pub fn into_floating_input(self) -> Pin<P, N, Floating>
pub fn into_pull_up_input(self) -> Pin<P, N, PullUp>
Sourcepub fn into_pull_down_input(self) -> Pin<P, N, PullDown>
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}Sourcepub fn into_serial_port(self) -> Pin<P, N, Func2Mode>where
Pin<P, N>: SerialPermitted,
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());
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}Trait Implementations§
Source§impl<const P: u8, const N: u8, MODE> ErrorType for Pin<P, N, MODE>
impl<const P: u8, const N: u8, MODE> ErrorType for Pin<P, N, MODE>
Source§type Error = Infallible
type Error = Infallible
Error type
impl OutputPermitted for Pin<0, 0>
impl OutputPermitted for Pin<0, 1>
impl OutputPermitted for Pin<0, 2>
impl OutputPermitted for Pin<0, 3>
impl OutputPermitted for Pin<0, 4>
impl OutputPermitted for Pin<0, 5>
impl OutputPermitted for Pin<0, 6>
impl OutputPermitted for Pin<0, 7>
impl OutputPermitted for Pin<0, 8>
impl OutputPermitted for Pin<0, 9>
impl OutputPermitted for Pin<0, 10>
impl OutputPermitted for Pin<0, 11>
impl OutputPermitted for Pin<0, 12>
impl OutputPermitted for Pin<0, 13>
impl OutputPermitted for Pin<0, 14>
impl OutputPermitted for Pin<0, 15>
impl OutputPermitted for Pin<1, 0>
impl OutputPermitted for Pin<1, 1>
impl OutputPermitted for Pin<1, 2>
impl OutputPermitted for Pin<1, 3>
impl OutputPermitted for Pin<1, 4>
impl OutputPermitted for Pin<1, 5>
impl OutputPermitted for Pin<1, 6>
impl OutputPermitted for Pin<1, 7>
impl OutputPermitted for Pin<1, 8>
impl OutputPermitted for Pin<1, 9>
impl OutputPermitted for Pin<1, 10>
impl OutputPermitted for Pin<1, 11>
impl OutputPermitted for Pin<1, 12>
impl OutputPermitted for Pin<1, 13>
impl OutputPermitted for Pin<1, 14>
impl OutputPermitted for Pin<1, 15>
impl OutputPermitted for Pin<2, 0>
impl OutputPermitted for Pin<2, 1>
impl OutputPermitted for Pin<2, 2>
impl OutputPermitted for Pin<2, 3>
impl OutputPermitted for Pin<2, 4>
impl OutputPermitted for Pin<2, 5>
impl OutputPermitted for Pin<2, 6>
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.
impl<const P: u8, const N: u8> OutputPin for Pin<P, N, Output>
Single digital push-pull output pin.
impl RxPin<Usart0> for Pin<0, 5, Func2Mode>
impl RxPin<Usart1> for Pin<1, 8, Func2Mode>
impl SerialPermitted for Pin<0, 5>
impl SerialPermitted for Pin<0, 6>
impl SerialPermitted for Pin<0, 7>
impl SerialPermitted for Pin<0, 8>
impl SerialPermitted for Pin<1, 8>
impl SerialPermitted for Pin<1, 9>
impl TxPin<Usart0> for Pin<0, 6, Func2Mode>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more