stm32/gpio: expose all functionality as inherent methods.
This commit is contained in:
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
@ -18,9 +17,9 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
|
||||
|
||||
loop {
|
||||
unwrap!(led.set_high());
|
||||
led.set_high();
|
||||
Timer::after(Duration::from_millis(300)).await;
|
||||
unwrap!(led.set_low());
|
||||
led.set_low();
|
||||
Timer::after(Duration::from_millis(300)).await;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embedded_hal::digital::v2::InputPin;
|
||||
use example_common::*;
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
@ -17,7 +16,7 @@ fn main() -> ! {
|
||||
let button = Input::new(p.PC13, Pull::Up);
|
||||
|
||||
loop {
|
||||
if unwrap!(button.is_high()) {
|
||||
if button.is_high() {
|
||||
info!("high");
|
||||
} else {
|
||||
info!("low");
|
||||
|
@ -10,7 +10,6 @@ use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embedded_hal::blocking::spi::Transfer;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use example_common::*;
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
@ -34,9 +33,9 @@ fn main() -> ! {
|
||||
|
||||
loop {
|
||||
let mut buf = [0x0Au8; 4];
|
||||
unwrap!(cs.set_low());
|
||||
cs.set_low();
|
||||
unwrap!(spi.transfer(&mut buf));
|
||||
unwrap!(cs.set_high());
|
||||
cs.set_high();
|
||||
info!("xfer {=[u8]:x}", buf);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::{adapter::BlockingAsync, spi::FullDuplex};
|
||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
@ -41,17 +40,17 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
let ready = Input::new(p.PE1, Pull::Up);
|
||||
|
||||
cortex_m::asm::delay(100_000);
|
||||
unwrap!(reset.set_high());
|
||||
reset.set_high();
|
||||
cortex_m::asm::delay(100_000);
|
||||
|
||||
while unwrap!(ready.is_low()) {
|
||||
while ready.is_low() {
|
||||
info!("waiting for ready");
|
||||
}
|
||||
|
||||
let write = [0x0A; 10];
|
||||
let mut read = [0; 10];
|
||||
unwrap!(cs.set_low());
|
||||
cs.set_low();
|
||||
spi.read_write(&mut read, &write).await.ok();
|
||||
unwrap!(cs.set_high());
|
||||
cs.set_high();
|
||||
info!("xfer {=[u8]:x}", read);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::spi::FullDuplex;
|
||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
@ -38,17 +37,17 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
let ready = Input::new(p.PE1, Pull::Up);
|
||||
|
||||
cortex_m::asm::delay(100_000);
|
||||
unwrap!(reset.set_high());
|
||||
reset.set_high();
|
||||
cortex_m::asm::delay(100_000);
|
||||
|
||||
while unwrap!(ready.is_low()) {
|
||||
while ready.is_low() {
|
||||
info!("waiting for ready");
|
||||
}
|
||||
|
||||
let write = [0x0A; 10];
|
||||
let mut read = [0; 10];
|
||||
unwrap!(cs.set_low());
|
||||
cs.set_low();
|
||||
spi.read_write(&mut read, &write).await.ok();
|
||||
unwrap!(cs.set_high());
|
||||
cs.set_high();
|
||||
info!("xfer {=[u8]:x}", read);
|
||||
}
|
||||
|
Reference in New Issue
Block a user