diff --git a/rp2040-hal/CHANGELOG.md b/rp2040-hal/CHANGELOG.md index 045c885..d94944a 100644 --- a/rp2040-hal/CHANGELOG.md +++ b/rp2040-hal/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Update embedded-hal alpha support to version 1.0.0-alpha.9 - @jannic + (Non-blocking traits were moved to embedded-hal-nb, which is not yet supported) + ## [0.6.0] - 2022-08-26 ### Added diff --git a/rp2040-hal/Cargo.toml b/rp2040-hal/Cargo.toml index c39ac50..7794cb9 100644 --- a/rp2040-hal/Cargo.toml +++ b/rp2040-hal/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" cortex-m = "0.7.2" cortex-m-rt = ">=0.6.15,<0.8" embedded-hal = { version = "0.2.5", features = ["unproven"] } -eh1_0_alpha = { package = "embedded-hal", version = "=1.0.0-alpha.8", optional = true } +eh1_0_alpha = { package = "embedded-hal", version = "=1.0.0-alpha.9", optional = true } fugit = "0.3.6" itertools = { version = "0.10.1", default-features = false } nb = "1.0" diff --git a/rp2040-hal/src/gpio/dynpin.rs b/rp2040-hal/src/gpio/dynpin.rs index 68ceea3..974d67a 100644 --- a/rp2040-hal/src/gpio/dynpin.rs +++ b/rp2040-hal/src/gpio/dynpin.rs @@ -556,7 +556,7 @@ impl eh1::ErrorType for DynPin { } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::OutputPin for DynPin { +impl eh1::OutputPin for DynPin { #[inline] fn set_high(&mut self) -> Result<(), Self::Error> { self._set_high() @@ -568,7 +568,7 @@ impl eh1::blocking::OutputPin for DynPin { } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::InputPin for DynPin { +impl eh1::InputPin for DynPin { #[inline] fn is_high(&self) -> Result { self._is_high() @@ -580,7 +580,7 @@ impl eh1::blocking::InputPin for DynPin { } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::ToggleableOutputPin for DynPin { +impl eh1::ToggleableOutputPin for DynPin { #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { self._toggle() @@ -588,7 +588,7 @@ impl eh1::blocking::ToggleableOutputPin for DynPin { } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::StatefulOutputPin for DynPin { +impl eh1::StatefulOutputPin for DynPin { #[inline] fn is_set_high(&self) -> Result { self._is_set_high() diff --git a/rp2040-hal/src/gpio/pin.rs b/rp2040-hal/src/gpio/pin.rs index fac7c73..1b6e7c8 100644 --- a/rp2040-hal/src/gpio/pin.rs +++ b/rp2040-hal/src/gpio/pin.rs @@ -881,7 +881,7 @@ where } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::OutputPin for Pin> +impl eh1::OutputPin for Pin> where I: PinId, C: OutputConfig, @@ -899,7 +899,7 @@ where } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::InputPin for Pin +impl eh1::InputPin for Pin where I: PinId, { @@ -923,7 +923,7 @@ where } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::InputPin for Pin> +impl eh1::InputPin for Pin> where I: PinId, C: InputConfig, @@ -939,7 +939,7 @@ where } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::ToggleableOutputPin for Pin> +impl eh1::ToggleableOutputPin for Pin> where I: PinId, C: OutputConfig, @@ -952,7 +952,7 @@ where } #[cfg(feature = "eh1_0_alpha")] -impl eh1::blocking::StatefulOutputPin for Pin> +impl eh1::StatefulOutputPin for Pin> where I: PinId, C: OutputConfig, diff --git a/rp2040-hal/src/i2c/controller.rs b/rp2040-hal/src/i2c/controller.rs index 862f9f2..fdcfa3e 100644 --- a/rp2040-hal/src/i2c/controller.rs +++ b/rp2040-hal/src/i2c/controller.rs @@ -279,7 +279,7 @@ impl, PINS> eh1::ErrorType for I2C } #[cfg(feature = "eh1_0_alpha")] -impl, PINS> eh1::blocking::I2c for I2C { +impl, PINS> eh1::I2c for I2C { fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> { Write::write(self, addr, bytes) } @@ -330,15 +330,15 @@ impl, PINS> eh1::blocking::I2c for I2C( &mut self, address: u8, - operations: &mut [eh1::blocking::Operation<'a>], + operations: &mut [eh1::Operation<'a>], ) -> Result<(), Self::Error> { let addr: u16 = address.into(); self.setup(addr); for i in 0..operations.len() { let last = i == operations.len() - 1; match &mut operations[i] { - eh1::blocking::Operation::Read(buf) => self.read_internal(buf, false, last)?, - eh1::blocking::Operation::Write(buf) => self.write_internal(buf, last)?, + eh1::Operation::Read(buf) => self.read_internal(buf, false, last)?, + eh1::Operation::Write(buf) => self.write_internal(buf, last)?, } } Ok(()) @@ -346,7 +346,7 @@ impl, PINS> eh1::blocking::I2c for I2C(&mut self, address: u8, operations: O) -> Result<(), Self::Error> where - O: IntoIterator>, + O: IntoIterator>, { let addr: u16 = address.into(); self.setup(addr); @@ -354,8 +354,8 @@ impl, PINS> eh1::blocking::I2c for I2C self.read_internal(buf, false, last)?, - eh1::blocking::Operation::Write(buf) => self.write_internal(buf, last)?, + eh1::Operation::Read(buf) => self.read_internal(buf, false, last)?, + eh1::Operation::Write(buf) => self.write_internal(buf, last)?, } } Ok(()) diff --git a/rp2040-hal/src/spi.rs b/rp2040-hal/src/spi.rs index 7ecbbab..1edd01b 100644 --- a/rp2040-hal/src/spi.rs +++ b/rp2040-hal/src/spi.rs @@ -192,29 +192,6 @@ impl Spi { } } -/// Same as core::convert::Infallible, but implementing spi::Error -/// -/// For eh 1.0.0-alpha.6, Infallible doesn't implement spi::Error, -/// so use a locally defined type instead. -/// This should be removed with the next release of e-h. -/// (https://github.com/rust-embedded/embedded-hal/pull/328) -#[cfg(feature = "eh1_0_alpha")] -pub enum SpiInfallible {} - -#[cfg(feature = "eh1_0_alpha")] -impl core::fmt::Debug for SpiInfallible { - fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match *self {} - } -} - -#[cfg(feature = "eh1_0_alpha")] -impl eh1::Error for SpiInfallible { - fn kind(&self) -> eh1::ErrorKind { - match *self {} - } -} - macro_rules! impl_write { ($type:ident, [$($nr:expr),+]) => { @@ -250,19 +227,20 @@ macro_rules! impl_write { #[cfg(feature = "eh1_0_alpha")] impl eh1::ErrorType for Spi { - type Error = SpiInfallible; + type Error = Infallible; } +/* disabled for now - nb was migrated to separate crate #[cfg(feature = "eh1_0_alpha")] impl eh1::nb::FullDuplex<$type> for Spi { - fn read(&mut self) -> Result<$type, nb::Error> { + fn read(&mut self) -> Result<$type, nb::Error> { if !self.is_readable() { return Err(nb::Error::WouldBlock); } Ok(self.device.sspdr.read().data().bits() as $type) } - fn write(&mut self, word: $type) -> Result<(), nb::Error> { + fn write(&mut self, word: $type) -> Result<(), nb::Error> { // Write to TX FIFO whilst ignoring RX, then clean up afterward. When RX // is full, PL022 inhibits RX pushes, and sets a sticky flag on // push-on-full, but continues shifting. Safe if SSPIMSC_RORIM is not set. @@ -276,6 +254,7 @@ macro_rules! impl_write { Ok(()) } } +*/ )+ diff --git a/rp2040-hal/src/uart/peripheral.rs b/rp2040-hal/src/uart/peripheral.rs index 7bdd0d2..b0e5f3b 100644 --- a/rp2040-hal/src/uart/peripheral.rs +++ b/rp2040-hal/src/uart/peripheral.rs @@ -357,6 +357,7 @@ impl> eh1::ErrorType for UartPeripheral> eh1::nb::Read for UartPeripheral { fn read(&mut self) -> nb::Result { @@ -371,6 +372,8 @@ impl> eh1::nb::Read for UartPeripheral< } } } +*/ + impl> Write for UartPeripheral { type Error = Infallible; @@ -387,6 +390,7 @@ impl> Write for UartPeripheral> eh1::nb::Write for UartPeripheral { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { @@ -404,6 +408,7 @@ impl> eh1::nb::Write for UartPeripheral }) } } +*/ impl> fmt::Write for UartPeripheral { fn write_str(&mut self, s: &str) -> fmt::Result { diff --git a/rp2040-hal/src/uart/reader.rs b/rp2040-hal/src/uart/reader.rs index 272d5b2..0528169 100644 --- a/rp2040-hal/src/uart/reader.rs +++ b/rp2040-hal/src/uart/reader.rs @@ -239,6 +239,7 @@ impl> eh1::ErrorType for Reader { type Error = ReadErrorType; } +/* disabled for now - nb was migrated to separate crate #[cfg(feature = "eh1_0_alpha")] impl> eh1::nb::Read for Reader { fn read(&mut self) -> nb::Result { @@ -253,3 +254,4 @@ impl> eh1::nb::Read for Reader { } } } +*/ diff --git a/rp2040-hal/src/uart/utils.rs b/rp2040-hal/src/uart/utils.rs index 42eb9e6..508207d 100644 --- a/rp2040-hal/src/uart/utils.rs +++ b/rp2040-hal/src/uart/utils.rs @@ -116,26 +116,3 @@ impl Default for UartConfig { } } } - -/// Same as core::convert::Infallible, but implementing serial::Error -/// -/// For eh 1.0.0-alpha.6, Infallible doesn't implement serial::Error, -/// so use a locally defined type instead. -/// This should be removed with the next release of e-h. -/// (https://github.com/rust-embedded/embedded-hal/pull/328) -#[cfg(feature = "eh1_0_alpha")] -pub enum SerialInfallible {} - -#[cfg(feature = "eh1_0_alpha")] -impl core::fmt::Debug for SerialInfallible { - fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match *self {} - } -} - -#[cfg(feature = "eh1_0_alpha")] -impl eh1_0_alpha::serial::Error for SerialInfallible { - fn kind(&self) -> eh1_0_alpha::serial::ErrorKind { - match *self {} - } -} diff --git a/rp2040-hal/src/uart/writer.rs b/rp2040-hal/src/uart/writer.rs index 34a50cf..4be2ddd 100644 --- a/rp2040-hal/src/uart/writer.rs +++ b/rp2040-hal/src/uart/writer.rs @@ -184,9 +184,10 @@ impl> Write for Writer { #[cfg(feature = "eh1_0_alpha")] impl> eh1::ErrorType for Writer { - type Error = super::utils::SerialInfallible; + type Error = core::convert::Infallible; } +/* disabled for now - nb was migrated to separate crate #[cfg(feature = "eh1_0_alpha")] impl> eh1::nb::Write for Writer { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { @@ -204,6 +205,7 @@ impl> eh1::nb::Write for Writer { }) } } +*/ impl> fmt::Write for Writer { fn write_str(&mut self, s: &str) -> fmt::Result {