Updated to latest embassy version
This commit is contained in:
parent
06f4ba549b
commit
af62ec315d
855
Cargo.lock
generated
855
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
12
Cargo.toml
12
Cargo.toml
|
@ -6,12 +6,12 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
|
embassy-sync = { version = "0.2.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-futures = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
|
||||||
embassy-time = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
|
embassy-executor = { version = "0.2.0", git = "https://github.com/embassy-rs/embassy.git", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
|
||||||
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-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 = { 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 = "0.3.2"
|
||||||
defmt-rtt = "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 = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
embedded-hal = "0.2.6"
|
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']}
|
heapless = { version = "0.7.5", default-features = false, features = ['ufmt-impl']}
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
use embassy_stm32::i2c;
|
use embassy_stm32::i2c;
|
||||||
use embassy_stm32::peripherals;
|
use embassy_stm32::peripherals;
|
||||||
|
use embassy_stm32::bind_interrupts;
|
||||||
|
use embassy_stm32::dma::NoDma;
|
||||||
use embassy_stm32::time::Hertz;
|
use embassy_stm32::time::Hertz;
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||||
use embassy_util::channel::mpmc::Receiver;
|
use embassy_sync::channel::Receiver;
|
||||||
use embassy_util::{select, Either};
|
use embassy_futures::select::{select, Either};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
mono_font::{
|
mono_font::{
|
||||||
|
@ -24,6 +28,10 @@ use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
|
||||||
|
|
||||||
use crate::{AzElPair, RotorState};
|
use crate::{AzElPair, RotorState};
|
||||||
|
|
||||||
|
bind_interrupts!(struct Irqs {
|
||||||
|
I2C1_EV => i2c::InterruptHandler<peripherals::I2C1>;
|
||||||
|
});
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn display_task(
|
pub async fn display_task(
|
||||||
i2c1: peripherals::I2C1,
|
i2c1: peripherals::I2C1,
|
||||||
|
@ -31,7 +39,7 @@ pub async fn display_task(
|
||||||
scl: peripherals::PB7,
|
scl: peripherals::PB7,
|
||||||
cmd_receiver: Receiver<'static, ThreadModeRawMutex, RotorState, 1>,
|
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);
|
let interface = I2CDisplayInterface::new(i2c);
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::time::Hertz;
|
use embassy_stm32::time::Hertz;
|
||||||
use embassy_stm32::Config;
|
use embassy_stm32::Config;
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||||
use embassy_util::channel::mpmc::Channel;
|
use embassy_sync::channel::Channel;
|
||||||
|
|
||||||
mod display;
|
mod display;
|
||||||
use display::display_task;
|
use display::display_task;
|
||||||
|
|
|
@ -2,10 +2,10 @@ use embassy_stm32::adc::Adc;
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::peripherals;
|
use embassy_stm32::peripherals;
|
||||||
use embassy_time::{with_timeout, Delay, Duration, Timer};
|
use embassy_time::{with_timeout, Delay, Duration, Timer};
|
||||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||||
use embassy_util::channel::mpmc::{Receiver, Sender};
|
use embassy_sync::channel::{Receiver, Sender};
|
||||||
use embassy_util::{select, Either};
|
use embassy_futures::select::{select, Either};
|
||||||
use futures_util::future::join;
|
use embassy_futures::join::join;
|
||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
|
|
||||||
use crate::usb::Gs232Cmd;
|
use crate::usb::Gs232Cmd;
|
||||||
|
@ -144,7 +144,7 @@ pub async fn movement_task(
|
||||||
|
|
||||||
// Send the state to the display task and the position usb.
|
// Send the state to the display task and the position usb.
|
||||||
// Use timeouts to prevent blocking if display or usb task are unresponsive.
|
// Use timeouts to prevent blocking if display or usb task are unresponsive.
|
||||||
join(
|
let _ = join(
|
||||||
with_timeout(
|
with_timeout(
|
||||||
Duration::from_millis(100),
|
Duration::from_millis(100),
|
||||||
pos_sender.send(rotor_state.actual_pos),
|
pos_sender.send(rotor_state.actual_pos),
|
||||||
|
|
26
src/usb.rs
26
src/usb.rs
|
@ -1,21 +1,25 @@
|
||||||
use defmt::Format;
|
use defmt::Format;
|
||||||
|
|
||||||
use embassy_stm32::interrupt;
|
|
||||||
use embassy_stm32::peripherals;
|
use embassy_stm32::peripherals;
|
||||||
|
use embassy_stm32::{bind_interrupts, usb};
|
||||||
use embassy_stm32::usb::Driver;
|
use embassy_stm32::usb::Driver;
|
||||||
use embassy_usb::Builder;
|
use embassy_usb::Builder;
|
||||||
use embassy_usb_serial::{CdcAcmClass, State};
|
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
|
||||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||||
use embassy_util::channel::mpmc::{Receiver, Sender};
|
use embassy_sync::channel::{Receiver, Sender};
|
||||||
use embassy_util::{select, Either};
|
use embassy_futures::select::{select, Either};
|
||||||
|
use embassy_futures::join::join;
|
||||||
use futures_util::future::join;
|
|
||||||
|
|
||||||
use heapless::String;
|
use heapless::String;
|
||||||
use ufmt::uwrite;
|
use ufmt::uwrite;
|
||||||
|
|
||||||
use crate::AzElPair;
|
use crate::AzElPair;
|
||||||
|
|
||||||
|
bind_interrupts!(struct Irqs {
|
||||||
|
USB_LP_CAN1_RX0 => usb::InterruptHandler<peripherals::USB>;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn usb_task(
|
pub async fn usb_task(
|
||||||
usb: peripherals::USB,
|
usb: peripherals::USB,
|
||||||
|
@ -24,8 +28,7 @@ pub async fn usb_task(
|
||||||
cmd_sender: Sender<'static, ThreadModeRawMutex, Gs232Cmd, 1>,
|
cmd_sender: Sender<'static, ThreadModeRawMutex, Gs232Cmd, 1>,
|
||||||
pos_receiver: Receiver<'static, ThreadModeRawMutex, AzElPair, 1>,
|
pos_receiver: Receiver<'static, ThreadModeRawMutex, AzElPair, 1>,
|
||||||
) {
|
) {
|
||||||
let irq = interrupt::take!(USB_LP_CAN1_RX0);
|
let driver = Driver::new(usb, Irqs, dp_pin, dm_pin);
|
||||||
let driver = Driver::new(usb, irq, dp_pin, dm_pin);
|
|
||||||
|
|
||||||
// Create embassy-usb Config
|
// Create embassy-usb Config
|
||||||
let config = embassy_usb::Config::new(0xc0de, 0xcafe);
|
let config = embassy_usb::Config::new(0xc0de, 0xcafe);
|
||||||
|
@ -45,8 +48,7 @@ pub async fn usb_task(
|
||||||
&mut device_descriptor,
|
&mut device_descriptor,
|
||||||
&mut config_descriptor,
|
&mut config_descriptor,
|
||||||
&mut bos_descriptor,
|
&mut bos_descriptor,
|
||||||
&mut control_buf,
|
&mut control_buf
|
||||||
None,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create classes on the builder.
|
// Create classes on the builder.
|
||||||
|
@ -160,7 +162,7 @@ pub async fn usb_task(
|
||||||
}
|
}
|
||||||
defmt::info!("USB disconnected");
|
defmt::info!("USB disconnected");
|
||||||
// USB connection is broken, so better stop the rotor.
|
// USB connection is broken, so better stop the rotor.
|
||||||
cmd_sender.send(Gs232Cmd::Stop);
|
cmd_sender.send(Gs232Cmd::Stop).await;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue