stm32/gpio: remove generics.
This commit is contained in:
parent
9f76dbb93b
commit
3387ee7238
29 changed files with 144 additions and 215 deletions
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner) {
|
async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh);
|
let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh);
|
||||||
let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
button.wait_for_any_edge().await;
|
button.wait_for_any_edge().await;
|
||||||
|
|
|
@ -6,13 +6,12 @@ use core::cell::RefCell;
|
||||||
use cortex_m::interrupt::Mutex;
|
use cortex_m::interrupt::Mutex;
|
||||||
use cortex_m::peripheral::NVIC;
|
use cortex_m::peripheral::NVIC;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::peripherals::{PB14, PC13};
|
|
||||||
use embassy_stm32::{interrupt, pac};
|
use embassy_stm32::{interrupt, pac};
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
static BUTTON: Mutex<RefCell<Option<Input<'static, PC13>>>> = Mutex::new(RefCell::new(None));
|
static BUTTON: Mutex<RefCell<Option<Input<'static>>>> = Mutex::new(RefCell::new(None));
|
||||||
static LED: Mutex<RefCell<Option<Output<'static, PB14>>>> = Mutex::new(RefCell::new(None));
|
static LED: Mutex<RefCell<Option<Output<'static>>>> = Mutex::new(RefCell::new(None));
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
|
@ -62,14 +61,14 @@ fn EXTI15_10() {
|
||||||
|
|
||||||
const PORT: u8 = 2;
|
const PORT: u8 = 2;
|
||||||
const PIN: usize = 13;
|
const PIN: usize = 13;
|
||||||
fn check_interrupt<P: Pin>(_pin: &mut Input<'static, P>) -> bool {
|
fn check_interrupt(_pin: &mut Input<'static>) -> bool {
|
||||||
let exti = pac::EXTI;
|
let exti = pac::EXTI;
|
||||||
let pin = PIN;
|
let pin = PIN;
|
||||||
let lines = exti.pr(0).read();
|
let lines = exti.pr(0).read();
|
||||||
lines.line(pin)
|
lines.line(pin)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) {
|
fn clear_interrupt(_pin: &mut Input<'static>) {
|
||||||
let exti = pac::EXTI;
|
let exti = pac::EXTI;
|
||||||
let pin = PIN;
|
let pin = PIN;
|
||||||
let mut lines = exti.pr(0).read();
|
let mut lines = exti.pr(0).read();
|
||||||
|
@ -77,7 +76,7 @@ fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) {
|
||||||
exti.pr(0).write_value(lines);
|
exti.pr(0).write_value(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enable_interrupt<P: Pin>(_pin: &mut Input<'static, P>) {
|
fn enable_interrupt(_pin: &mut Input<'static>) {
|
||||||
cortex_m::interrupt::free(|_| {
|
cortex_m::interrupt::free(|_| {
|
||||||
let rcc = pac::RCC;
|
let rcc = pac::RCC;
|
||||||
rcc.apb2enr().modify(|w| w.set_syscfgen(true));
|
rcc.apb2enr().modify(|w| w.set_syscfgen(true));
|
||||||
|
|
|
@ -5,10 +5,10 @@ use core::marker::PhantomData;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use core::task::{Context, Poll};
|
use core::task::{Context, Poll};
|
||||||
|
|
||||||
use embassy_hal_internal::impl_peripheral;
|
use embassy_hal_internal::{impl_peripheral, into_ref};
|
||||||
use embassy_sync::waitqueue::AtomicWaker;
|
use embassy_sync::waitqueue::AtomicWaker;
|
||||||
|
|
||||||
use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin};
|
use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, Pull};
|
||||||
use crate::pac::exti::regs::Lines;
|
use crate::pac::exti::regs::Lines;
|
||||||
use crate::pac::EXTI;
|
use crate::pac::EXTI;
|
||||||
use crate::{interrupt, pac, peripherals, Peripheral};
|
use crate::{interrupt, pac, peripherals, Peripheral};
|
||||||
|
@ -93,16 +93,27 @@ impl Iterator for BitIter {
|
||||||
/// EXTI channel, which is a limited resource.
|
/// EXTI channel, which is a limited resource.
|
||||||
///
|
///
|
||||||
/// Pins PA5, PB5, PC5... all use EXTI channel 5, so you can't use EXTI on, say, PA5 and PC5 at the same time.
|
/// Pins PA5, PB5, PC5... all use EXTI channel 5, so you can't use EXTI on, say, PA5 and PC5 at the same time.
|
||||||
pub struct ExtiInput<'d, T: GpioPin> {
|
pub struct ExtiInput<'d> {
|
||||||
pin: Input<'d, T>,
|
pin: Input<'d>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> Unpin for ExtiInput<'d, T> {}
|
impl<'d> Unpin for ExtiInput<'d> {}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> ExtiInput<'d, T> {
|
impl<'d> ExtiInput<'d> {
|
||||||
/// Create an EXTI input.
|
/// Create an EXTI input.
|
||||||
pub fn new(pin: Input<'d, T>, _ch: impl Peripheral<P = T::ExtiChannel> + 'd) -> Self {
|
pub fn new<T: GpioPin>(
|
||||||
Self { pin }
|
pin: impl Peripheral<P = T> + 'd,
|
||||||
|
ch: impl Peripheral<P = T::ExtiChannel> + 'd,
|
||||||
|
pull: Pull,
|
||||||
|
) -> Self {
|
||||||
|
into_ref!(pin, ch);
|
||||||
|
|
||||||
|
// Needed if using AnyPin+AnyChannel.
|
||||||
|
assert_eq!(pin.pin(), ch.number());
|
||||||
|
|
||||||
|
Self {
|
||||||
|
pin: Input::new(pin, pull),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin is high.
|
/// Get whether the pin is high.
|
||||||
|
@ -162,7 +173,7 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
|
@ -174,11 +185,11 @@ impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> {
|
impl<'d> embedded_hal_1::digital::ErrorType for ExtiInput<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> {
|
impl<'d> embedded_hal_1::digital::InputPin for ExtiInput<'d> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok((*self).is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
@ -188,7 +199,7 @@ impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> {
|
impl<'d> embedded_hal_async::digital::Wait for ExtiInput<'d> {
|
||||||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
||||||
self.wait_for_high().await;
|
self.wait_for_high().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -326,7 +337,7 @@ pub(crate) mod sealed {
|
||||||
/// EXTI channel trait.
|
/// EXTI channel trait.
|
||||||
pub trait Channel: sealed::Channel + Sized {
|
pub trait Channel: sealed::Channel + Sized {
|
||||||
/// Get the EXTI channel number.
|
/// Get the EXTI channel number.
|
||||||
fn number(&self) -> usize;
|
fn number(&self) -> u8;
|
||||||
|
|
||||||
/// Type-erase (degrade) this channel into an `AnyChannel`.
|
/// Type-erase (degrade) this channel into an `AnyChannel`.
|
||||||
///
|
///
|
||||||
|
@ -350,8 +361,8 @@ pub struct AnyChannel {
|
||||||
impl_peripheral!(AnyChannel);
|
impl_peripheral!(AnyChannel);
|
||||||
impl sealed::Channel for AnyChannel {}
|
impl sealed::Channel for AnyChannel {}
|
||||||
impl Channel for AnyChannel {
|
impl Channel for AnyChannel {
|
||||||
fn number(&self) -> usize {
|
fn number(&self) -> u8 {
|
||||||
self.number as usize
|
self.number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,8 +370,8 @@ macro_rules! impl_exti {
|
||||||
($type:ident, $number:expr) => {
|
($type:ident, $number:expr) => {
|
||||||
impl sealed::Channel for peripherals::$type {}
|
impl sealed::Channel for peripherals::$type {}
|
||||||
impl Channel for peripherals::$type {
|
impl Channel for peripherals::$type {
|
||||||
fn number(&self) -> usize {
|
fn number(&self) -> u8 {
|
||||||
$number as usize
|
$number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@ use core::convert::Infallible;
|
||||||
use critical_section::CriticalSection;
|
use critical_section::CriticalSection;
|
||||||
use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef};
|
use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef};
|
||||||
|
|
||||||
|
use self::sealed::Pin as _;
|
||||||
use crate::pac::gpio::{self, vals};
|
use crate::pac::gpio::{self, vals};
|
||||||
use crate::{pac, peripherals, Peripheral};
|
use crate::{pac, peripherals, Peripheral};
|
||||||
|
|
||||||
|
@ -14,41 +15,21 @@ use crate::{pac, peripherals, Peripheral};
|
||||||
/// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain
|
/// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain
|
||||||
/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
|
/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
|
||||||
/// mode.
|
/// mode.
|
||||||
pub struct Flex<'d, T: Pin> {
|
pub struct Flex<'d> {
|
||||||
pub(crate) pin: PeripheralRef<'d, T>,
|
pub(crate) pin: PeripheralRef<'d, AnyPin>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> Flex<'d, T> {
|
impl<'d> Flex<'d> {
|
||||||
/// Wrap the pin in a `Flex`.
|
/// Wrap the pin in a `Flex`.
|
||||||
///
|
///
|
||||||
/// The pin remains disconnected. The initial output level is unspecified, but can be changed
|
/// The pin remains disconnected. The initial output level is unspecified, but can be changed
|
||||||
/// before the pin is put into output mode.
|
/// before the pin is put into output mode.
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self {
|
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self {
|
||||||
into_ref!(pin);
|
into_ref!(pin);
|
||||||
// Pin will be in disconnected state.
|
// Pin will be in disconnected state.
|
||||||
Self { pin }
|
Self { pin: pin.map_into() }
|
||||||
}
|
|
||||||
|
|
||||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
|
||||||
///
|
|
||||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
|
||||||
/// are all different types, into the same type. It is useful for
|
|
||||||
/// creating arrays of pins, or avoiding generics.
|
|
||||||
#[inline]
|
|
||||||
pub fn degrade(self) -> Flex<'d, AnyPin> {
|
|
||||||
// Safety: We are about to drop the other copy of this pin, so
|
|
||||||
// this clone is safe.
|
|
||||||
let pin = unsafe { self.pin.clone_unchecked() };
|
|
||||||
|
|
||||||
// We don't want to run the destructor here, because that would
|
|
||||||
// deconfigure the pin.
|
|
||||||
core::mem::forget(self);
|
|
||||||
|
|
||||||
Flex {
|
|
||||||
pin: pin.map_into::<AnyPin>(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Put the pin into input mode.
|
/// Put the pin into input mode.
|
||||||
|
@ -218,7 +199,7 @@ impl<'d, T: Pin> Flex<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> Drop for Flex<'d, T> {
|
impl<'d> Drop for Flex<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
critical_section::with(|_| {
|
critical_section::with(|_| {
|
||||||
|
@ -309,31 +290,19 @@ impl From<Speed> for vals::Ospeedr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GPIO input driver.
|
/// GPIO input driver.
|
||||||
pub struct Input<'d, T: Pin> {
|
pub struct Input<'d> {
|
||||||
pub(crate) pin: Flex<'d, T>,
|
pub(crate) pin: Flex<'d>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> Input<'d, T> {
|
impl<'d> Input<'d> {
|
||||||
/// Create GPIO input driver for a [Pin] with the provided [Pull] configuration.
|
/// Create GPIO input driver for a [Pin] with the provided [Pull] configuration.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self {
|
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self {
|
||||||
let mut pin = Flex::new(pin);
|
let mut pin = Flex::new(pin);
|
||||||
pin.set_as_input(pull);
|
pin.set_as_input(pull);
|
||||||
Self { pin }
|
Self { pin }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
|
||||||
///
|
|
||||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
|
||||||
/// are all different types, into the same type. It is useful for
|
|
||||||
/// creating arrays of pins, or avoiding generics.
|
|
||||||
#[inline]
|
|
||||||
pub fn degrade(self) -> Input<'d, AnyPin> {
|
|
||||||
Input {
|
|
||||||
pin: self.pin.degrade(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
|
@ -386,14 +355,14 @@ impl From<Level> for bool {
|
||||||
/// Note that pins will **return to their floating state** when `Output` is dropped.
|
/// Note that pins will **return to their floating state** when `Output` is dropped.
|
||||||
/// If pins should retain their state indefinitely, either keep ownership of the
|
/// If pins should retain their state indefinitely, either keep ownership of the
|
||||||
/// `Output`, or pass it to [`core::mem::forget`].
|
/// `Output`, or pass it to [`core::mem::forget`].
|
||||||
pub struct Output<'d, T: Pin> {
|
pub struct Output<'d> {
|
||||||
pub(crate) pin: Flex<'d, T>,
|
pub(crate) pin: Flex<'d>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> Output<'d, T> {
|
impl<'d> Output<'d> {
|
||||||
/// Create GPIO output driver for a [Pin] with the provided [Level] and [Speed] configuration.
|
/// Create GPIO output driver for a [Pin] with the provided [Level] and [Speed] configuration.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, speed: Speed) -> Self {
|
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, speed: Speed) -> Self {
|
||||||
let mut pin = Flex::new(pin);
|
let mut pin = Flex::new(pin);
|
||||||
match initial_output {
|
match initial_output {
|
||||||
Level::High => pin.set_high(),
|
Level::High => pin.set_high(),
|
||||||
|
@ -403,18 +372,6 @@ impl<'d, T: Pin> Output<'d, T> {
|
||||||
Self { pin }
|
Self { pin }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
|
||||||
///
|
|
||||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
|
||||||
/// are all different types, into the same type. It is useful for
|
|
||||||
/// creating arrays of pins, or avoiding generics.
|
|
||||||
#[inline]
|
|
||||||
pub fn degrade(self) -> Output<'d, AnyPin> {
|
|
||||||
Output {
|
|
||||||
pin: self.pin.degrade(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the output as high.
|
/// Set the output as high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_high(&mut self) {
|
pub fn set_high(&mut self) {
|
||||||
|
@ -463,14 +420,14 @@ impl<'d, T: Pin> Output<'d, T> {
|
||||||
/// Note that pins will **return to their floating state** when `OutputOpenDrain` is dropped.
|
/// Note that pins will **return to their floating state** when `OutputOpenDrain` is dropped.
|
||||||
/// If pins should retain their state indefinitely, either keep ownership of the
|
/// If pins should retain their state indefinitely, either keep ownership of the
|
||||||
/// `OutputOpenDrain`, or pass it to [`core::mem::forget`].
|
/// `OutputOpenDrain`, or pass it to [`core::mem::forget`].
|
||||||
pub struct OutputOpenDrain<'d, T: Pin> {
|
pub struct OutputOpenDrain<'d> {
|
||||||
pub(crate) pin: Flex<'d, T>,
|
pub(crate) pin: Flex<'d>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
impl<'d> OutputOpenDrain<'d> {
|
||||||
/// Create a new GPIO open drain output driver for a [Pin] with the provided [Level] and [Speed], [Pull] configuration.
|
/// Create a new GPIO open drain output driver for a [Pin] with the provided [Level] and [Speed], [Pull] configuration.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self {
|
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self {
|
||||||
let mut pin = Flex::new(pin);
|
let mut pin = Flex::new(pin);
|
||||||
|
|
||||||
match initial_output {
|
match initial_output {
|
||||||
|
@ -482,18 +439,6 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
||||||
Self { pin }
|
Self { pin }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
|
||||||
///
|
|
||||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
|
||||||
/// are all different types, into the same type. It is useful for
|
|
||||||
/// creating arrays of pins, or avoiding generics.
|
|
||||||
#[inline]
|
|
||||||
pub fn degrade(self) -> Output<'d, AnyPin> {
|
|
||||||
Output {
|
|
||||||
pin: self.pin.degrade(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
|
@ -836,7 +781,7 @@ pub(crate) unsafe fn init(_cs: CriticalSection) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -850,7 +795,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -866,7 +811,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok(self.is_set_high())
|
||||||
|
@ -879,7 +824,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||||
|
@ -888,7 +833,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -904,7 +849,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok(self.is_set_high())
|
||||||
|
@ -917,7 +862,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||||
|
@ -926,7 +871,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -940,7 +885,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -956,7 +901,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok(self.is_set_high())
|
||||||
|
@ -969,7 +914,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> {
|
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||||
|
@ -978,11 +923,11 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
impl<'d> embedded_hal_1::digital::InputPin for Input<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok((*self).is_high())
|
Ok((*self).is_high())
|
||||||
|
@ -994,11 +939,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> {
|
impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||||
Ok(self.set_high())
|
Ok(self.set_high())
|
||||||
|
@ -1010,7 +955,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok((*self).is_set_high())
|
Ok((*self).is_set_high())
|
||||||
|
@ -1023,11 +968,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> {
|
impl<'d> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
impl<'d> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok((*self).is_high())
|
Ok((*self).is_high())
|
||||||
|
@ -1039,7 +984,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
impl<'d> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||||
Ok(self.set_high())
|
Ok(self.set_high())
|
||||||
|
@ -1051,7 +996,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
impl<'d> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok((*self).is_set_high())
|
Ok((*self).is_set_high())
|
||||||
|
@ -1064,7 +1009,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok((*self).is_high())
|
Ok((*self).is_high())
|
||||||
|
@ -1076,7 +1021,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||||
Ok(self.set_high())
|
Ok(self.set_high())
|
||||||
|
@ -1088,11 +1033,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
|
impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok((*self).is_set_high())
|
Ok((*self).is_set_high())
|
||||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_sync::mutex::Mutex;
|
use embassy_sync::mutex::Mutex;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let flash = Flash::new_blocking(p.FLASH);
|
let flash = Flash::new_blocking(p.FLASH);
|
||||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Up);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
let mut led = Output::new(p.PA5, Level::Low, Speed::Low);
|
let mut led = Output::new(p.PA5, Level::Low, Speed::Low);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
|
|
@ -9,7 +9,7 @@ use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdater
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_sync::blocking_mutex::Mutex;
|
use embassy_sync::blocking_mutex::Mutex;
|
||||||
use embedded_storage::nor_flash::NorFlash;
|
use embedded_storage::nor_flash::NorFlash;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let flash = Flash::new_blocking(p.FLASH);
|
let flash = Flash::new_blocking(p.FLASH);
|
||||||
let flash = Mutex::new(RefCell::new(flash));
|
let flash = Mutex::new(RefCell::new(flash));
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
let mut led = Output::new(p.PB7, Level::Low, Speed::Low);
|
let mut led = Output::new(p.PB7, Level::Low, Speed::Low);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
|
|
@ -9,7 +9,7 @@ use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdater
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_sync::blocking_mutex::Mutex;
|
use embassy_sync::blocking_mutex::Mutex;
|
||||||
use embedded_storage::nor_flash::NorFlash;
|
use embedded_storage::nor_flash::NorFlash;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let flash = Flash::new_blocking(p.FLASH);
|
let flash = Flash::new_blocking(p.FLASH);
|
||||||
let flash = Mutex::new(RefCell::new(flash));
|
let flash = Mutex::new(RefCell::new(flash));
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
|
let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_sync::mutex::Mutex;
|
use embassy_sync::mutex::Mutex;
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let flash = Flash::new_blocking(p.FLASH);
|
let flash = Flash::new_blocking(p.FLASH);
|
||||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||||
|
|
||||||
let button = Input::new(p.PB2, Pull::Up);
|
let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI2);
|
|
||||||
|
|
||||||
let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
|
let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_sync::mutex::Mutex;
|
use embassy_sync::mutex::Mutex;
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let flash = Flash::new_blocking(p.FLASH);
|
let flash = Flash::new_blocking(p.FLASH);
|
||||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||||
|
|
||||||
let button = Input::new(p.PB2, Pull::Up);
|
let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI2);
|
|
||||||
|
|
||||||
let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
|
let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_sync::mutex::Mutex;
|
use embassy_sync::mutex::Mutex;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let flash = Flash::new_blocking(p.FLASH);
|
let flash = Flash::new_blocking(p.FLASH);
|
||||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Up);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
|
let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_sync::mutex::Mutex;
|
use embassy_sync::mutex::Mutex;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let flash = Flash::new_blocking(p.FLASH);
|
let flash = Flash::new_blocking(p.FLASH);
|
||||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||||
|
|
||||||
let button = Input::new(p.PA0, Pull::Up);
|
let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI0);
|
|
||||||
|
|
||||||
let mut led = Output::new(p.PB9, Level::Low, Speed::Low);
|
let mut led = Output::new(p.PB9, Level::Low, Speed::Low);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Up);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
|
||||||
use defmt::info;
|
use defmt::info;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed};
|
use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Pull, Speed};
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ async fn main(spawner: Spawner) {
|
||||||
|
|
||||||
// Configure the button pin and obtain handler.
|
// Configure the button pin and obtain handler.
|
||||||
// On the Nucleo F091RC there is a button connected to pin PC13.
|
// On the Nucleo F091RC there is a button connected to pin PC13.
|
||||||
let button = Input::new(p.PC13, Pull::None);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::None);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
// Create and initialize a delay variable to manage delay loop
|
// Create and initialize a delay variable to manage delay loop
|
||||||
let mut del_var = 2000;
|
let mut del_var = 2000;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
// Configure the button pin and obtain handler.
|
// Configure the button pin and obtain handler.
|
||||||
// On the Nucleo F091RC there is a button connected to pin PC13.
|
// On the Nucleo F091RC there is a button connected to pin PC13.
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -12,21 +12,20 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed};
|
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::peripherals::PA0;
|
|
||||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||||
use embassy_sync::channel::Channel;
|
use embassy_sync::channel::Channel;
|
||||||
use embassy_time::{with_timeout, Duration, Timer};
|
use embassy_time::{with_timeout, Duration, Timer};
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
struct Leds<'a> {
|
struct Leds<'a> {
|
||||||
leds: [Output<'a, AnyPin>; 8],
|
leds: [Output<'a>; 8],
|
||||||
direction: i8,
|
direction: i8,
|
||||||
current_led: usize,
|
current_led: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Leds<'a> {
|
impl<'a> Leds<'a> {
|
||||||
fn new(pins: [Output<'a, AnyPin>; 8]) -> Self {
|
fn new(pins: [Output<'a>; 8]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
leds: pins,
|
leds: pins,
|
||||||
direction: 1,
|
direction: 1,
|
||||||
|
@ -100,18 +99,17 @@ static CHANNEL: Channel<ThreadModeRawMutex, ButtonEvent, 4> = Channel::new();
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(spawner: Spawner) {
|
async fn main(spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
let button = Input::new(p.PA0, Pull::Down);
|
let button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down);
|
||||||
let button = ExtiInput::new(button, p.EXTI0);
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
let leds = [
|
let leds = [
|
||||||
Output::new(p.PE9.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE9, Level::Low, Speed::Low),
|
||||||
Output::new(p.PE10.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE10, Level::Low, Speed::Low),
|
||||||
Output::new(p.PE11.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE11, Level::Low, Speed::Low),
|
||||||
Output::new(p.PE12.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE12, Level::Low, Speed::Low),
|
||||||
Output::new(p.PE13.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE13, Level::Low, Speed::Low),
|
||||||
Output::new(p.PE14.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE14, Level::Low, Speed::Low),
|
||||||
Output::new(p.PE15.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE15, Level::Low, Speed::Low),
|
||||||
Output::new(p.PE8.degrade(), Level::Low, Speed::Low),
|
Output::new(p.PE8, Level::Low, Speed::Low),
|
||||||
];
|
];
|
||||||
let leds = Leds::new(leds);
|
let leds = Leds::new(leds);
|
||||||
|
|
||||||
|
@ -127,7 +125,7 @@ async fn led_blinker(mut leds: Leds<'static>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
async fn button_waiter(mut button: ExtiInput<'static, PA0>) {
|
async fn button_waiter(mut button: ExtiInput<'static>) {
|
||||||
const DOUBLE_CLICK_DELAY: u64 = 250;
|
const DOUBLE_CLICK_DELAY: u64 = 250;
|
||||||
const HOLD_DELAY: u64 = 1000;
|
const HOLD_DELAY: u64 = 1000;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PA0, Pull::Down);
|
let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI0);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Up);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use embassy_stm32::Config;
|
use embassy_stm32::Config;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let config = Config::default();
|
let config = Config::default();
|
||||||
let p = embassy_stm32::init(config);
|
let p = embassy_stm32::init(config);
|
||||||
|
|
||||||
let button = Input::new(p.PB2, Pull::Up);
|
let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI2);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Up);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,9 @@ const IP_ADDRESS: Ipv4Cidr = Ipv4Cidr::new(Ipv4Address([192, 168, 1, 5]), 24);
|
||||||
const HTTP_LISTEN_PORT: u16 = 80;
|
const HTTP_LISTEN_PORT: u16 = 80;
|
||||||
|
|
||||||
pub type SpeSpi = Spi<'static, peripherals::SPI2, peripherals::DMA1_CH1, peripherals::DMA1_CH2>;
|
pub type SpeSpi = Spi<'static, peripherals::SPI2, peripherals::DMA1_CH1, peripherals::DMA1_CH2>;
|
||||||
pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static, peripherals::PB12>, Delay>;
|
pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>;
|
||||||
pub type SpeInt = exti::ExtiInput<'static, peripherals::PB11>;
|
pub type SpeInt = exti::ExtiInput<'static>;
|
||||||
pub type SpeRst = Output<'static, peripherals::PC7>;
|
pub type SpeRst = Output<'static>;
|
||||||
pub type Adin1110T = ADIN1110<SpeSpiCs>;
|
pub type Adin1110T = ADIN1110<SpeSpiCs>;
|
||||||
pub type TempSensI2c = I2c<'static, peripherals::I2C3, peripherals::DMA1_CH6, peripherals::DMA1_CH7>;
|
pub type TempSensI2c = I2c<'static, peripherals::I2C3, peripherals::DMA1_CH6, peripherals::DMA1_CH7>;
|
||||||
|
|
||||||
|
@ -134,8 +134,7 @@ async fn main(spawner: Spawner) {
|
||||||
let spe_cfg1 = Input::new(dp.PC9, Pull::None);
|
let spe_cfg1 = Input::new(dp.PC9, Pull::None);
|
||||||
let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low);
|
let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low);
|
||||||
|
|
||||||
let spe_int = Input::new(dp.PB11, Pull::None);
|
let spe_int = exti::ExtiInput::new(dp.PB11, dp.EXTI11, Pull::None);
|
||||||
let spe_int = exti::ExtiInput::new(spe_int, dp.EXTI11);
|
|
||||||
|
|
||||||
let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High);
|
let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High);
|
||||||
let spe_spi_sclk = dp.PB13;
|
let spe_spi_sclk = dp.PB13;
|
||||||
|
@ -298,7 +297,7 @@ async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net:
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) {
|
async fn heartbeat_led(mut led: Output<'static>) {
|
||||||
let mut tmr = Ticker::every(Duration::from_hz(3));
|
let mut tmr = Ticker::every(Duration::from_hz(3));
|
||||||
loop {
|
loop {
|
||||||
led.toggle();
|
led.toggle();
|
||||||
|
@ -308,7 +307,7 @@ async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) {
|
||||||
|
|
||||||
// ADT7422
|
// ADT7422
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static, peripherals::PG15>) -> ! {
|
async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static>) -> ! {
|
||||||
let mut tmr = Ticker::every(Duration::from_hz(1));
|
let mut tmr = Ticker::every(Duration::from_hz(1));
|
||||||
let mut temp_sens = ADT7422::new(temp_dev_i2c, 0x48).unwrap();
|
let mut temp_sens = ADT7422::new(temp_dev_i2c, 0x48).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Down);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC4, Pull::Up);
|
let mut button = ExtiInput::new(p.PC4, p.EXTI4, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI4);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PC13, Pull::Up);
|
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::Pull;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let button = Input::new(p.PA0, Pull::Up);
|
let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up);
|
||||||
let mut button = ExtiInput::new(button, p.EXTI0);
|
|
||||||
|
|
||||||
info!("Press the USER button...");
|
info!("Press the USER button...");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue