Updated to latest embassy version

This commit is contained in:
Sebastian 2023-05-28 16:02:12 +02:00
parent 06f4ba549b
commit af62ec315d
6 changed files with 301 additions and 622 deletions

855
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -6,12 +6,12 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
embassy-util = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-executor = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] }
embassy-sync = { version = "0.2.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-futures = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-executor = { version = "0.2.0", git = "https://github.com/embassy-rs/embassy.git", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
embassy-time = { version = "0.1.1", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-stm32 = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits"] }
embassy-usb = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-usb-serial = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
defmt = "0.3.2"
defmt-rtt = "0.3.2"
@ -20,8 +20,6 @@ panic-probe = { version = "0.3.0"}
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
embedded-hal = "0.2.6"
futures-util = { version = "0.3.23", default-features = false, features = ["async-await"] }
heapless = { version = "0.7.5", default-features = false, features = ['ufmt-impl']}
nb = "1.0.0"

View file

@ -1,10 +1,14 @@
use embassy_stm32::i2c;
use embassy_stm32::peripherals;
use embassy_stm32::bind_interrupts;
use embassy_stm32::dma::NoDma;
use embassy_stm32::time::Hertz;
use embassy_time::{Duration, Timer};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Receiver;
use embassy_util::{select, Either};
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Receiver;
use embassy_futures::select::{select, Either};
use embedded_graphics::{
mono_font::{
@ -24,6 +28,10 @@ use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
use crate::{AzElPair, RotorState};
bind_interrupts!(struct Irqs {
I2C1_EV => i2c::InterruptHandler<peripherals::I2C1>;
});
#[embassy_executor::task]
pub async fn display_task(
i2c1: peripherals::I2C1,
@ -31,7 +39,7 @@ pub async fn display_task(
scl: peripherals::PB7,
cmd_receiver: Receiver<'static, ThreadModeRawMutex, RotorState, 1>,
) {
let i2c = i2c::I2c::new(i2c1, sda, scl, Hertz::hz(100_000), i2c::Config::default());
let i2c = i2c::I2c::new(i2c1, sda, scl, Irqs, NoDma, NoDma, Hertz(100_000), Default::default());
let interface = I2CDisplayInterface::new(i2c);

View file

@ -11,8 +11,8 @@ use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::time::Hertz;
use embassy_stm32::Config;
use embassy_time::{Duration, Timer};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Channel;
mod display;
use display::display_task;

View file

@ -2,10 +2,10 @@ use embassy_stm32::adc::Adc;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::peripherals;
use embassy_time::{with_timeout, Delay, Duration, Timer};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::{Receiver, Sender};
use embassy_util::{select, Either};
use futures_util::future::join;
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::{Receiver, Sender};
use embassy_futures::select::{select, Either};
use embassy_futures::join::join;
use heapless::Vec;
use crate::usb::Gs232Cmd;
@ -144,7 +144,7 @@ pub async fn movement_task(
// Send the state to the display task and the position usb.
// Use timeouts to prevent blocking if display or usb task are unresponsive.
join(
let _ = join(
with_timeout(
Duration::from_millis(100),
pos_sender.send(rotor_state.actual_pos),

View file

@ -1,21 +1,25 @@
use defmt::Format;
use embassy_stm32::interrupt;
use embassy_stm32::peripherals;
use embassy_stm32::{bind_interrupts, usb};
use embassy_stm32::usb::Driver;
use embassy_usb::Builder;
use embassy_usb_serial::{CdcAcmClass, State};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::{Receiver, Sender};
use embassy_util::{select, Either};
use futures_util::future::join;
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::{Receiver, Sender};
use embassy_futures::select::{select, Either};
use embassy_futures::join::join;
use heapless::String;
use ufmt::uwrite;
use crate::AzElPair;
bind_interrupts!(struct Irqs {
USB_LP_CAN1_RX0 => usb::InterruptHandler<peripherals::USB>;
});
#[embassy_executor::task]
pub async fn usb_task(
usb: peripherals::USB,
@ -24,8 +28,7 @@ pub async fn usb_task(
cmd_sender: Sender<'static, ThreadModeRawMutex, Gs232Cmd, 1>,
pos_receiver: Receiver<'static, ThreadModeRawMutex, AzElPair, 1>,
) {
let irq = interrupt::take!(USB_LP_CAN1_RX0);
let driver = Driver::new(usb, irq, dp_pin, dm_pin);
let driver = Driver::new(usb, Irqs, dp_pin, dm_pin);
// Create embassy-usb Config
let config = embassy_usb::Config::new(0xc0de, 0xcafe);
@ -45,8 +48,7 @@ pub async fn usb_task(
&mut device_descriptor,
&mut config_descriptor,
&mut bos_descriptor,
&mut control_buf,
None,
&mut control_buf
);
// Create classes on the builder.
@ -160,7 +162,7 @@ pub async fn usb_task(
}
defmt::info!("USB disconnected");
// USB connection is broken, so better stop the rotor.
cmd_sender.send(Gs232Cmd::Stop);
cmd_sender.send(Gs232Cmd::Stop).await;
}
};