diff --git a/Cargo.toml b/Cargo.toml index 87ff90b..208c689 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ ] [workspace.package] -version = "0.1.0" +version = "0.2.0" edition = "2021" repository = "https://git.bfpower.io/BFPOWER/physical" readme = "README.md" @@ -29,7 +29,7 @@ license = "MIT" version = "0.2.*" # Units of measurement [workspace.dependencies.uom] -version = "0.34.*" +version = "0.35.*" default-features = false features = ["f32", "si"] # Logging @@ -45,14 +45,14 @@ version = "3.6.*" default-features = false # Embedded-HAL [workspace.dependencies.embedded-hal] -version = "1.0.0-alpha.10" +version = "1.0.*" [workspace.dependencies.embedded-hal-async] -version = "0.2.0-alpha.1" +version = "1.0.*" # Memory [workspace.dependencies.static_cell] -version = "1.1.*" +version = "2.0.*" [workspace.dependencies.heapless] -version = "0.7.*" +version = "0.8.*" # Other embedded utilities [workspace.dependencies.cortex-m] version = "0.7.*" @@ -72,23 +72,22 @@ features = ["uom"] [workspace.dependencies.embassy-futures] version = "0.1.*" [workspace.dependencies.embassy-time] -version = "0.1.*" -features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "nightly", ] +version = "0.3.*" +features = ["defmt", "defmt-timestamp-uptime"] [workspace.dependencies.embassy-sync] -version = "0.1.*" +version = "0.5.*" features = ["defmt"] [workspace.dependencies.embassy-embedded-hal] version = "0.1.*" -features = ["nightly"] [workspace.dependencies.embassy-executor] -version = "0.1.*" -features = ["defmt", "arch-cortex-m", "integrated-timers", "executor-interrupt", "executor-thread", "nightly"] +version = "0.5.*" +features = ["defmt", "arch-cortex-m", "integrated-timers", "executor-interrupt", "executor-thread"] [workspace.dependencies.embassy-stm32] version = "0.1.*" -features = ["defmt", "unstable-traits", "unstable-pac", "nightly"] +features = ["defmt", "unstable-pac"] [workspace.dependencies.embassy-nrf] version = "0.1.*" -features = ["defmt", "unstable-traits", "nightly"] +features = ["defmt"] # Macros [workspace.dependencies.syn] version = "2.0.*" @@ -98,22 +97,6 @@ version = "1.0.*" [workspace.dependencies.trybuild] version = "1.0.*" -#--------------------------------------------------------------------------------------------------------------------- -#----- Patch ------------------------ -#--------------------------------------------------------------------------------------------------------------------- -[patch.crates-io] -embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-embedded-hal = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-nrf = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-stm32 = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } -embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "047ea9066f0d946fd4d706577b21df38fd3b1647" } - #--------------------------------------------------------------------------------------------------------------------- #----- Package ------------------------ #--------------------------------------------------------------------------------------------------------------------- diff --git a/examples/ads1256/.cargo/config.toml b/examples/ads1256/.cargo/config.toml index dbcc285..608c37e 100644 --- a/examples/ads1256/.cargo/config.toml +++ b/examples/ads1256/.cargo/config.toml @@ -1,6 +1,6 @@ [target.'cfg(all(target_arch = "arm", target_os = "none"))'] -# replace STM32F429ZITx with your chip as listed in `probe-run --list-chips` -runner = "probe-rs-cli run --chip STM32F429ZITx" +# replace STM32F429ZITx with your chip as listed in `probe-rs chip list` +runner = "probe-rs run --chip STM32F411CEUx" [build] target = "thumbv7em-none-eabi" diff --git a/examples/ads1256/Cargo.toml b/examples/ads1256/Cargo.toml index b75e37d..6bd1c22 100644 --- a/examples/ads1256/Cargo.toml +++ b/examples/ads1256/Cargo.toml @@ -16,6 +16,8 @@ features = ["embassy-sync"] [dependencies.physical-ads1256] path = "../../peripheral-components/ads1256/node" features = ["poll"] +[dependencies.static_cell] +workspace = true [dependencies.ads1256] workspace = true [dependencies.uom] @@ -31,7 +33,7 @@ features = ["critical-section-single-core"] workspace = true [dependencies.embassy-stm32] workspace = true -features = ["stm32f429zi", "memory-x", "time", "exti", "time-driver-any"] +features = ["stm32f411ce", "memory-x", "time", "exti", "time-driver-any"] [dependencies.embassy-executor] workspace = true [dependencies.embassy-futures] diff --git a/examples/ads1256/src/bin/multiplex.rs b/examples/ads1256/src/bin/multiplex.rs index 8f48021..601fcb3 100644 --- a/examples/ads1256/src/bin/multiplex.rs +++ b/examples/ads1256/src/bin/multiplex.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait, async_fn_in_trait)] use core::cell::Cell; use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; @@ -26,8 +25,8 @@ use uom::si::electric_potential::volt; use uom::si::f32; use defmt::{debug, error, info, trace, unwrap}; -use embassy_executor::_export::StaticCell; -use embassy_stm32::peripherals::{PF6, PF7, SPI3}; +use static_cell::StaticCell; +use embassy_stm32::peripherals::{PA1, PA3, SPI1}; use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embassy_sync::pubsub::PubSubChannel; use physical_node::transducer::{Publish, StatefulPublisher}; @@ -61,8 +60,8 @@ struct Inputs { // Inputs static ANALOG_INPUTS: StaticCell = StaticCell::new(); -static ADS_1256: StaticCell, ExtiInput>> = StaticCell::new(); -static SPI: StaticCell> = StaticCell::new(); +static ADS_1256: StaticCell, ExtiInput>> = StaticCell::new(); +static SPI: StaticCell> = StaticCell::new(); #[embassy_executor::main] async fn main(spawner: Spawner) { @@ -79,18 +78,18 @@ async fn main(spawner: Spawner) { let mut spi_conf = spi::Config::default(); spi_conf.mode = spi::MODE_1; spi_conf.bit_order = spi::BitOrder::MsbFirst; + spi_conf.frequency = Hertz(ads1256::defaults::SPI_CLK_HZ); - let ads1256_data_ready = ExtiInput::new(Input::new(p.PF6, Pull::Up), p.EXTI6); - let select_ads1256 = Output::new(p.PF7, Level::High, Speed::VeryHigh); + let ads1256_data_ready = ExtiInput::new(Input::new(p.PA3, Pull::Up), p.EXTI3); + let select_ads1256 = Output::new(p.PA1, Level::High, Speed::VeryHigh); let spi = SPI.init(Spi::new( - p.SPI3, - p.PC10, - p.PC12, - p.PC11, + p.SPI1, + p.PA5, + p.PA7, + p.PA6, NoDma, NoDma, - Hertz(ads1256::defaults::SPI_CLK_HZ), spi_conf, )); @@ -120,8 +119,8 @@ async fn main(spawner: Spawner) { #[embassy_executor::task] async fn drive_inputs_task( - ads_1256: &'static mut Ads1256, ExtiInput<'static, PF6>>, - spi: &'static mut Spi<'static, SPI3, NoDma, NoDma>, + ads_1256: &'static mut Ads1256, ExtiInput<'static, PA3>>, + spi: &'static mut Spi<'static, SPI1, NoDma, NoDma>, inputs: &'static Inputs, ) { let Inputs { ai0, ai1, ai2 } = inputs; diff --git a/examples/ads1256/src/bin/poll.rs b/examples/ads1256/src/bin/poll.rs index f161f7c..a1dca6b 100644 --- a/examples/ads1256/src/bin/poll.rs +++ b/examples/ads1256/src/bin/poll.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait, async_fn_in_trait)] use core::cell::Cell; @@ -27,8 +26,8 @@ use uom::si::electric_potential::volt; use uom::si::f32; use defmt::info; -use embassy_executor::_export::StaticCell; -use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3}; +use static_cell::StaticCell; +use embassy_stm32::peripherals::{PA1, PA3, SPI1}; use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embassy_sync::mutex::Mutex; use embassy_sync::pubsub::PubSubChannel; @@ -65,9 +64,9 @@ type ExampleInput = AutocalPollStatePub< NoopRawMutex, ModInputOnly, Ads1256Delay, - Output<'static, PF7>, - ExtiInput<'static, PF6>, - Spi<'static, SPI3, NoDma, NoDma>, + Output<'static, PA1>, + ExtiInput<'static, PA3>, + Spi<'static, SPI1, NoDma, NoDma>, 10, 1, >; @@ -81,9 +80,9 @@ struct Inputs { // Inputs static ANALOG_INPUTS: StaticCell = StaticCell::new(); static ADS_1256: StaticCell< - Mutex, ExtiInput>>, + Mutex, ExtiInput>>, > = StaticCell::new(); -static SPI: StaticCell>> = StaticCell::new(); +static SPI: StaticCell>> = StaticCell::new(); #[embassy_executor::main] async fn main(spawner: Spawner) { @@ -100,20 +99,22 @@ async fn main(spawner: Spawner) { let mut spi_conf = spi::Config::default(); spi_conf.mode = spi::MODE_1; spi_conf.bit_order = spi::BitOrder::MsbFirst; + spi_conf.frequency = Hertz(ads1256::defaults::SPI_CLK_HZ); - let ads1256_data_ready = ExtiInput::new(Input::new(p.PF6, Pull::Up), p.EXTI6); - let select_ads1256 = Output::new(p.PF7, Level::High, Speed::VeryHigh); + let ads1256_data_ready = ExtiInput::new(Input::new(p.PA3, Pull::Up), p.EXTI3); + let select_ads1256 = Output::new(p.PA1, Level::High, Speed::VeryHigh); - let spi = SPI.init(Mutex::new(Spi::new( - p.SPI3, - p.PC10, - p.PC12, - p.PC11, - NoDma, - NoDma, - Hertz(ads1256::defaults::SPI_CLK_HZ), - spi_conf, - ))); + let spi = SPI.init(Mutex::new( + Spi::new( + p.SPI1, + p.PA5, + p.PA7, + p.PA6, + NoDma, + NoDma, + spi_conf, + ) + )); let ads_1256 = ADS_1256.init(Mutex::new(Ads1256::new(Ads1256Delay, select_ads1256, ads1256_data_ready))); diff --git a/examples/ads1256/src/bin/thermocouple.rs b/examples/ads1256/src/bin/thermocouple.rs index b96bb02..42fd04b 100644 --- a/examples/ads1256/src/bin/thermocouple.rs +++ b/examples/ads1256/src/bin/thermocouple.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait, async_fn_in_trait)] use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; // Necessary unused import. @@ -64,18 +63,18 @@ async fn main(spawner: Spawner) { let mut spi_conf = spi::Config::default(); spi_conf.mode = spi::MODE_1; spi_conf.bit_order = spi::BitOrder::MsbFirst; + spi_conf.frequency = Hertz(ads1256::defaults::SPI_CLK_HZ); - let ads1256_data_ready = ExtiInput::new(Input::new(p.PF6, Pull::Up), p.EXTI6); - let select_ads1256 = Output::new(p.PF7, Level::High, Speed::VeryHigh); + let ads1256_data_ready = ExtiInput::new(Input::new(p.PA3, Pull::Up), p.EXTI3); + let select_ads1256 = Output::new(p.PA1, Level::High, Speed::VeryHigh); let mut spi = Spi::new( - p.SPI3, - p.PC10, - p.PC12, - p.PC11, + p.SPI1, + p.PA5, + p.PA7, + p.PA6, NoDma, NoDma, - Hertz(ads1256::defaults::SPI_CLK_HZ), spi_conf, ); diff --git a/node/src/lib.rs b/node/src/lib.rs index ff5daeb..aed9b0d 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -1,5 +1,4 @@ #![no_std] -#![feature(async_fn_in_trait)] pub mod transducer; diff --git a/peripheral-components/ads1256/node/src/lib.rs b/peripheral-components/ads1256/node/src/lib.rs index ed52f0c..8487fab 100644 --- a/peripheral-components/ads1256/node/src/lib.rs +++ b/peripheral-components/ads1256/node/src/lib.rs @@ -1,4 +1,3 @@ #![no_std] -#![feature(async_fn_in_trait, impl_trait_projections)] pub mod standard; \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 2301ddc..941c636 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,8 +1,8 @@ # Before upgrading check that everything is available on all tier1 targets here: # https://rust-lang.github.io/rustup-components-history [toolchain] -channel = "nightly-2023-04-18" -components = [ "rust-src", "rustfmt", "llvm-tools-preview" ] +channel = "1.75" +components = [ "rust-src", "rustfmt", "llvm-tools" ] targets = [ "thumbv7em-none-eabi", "thumbv7m-none-eabi", diff --git a/src/error.rs b/src/error.rs index 096e009..08aae35 100644 --- a/src/error.rs +++ b/src/error.rs @@ -15,7 +15,8 @@ pub enum CriticalError { } impl CriticalError { - pub fn emergency_procedure(self, procedure: impl FnOnce(CriticalError) -> !) -> ! { + //TODO: Switch to using ! as the return type for the FnOnce and the entire function when the ! feature is stabilized + pub fn emergency_procedure(self, procedure: impl FnOnce(CriticalError)) { procedure(self); } } @@ -24,18 +25,24 @@ impl CriticalError { pub trait CriticalErrResult: Copy { type Value: Copy; + //TODO: Switch to using ! as the return type for the FnOnce when the ! feature is stabilized /// Execute emergency procedure in the event of a critical, the emergency procedure cannot /// return. It should usually terminate the program, potentially rebooting the device in some sort of recovery mode. - fn err_emproc(self, procedure: impl FnOnce(CriticalError) -> !) -> Self::Value; + fn err_emproc(self, procedure: impl FnOnce(CriticalError)) -> Self::Value; } impl CriticalErrResult for Result { type Value = T; - fn err_emproc(self, procedure: impl FnOnce(CriticalError) -> !) -> Self::Value { + //TODO: Switch to using ! as the return type for the FnOnce when the ! feature is stabilized + fn err_emproc(self, procedure: impl FnOnce(CriticalError)) -> Self::Value { match self { Ok(val) => val, - Err(error) => error.emergency_procedure(procedure), + Err(error) => { + error.emergency_procedure(procedure); + //TODO: Remove this panic when we switch to ! return type + panic!() + }, } } } diff --git a/src/lib.rs b/src/lib.rs index b064117..112b8d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ #![no_std] -#![feature(async_fn_in_trait, never_type)] pub mod transducer; pub mod cell;