stm32: Update gpio examples

This commit is contained in:
Thales Fragoso 2021-06-25 17:32:24 -03:00
parent a3f0aa02a4
commit 0eaadfc125
12 changed files with 37 additions and 39 deletions

View File

@ -34,11 +34,11 @@ impl From<Pull> for vals::Pupdr {
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Speed {
LowSpeed,
MediumSpeed,
Low,
Medium,
#[cfg(not(syscfg_f0))]
HighSpeed,
VeryHighSpeed,
High,
VeryHigh,
}
impl From<Speed> for vals::Ospeedr {
@ -46,11 +46,11 @@ impl From<Speed> for vals::Ospeedr {
use Speed::*;
match speed {
LowSpeed => vals::Ospeedr::LOWSPEED,
MediumSpeed => vals::Ospeedr::MEDIUMSPEED,
Low => vals::Ospeedr::LOWSPEED,
Medium => vals::Ospeedr::MEDIUMSPEED,
#[cfg(not(syscfg_f0))]
HighSpeed => vals::Ospeedr::HIGHSPEED,
VeryHighSpeed => vals::Ospeedr::VERYHIGHSPEED,
High => vals::Ospeedr::HIGHSPEED,
VeryHigh => vals::Ospeedr::VERYHIGHSPEED,
}
}
}
@ -246,7 +246,7 @@ impl<'d, T: Pin> OutputPin for OutputOpenDrain<'d, T> {
}
}
impl<'d, T: Pin> InputPin for Input<'d, T> {
impl<'d, T: Pin> InputPin for OutputOpenDrain<'d, T> {
type Error = Infallible;
fn is_high(&self) -> Result<bool, Self::Error> {

View File

@ -8,7 +8,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output};
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
@ -40,7 +40,7 @@ fn main() -> ! {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB7, Level::High);
let mut led = Output::new(p.PB7, Level::High, Speed::Low);
loop {
info!("high");

View File

@ -8,7 +8,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Input, Level, Output, Pull};
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
@ -41,9 +41,9 @@ fn main() -> ! {
let p = embassy_stm32::init(Default::default());
let button = Input::new(p.PC13, Pull::Down);
let mut led1 = Output::new(p.PB0, Level::High);
let _led2 = Output::new(p.PB7, Level::High);
let mut led3 = Output::new(p.PB14, Level::High);
let mut led1 = Output::new(p.PB0, Level::High, Speed::Low);
let _led2 = Output::new(p.PB7, Level::High, Speed::Low);
let mut led3 = Output::new(p.PB14, Level::High, Speed::Low);
loop {
if button.is_high().unwrap() {

View File

@ -9,7 +9,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output};
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
@ -58,7 +58,7 @@ fn main() -> ! {
Config::default(),
);
let mut cs = Output::new(p.PE0, Level::High);
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
loop {
let mut buf = [0x0A; 4];

View File

@ -8,15 +8,15 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output};
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
use cortex_m_rt::entry;
use stm32h7::stm32h743 as pac;
use stm32h7xx_hal as hal;
use hal::prelude::*;
use stm32h7xx_hal as hal;
#[entry]
fn main() -> ! {
@ -24,8 +24,7 @@ fn main() -> ! {
let pp = pac::Peripherals::take().unwrap();
let pwrcfg = pp.PWR.constrain()
.freeze();
let pwrcfg = pp.PWR.constrain().freeze();
let rcc = pp.RCC.constrain();
@ -60,7 +59,7 @@ fn main() -> ! {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB14, Level::High);
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
loop {
info!("high");
@ -71,5 +70,4 @@ fn main() -> ! {
led.set_low().unwrap();
cortex_m::asm::delay(10_000_000);
}
}

View File

@ -9,7 +9,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::{
gpio::{Level, Output},
gpio::{Level, Output, Speed},
rcc::*,
};
use embedded_hal::digital::v2::OutputPin;
@ -25,7 +25,7 @@ fn main() -> ! {
Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true);
let mut led = Output::new(p.PB5, Level::High);
let mut led = Output::new(p.PB5, Level::High, Speed::Low);
loop {
info!("high");

View File

@ -9,7 +9,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::{
gpio::{Input, Level, Output, Pull},
gpio::{Input, Level, Output, Pull, Speed},
rcc::*,
};
use embedded_hal::digital::v2::{InputPin, OutputPin};
@ -25,8 +25,8 @@ fn main() -> ! {
Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true);
let button = Input::new(p.PB2, Pull::Up);
let mut led1 = Output::new(p.PA5, Level::High);
let mut led2 = Output::new(p.PB5, Level::High);
let mut led1 = Output::new(p.PA5, Level::High, Speed::Low);
let mut led2 = Output::new(p.PB5, Level::High, Speed::Low);
loop {
if button.is_high().unwrap() {

View File

@ -9,7 +9,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output};
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
@ -36,7 +36,7 @@ fn main() -> ! {
Config::default(),
);
let mut cs = Output::new(p.PA15, Level::High);
let mut cs = Output::new(p.PA15, Level::High, Speed::VeryHigh);
loop {
let mut buf = [0x0A; 4];

View File

@ -8,7 +8,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output};
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
@ -39,7 +39,7 @@ fn main() -> ! {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB14, Level::High);
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
loop {
info!("high");

View File

@ -8,7 +8,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Input, Level, Output, Pull};
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
@ -40,8 +40,8 @@ fn main() -> ! {
let p = embassy_stm32::init(Default::default());
let button = Input::new(p.PC13, Pull::Up);
let mut led1 = Output::new(p.PA5, Level::High);
let mut led2 = Output::new(p.PB14, Level::High);
let mut led1 = Output::new(p.PA5, Level::High, Speed::Low);
let mut led2 = Output::new(p.PB14, Level::High, Speed::Low);
loop {
if button.is_high().unwrap() {

View File

@ -9,7 +9,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output};
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
@ -52,7 +52,7 @@ fn main() -> ! {
Config::default(),
);
let mut cs = Output::new(p.PE0, Level::High);
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
loop {
let mut buf = [0x0A; 4];

View File

@ -8,7 +8,7 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output};
use embassy_stm32::gpio::{Level, Output, Speed};
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
@ -28,7 +28,7 @@ fn main() -> ! {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB0, Level::High);
let mut led = Output::new(p.PB0, Level::High, Speed::Low);
loop {
info!("high");