formatting

This commit is contained in:
Bruno Bousquet 2024-05-05 22:30:16 -04:00
parent ad66dc3aab
commit 431a60ca63
3 changed files with 18 additions and 14 deletions

View File

@ -3,7 +3,6 @@
use core::marker::PhantomData;
use embassy_hal_internal::{into_ref, PeripheralRef};
use embassy_sync::channel;
use super::low_level::{CountingMode, InputCaptureMode, InputTISelection, Timer};
use super::{Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin, GeneralInstance4Channel};

View File

@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
[dependencies]
# Change stm32f429zi to your chip name, if necessary.
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f446re", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"] }
embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }

View File

@ -3,17 +3,14 @@
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::{
gpio::{self, Level, Output, Speed},
time::Hertz,
};
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
use embassy_stm32::time::khz;
use embassy_stm32::timer::input_capture::{CapturePin, InputCapture};
use embassy_stm32::timer::Channel;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
use embassy_stm32::timer::{
input_capture::{CapturePin, InputCapture},
Channel,
};
/// Connect PB2 and PB10 with a 1k Ohm resistor
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
@ -22,9 +19,11 @@ async fn main(_spawner: Spawner) {
let mut led = Output::new(p.PB2, Level::High, Speed::Low);
let ic = CapturePin::new_ch3(p.PB10, gpio::Pull::None);
let drv = InputCapture::new(p.TIM2, None, None, Some(ic), None, Hertz::mhz(1), Default::default());
let mut _last: u32;
let ch3 = CapturePin::new_ch3(p.PB10, Pull::None);
let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, khz(1000), Default::default());
ic.enable(Channel::Ch3);
let mut last = 0;
loop {
info!("high");
@ -34,6 +33,12 @@ async fn main(_spawner: Spawner) {
info!("low");
led.set_low();
Timer::after_millis(300).await;
_last = drv.get_capture_value(Channel::Ch1);
// Check for input capture
let cap = ic.get_capture_value(Channel::Ch3);
if cap != last {
info!("New capture!");
last = cap;
}
}
}