diff --git a/.github/ci/doc.sh b/.github/ci/doc.sh index 1402e742..e4d83e4b 100755 --- a/.github/ci/doc.sh +++ b/.github/ci/doc.sh @@ -15,30 +15,31 @@ export BUILDER_COMPRESS=true # which makes rustup very sad rustc --version > /dev/null -docserver-builder -i ./embassy-stm32 -o crates/embassy-stm32/git.zup -docserver-builder -i ./embassy-boot/boot -o crates/embassy-boot/git.zup -docserver-builder -i ./embassy-boot/nrf -o crates/embassy-boot-nrf/git.zup -docserver-builder -i ./embassy-boot/rp -o crates/embassy-boot-rp/git.zup -docserver-builder -i ./embassy-boot/stm32 -o crates/embassy-boot-stm32/git.zup -docserver-builder -i ./embassy-embedded-hal -o crates/embassy-embedded-hal/git.zup -docserver-builder -i ./embassy-executor -o crates/embassy-executor/git.zup -docserver-builder -i ./embassy-futures -o crates/embassy-futures/git.zup -docserver-builder -i ./embassy-lora -o crates/embassy-lora/git.zup -docserver-builder -i ./embassy-net -o crates/embassy-net/git.zup -docserver-builder -i ./embassy-net-driver -o crates/embassy-net-driver/git.zup -docserver-builder -i ./embassy-net-driver-channel -o crates/embassy-net-driver-channel/git.zup -docserver-builder -i ./embassy-nrf -o crates/embassy-nrf/git.zup -docserver-builder -i ./embassy-rp -o crates/embassy-rp/git.zup -docserver-builder -i ./embassy-sync -o crates/embassy-sync/git.zup -docserver-builder -i ./embassy-time -o crates/embassy-time/git.zup -docserver-builder -i ./embassy-usb -o crates/embassy-usb/git.zup -docserver-builder -i ./embassy-usb-driver -o crates/embassy-usb-driver/git.zup -docserver-builder -i ./embassy-usb-logger -o crates/embassy-usb-logger/git.zup -docserver-builder -i ./cyw43 -o crates/cyw43/git.zup -docserver-builder -i ./cyw43-pio -o crates/cyw43-pio/git.zup -docserver-builder -i ./embassy-net-w5500 -o crates/embassy-net-w5500/git.zup -docserver-builder -i ./embassy-stm32-wpan -o crates/embassy-stm32-wpan/git.zup +docserver-builder -i ./embassy-stm32 -o webroot/crates/embassy-stm32/git.zup +docserver-builder -i ./embassy-boot/boot -o webroot/crates/embassy-boot/git.zup +docserver-builder -i ./embassy-boot/nrf -o webroot/crates/embassy-boot-nrf/git.zup +docserver-builder -i ./embassy-boot/rp -o webroot/crates/embassy-boot-rp/git.zup +docserver-builder -i ./embassy-boot/stm32 -o webroot/crates/embassy-boot-stm32/git.zup +docserver-builder -i ./embassy-embedded-hal -o webroot/crates/embassy-embedded-hal/git.zup +docserver-builder -i ./embassy-executor -o webroot/crates/embassy-executor/git.zup +docserver-builder -i ./embassy-futures -o webroot/crates/embassy-futures/git.zup +docserver-builder -i ./embassy-lora -o webroot/crates/embassy-lora/git.zup +docserver-builder -i ./embassy-net -o webroot/crates/embassy-net/git.zup +docserver-builder -i ./embassy-net-driver -o webroot/crates/embassy-net-driver/git.zup +docserver-builder -i ./embassy-net-driver-channel -o webroot/crates/embassy-net-driver-channel/git.zup +docserver-builder -i ./embassy-nrf -o webroot/crates/embassy-nrf/git.zup +docserver-builder -i ./embassy-rp -o webroot/crates/embassy-rp/git.zup +docserver-builder -i ./embassy-sync -o webroot/crates/embassy-sync/git.zup +docserver-builder -i ./embassy-time -o webroot/crates/embassy-time/git.zup +docserver-builder -i ./embassy-usb -o webroot/crates/embassy-usb/git.zup +docserver-builder -i ./embassy-usb-driver -o webroot/crates/embassy-usb-driver/git.zup +docserver-builder -i ./embassy-usb-logger -o webroot/crates/embassy-usb-logger/git.zup +docserver-builder -i ./cyw43 -o webroot/crates/cyw43/git.zup +docserver-builder -i ./cyw43-pio -o webroot/crates/cyw43-pio/git.zup +docserver-builder -i ./embassy-net-w5500 -o webroot/crates/embassy-net-w5500/git.zup +docserver-builder -i ./embassy-stm32-wpan -o webroot/crates/embassy-stm32-wpan/git.zup --output-static webroot/static export KUBECONFIG=/ci/secrets/kubeconfig.yml POD=$(kubectl -n embassy get po -l app=docserver -o jsonpath={.items[0].metadata.name}) -kubectl cp crates $POD:/data +kubectl cp webroot/crates $POD:/data +kubectl cp webroot/static $POD:/data \ No newline at end of file diff --git a/cyw43/Cargo.toml b/cyw43/Cargo.toml index 61caa027..7d2f9dfd 100644 --- a/cyw43/Cargo.toml +++ b/cyw43/Cargo.toml @@ -24,7 +24,7 @@ cortex-m = "0.7.6" cortex-m-rt = "0.7.0" futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.10" } +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.11" } num_enum = { version = "0.5.7", default-features = false } [package.metadata.embassy_docs] diff --git a/cyw43/src/runner.rs b/cyw43/src/runner.rs index 5706696b..1c187faa 100644 --- a/cyw43/src/runner.rs +++ b/cyw43/src/runner.rs @@ -345,7 +345,9 @@ where } fn rx(&mut self, packet: &mut [u8]) { - let Some((sdpcm_header, payload)) = SdpcmHeader::parse(packet) else { return }; + let Some((sdpcm_header, payload)) = SdpcmHeader::parse(packet) else { + return; + }; self.update_credit(&sdpcm_header); @@ -353,7 +355,9 @@ where match channel { CHANNEL_TYPE_CONTROL => { - let Some((cdc_header, response)) = CdcHeader::parse(payload) else { return; }; + let Some((cdc_header, response)) = CdcHeader::parse(payload) else { + return; + }; trace!(" {:?}", cdc_header); if cdc_header.id == self.ioctl_id { @@ -417,8 +421,12 @@ where let status = event_packet.msg.status; let event_payload = match evt_type { Event::ESCAN_RESULT if status == EStatus::PARTIAL => { - let Some((_, bss_info)) = ScanResults::parse(evt_data) else { return }; - let Some(bss_info) = BssInfo::parse(bss_info) else { return }; + let Some((_, bss_info)) = ScanResults::parse(evt_data) else { + return; + }; + let Some(bss_info) = BssInfo::parse(bss_info) else { + return; + }; events::Payload::BssInfo(*bss_info) } Event::ESCAN_RESULT => events::Payload::None, @@ -439,7 +447,9 @@ where } } CHANNEL_TYPE_DATA => { - let Some((_, packet)) = BdcHeader::parse(payload) else { return }; + let Some((_, packet)) = BdcHeader::parse(payload) else { + return; + }; trace!("rx pkt {:02x}", Bytes(&packet[..packet.len().min(48)])); match self.ch.try_rx_buf() { diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 35c70bb6..2d11dc3c 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -15,15 +15,18 @@ target = "x86_64-unknown-linux-gnu" std = [] # Enable nightly-only features nightly = ["embassy-futures", "embedded-hal-async", "embedded-storage-async"] +time = ["dep:embassy-time"] +default = ["time"] [dependencies] embassy-futures = { version = "0.1.0", path = "../embassy-futures", optional = true } embassy-sync = { version = "0.2.0", path = "../embassy-sync" } +embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ "unproven", ] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1", optional = true } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2", optional = true } embedded-storage = "0.3.0" embedded-storage-async = { version = "0.4.0", optional = true } nb = "1.0.0" diff --git a/embassy-embedded-hal/src/adapter/blocking_async.rs b/embassy-embedded-hal/src/adapter/blocking_async.rs index b996d6a7..98ae2b02 100644 --- a/embassy-embedded-hal/src/adapter/blocking_async.rs +++ b/embassy-embedded-hal/src/adapter/blocking_async.rs @@ -74,7 +74,21 @@ where E: embedded_hal_1::spi::Error + 'static, T: blocking::spi::Transfer + blocking::spi::Write, { - async fn transfer<'a>(&'a mut self, read: &'a mut [u8], write: &'a [u8]) -> Result<(), Self::Error> { + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } + + async fn write(&mut self, data: &[u8]) -> Result<(), Self::Error> { + self.wrapped.write(data)?; + Ok(()) + } + + async fn read(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { + self.wrapped.transfer(data)?; + Ok(()) + } + + async fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { // Ensure we write the expected bytes for i in 0..core::cmp::min(read.len(), write.len()) { read[i] = write[i].clone(); @@ -83,38 +97,7 @@ where Ok(()) } - async fn transfer_in_place<'a>(&'a mut self, _: &'a mut [u8]) -> Result<(), Self::Error> { - todo!() - } -} - -impl embedded_hal_async::spi::SpiBusFlush for BlockingAsync -where - E: embedded_hal_1::spi::Error + 'static, - T: blocking::spi::Transfer + blocking::spi::Write, -{ - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } -} - -impl embedded_hal_async::spi::SpiBusWrite for BlockingAsync -where - E: embedded_hal_1::spi::Error + 'static, - T: blocking::spi::Transfer + blocking::spi::Write, -{ - async fn write(&mut self, data: &[u8]) -> Result<(), Self::Error> { - self.wrapped.write(data)?; - Ok(()) - } -} - -impl embedded_hal_async::spi::SpiBusRead for BlockingAsync -where - E: embedded_hal_1::spi::Error + 'static, - T: blocking::spi::Transfer + blocking::spi::Write, -{ - async fn read(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { + async fn transfer_in_place(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { self.wrapped.transfer(data)?; Ok(()) } diff --git a/embassy-embedded-hal/src/adapter/yielding_async.rs b/embassy-embedded-hal/src/adapter/yielding_async.rs index f51e4076..fe9c9c34 100644 --- a/embassy-embedded-hal/src/adapter/yielding_async.rs +++ b/embassy-embedded-hal/src/adapter/yielding_async.rs @@ -69,54 +69,39 @@ where type Error = T::Error; } -impl embedded_hal_async::spi::SpiBus for YieldingAsync +impl embedded_hal_async::spi::SpiBus for YieldingAsync where - T: embedded_hal_async::spi::SpiBus, -{ - async fn transfer<'a>(&'a mut self, read: &'a mut [u8], write: &'a [u8]) -> Result<(), Self::Error> { - self.wrapped.transfer(read, write).await?; - yield_now().await; - Ok(()) - } - - async fn transfer_in_place<'a>(&'a mut self, words: &'a mut [u8]) -> Result<(), Self::Error> { - self.wrapped.transfer_in_place(words).await?; - yield_now().await; - Ok(()) - } -} - -impl embedded_hal_async::spi::SpiBusFlush for YieldingAsync -where - T: embedded_hal_async::spi::SpiBusFlush, + T: embedded_hal_async::spi::SpiBus, { async fn flush(&mut self) -> Result<(), Self::Error> { self.wrapped.flush().await?; yield_now().await; Ok(()) } -} -impl embedded_hal_async::spi::SpiBusWrite for YieldingAsync -where - T: embedded_hal_async::spi::SpiBusWrite, -{ - async fn write(&mut self, data: &[u8]) -> Result<(), Self::Error> { + async fn write(&mut self, data: &[Word]) -> Result<(), Self::Error> { self.wrapped.write(data).await?; yield_now().await; Ok(()) } -} -impl embedded_hal_async::spi::SpiBusRead for YieldingAsync -where - T: embedded_hal_async::spi::SpiBusRead, -{ - async fn read(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { + async fn read(&mut self, data: &mut [Word]) -> Result<(), Self::Error> { self.wrapped.read(data).await?; yield_now().await; Ok(()) } + + async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), Self::Error> { + self.wrapped.transfer(read, write).await?; + yield_now().await; + Ok(()) + } + + async fn transfer_in_place(&mut self, words: &mut [Word]) -> Result<(), Self::Error> { + self.wrapped.transfer_in_place(words).await?; + yield_now().await; + Ok(()) + } } /// diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index b5549a6c..03039218 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs @@ -56,62 +56,6 @@ where type Error = SpiDeviceError; } -impl spi::SpiDeviceRead for SpiDevice<'_, M, BUS, CS> -where - M: RawMutex, - BUS: spi::SpiBusRead, - CS: OutputPin, -{ - async fn read_transaction(&mut self, operations: &mut [&mut [u8]]) -> Result<(), Self::Error> { - let mut bus = self.bus.lock().await; - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res: Result<(), BUS::Error> = try { - for buf in operations { - bus.read(buf).await?; - } - }; - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush().await; - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - - Ok(op_res) - } -} - -impl spi::SpiDeviceWrite for SpiDevice<'_, M, BUS, CS> -where - M: RawMutex, - BUS: spi::SpiBusWrite, - CS: OutputPin, -{ - async fn write_transaction(&mut self, operations: &[&[u8]]) -> Result<(), Self::Error> { - let mut bus = self.bus.lock().await; - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res: Result<(), BUS::Error> = try { - for buf in operations { - bus.write(buf).await?; - } - }; - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush().await; - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - - Ok(op_res) - } -} - impl spi::SpiDevice for SpiDevice<'_, M, BUS, CS> where M: RawMutex, @@ -129,6 +73,12 @@ where Operation::Write(buf) => bus.write(buf).await?, Operation::Transfer(read, write) => bus.transfer(read, write).await?, Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await?, + #[cfg(not(feature = "time"))] + Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported), + #[cfg(feature = "time")] + Operation::DelayUs(us) => { + embassy_time::Timer::after(embassy_time::Duration::from_micros(*us as _)).await + } } } }; @@ -172,64 +122,6 @@ where type Error = SpiDeviceError; } -impl spi::SpiDeviceWrite for SpiDeviceWithConfig<'_, M, BUS, CS> -where - M: RawMutex, - BUS: spi::SpiBusWrite + SetConfig, - CS: OutputPin, -{ - async fn write_transaction(&mut self, operations: &[&[u8]]) -> Result<(), Self::Error> { - let mut bus = self.bus.lock().await; - bus.set_config(&self.config); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res: Result<(), BUS::Error> = try { - for buf in operations { - bus.write(buf).await?; - } - }; - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush().await; - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - - Ok(op_res) - } -} - -impl spi::SpiDeviceRead for SpiDeviceWithConfig<'_, M, BUS, CS> -where - M: RawMutex, - BUS: spi::SpiBusRead + SetConfig, - CS: OutputPin, -{ - async fn read_transaction(&mut self, operations: &mut [&mut [u8]]) -> Result<(), Self::Error> { - let mut bus = self.bus.lock().await; - bus.set_config(&self.config); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res: Result<(), BUS::Error> = try { - for buf in operations { - bus.read(buf).await?; - } - }; - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush().await; - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - - Ok(op_res) - } -} - impl spi::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS> where M: RawMutex, @@ -248,6 +140,12 @@ where Operation::Write(buf) => bus.write(buf).await?, Operation::Transfer(read, write) => bus.transfer(read, write).await?, Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await?, + #[cfg(not(feature = "time"))] + Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported), + #[cfg(feature = "time")] + Operation::DelayUs(us) => { + embassy_time::Timer::after(embassy_time::Duration::from_micros(*us as _)).await + } } } }; diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index 22e013be..6d03d626 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs @@ -22,7 +22,7 @@ use core::cell::RefCell; use embassy_sync::blocking_mutex::raw::RawMutex; use embassy_sync::blocking_mutex::Mutex; use embedded_hal_1::digital::OutputPin; -use embedded_hal_1::spi::{self, Operation, SpiBus, SpiBusRead, SpiBusWrite}; +use embedded_hal_1::spi::{self, Operation, SpiBus}; use crate::shared_bus::SpiDeviceError; use crate::SetConfig; @@ -48,58 +48,6 @@ where type Error = SpiDeviceError; } -impl embedded_hal_1::spi::SpiDeviceRead for SpiDevice<'_, M, BUS, CS> -where - M: RawMutex, - BUS: SpiBusRead, - CS: OutputPin, -{ - fn read_transaction(&mut self, operations: &mut [&mut [u8]]) -> Result<(), Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res = operations.iter_mut().try_for_each(|buf| bus.read(buf)); - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush(); - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - - Ok(op_res) - }) - } -} - -impl embedded_hal_1::spi::SpiDeviceWrite for SpiDevice<'_, M, BUS, CS> -where - M: RawMutex, - BUS: SpiBusWrite, - CS: OutputPin, -{ - fn write_transaction(&mut self, operations: &[&[u8]]) -> Result<(), Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res = operations.iter().try_for_each(|buf| bus.write(buf)); - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush(); - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - - Ok(op_res) - }) - } -} - impl embedded_hal_1::spi::SpiDevice for SpiDevice<'_, M, BUS, CS> where M: RawMutex, @@ -116,6 +64,13 @@ where Operation::Write(buf) => bus.write(buf), Operation::Transfer(read, write) => bus.transfer(read, write), Operation::TransferInPlace(buf) => bus.transfer_in_place(buf), + #[cfg(not(feature = "time"))] + Operation::DelayUs(_) => Err(SpiDeviceError::DelayUsNotSupported), + #[cfg(feature = "time")] + Operation::DelayUs(us) => { + embassy_time::block_for(embassy_time::Duration::from_micros(*us as _)); + Ok(()) + } }); // On failure, it's important to still flush and deassert CS. @@ -199,58 +154,6 @@ where type Error = SpiDeviceError; } -impl embedded_hal_1::spi::SpiDeviceRead for SpiDeviceWithConfig<'_, M, BUS, CS> -where - M: RawMutex, - BUS: SpiBusRead + SetConfig, - CS: OutputPin, -{ - fn read_transaction(&mut self, operations: &mut [&mut [u8]]) -> Result<(), Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - bus.set_config(&self.config); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res = operations.iter_mut().try_for_each(|buf| bus.read(buf)); - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush(); - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - Ok(op_res) - }) - } -} - -impl embedded_hal_1::spi::SpiDeviceWrite for SpiDeviceWithConfig<'_, M, BUS, CS> -where - M: RawMutex, - BUS: SpiBusWrite + SetConfig, - CS: OutputPin, -{ - fn write_transaction(&mut self, operations: &[&[u8]]) -> Result<(), Self::Error> { - self.bus.lock(|bus| { - let mut bus = bus.borrow_mut(); - bus.set_config(&self.config); - self.cs.set_low().map_err(SpiDeviceError::Cs)?; - - let op_res = operations.iter().try_for_each(|buf| bus.write(buf)); - - // On failure, it's important to still flush and deassert CS. - let flush_res = bus.flush(); - let cs_res = self.cs.set_high(); - - let op_res = op_res.map_err(SpiDeviceError::Spi)?; - flush_res.map_err(SpiDeviceError::Spi)?; - cs_res.map_err(SpiDeviceError::Cs)?; - Ok(op_res) - }) - } -} - impl embedded_hal_1::spi::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS> where M: RawMutex, @@ -268,6 +171,13 @@ where Operation::Write(buf) => bus.write(buf), Operation::Transfer(read, write) => bus.transfer(read, write), Operation::TransferInPlace(buf) => bus.transfer_in_place(buf), + #[cfg(not(feature = "time"))] + Operation::DelayUs(_) => Err(SpiDeviceError::DelayUsNotSupported), + #[cfg(feature = "time")] + Operation::DelayUs(us) => { + embassy_time::block_for(embassy_time::Duration::from_micros(*us as _)); + Ok(()) + } }); // On failure, it's important to still flush and deassert CS. diff --git a/embassy-embedded-hal/src/shared_bus/mod.rs b/embassy-embedded-hal/src/shared_bus/mod.rs index 617d921e..79a90bd5 100644 --- a/embassy-embedded-hal/src/shared_bus/mod.rs +++ b/embassy-embedded-hal/src/shared_bus/mod.rs @@ -30,11 +30,14 @@ where /// Error returned by SPI device implementations in this crate. #[derive(Copy, Clone, Eq, PartialEq, Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[non_exhaustive] pub enum SpiDeviceError { /// An operation on the inner SPI bus failed. Spi(BUS), /// Setting the value of the Chip Select (CS) pin failed. Cs(CS), + /// DelayUs operations are not supported when the `time` Cargo feature is not enabled. + DelayUsNotSupported, } impl spi::Error for SpiDeviceError @@ -46,6 +49,7 @@ where match self { Self::Spi(e) => e.kind(), Self::Cs(_) => spi::ErrorKind::Other, + Self::DelayUsNotSupported => spi::ErrorKind::Other, } } } diff --git a/embassy-hal-common/src/peripheral.rs b/embassy-hal-common/src/peripheral.rs index c7133bac..38b4c452 100644 --- a/embassy-hal-common/src/peripheral.rs +++ b/embassy-hal-common/src/peripheral.rs @@ -161,7 +161,7 @@ pub trait Peripheral: Sized { } } -impl<'b, T: Deref> Peripheral for T +impl<'b, T: DerefMut> Peripheral for T where T::Target: Peripheral, { diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml index 05b6fa2d..dc44f96d 100644 --- a/embassy-lora/Cargo.toml +++ b/embassy-lora/Cargo.toml @@ -23,8 +23,8 @@ log = { version = "0.4.14", optional = true } embassy-time = { version = "0.1.0", path = "../embassy-time" } embassy-sync = { version = "0.2.0", path = "../embassy-sync" } embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common", default-features = false } futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } embedded-hal = { version = "0.2", features = ["unproven"] } @@ -32,3 +32,6 @@ bit_field = { version = "0.10" } lora-phy = { version = "1" } lorawan-device = { version = "0.10.0", default-features = false, features = ["async"] } + +[patch.crates-io] +lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "ad289428fd44b02788e2fa2116445cc8f640a265" } diff --git a/embassy-net-esp-hosted/Cargo.toml b/embassy-net-esp-hosted/Cargo.toml index a7e18ee0..a52570f5 100644 --- a/embassy-net-esp-hosted/Cargo.toml +++ b/embassy-net-esp-hosted/Cargo.toml @@ -12,8 +12,8 @@ embassy-sync = { version = "0.2.0", path = "../embassy-sync"} embassy-futures = { version = "0.1.0", path = "../embassy-futures"} embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel"} -embedded-hal = { version = "1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal = { version = "1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } noproto = { git="https://github.com/embassy-rs/noproto", default-features = false, features = ["derive"] } #noproto = { version = "0.1", path = "/home/dirbaio/noproto", default-features = false, features = ["derive"] } diff --git a/embassy-net-esp-hosted/src/control.rs b/embassy-net-esp-hosted/src/control.rs index fce82ade..79f8cde7 100644 --- a/embassy-net-esp-hosted/src/control.rs +++ b/embassy-net-esp-hosted/src/control.rs @@ -54,7 +54,9 @@ impl<'a> Control<'a> { })), }; let resp = self.ioctl(req).await; - let proto::CtrlMsgPayload::RespConnectAp(resp) = resp.payload.unwrap() else { panic!("unexpected resp") }; + let proto::CtrlMsgPayload::RespConnectAp(resp) = resp.payload.unwrap() else { + panic!("unexpected resp") + }; debug!("======= {:?}", Debug2Format(&resp)); assert_eq!(resp.resp, 0); self.state_ch.set_link_state(LinkState::Up); @@ -71,7 +73,9 @@ impl<'a> Control<'a> { )), }; let resp = self.ioctl(req).await; - let proto::CtrlMsgPayload::RespGetMacAddress(resp) = resp.payload.unwrap() else { panic!("unexpected resp") }; + let proto::CtrlMsgPayload::RespGetMacAddress(resp) = resp.payload.unwrap() else { + panic!("unexpected resp") + }; assert_eq!(resp.resp, 0); // WHY IS THIS A STRING? WHYYYY @@ -100,7 +104,9 @@ impl<'a> Control<'a> { payload: Some(proto::CtrlMsgPayload::ReqSetWifiMode(proto::CtrlMsgReqSetMode { mode })), }; let resp = self.ioctl(req).await; - let proto::CtrlMsgPayload::RespSetWifiMode(resp) = resp.payload.unwrap() else { panic!("unexpected resp") }; + let proto::CtrlMsgPayload::RespSetWifiMode(resp) = resp.payload.unwrap() else { + panic!("unexpected resp") + }; assert_eq!(resp.resp, 0); } diff --git a/embassy-net-esp-hosted/src/lib.rs b/embassy-net-esp-hosted/src/lib.rs index 44dfbe89..a35adfca 100644 --- a/embassy-net-esp-hosted/src/lib.rs +++ b/embassy-net-esp-hosted/src/lib.rs @@ -311,14 +311,14 @@ where fn handle_event(&self, data: &[u8]) { let Ok(event) = noproto::read::(data) else { warn!("failed to parse event"); - return + return; }; debug!("event: {:?}", &event); let Some(payload) = &event.payload else { warn!("event without payload?"); - return + return; }; match payload { diff --git a/embassy-net-w5500/Cargo.toml b/embassy-net-w5500/Cargo.toml index 37d15c7a..41d41111 100644 --- a/embassy-net-w5500/Cargo.toml +++ b/embassy-net-w5500/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0" edition = "2021" [dependencies] -embedded-hal = { version = "1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal = { version = "1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel"} embassy-time = { version = "0.1.0" } embassy-futures = { version = "0.1.0" } diff --git a/embassy-net-w5500/src/spi.rs b/embassy-net-w5500/src/spi.rs index 6cd52c44..07749d6b 100644 --- a/embassy-net-w5500/src/spi.rs +++ b/embassy-net-w5500/src/spi.rs @@ -22,7 +22,11 @@ impl SpiInterface { let address_phase = address.to_be_bytes(); let control_phase = [(block as u8) << 3 | 0b0000_0100]; let data_phase = data; - let operations = &[&address_phase[..], &control_phase, &data_phase]; - self.0.write_transaction(operations).await + let operations = &mut [ + Operation::Write(&address_phase[..]), + Operation::Write(&control_phase), + Operation::Write(&data_phase), + ]; + self.0.transaction(operations).await } } diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 3e858f85..ae76af3e 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-nrf-v$VERSION/embassy-nrf/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-nrf/src/" -features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "gpiote", "time-driver-rtc1"] +features = ["nightly", "time", "defmt", "unstable-pac", "unstable-traits", "gpiote", "time-driver-rtc1"] flavors = [ { regex_feature = "nrf52.*", target = "thumbv7em-none-eabihf" }, { regex_feature = "nrf53.*", target = "thumbv8m.main-none-eabihf" }, @@ -98,8 +98,8 @@ embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional=true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10", optional = true} -embedded-hal-async = { version = "=0.2.0-alpha.1", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11", optional = true} +embedded-hal-async = { version = "=0.2.0-alpha.2", optional = true} embedded-io = { version = "0.4.0", features = ["async"], optional = true } defmt = { version = "0.3", optional = true } diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index 66bbd1a8..b7dc332e 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs @@ -468,25 +468,19 @@ mod eh1 { type Error = Error; } - impl<'d, T: Instance> embedded_hal_1::spi::SpiBusFlush for Spim<'d, T> { + impl<'d, T: Instance> embedded_hal_1::spi::SpiBus for Spim<'d, T> { fn flush(&mut self) -> Result<(), Self::Error> { Ok(()) } - } - impl<'d, T: Instance> embedded_hal_1::spi::SpiBusRead for Spim<'d, T> { fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { self.blocking_transfer(words, &[]) } - } - impl<'d, T: Instance> embedded_hal_1::spi::SpiBusWrite for Spim<'d, T> { fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { self.blocking_write(words) } - } - impl<'d, T: Instance> embedded_hal_1::spi::SpiBus for Spim<'d, T> { fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { self.blocking_transfer(read, write) } @@ -502,25 +496,19 @@ mod eha { use super::*; - impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spim<'d, T> { + impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spim<'d, T> { async fn flush(&mut self) -> Result<(), Error> { Ok(()) } - } - impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead for Spim<'d, T> { async fn read(&mut self, words: &mut [u8]) -> Result<(), Error> { self.read(words).await } - } - impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite for Spim<'d, T> { async fn write(&mut self, data: &[u8]) -> Result<(), Error> { self.write(data).await } - } - impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spim<'d, T> { async fn transfer(&mut self, rx: &mut [u8], tx: &[u8]) -> Result<(), Error> { self.transfer(rx, tx).await } diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 66823771..a06831a9 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -79,9 +79,9 @@ fixed = "1.23.1" rp-pac = { version = "6" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10", optional = true} -embedded-hal-async = { version = "=0.2.0-alpha.1", optional = true} -embedded-hal-nb = { version = "=1.0.0-alpha.2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11", optional = true} +embedded-hal-async = { version = "=0.2.0-alpha.2", optional = true} +embedded-hal-nb = { version = "=1.0.0-alpha.3", optional = true} paste = "1.0" pio-proc = {version= "0.2" } diff --git a/embassy-rp/src/spi.rs b/embassy-rp/src/spi.rs index e817d074..af101cf4 100644 --- a/embassy-rp/src/spi.rs +++ b/embassy-rp/src/spi.rs @@ -545,25 +545,19 @@ mod eh1 { type Error = Error; } - impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBusFlush for Spi<'d, T, M> { + impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBus for Spi<'d, T, M> { fn flush(&mut self) -> Result<(), Self::Error> { Ok(()) } - } - impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBusRead for Spi<'d, T, M> { fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { self.blocking_transfer(words, &[]) } - } - impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBusWrite for Spi<'d, T, M> { fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { self.blocking_write(words) } - } - impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBus for Spi<'d, T, M> { fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { self.blocking_transfer(read, write) } @@ -578,30 +572,24 @@ mod eh1 { mod eha { use super::*; - impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spi<'d, T, Async> { + impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spi<'d, T, Async> { async fn flush(&mut self) -> Result<(), Self::Error> { Ok(()) } - } - impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite for Spi<'d, T, Async> { async fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { self.write(words).await } - } - impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead for Spi<'d, T, Async> { async fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { self.read(words).await } - } - impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spi<'d, T, Async> { - async fn transfer<'a>(&'a mut self, read: &'a mut [u8], write: &'a [u8]) -> Result<(), Self::Error> { + async fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { self.transfer(read, write).await } - async fn transfer_in_place<'a>(&'a mut self, words: &'a mut [u8]) -> Result<(), Self::Error> { + async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { self.transfer_in_place(words).await } } diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index b3fe9c1f..04514963 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -40,9 +40,9 @@ embassy-net-driver = { version = "0.1.0", path = "../embassy-net-driver" } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10", optional = true} -embedded-hal-async = { version = "=0.2.0-alpha.1", optional = true} -embedded-hal-nb = { version = "=1.0.0-alpha.2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11", optional = true} +embedded-hal-async = { version = "=0.2.0-alpha.2", optional = true} +embedded-hal-nb = { version = "=1.0.0-alpha.3", optional = true} embedded-storage = "0.3.0" embedded-storage-async = { version = "0.4.0", optional = true } diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index fa66da1f..995ad144 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -348,9 +348,7 @@ fn main() { g.extend(quote! { impl crate::rcc::sealed::RccPeripheral for peripherals::#pname { fn frequency() -> crate::time::Hertz { - critical_section::with(|_| unsafe { - crate::rcc::get_freqs().#clk - }) + unsafe { crate::rcc::get_freqs().#clk } } fn enable() { critical_section::with(|_| { diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs index 1dc13949..31a2d886 100644 --- a/embassy-stm32/src/dac/mod.rs +++ b/embassy-stm32/src/dac/mod.rs @@ -264,7 +264,7 @@ impl<'d, T: Instance, Tx> DacCh1<'d, T, Tx> { }); let tx_request = self.dma.request(); - let dma_channel = &self.dma; + let dma_channel = &mut self.dma; let tx_options = crate::dma::TransferOptions { circular, @@ -376,7 +376,7 @@ impl<'d, T: Instance, Tx> DacCh2<'d, T, Tx> { }); let tx_request = self.dma.request(); - let dma_channel = &self.dma; + let dma_channel = &mut self.dma; let tx_options = crate::dma::TransferOptions { circular, diff --git a/embassy-stm32/src/fmc.rs b/embassy-stm32/src/fmc.rs index a4f3b968..60d7a00e 100644 --- a/embassy-stm32/src/fmc.rs +++ b/embassy-stm32/src/fmc.rs @@ -86,6 +86,24 @@ macro_rules! fmc_sdram_constructor { } impl<'d, T: Instance> Fmc<'d, T> { + fmc_sdram_constructor!(sdram_a12bits_d16bits_4banks_bank1: ( + bank: stm32_fmc::SdramTargetBank::Bank1, + addr: [ + (a0: A0Pin), (a1: A1Pin), (a2: A2Pin), (a3: A3Pin), (a4: A4Pin), (a5: A5Pin), (a6: A6Pin), (a7: A7Pin), (a8: A8Pin), (a9: A9Pin), (a10: A10Pin), (a11: A11Pin) + ], + ba: [(ba0: BA0Pin), (ba1: BA1Pin)], + d: [ + (d0: D0Pin), (d1: D1Pin), (d2: D2Pin), (d3: D3Pin), (d4: D4Pin), (d5: D5Pin), (d6: D6Pin), (d7: D7Pin), + (d8: D8Pin), (d9: D9Pin), (d10: D10Pin), (d11: D11Pin), (d12: D12Pin), (d13: D13Pin), (d14: D14Pin), (d15: D15Pin) + ], + nbl: [ + (nbl0: NBL0Pin), (nbl1: NBL1Pin) + ], + ctrl: [ + (sdcke: SDCKE0Pin), (sdclk: SDCLKPin), (sdncas: SDNCASPin), (sdne: SDNE0Pin), (sdnras: SDNRASPin), (sdnwe: SDNWEPin) + ] + )); + fmc_sdram_constructor!(sdram_a12bits_d32bits_4banks_bank1: ( bank: stm32_fmc::SdramTargetBank::Bank1, addr: [ diff --git a/embassy-stm32/src/rcc/h5.rs b/embassy-stm32/src/rcc/h5.rs index 4025a4e0..7e2f75ab 100644 --- a/embassy-stm32/src/rcc/h5.rs +++ b/embassy-stm32/src/rcc/h5.rs @@ -473,11 +473,11 @@ fn init_pll(num: usize, config: Option, input: &PllInput) -> PllOutput { w.set_divm(0); }); - return PllOutput{ + return PllOutput { p: None, q: None, r: None, - } + }; }; assert!(1 <= config.prediv && config.prediv <= 63); diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index d6816d6a..886fc0b9 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs @@ -83,12 +83,12 @@ static mut CLOCK_FREQS: MaybeUninit = MaybeUninit::uninit(); /// Safety: Sets a mutable global. pub(crate) unsafe fn set_freqs(freqs: Clocks) { debug!("rcc: {:?}", freqs); - CLOCK_FREQS.as_mut_ptr().write(freqs); + CLOCK_FREQS = MaybeUninit::new(freqs); } /// Safety: Reads a mutable global. pub(crate) unsafe fn get_freqs() -> &'static Clocks { - &*CLOCK_FREQS.as_ptr() + CLOCK_FREQS.assume_init_ref() } #[cfg(feature = "unstable-pac")] diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index c3224073..d5f63f84 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs @@ -852,25 +852,19 @@ mod eh1 { type Error = Error; } - impl<'d, T: Instance, Tx, Rx> embedded_hal_1::spi::SpiBusFlush for Spi<'d, T, Tx, Rx> { + impl<'d, T: Instance, W: Word, Tx, Rx> embedded_hal_1::spi::SpiBus for Spi<'d, T, Tx, Rx> { fn flush(&mut self) -> Result<(), Self::Error> { Ok(()) } - } - impl<'d, T: Instance, W: Word, Tx, Rx> embedded_hal_1::spi::SpiBusRead for Spi<'d, T, Tx, Rx> { fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> { self.blocking_read(words) } - } - impl<'d, T: Instance, W: Word, Tx, Rx> embedded_hal_1::spi::SpiBusWrite for Spi<'d, T, Tx, Rx> { fn write(&mut self, words: &[W]) -> Result<(), Self::Error> { self.blocking_write(words) } - } - impl<'d, T: Instance, W: Word, Tx, Rx> embedded_hal_1::spi::SpiBus for Spi<'d, T, Tx, Rx> { fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> { self.blocking_transfer(read, write) } @@ -895,32 +889,25 @@ mod eh1 { #[cfg(all(feature = "unstable-traits", feature = "nightly"))] mod eha { use super::*; - impl<'d, T: Instance, Tx, Rx> embedded_hal_async::spi::SpiBusFlush for Spi<'d, T, Tx, Rx> { + + impl<'d, T: Instance, Tx: TxDma, Rx: RxDma, W: Word> embedded_hal_async::spi::SpiBus for Spi<'d, T, Tx, Rx> { async fn flush(&mut self) -> Result<(), Self::Error> { Ok(()) } - } - impl<'d, T: Instance, Tx: TxDma, Rx, W: Word> embedded_hal_async::spi::SpiBusWrite for Spi<'d, T, Tx, Rx> { async fn write(&mut self, words: &[W]) -> Result<(), Self::Error> { self.write(words).await } - } - impl<'d, T: Instance, Tx: TxDma, Rx: RxDma, W: Word> embedded_hal_async::spi::SpiBusRead - for Spi<'d, T, Tx, Rx> - { async fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> { self.read(words).await } - } - impl<'d, T: Instance, Tx: TxDma, Rx: RxDma, W: Word> embedded_hal_async::spi::SpiBus for Spi<'d, T, Tx, Rx> { - async fn transfer<'a>(&'a mut self, read: &'a mut [W], write: &'a [W]) -> Result<(), Self::Error> { + async fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> { self.transfer(read, write).await } - async fn transfer_in_place<'a>(&'a mut self, words: &'a mut [W]) -> Result<(), Self::Error> { + async fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error> { self.transfer_in_place(words).await } } diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index 857da546..0213eef0 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml @@ -152,8 +152,8 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10", optional = true} -embedded-hal-async = { version = "=0.2.0-alpha.1", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11", optional = true} +embedded-hal-async = { version = "=0.2.0-alpha.2", optional = true} futures-util = { version = "0.3.17", default-features = false } atomic-polyfill = "1.0.1" diff --git a/embassy-time/src/queue_generic.rs b/embassy-time/src/queue_generic.rs index 4795eb2f..77947ab2 100644 --- a/embassy-time/src/queue_generic.rs +++ b/embassy-time/src/queue_generic.rs @@ -16,7 +16,7 @@ const QUEUE_SIZE: usize = 16; #[cfg(feature = "generic-queue-32")] const QUEUE_SIZE: usize = 32; #[cfg(feature = "generic-queue-64")] -const QUEUE_SIZE: usize = 32; +const QUEUE_SIZE: usize = 64; #[cfg(feature = "generic-queue-128")] const QUEUE_SIZE: usize = 128; #[cfg(not(any( diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index 8c417596..2ccd5045 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -52,4 +52,7 @@ rand = { version = "0.8.4", default-features = false } embedded-storage = "0.3.0" usbd-hid = "0.6.0" serde = { version = "1.0.136", default-features = false } -embedded-hal-async = { version = "0.2.0-alpha.1", optional = true } +embedded-hal-async = { version = "0.2.0-alpha.2", optional = true } + +[patch.crates-io] +lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "ad289428fd44b02788e2fa2116445cc8f640a265" } diff --git a/examples/nrf52840/src/bin/wifi_esp_hosted.rs b/examples/nrf52840/src/bin/wifi_esp_hosted.rs index 4eb31b10..f7496703 100644 --- a/examples/nrf52840/src/bin/wifi_esp_hosted.rs +++ b/examples/nrf52840/src/bin/wifi_esp_hosted.rs @@ -10,6 +10,7 @@ use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; use embassy_nrf::rng::Rng; use embassy_nrf::spim::{self, Spim}; use embassy_nrf::{bind_interrupts, peripherals}; +use embassy_time::Delay; use embedded_hal_async::spi::ExclusiveDevice; use embedded_io::asynch::Write; use static_cell::make_static; @@ -24,7 +25,7 @@ bind_interrupts!(struct Irqs { async fn wifi_task( runner: hosted::Runner< 'static, - ExclusiveDevice, Output<'static, peripherals::P0_31>>, + ExclusiveDevice, Output<'static, peripherals::P0_31>, Delay>, Input<'static, AnyPin>, Output<'static, peripherals::P1_05>, >, @@ -55,7 +56,7 @@ async fn main(spawner: Spawner) { config.frequency = spim::Frequency::M32; config.mode = spim::MODE_2; // !!! let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); - let spi = ExclusiveDevice::new(spi, cs); + let spi = ExclusiveDevice::new(spi, cs, Delay); let (device, mut control, runner) = embassy_net_esp_hosted::new( make_static!(embassy_net_esp_hosted::State::new()), diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 48f3a26b..17ebea86 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -41,8 +41,8 @@ byte-slice-cast = { version = "1.2.0", default-features = false } smart-leds = "0.3.0" heapless = "0.7.15" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = "0.2.0-alpha.1" +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = "0.2.0-alpha.2" embedded-io = { version = "0.4.0", features = ["async", "defmt"] } embedded-storage = { version = "0.3" } static_cell = { version = "1.1", features = ["nightly"]} @@ -53,3 +53,6 @@ rand = { version = "0.8.5", default-features = false } [profile.release] debug = true + +[patch.crates-io] +lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "ad289428fd44b02788e2fa2116445cc8f640a265" } diff --git a/examples/rp/src/bin/ethernet_w5500_multisocket.rs b/examples/rp/src/bin/ethernet_w5500_multisocket.rs index 82568254..e81da177 100644 --- a/examples/rp/src/bin/ethernet_w5500_multisocket.rs +++ b/examples/rp/src/bin/ethernet_w5500_multisocket.rs @@ -15,7 +15,7 @@ use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; -use embassy_time::Duration; +use embassy_time::{Delay, Duration}; use embedded_hal_async::spi::ExclusiveDevice; use embedded_io::asynch::Write; use rand::RngCore; @@ -26,7 +26,7 @@ use {defmt_rtt as _, panic_probe as _}; async fn ethernet_task( runner: Runner< 'static, - ExclusiveDevice, Output<'static, PIN_17>>, + ExclusiveDevice, Output<'static, PIN_17>, Delay>, Input<'static, PIN_21>, Output<'static, PIN_20>, >, @@ -54,8 +54,14 @@ async fn main(spawner: Spawner) { let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; let state = make_static!(State::<8, 8>::new()); - let (device, runner) = - embassy_net_w5500::new(mac_addr, state, ExclusiveDevice::new(spi, cs), w5500_int, w5500_reset).await; + let (device, runner) = embassy_net_w5500::new( + mac_addr, + state, + ExclusiveDevice::new(spi, cs, Delay), + w5500_int, + w5500_reset, + ) + .await; unwrap!(spawner.spawn(ethernet_task(runner))); // Generate random seed diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs index d562defa..9dd7ae97 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs @@ -17,7 +17,7 @@ use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; -use embassy_time::{Duration, Timer}; +use embassy_time::{Delay, Duration, Timer}; use embedded_hal_async::spi::ExclusiveDevice; use embedded_io::asynch::Write; use rand::RngCore; @@ -28,7 +28,7 @@ use {defmt_rtt as _, panic_probe as _}; async fn ethernet_task( runner: Runner< 'static, - ExclusiveDevice, Output<'static, PIN_17>>, + ExclusiveDevice, Output<'static, PIN_17>, Delay>, Input<'static, PIN_21>, Output<'static, PIN_20>, >, @@ -57,8 +57,14 @@ async fn main(spawner: Spawner) { let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; let state = make_static!(State::<8, 8>::new()); - let (device, runner) = - embassy_net_w5500::new(mac_addr, state, ExclusiveDevice::new(spi, cs), w5500_int, w5500_reset).await; + let (device, runner) = embassy_net_w5500::new( + mac_addr, + state, + ExclusiveDevice::new(spi, cs, Delay), + w5500_int, + w5500_reset, + ) + .await; unwrap!(spawner.spawn(ethernet_task(runner))); // Generate random seed diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs index 7f521cdb..db21c2b6 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs @@ -16,7 +16,7 @@ use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; -use embassy_time::Duration; +use embassy_time::{Delay, Duration}; use embedded_hal_async::spi::ExclusiveDevice; use embedded_io::asynch::Write; use rand::RngCore; @@ -26,7 +26,7 @@ use {defmt_rtt as _, panic_probe as _}; async fn ethernet_task( runner: Runner< 'static, - ExclusiveDevice, Output<'static, PIN_17>>, + ExclusiveDevice, Output<'static, PIN_17>, Delay>, Input<'static, PIN_21>, Output<'static, PIN_20>, >, @@ -55,8 +55,14 @@ async fn main(spawner: Spawner) { let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; let state = make_static!(State::<8, 8>::new()); - let (device, runner) = - embassy_net_w5500::new(mac_addr, state, ExclusiveDevice::new(spi, cs), w5500_int, w5500_reset).await; + let (device, runner) = embassy_net_w5500::new( + mac_addr, + state, + ExclusiveDevice::new(spi, cs, Delay), + w5500_int, + w5500_reset, + ) + .await; unwrap!(spawner.spawn(ethernet_task(runner))); // Generate random seed diff --git a/examples/rp/src/bin/ethernet_w5500_udp.rs b/examples/rp/src/bin/ethernet_w5500_udp.rs index ada86ae5..038432b1 100644 --- a/examples/rp/src/bin/ethernet_w5500_udp.rs +++ b/examples/rp/src/bin/ethernet_w5500_udp.rs @@ -16,6 +16,7 @@ use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; +use embassy_time::Delay; use embedded_hal_async::spi::ExclusiveDevice; use rand::RngCore; use static_cell::make_static; @@ -24,7 +25,7 @@ use {defmt_rtt as _, panic_probe as _}; async fn ethernet_task( runner: Runner< 'static, - ExclusiveDevice, Output<'static, PIN_17>>, + ExclusiveDevice, Output<'static, PIN_17>, Delay>, Input<'static, PIN_21>, Output<'static, PIN_20>, >, @@ -52,8 +53,14 @@ async fn main(spawner: Spawner) { let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; let state = make_static!(State::<8, 8>::new()); - let (device, runner) = - embassy_net_w5500::new(mac_addr, state, ExclusiveDevice::new(spi, cs), w5500_int, w5500_reset).await; + let (device, runner) = embassy_net_w5500::new( + mac_addr, + state, + ExclusiveDevice::new(spi, cs, Delay), + w5500_int, + w5500_reset, + ) + .await; unwrap!(spawner.spawn(ethernet_task(runner))); // Generate random seed diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index 85a19ce0..2fd20159 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -175,7 +175,7 @@ mod touch { mod my_display_interface { use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; use embedded_hal_1::digital::OutputPin; - use embedded_hal_1::spi::SpiDeviceWrite; + use embedded_hal_1::spi::SpiDevice; /// SPI display interface. /// @@ -187,7 +187,7 @@ mod my_display_interface { impl SPIDeviceInterface where - SPI: SpiDeviceWrite, + SPI: SpiDevice, DC: OutputPin, { /// Create new SPI interface for communciation with a display driver @@ -198,7 +198,7 @@ mod my_display_interface { impl WriteOnlyDataCommand for SPIDeviceInterface where - SPI: SpiDeviceWrite, + SPI: SpiDevice, DC: OutputPin, { fn send_commands(&mut self, cmds: DataFormat<'_>) -> Result<(), DisplayError> { @@ -218,7 +218,7 @@ mod my_display_interface { } } - fn send_u8(spi: &mut T, words: DataFormat<'_>) -> Result<(), T::Error> { + fn send_u8(spi: &mut T, words: DataFormat<'_>) -> Result<(), T::Error> { match words { DataFormat::U8(slice) => spi.write(slice), DataFormat::U16(slice) => { diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index ebe51134..789ef59c 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml @@ -19,8 +19,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } embedded-nal-async = "0.4.0" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 62ef5e9e..04a2baab 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -19,8 +19,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } embedded-nal-async = "0.4.0" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 2ead714e..988fd3a7 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -32,3 +32,6 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa heapless = { version = "0.7.5", default-features = false } embedded-hal = "0.2.6" static_cell = "1.1" + +[patch.crates-io] +lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "ad289428fd44b02788e2fa2116445cc8f640a265" } diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 780256cc..dca052c2 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -18,10 +18,11 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.7.5", default-features = false } +chrono = { version = "^0.4", default-features = false } micromath = "2.0.0" diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 260f9afa..75a5f1c4 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -25,3 +25,6 @@ embedded-storage = "0.3.0" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.7.5", default-features = false } + +[patch.crates-io] +lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "ad289428fd44b02788e2fa2116445cc8f640a265" } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index fd454db2..c201d8bd 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ # Before upgrading check that everything is available on all tier1 targets here: # https://rust-lang.github.io/rustup-components-history [toolchain] -channel = "nightly-2023-05-18" +channel = "nightly-2023-07-03" components = [ "rust-src", "rustfmt", "llvm-tools-preview" ] targets = [ "thumbv7em-none-eabi", diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 4f9ecc47..247287e4 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -10,12 +10,12 @@ teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt", "nightly"] } embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "nightly", "defmt-timestamp-uptime"] } +embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io = { version = "0.4.0", features = ["async"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } -embedded-hal-async = { version = "0.2.0-alpha.1" } +embedded-hal-async = { version = "0.2.0-alpha.2" } static_cell = { version = "1.1", features = [ "nightly" ] } defmt = "0.3" diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs index 277b985c..398ab9d2 100644 --- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs +++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs @@ -14,7 +14,7 @@ use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; use embassy_nrf::rng::Rng; use embassy_nrf::spim::{self, Spim}; use embassy_nrf::{bind_interrupts, peripherals}; -use embassy_time::{with_timeout, Duration, Timer}; +use embassy_time::{with_timeout, Delay, Duration, Timer}; use embedded_hal_async::spi::ExclusiveDevice; use static_cell::make_static; use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; @@ -30,7 +30,7 @@ bind_interrupts!(struct Irqs { async fn wifi_task( runner: hosted::Runner< 'static, - ExclusiveDevice, Output<'static, peripherals::P0_31>>, + ExclusiveDevice, Output<'static, peripherals::P0_31>, Delay>, Input<'static, AnyPin>, Output<'static, peripherals::P1_05>, >, @@ -63,7 +63,7 @@ async fn main(spawner: Spawner) { config.frequency = spim::Frequency::M32; config.mode = spim::MODE_2; // !!! let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); - let spi = ExclusiveDevice::new(spi, cs); + let spi = ExclusiveDevice::new(spi, cs, Delay); let (device, mut control, runner) = embassy_net_esp_hosted::new( make_static!(embassy_net_esp_hosted::State::new()), diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 180d0ebb..f1b48e74 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -22,8 +22,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6" } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } panic-probe = { version = "0.3.0", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } embedded-io = { version = "0.4.0", features = ["async"] } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index c2422f7b..c69af6d5 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -38,8 +38,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } -embedded-hal-async = { version = "=0.2.0-alpha.1" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } +embedded-hal-async = { version = "=0.2.0-alpha.2" } panic-probe = { version = "0.3.0", features = ["print-defmt"] } rand_core = { version = "0.6", default-features = false } rand_chacha = { version = "0.3", default-features = false }