diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/Cargo.toml b/Cargo.toml index 97ab8c4..4ff435b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,20 +10,19 @@ readme = "README.md" keywords = ["no_std", "embedded", "bitbang", "embedded-hal", "hal"] categories = ["embedded", "no-std"] -[dependencies] -nb = "1" +[dependencies.embedded-hal-nb] +version = "1" [dependencies.embedded-hal] -version = "0.2.7" -features = ["unproven"] +version = "1" [dev-dependencies.stm32f1xx-hal] -version = "0.9" +version = "0.10.0" features = ["stm32f103", "rt", "medium"] [dev-dependencies] cortex-m = "0.7" cortex-m-rt = "0.7" panic-halt = "0.2.0" -eeprom24x = "0.5.0" -lm75 = "0.2" +eeprom24x = "0.7.1" +lm75 = "1" diff --git a/examples/i2c-eeprom24x.rs b/examples/i2c-eeprom24x.rs index 65d223f..1fbf33e 100644 --- a/examples/i2c-eeprom24x.rs +++ b/examples/i2c-eeprom24x.rs @@ -43,13 +43,13 @@ fn main() -> ! { for addr in addrs.iter() { eeprom.write_byte(*addr, byte).unwrap(); // need to wait before next write - block!(delay.wait()).ok(); + block!(delay.try_wait()).ok(); } loop { for addr in addrs.iter() { let _ = eeprom.read_byte(*addr).unwrap(); - block!(delay.wait()).ok(); + block!(delay.try_wait()).ok(); } } } diff --git a/examples/serial.rs b/examples/serial.rs index 59fa50b..ca555e9 100644 --- a/examples/serial.rs +++ b/examples/serial.rs @@ -34,7 +34,7 @@ fn main() -> ! { loop { for byte in b"Hello, World!\r\n" { - block!(serial.write(*byte)).unwrap(); + block!(serial.try_write(*byte)).unwrap(); } delay.delay_ms(1000u16); diff --git a/src/i2c.rs b/src/i2c.rs index 401173b..2df9e90 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -50,10 +50,9 @@ ``` */ -use embedded_hal::blocking::i2c::{Read, Write, WriteRead}; -use embedded_hal::digital::v2::{InputPin, OutputPin}; -use embedded_hal::timer::{CountDown, Periodic}; -use nb::block; +use embedded_hal::delay::DelayNs; +use embedded_hal::digital::{InputPin, OutputPin}; +use embedded_hal_nb::nb::block; /// I2C error #[derive(Debug, Eq, PartialEq)] @@ -71,7 +70,7 @@ pub struct I2cBB where SCL: OutputPin, SDA: OutputPin + InputPin, - CLK: CountDown + Periodic, + CLK: DelayNs, { scl: SCL, sda: SDA, @@ -82,7 +81,7 @@ impl I2cBB where SCL: OutputPin, SDA: OutputPin + InputPin, - CLK: CountDown + Periodic, + CLK: DelayNs, { /// Create instance pub fn new(scl: SCL, sda: SDA, clk: CLK) -> Self { @@ -258,7 +257,7 @@ impl Write for I2cBB where SCL: OutputPin, SDA: OutputPin + InputPin, - CLK: CountDown + Periodic, + CLK: DelayNs, { type Error = crate::i2c::Error; @@ -281,7 +280,7 @@ impl Read for I2cBB where SCL: OutputPin, SDA: OutputPin + InputPin, - CLK: CountDown + Periodic, + CLK: DelayNs, { type Error = crate::i2c::Error; @@ -308,7 +307,7 @@ impl WriteRead for I2cBB where SCL: OutputPin, SDA: OutputPin + InputPin, - CLK: CountDown + Periodic, + CLK: DelayNs, { type Error = crate::i2c::Error; diff --git a/src/serial.rs b/src/serial.rs index 51b1e6b..0dc3f63 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -8,10 +8,11 @@ //! The timer must be configured to twice the desired communication frequency. //! -use embedded_hal::digital::v2::{InputPin, OutputPin}; -use embedded_hal::serial; -use embedded_hal::timer::{CountDown, Periodic}; -use nb::block; +use embedded_hal::{ + delay::DelayNs, + digital::{InputPin, OutputPin}, +}; +use embedded_hal_nb::nb::block; /// Serial communication error type #[derive(Debug)] @@ -25,7 +26,7 @@ pub struct Serial where TX: OutputPin, RX: InputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { tx: TX, rx: RX, @@ -36,7 +37,7 @@ impl Serial where TX: OutputPin, RX: InputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { /// Create instance pub fn new(tx: TX, rx: RX, timer: Timer) -> Self { @@ -53,7 +54,7 @@ impl serial::Write for Serial where TX: OutputPin, RX: InputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { type Error = crate::serial::Error; @@ -84,7 +85,7 @@ impl serial::Read for Serial where TX: OutputPin, RX: InputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { type Error = crate::serial::Error; diff --git a/src/spi.rs b/src/spi.rs index 86fd68d..064ece2 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -13,12 +13,11 @@ //! MSB-first and LSB-first bit orders are supported. //! +use embedded_hal::delay::DelayNs; pub use embedded_hal::spi::{MODE_0, MODE_1, MODE_2, MODE_3}; -use embedded_hal::digital::v2::{InputPin, OutputPin}; +use embedded_hal::digital::{InputPin, OutputPin}; use embedded_hal::spi::{FullDuplex, Mode, Polarity}; -use embedded_hal::timer::{CountDown, Periodic}; -use nb::block; /// Error type #[derive(Debug)] @@ -52,7 +51,7 @@ where Miso: InputPin, Mosi: OutputPin, Sck: OutputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { mode: Mode, miso: Miso, @@ -68,7 +67,7 @@ where Miso: InputPin, Mosi: OutputPin, Sck: OutputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { /// Create instance pub fn new(mode: Mode, miso: Miso, mosi: Mosi, sck: Sck, timer: Timer) -> Self { @@ -156,7 +155,7 @@ where Miso: InputPin, Mosi: OutputPin, Sck: OutputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { type Error = crate::spi::Error; @@ -217,22 +216,22 @@ where } } -impl embedded_hal::blocking::spi::transfer::Default +impl embedded_hal::spi::transfer::Default for SPI where Miso: InputPin, Mosi: OutputPin, Sck: OutputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { } -impl embedded_hal::blocking::spi::write::Default +impl embedded_hal::spi::write::Default for SPI where Miso: InputPin, Mosi: OutputPin, Sck: OutputPin, - Timer: CountDown + Periodic, + Timer: DelayNs, { }