diff --git a/Cargo.toml b/Cargo.toml index 0a6c071..09fdb42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitbang-hal" -version = "0.2.3" +version = "0.2.4" authors = ["Paul Sajna "] edition = "2018" description = "Implements embedded-hal traits by bitbanging" diff --git a/src/i2c.rs b/src/i2c.rs index d07097a..f832451 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -100,14 +100,14 @@ where self.sda.set_low().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); - self.sda.set_low().map_err(Error::Bus)?; + self.scl.set_low().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); Ok(()) } fn i2c_stop(&mut self) -> Result<(), crate::i2c::Error> { - self.sda.set_high().map_err(Error::Bus)?; + self.scl.set_high().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); self.sda.set_high().map_err(Error::Bus)?; @@ -118,12 +118,12 @@ where fn i2c_is_ack(&mut self) -> Result> { self.sda.set_high().map_err(Error::Bus)?; - self.sda.set_high().map_err(Error::Bus)?; + self.scl.set_high().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); let ack = self.sda.is_low().map_err(Error::Bus)?; - self.sda.set_low().map_err(Error::Bus)?; + self.scl.set_low().map_err(Error::Bus)?; self.sda.set_low().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); @@ -136,14 +136,14 @@ where self.sda.set_high().map_err(Error::Bus)?; for i in 0..8 { - self.sda.set_high().map_err(Error::Bus)?; + self.scl.set_high().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); if self.sda.is_high().map_err(Error::Bus)? { byte |= 1 << (7 - i); } - self.sda.set_low().map_err(Error::Bus)?; + self.scl.set_low().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); } @@ -153,10 +153,10 @@ where self.sda.set_high().map_err(Error::Bus)?; } - self.sda.set_high().map_err(Error::Bus)?; + self.scl.set_high().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); - self.sda.set_low().map_err(Error::Bus)?; + self.scl.set_low().map_err(Error::Bus)?; self.sda.set_low().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); @@ -173,10 +173,10 @@ where self.sda.set_low().map_err(Error::Bus)?; } - self.sda.set_high().map_err(Error::Bus)?; + self.scl.set_high().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); - self.sda.set_low().map_err(Error::Bus)?; + self.scl.set_low().map_err(Error::Bus)?; self.sda.set_low().map_err(Error::Bus)?; block!(self.clk.wait()).ok(); } @@ -191,7 +191,7 @@ where SDA: OutputPin + InputPin, CLK: CountDown + Periodic, { - type Error = crate::i2c::Error; + type Error = crate::i2c::Error; fn write(&mut self, addr: u8, output: &[u8]) -> Result<(), Self::Error> { if output.is_empty() { @@ -229,7 +229,7 @@ where SDA: OutputPin + InputPin, CLK: CountDown + Periodic, { - type Error = crate::i2c::Error; + type Error = crate::i2c::Error; fn read(&mut self, addr: u8, input: &mut [u8]) -> Result<(), Self::Error> { if input.is_empty() { @@ -263,7 +263,7 @@ where SDA: OutputPin + InputPin, CLK: CountDown + Periodic, { - type Error = crate::i2c::Error; + type Error = crate::i2c::Error; fn write_read(&mut self, addr: u8, output: &[u8], input: &mut [u8]) -> Result<(), Self::Error> { if output.is_empty() || input.is_empty() {