diff --git a/Cargo.lock b/Cargo.lock index b13d613..e42c2b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,7 +96,7 @@ dependencies = [ "defmt", "document-features", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-time", "embedded-io-async", "embedded-nal-async", @@ -117,24 +117,11 @@ dependencies = [ name = "embassy-sync" version = "0.6.0" source = "git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7#1c466b81e6af6b34b1f706318cc0870a459550b7" -dependencies = [ - "cfg-if", - "critical-section", - "embedded-io-async", - "futures-util", - "heapless", -] - -[[package]] -name = "embassy-sync" -version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy#227e073fca97bcbcec42d9705e0a8ef19fc433b5" dependencies = [ "cfg-if", "critical-section", "defmt", "embedded-io-async", - "futures-sink", "futures-util", "heapless", ] @@ -242,12 +229,6 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" -[[package]] -name = "futures-sink" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" - [[package]] name = "futures-task" version = "0.3.31" @@ -334,7 +315,7 @@ dependencies = [ name = "hyped_sensors" version = "0.1.0" dependencies = [ - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync", "heapless", "hyped_core", "hyped_io", @@ -352,9 +333,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "7a73e9fe3c49d7afb2ace819fa181a287ce54a0983eda4e0eb05c22f82ffe534" [[package]] name = "libm" @@ -664,9 +645,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "version_check" diff --git a/boards/stm32f767zi/Cargo.lock b/boards/stm32f767zi/Cargo.lock index 0a1abc3..fc67b71 100644 --- a/boards/stm32f767zi/Cargo.lock +++ b/boards/stm32f767zi/Cargo.lock @@ -185,7 +185,7 @@ source = "git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f70631 dependencies = [ "defmt", "embassy-futures", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-time", "embedded-hal 0.2.7", "embedded-hal 1.0.0", @@ -244,7 +244,7 @@ dependencies = [ "defmt", "document-features", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-time", "embedded-io-async", "embedded-nal-async", @@ -278,7 +278,7 @@ dependencies = [ "embassy-futures", "embassy-hal-internal", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-time", "embassy-time-driver", "embassy-usb-driver", @@ -318,19 +318,6 @@ dependencies = [ "heapless", ] -[[package]] -name = "embassy-sync" -version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy#9555259c57a07338792cfe0fdd363a59616a8062" -dependencies = [ - "cfg-if", - "critical-section", - "defmt", - "embedded-io-async", - "futures-util", - "heapless", -] - [[package]] name = "embassy-time" version = "0.3.2" @@ -376,7 +363,7 @@ version = "0.1.0" source = "git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7#1c466b81e6af6b34b1f706318cc0870a459550b7" dependencies = [ "critical-section", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-usb-driver", ] @@ -543,7 +530,7 @@ dependencies = [ "embassy-futures", "embassy-net", "embassy-stm32", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync", "embassy-time", "embedded-hal 0.2.7", "embedded-storage", @@ -578,6 +565,7 @@ dependencies = [ name = "hyped_sensors" version = "0.1.0" dependencies = [ + "embassy-sync", "heapless", "hyped_core", "hyped_io", diff --git a/boards/stm32f767zi/Cargo.toml b/boards/stm32f767zi/Cargo.toml index a2c008b..8cc779f 100644 --- a/boards/stm32f767zi/Cargo.toml +++ b/boards/stm32f767zi/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] embassy-stm32 = { version = "0.1.0", features = ["defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] , git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} -embassy-sync = { version = "0.6.0", features = ["defmt"], git = "https://github.com/embassy-rs/embassy"} +embassy-sync = { version = "0.6.0", features = ["defmt"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} embassy-executor = { version = "0.6.0", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} embassy-time = { version = "0.3.1", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} embassy-net = { version = "0.4.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} diff --git a/boards/stm32f767zi/src/io/adc.rs b/boards/stm32f767zi/src/io/adc.rs index eef5eaf..af739c2 100644 --- a/boards/stm32f767zi/src/io/adc.rs +++ b/boards/stm32f767zi/src/io/adc.rs @@ -15,7 +15,7 @@ impl<'d, T: Instance> HypedAdc for Stm32f767ziAdc<'d, T> { impl<'d, T: Instance> Stm32f767ziAdc<'d, T> { /// Create a new instance of our ADC implementation for the STM32F767ZI - pub fn new(mut adc: Adc<'d, T>, channel: AnyAdcChannel) -> Self { + pub fn new(adc: Adc<'d, T>, channel: AnyAdcChannel) -> Self { Self { adc, channel } } } diff --git a/boards/stm32f767zi/src/tasks/temperature.rs b/boards/stm32f767zi/src/tasks/temperature.rs index c735dfd..1137bca 100644 --- a/boards/stm32f767zi/src/tasks/temperature.rs +++ b/boards/stm32f767zi/src/tasks/temperature.rs @@ -1,7 +1,10 @@ +use core::cell::RefCell; + use crate::io::i2c::Stm32f767ziI2c; use defmt_rtt as _; use embassy_stm32::i2c::I2c; use embassy_stm32::time::Hertz; +use embassy_sync::blocking_mutex::Mutex; use hyped_sensors::temperature::{Status, Temperature, TemperatureAddresses}; /// Test task that just reads the temperature from the sensor and prints it to the console @@ -9,9 +12,9 @@ use hyped_sensors::temperature::{Status, Temperature, TemperatureAddresses}; pub async fn read_temp() -> ! { let p = embassy_stm32::init(Default::default()); let i2c = I2c::new_blocking(p.I2C1, p.PB8, p.PB9, Hertz(100_000), Default::default()); - let mut hyped_i2c = Stm32f767ziI2c::new(i2c); + let hyped_i2c = Mutex::new(RefCell::new(Stm32f767ziI2c::new(i2c))); - let mut temperature_sensor = Temperature::new(&mut hyped_i2c, TemperatureAddresses::Address3f) + let mut temperature_sensor = Temperature::new(&hyped_i2c, TemperatureAddresses::Address3f) .expect( "Failed to create temperature sensor. Check the wiring and the I2C address of the sensor.", ); diff --git a/boards/stm32l476rg/Cargo.lock b/boards/stm32l476rg/Cargo.lock index 108883d..e4dd087 100644 --- a/boards/stm32l476rg/Cargo.lock +++ b/boards/stm32l476rg/Cargo.lock @@ -185,7 +185,7 @@ source = "git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f70631 dependencies = [ "defmt", "embassy-futures", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-time", "embedded-hal 0.2.7", "embedded-hal 1.0.0", @@ -244,7 +244,7 @@ dependencies = [ "defmt", "document-features", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-time", "embedded-io-async", "embedded-nal-async", @@ -278,7 +278,7 @@ dependencies = [ "embassy-futures", "embassy-hal-internal", "embassy-net-driver", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-time", "embassy-time-driver", "embassy-usb-driver", @@ -318,19 +318,6 @@ dependencies = [ "heapless", ] -[[package]] -name = "embassy-sync" -version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy#9555259c57a07338792cfe0fdd363a59616a8062" -dependencies = [ - "cfg-if", - "critical-section", - "defmt", - "embedded-io-async", - "futures-util", - "heapless", -] - [[package]] name = "embassy-time" version = "0.3.2" @@ -376,7 +363,7 @@ version = "0.1.0" source = "git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7#1c466b81e6af6b34b1f706318cc0870a459550b7" dependencies = [ "critical-section", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy?rev=1c466b81e6af6b34b1f706318cc0870a459550b7)", + "embassy-sync", "embassy-usb-driver", ] @@ -543,7 +530,7 @@ dependencies = [ "embassy-futures", "embassy-net", "embassy-stm32", - "embassy-sync 0.6.0 (git+https://github.com/embassy-rs/embassy)", + "embassy-sync", "embassy-time", "embedded-hal 0.2.7", "embedded-storage", @@ -578,6 +565,7 @@ dependencies = [ name = "hyped_sensors" version = "0.1.0" dependencies = [ + "embassy-sync", "heapless", "hyped_core", "hyped_io", diff --git a/boards/stm32l476rg/Cargo.toml b/boards/stm32l476rg/Cargo.toml index 55a129f..1b93b63 100644 --- a/boards/stm32l476rg/Cargo.toml +++ b/boards/stm32l476rg/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] embassy-stm32 = { version = "0.1.0", features = ["defmt", "stm32l476rg", "memory-x", "unstable-pac", "time-driver-any", "exti"] , git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} -embassy-sync = { version = "0.6.0", features = ["defmt"], git = "https://github.com/embassy-rs/embassy"} +embassy-sync = { version = "0.6.0", features = ["defmt"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} embassy-executor = { version = "0.6.0", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} embassy-time = { version = "0.3.1", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} embassy-net = { version = "0.4.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} diff --git a/boards/stm32l476rg/src/tasks/temperature.rs b/boards/stm32l476rg/src/tasks/temperature.rs index d6e1068..c0a371f 100644 --- a/boards/stm32l476rg/src/tasks/temperature.rs +++ b/boards/stm32l476rg/src/tasks/temperature.rs @@ -1,7 +1,9 @@ use crate::io::i2c::Stm32l476rgI2c; +use core::cell::RefCell; use defmt_rtt as _; use embassy_stm32::i2c::I2c; use embassy_stm32::time::Hertz; +use embassy_sync::blocking_mutex::Mutex; use hyped_sensors::temperature::{Status, Temperature, TemperatureAddresses}; /// Test task that just reads the temperature from the sensor and prints it to the console @@ -9,9 +11,9 @@ use hyped_sensors::temperature::{Status, Temperature, TemperatureAddresses}; pub async fn read_temp() -> ! { let p = embassy_stm32::init(Default::default()); let i2c = I2c::new_blocking(p.I2C1, p.PB8, p.PB9, Hertz(100_000), Default::default()); - let mut hyped_i2c = Stm32l476rgI2c::new(i2c); + let hyped_i2c = Mutex::new(RefCell::new(Stm32l476rgI2c::new(i2c))); - let mut temperature_sensor = Temperature::new(&mut hyped_i2c, TemperatureAddresses::Address3f) + let mut temperature_sensor = Temperature::new(&hyped_i2c, TemperatureAddresses::Address3f) .expect( "Failed to create temperature sensor. Check the wiring and the I2C address of the sensor.", ); diff --git a/lib/sensors/Cargo.toml b/lib/sensors/Cargo.toml index 8726f40..b7fdccd 100644 --- a/lib/sensors/Cargo.toml +++ b/lib/sensors/Cargo.toml @@ -5,8 +5,10 @@ edition = "2021" [dependencies] heapless = "0.8.0" -embassy-sync = { version = "0.6.0", features = ["defmt"], git = "https://github.com/embassy-rs/embassy"} - +embassy-sync = { version = "0.6.0", features = ["defmt"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} hyped_core = { path = "../core" } hyped_io = { path = "../io" } +[dev-dependencies] +embassy-sync = { version = "0.6.0", features = ["defmt", "std"], git = "https://github.com/embassy-rs/embassy", rev = "1c466b81e6af6b34b1f706318cc0870a459550b7"} +