From 518e525e344cda498717d936f5f558fbe65a4ea1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 11 Jan 2024 02:32:50 +0100 Subject: [PATCH] Update to `embedded-hal` 1.0. --- Cargo.toml | 4 +- src/gpio/hal.rs | 83 ++++++++++++++-------------------------- src/gpio/hal_unproven.rs | 44 +++++++-------------- src/hal.rs | 11 ------ src/i2c/hal.rs | 24 +++++------- src/pwm/hal.rs | 1 - src/pwm/hal_unproven.rs | 1 - src/spi/hal.rs | 34 +++++++--------- src/uart/hal.rs | 20 ++++------ 9 files changed, 73 insertions(+), 149 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 129419b1..d29b3b89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,8 +17,8 @@ keywords = ["raspberry", "pi", "embedded-hal", "embedded-hal-impl", "hal"] libc = "0.2" nb = { version = "0.1.1", optional = true } embedded-hal-0 = { version = "0.2.7", optional = true, package = "embedded-hal" } -embedded-hal = { version = "=1.0.0-rc.2", optional = true } -embedded-hal-nb = { version = "=1.0.0-rc.2", optional = true } +embedded-hal = { version = "1", optional = true } +embedded-hal-nb = { version = "1", optional = true } void = { version = "1.0.2", optional = true } spin_sleep = { version = "1.0.0", optional = true } diff --git a/src/gpio/hal.rs b/src/gpio/hal.rs index 63aebb87..97ccc0a4 100644 --- a/src/gpio/hal.rs +++ b/src/gpio/hal.rs @@ -1,78 +1,64 @@ use core::convert::Infallible; -use embedded_hal::digital::{ - ErrorType, InputPin as InputPinHal, OutputPin as OutputPinHal, - StatefulOutputPin as StatefulOutputPinHal, ToggleableOutputPin as ToggleableOutputPinHal, -}; - use super::{InputPin, IoPin, Level, OutputPin, Pin}; -/// `ErrorType` trait implementation for `embedded-hal` v1.0.0. -impl ErrorType for Pin { +impl embedded_hal::digital::ErrorType for Pin { type Error = Infallible; } -/// `InputPin` trait implementation for `embedded-hal` v1.0.0. -impl InputPinHal for Pin { - fn is_high(&self) -> Result { +impl embedded_hal::digital::InputPin for Pin { + fn is_high(&mut self) -> Result { Ok(Self::read(self) == Level::High) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(Self::read(self) == Level::Low) } } -/// `ErrorType` trait implementation for `embedded-hal` v1.0.0. -impl ErrorType for InputPin { +impl embedded_hal::digital::ErrorType for InputPin { type Error = Infallible; } -/// `InputPin` trait implementation for `embedded-hal` v1.0.0. -impl InputPinHal for InputPin { - fn is_high(&self) -> Result { +impl embedded_hal::digital::InputPin for InputPin { + fn is_high(&mut self) -> Result { Ok(Self::is_high(self)) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(Self::is_low(self)) } } -/// `ErrorType` trait implementation for `embedded-hal` v1.0.0. -impl ErrorType for IoPin { +impl embedded_hal::digital::ErrorType for IoPin { type Error = Infallible; } -/// `InputPin` trait implementation for `embedded-hal` v1.0.0. -impl InputPinHal for IoPin { - fn is_high(&self) -> Result { +impl embedded_hal::digital::InputPin for IoPin { + fn is_high(&mut self) -> Result { Ok(Self::is_high(self)) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(Self::is_low(self)) } } -/// `ErrorType` trait implementation for `embedded-hal` v1.0.0. -impl ErrorType for OutputPin { +impl embedded_hal::digital::ErrorType for OutputPin { type Error = Infallible; } -/// `InputPin` trait implementation for `embedded-hal` v1.0.0. -impl InputPinHal for OutputPin { - fn is_high(&self) -> Result { +impl embedded_hal::digital::InputPin for OutputPin { + fn is_high(&mut self) -> Result { Ok(Self::is_set_high(self)) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(Self::is_set_low(self)) } } -/// `OutputPin` trait implementation for `embedded-hal` v1.0.0. -impl OutputPinHal for OutputPin { +impl embedded_hal::digital::OutputPin for OutputPin { fn set_low(&mut self) -> Result<(), Self::Error> { OutputPin::set_low(self); @@ -86,32 +72,27 @@ impl OutputPinHal for OutputPin { } } -/// `OutputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::OutputPin for OutputPin { type Error = Infallible; fn set_low(&mut self) -> Result<(), Self::Error> { - OutputPinHal::set_low(self) + embedded_hal::digital::OutputPin::set_low(self) } fn set_high(&mut self) -> Result<(), Self::Error> { - OutputPinHal::set_high(self) + embedded_hal::digital::OutputPin::set_high(self) } } -/// `StatefulOutputPin` trait implementation for `embedded-hal` v1.0.0. -impl StatefulOutputPinHal for OutputPin { - fn is_set_high(&self) -> Result { +impl embedded_hal::digital::StatefulOutputPin for OutputPin { + fn is_set_high(&mut self) -> Result { Ok(OutputPin::is_set_high(self)) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(OutputPin::is_set_low(self)) } -} -/// `ToggleableOutputPin` trait implementation for `embedded-hal` v1.0.0. -impl ToggleableOutputPinHal for OutputPin { fn toggle(&mut self) -> Result<(), Self::Error> { OutputPin::toggle(self); @@ -119,8 +100,7 @@ impl ToggleableOutputPinHal for OutputPin { } } -/// `OutputPin` trait implementation for `embedded-hal` v1.0.0. -impl OutputPinHal for IoPin { +impl embedded_hal::digital::OutputPin for IoPin { fn set_low(&mut self) -> Result<(), Self::Error> { IoPin::set_low(self); @@ -134,32 +114,27 @@ impl OutputPinHal for IoPin { } } -/// `OutputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::OutputPin for IoPin { type Error = Infallible; fn set_low(&mut self) -> Result<(), Self::Error> { - OutputPinHal::set_low(self) + embedded_hal::digital::OutputPin::set_low(self) } fn set_high(&mut self) -> Result<(), Self::Error> { - OutputPinHal::set_high(self) + embedded_hal::digital::OutputPin::set_high(self) } } -/// `StatefulOutputPin` trait implementation for `embedded-hal` v1.0.0. -impl StatefulOutputPinHal for IoPin { - fn is_set_high(&self) -> Result { +impl embedded_hal::digital::StatefulOutputPin for IoPin { + fn is_set_high(&mut self) -> Result { Ok(IoPin::is_high(self)) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(IoPin::is_low(self)) } -} -/// `ToggleableOutputPin` trait implementation for `embedded-hal` v1.0.0. -impl ToggleableOutputPinHal for IoPin { fn toggle(&mut self) -> Result<(), Self::Error> { IoPin::toggle(self); @@ -167,7 +142,6 @@ impl ToggleableOutputPinHal for IoPin { } } -/// `PwmPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::PwmPin for OutputPin { type Duty = f64; @@ -196,7 +170,6 @@ impl embedded_hal_0::PwmPin for OutputPin { } } -/// `PwmPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::PwmPin for IoPin { type Duty = f64; diff --git a/src/gpio/hal_unproven.rs b/src/gpio/hal_unproven.rs index a026f2f8..766b053f 100644 --- a/src/gpio/hal_unproven.rs +++ b/src/gpio/hal_unproven.rs @@ -1,109 +1,95 @@ use core::convert::Infallible; use std::time::Duration; -use embedded_hal::digital::{ - InputPin as InputPinHal, StatefulOutputPin as StatefulOutputPinHal, - ToggleableOutputPin as ToggleableOutputPinHal, -}; - use super::{InputPin, IoPin, OutputPin, Pin}; use crate::gpio::Mode; const NANOS_PER_SEC: f64 = 1_000_000_000.0; -/// Unproven `InputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::InputPin for Pin { type Error = Infallible; fn is_high(&self) -> Result { - InputPinHal::is_high(self) + Self::is_high(self) } fn is_low(&self) -> Result { - InputPinHal::is_low(self) + Self::is_low(self) } } -/// Unproven `InputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::InputPin for InputPin { type Error = Infallible; fn is_high(&self) -> Result { - InputPinHal::is_high(self) + Self::is_high(self) } fn is_low(&self) -> Result { - InputPinHal::is_low(self) + Self::is_low(self) } } -/// Unproven `InputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::InputPin for IoPin { type Error = Infallible; fn is_high(&self) -> Result { - InputPinHal::is_high(self) + Self::is_high(self) } fn is_low(&self) -> Result { - InputPinHal::is_low(self) + Self::is_low(self) } } -/// Unproven `InputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::InputPin for OutputPin { type Error = Infallible; fn is_high(&self) -> Result { - InputPinHal::is_high(self) + Ok(Self::is_high(self)) } fn is_low(&self) -> Result { - InputPinHal::is_low(self) + Ok(Self::is_low(self)) } } -/// Unproven `StatefulOutputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::StatefulOutputPin for IoPin { fn is_set_high(&self) -> Result { - StatefulOutputPinHal::is_set_high(self) + Ok(Self::is_set_high(self)) } fn is_set_low(&self) -> Result { - StatefulOutputPinHal::is_set_low(self) + Ok(Self::is_set_low(self)) } } -/// Unproven `StatefulOutputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::StatefulOutputPin for OutputPin { fn is_set_high(&self) -> Result { - StatefulOutputPinHal::is_set_high(self) + Self::is_set_high(self) } fn is_set_low(&self) -> Result { - StatefulOutputPinHal::is_set_low(self) + Self::is_set_low(self) } } -/// Unproven `ToggleableOutputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::ToggleableOutputPin for IoPin { type Error = Infallible; fn toggle(&mut self) -> Result<(), Self::Error> { - ToggleableOutputPinHal::toggle(self) + embedded_hal::digital::StatefulOutputPin::toggle(self) } } -/// Unproven `ToggleableOutputPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::ToggleableOutputPin for OutputPin { type Error = Infallible; fn toggle(&mut self) -> Result<(), Self::Error> { - ToggleableOutputPinHal::toggle(self) + embedded_hal::digital::StatefulOutputPin::toggle(self) } } -/// Unproven `Pwm` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::Pwm for OutputPin { type Duty = f64; type Channel = (); @@ -162,7 +148,6 @@ impl embedded_hal_0::Pwm for OutputPin { } } -/// Unproven `Pwm` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::Pwm for IoPin { type Duty = f64; type Channel = (); @@ -221,7 +206,6 @@ impl embedded_hal_0::Pwm for IoPin { } } -/// Unproven `IoPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::digital::v2::IoPin for IoPin { type Error = Infallible; diff --git a/src/hal.rs b/src/hal.rs index ba33fab7..41f76e79 100644 --- a/src/hal.rs +++ b/src/hal.rs @@ -16,7 +16,6 @@ use void::Void; #[derive(Debug, Default)] pub struct Delay; -/// `Delay` trait implementation for `embedded-hal` v1.0.0. impl Delay { /// Constructs a new `Delay`. pub fn new() -> Delay { @@ -24,28 +23,24 @@ impl Delay { } } -/// `DelayMs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayMs for Delay { fn delay_ms(&mut self, ms: u8) { DelayNs::delay_ms(self, ms as u32); } } -/// `DelayMs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayMs for Delay { fn delay_ms(&mut self, ms: u16) { DelayNs::delay_ms(self, ms as u32); } } -/// `DelayMs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayMs for Delay { fn delay_ms(&mut self, ms: u32) { DelayNs::delay_ms(self, ms); } } -/// `DelayMs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayMs for Delay { fn delay_ms(&mut self, mut ms: u64) { while ms > (u32::MAX as u64) { @@ -57,21 +52,18 @@ impl embedded_hal_0::blocking::delay::DelayMs for Delay { } } -/// `DelayNs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayUs for Delay { fn delay_us(&mut self, us: u8) { DelayNs::delay_us(self, us as u32); } } -/// `DelayNs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayUs for Delay { fn delay_us(&mut self, us: u16) { DelayNs::delay_us(self, us as u32); } } -/// `DelayNs` trait implementation for `embedded-hal` v1.0.0. impl DelayNs for Delay { fn delay_ns(&mut self, ns: u32) { sleep(Duration::from_nanos(ns.into())); @@ -86,14 +78,12 @@ impl DelayNs for Delay { } } -/// `DelayNs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayUs for Delay { fn delay_us(&mut self, us: u32) { DelayNs::delay_us(self, us); } } -/// `DelayNs` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::delay::DelayUs for Delay { fn delay_us(&mut self, mut us: u64) { while us > (u32::MAX as u64) { @@ -143,7 +133,6 @@ impl Default for Timer { } } -/// `CountDown` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::timer::CountDown for Timer { type Time = Duration; diff --git a/src/i2c/hal.rs b/src/i2c/hal.rs index 6a6dfe22..6959a538 100644 --- a/src/i2c/hal.rs +++ b/src/i2c/hal.rs @@ -1,26 +1,21 @@ -use embedded_hal::i2c::{self, ErrorType, I2c as I2cHal, Operation as I2cOperation}; - use super::{Error, I2c}; -/// `Write` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::i2c::Write for I2c { type Error = Error; fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error> { - I2cHal::write(self, address, bytes) + embedded_hal::i2c::I2c::write(self, address, bytes) } } -/// `Read` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::i2c::Read for I2c { type Error = Error; fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { - I2cHal::read(self, address, buffer) + embedded_hal::i2c::I2c::read(self, address, buffer) } } -/// `WriteRead` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::i2c::WriteRead for I2c { type Error = Error; @@ -30,15 +25,15 @@ impl embedded_hal_0::blocking::i2c::WriteRead for I2c { bytes: &[u8], buffer: &mut [u8], ) -> Result<(), Self::Error> { - I2cHal::write_read(self, address, bytes, buffer) + embedded_hal::i2c::I2c::write_read(self, address, bytes, buffer) } } -impl ErrorType for I2c { +impl embedded_hal::i2c::ErrorType for I2c { type Error = Error; } -impl i2c::Error for Error { +impl embedded_hal::i2c::Error for Error { fn kind(&self) -> i2c::ErrorKind { if let Error::Io(e) = self { use std::io::ErrorKind::*; @@ -54,20 +49,19 @@ impl i2c::Error for Error { } } -/// `I2c` trait implementation for `embedded-hal` v1.0.0. -impl I2cHal for I2c { +impl embedded_hal::i2c::I2c for I2c { fn transaction( &mut self, address: u8, - operations: &mut [I2cOperation], + operations: &mut [embedded_hal::i2c::Operation], ) -> Result<(), Self::Error> { self.set_slave_address(u16::from(address))?; for op in operations { match op { - I2cOperation::Read(buff) => { + embedded_hal::i2c::Operation::Read(buff) => { I2c::read(self, buff)?; } - I2cOperation::Write(buff) => { + embedded_hal::i2c::Operation::Write(buff) => { I2c::write(self, buff)?; } } diff --git a/src/pwm/hal.rs b/src/pwm/hal.rs index ddbad28c..628e5bcc 100644 --- a/src/pwm/hal.rs +++ b/src/pwm/hal.rs @@ -1,6 +1,5 @@ use super::Pwm; -/// `PwmPin` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::PwmPin for Pwm { type Duty = f64; diff --git a/src/pwm/hal_unproven.rs b/src/pwm/hal_unproven.rs index 4a493c26..9e43cbae 100644 --- a/src/pwm/hal_unproven.rs +++ b/src/pwm/hal_unproven.rs @@ -2,7 +2,6 @@ use std::time::Duration; use super::Pwm; -/// Unproven `Pwm` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::Pwm for Pwm { type Duty = f64; type Channel = (); diff --git a/src/spi/hal.rs b/src/spi/hal.rs index c28bba8b..18300723 100644 --- a/src/spi/hal.rs +++ b/src/spi/hal.rs @@ -1,24 +1,20 @@ -use embedded_hal::{ - delay::DelayNs, - spi::{self, ErrorType, Operation, SpiBus, SpiDevice}, -}; +use embedded_hal::delay::DelayNs; use embedded_hal_nb::spi::FullDuplex; use std::io; use super::{super::hal::Delay, Error, Spi}; -impl ErrorType for Spi { +impl embedded_hal::spi::ErrorType for Spi { type Error = Error; } -impl spi::Error for Error { +impl embedded_hal::spi::Error for Error { fn kind(&self) -> spi::ErrorKind { spi::ErrorKind::Other } } -/// `SpiBus` trait implementation for `embedded-hal` v1.0.0. -impl SpiBus for Spi { +impl embedded_hal::spi::SpiBus for Spi { fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { Spi::read(self, words)?; Ok(()) @@ -44,7 +40,6 @@ impl SpiBus for Spi { } } -/// `Transfer` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::spi::Transfer for Spi { type Error = Error; @@ -55,7 +50,6 @@ impl embedded_hal_0::blocking::spi::Transfer for Spi { } } -/// `Write` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::blocking::spi::Write for Spi { type Error = Error; @@ -64,8 +58,7 @@ impl embedded_hal_0::blocking::spi::Write for Spi { } } -/// `FullDuplex` trait implementation for `embedded-hal` v1.0.0 -impl FullDuplex for Spi { +impl embedded_hal_nb::spi::FullDuplex for Spi { fn read(&mut self) -> nb::Result { if let Some(last_read) = self.last_read.take() { Ok(last_read) @@ -84,7 +77,6 @@ impl FullDuplex for Spi { } } -/// `FullDuplex` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::spi::FullDuplex for Spi { type Error = Error; @@ -108,17 +100,17 @@ pub struct SimpleHalSpiDevice { bus: B, } -impl> SimpleHalSpiDevice { +impl> SimpleHalSpiDevice { pub fn new(bus: B) -> SimpleHalSpiDevice { SimpleHalSpiDevice { bus } } } -impl> SpiDevice for SimpleHalSpiDevice { +impl> embedded_hal::spi::SpiDevice for SimpleHalSpiDevice { fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Error> { for op in operations { match op { - Operation::Read(read) => { + embedded_hal::spi::Operation::Read(read) => { self.bus.read(read).map_err(|_| { Error::Io(io::Error::new( io::ErrorKind::Other, @@ -126,7 +118,7 @@ impl> SpiDevice for SimpleHalSpiDevice { )) })?; } - Operation::Write(write) => { + embedded_hal::spi::Operation::Write(write) => { self.bus.write(write).map_err(|_| { Error::Io(io::Error::new( io::ErrorKind::Other, @@ -134,7 +126,7 @@ impl> SpiDevice for SimpleHalSpiDevice { )) })?; } - Operation::Transfer(read, write) => { + embedded_hal::spi::Operation::Transfer(read, write) => { self.bus.transfer(read, write).map_err(|_| { Error::Io(io::Error::new( io::ErrorKind::Other, @@ -142,7 +134,7 @@ impl> SpiDevice for SimpleHalSpiDevice { )) })?; } - Operation::TransferInPlace(words) => { + embedded_hal::spi::Operation::TransferInPlace(words) => { self.bus.transfer_in_place(words).map_err(|_| { Error::Io(io::Error::new( io::ErrorKind::Other, @@ -150,7 +142,7 @@ impl> SpiDevice for SimpleHalSpiDevice { )) })?; } - Operation::DelayNs(us) => { + embedded_hal::spi::Operation::DelayNs(us) => { Delay::new().delay_us(*us); } } @@ -159,6 +151,6 @@ impl> SpiDevice for SimpleHalSpiDevice { } } -impl> ErrorType for SimpleHalSpiDevice { +impl> embedded_hal::spi::ErrorType for SimpleHalSpiDevice { type Error = Error; } diff --git a/src/uart/hal.rs b/src/uart/hal.rs index f5be015d..1efd39f9 100644 --- a/src/uart/hal.rs +++ b/src/uart/hal.rs @@ -1,19 +1,16 @@ -use embedded_hal_nb::serial::{self, ErrorType, Read, Write}; - use super::{Error, Queue, Uart}; -impl ErrorType for Uart { +impl embedded_hal_nb::serial::ErrorType for Uart { type Error = Error; } -impl serial::Error for Error { - fn kind(&self) -> serial::ErrorKind { +impl embedded_hal_nb::serial::Error for Error { + fn kind(&self) -> embedded_hal_nb::serial::ErrorKind { serial::ErrorKind::Other } } -/// `Read` trait implementation for `embedded-hal` v1.0.0. -impl Read for Uart { +impl embedded_hal_nb::serial::Read for Uart { fn read(&mut self) -> nb::Result { let mut buffer = [0u8; 1]; if Uart::read(self, &mut buffer)? == 0 { @@ -24,7 +21,6 @@ impl Read for Uart { } } -/// `Read` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::serial::Read for Uart { type Error = Error; @@ -33,8 +29,7 @@ impl embedded_hal_0::serial::Read for Uart { } } -/// `Write` trait implementation for `embedded-hal` v1.0.0. -impl Write for Uart { +impl embedded_hal_nb::serial::Write for Uart { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { if Uart::write(self, &[word])? == 0 { Err(nb::Error::WouldBlock) @@ -50,15 +45,14 @@ impl Write for Uart { } } -/// `Write` trait implementation for `embedded-hal` v0.2.7. impl embedded_hal_0::serial::Write for Uart { type Error = Error; fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { - Write::write(self, word) + embedded_hal_nb::serial::Write::write(self, word) } fn flush(&mut self) -> nb::Result<(), Self::Error> { - Write::flush(self) + embedded_hal_nb::serial::Write::flush(self) } }