diff options
5 files changed, 19 insertions, 19 deletions
diff --git a/embassy-embedded-hal/src/flash/partition/asynch.rs b/embassy-embedded-hal/src/flash/partition/asynch.rs index 82e27bb7c..a6fa2a562 100644 --- a/embassy-embedded-hal/src/flash/partition/asynch.rs +++ b/embassy-embedded-hal/src/flash/partition/asynch.rs | |||
| @@ -119,7 +119,7 @@ mod tests { | |||
| 119 | let mut read_buf = [0; 8]; | 119 | let mut read_buf = [0; 8]; |
| 120 | partition.read(4, &mut read_buf).await.unwrap(); | 120 | partition.read(4, &mut read_buf).await.unwrap(); |
| 121 | 121 | ||
| 122 | assert!(read_buf.iter().position(|&x| x != 0xAA).is_none()); | 122 | assert!(!read_buf.iter().any(|&x| x != 0xAA)); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | #[futures_test::test] | 125 | #[futures_test::test] |
| @@ -133,7 +133,7 @@ mod tests { | |||
| 133 | partition.write(4, &write_buf).await.unwrap(); | 133 | partition.write(4, &write_buf).await.unwrap(); |
| 134 | 134 | ||
| 135 | let flash = flash.try_lock().unwrap(); | 135 | let flash = flash.try_lock().unwrap(); |
| 136 | assert!(flash.mem[132..132 + 8].iter().position(|&x| x != 0xAA).is_none()); | 136 | assert!(!flash.mem[132..132 + 8].iter().any(|&x| x != 0xAA)); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | #[futures_test::test] | 139 | #[futures_test::test] |
| @@ -146,6 +146,6 @@ mod tests { | |||
| 146 | partition.erase(0, 128).await.unwrap(); | 146 | partition.erase(0, 128).await.unwrap(); |
| 147 | 147 | ||
| 148 | let flash = flash.try_lock().unwrap(); | 148 | let flash = flash.try_lock().unwrap(); |
| 149 | assert!(flash.mem[128..256].iter().position(|&x| x != 0xFF).is_none()); | 149 | assert!(!flash.mem[128..256].iter().any(|&x| x != 0xFF)); |
| 150 | } | 150 | } |
| 151 | } | 151 | } |
diff --git a/embassy-embedded-hal/src/flash/partition/blocking.rs b/embassy-embedded-hal/src/flash/partition/blocking.rs index 951998166..cb30290a8 100644 --- a/embassy-embedded-hal/src/flash/partition/blocking.rs +++ b/embassy-embedded-hal/src/flash/partition/blocking.rs | |||
| @@ -129,7 +129,7 @@ mod tests { | |||
| 129 | let mut read_buf = [0; 8]; | 129 | let mut read_buf = [0; 8]; |
| 130 | partition.read(4, &mut read_buf).unwrap(); | 130 | partition.read(4, &mut read_buf).unwrap(); |
| 131 | 131 | ||
| 132 | assert!(read_buf.iter().position(|&x| x != 0xAA).is_none()); | 132 | assert!(!read_buf.iter().any(|&x| x != 0xAA)); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | #[test] | 135 | #[test] |
| @@ -143,7 +143,7 @@ mod tests { | |||
| 143 | partition.write(4, &write_buf).unwrap(); | 143 | partition.write(4, &write_buf).unwrap(); |
| 144 | 144 | ||
| 145 | let flash = flash.into_inner().take(); | 145 | let flash = flash.into_inner().take(); |
| 146 | assert!(flash.mem[132..132 + 8].iter().position(|&x| x != 0xAA).is_none()); | 146 | assert!(!flash.mem[132..132 + 8].iter().any(|&x| x != 0xAA)); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | #[test] | 149 | #[test] |
| @@ -156,6 +156,6 @@ mod tests { | |||
| 156 | partition.erase(0, 128).unwrap(); | 156 | partition.erase(0, 128).unwrap(); |
| 157 | 157 | ||
| 158 | let flash = flash.into_inner().take(); | 158 | let flash = flash.into_inner().take(); |
| 159 | assert!(flash.mem[128..256].iter().position(|&x| x != 0xFF).is_none()); | 159 | assert!(!flash.mem[128..256].iter().any(|&x| x != 0xFF)); |
| 160 | } | 160 | } |
| 161 | } | 161 | } |
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index 78709b7d3..0faefbc1e 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs | |||
| @@ -112,11 +112,11 @@ where | |||
| 112 | cs_drop.defuse(); | 112 | cs_drop.defuse(); |
| 113 | let cs_res = self.cs.set_high(); | 113 | let cs_res = self.cs.set_high(); |
| 114 | 114 | ||
| 115 | let op_res = op_res.map_err(SpiDeviceError::Spi)?; | 115 | op_res.map_err(SpiDeviceError::Spi)?; |
| 116 | flush_res.map_err(SpiDeviceError::Spi)?; | 116 | flush_res.map_err(SpiDeviceError::Spi)?; |
| 117 | cs_res.map_err(SpiDeviceError::Cs)?; | 117 | cs_res.map_err(SpiDeviceError::Cs)?; |
| 118 | 118 | ||
| 119 | Ok(op_res) | 119 | Ok(()) |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| @@ -203,10 +203,10 @@ where | |||
| 203 | cs_drop.defuse(); | 203 | cs_drop.defuse(); |
| 204 | let cs_res = self.cs.set_high(); | 204 | let cs_res = self.cs.set_high(); |
| 205 | 205 | ||
| 206 | let op_res = op_res.map_err(SpiDeviceError::Spi)?; | 206 | op_res.map_err(SpiDeviceError::Spi)?; |
| 207 | flush_res.map_err(SpiDeviceError::Spi)?; | 207 | flush_res.map_err(SpiDeviceError::Spi)?; |
| 208 | cs_res.map_err(SpiDeviceError::Cs)?; | 208 | cs_res.map_err(SpiDeviceError::Cs)?; |
| 209 | 209 | ||
| 210 | Ok(op_res) | 210 | Ok(()) |
| 211 | } | 211 | } |
| 212 | } | 212 | } |
diff --git a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs index fa34cd416..dc634a209 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs | |||
| @@ -81,33 +81,33 @@ where | |||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | impl<'a, M, BUS, E> embedded_hal_02::blocking::i2c::Write for I2cDevice<'_, M, BUS> | 84 | impl<M, BUS, E> embedded_hal_02::blocking::i2c::Write for I2cDevice<'_, M, BUS> |
| 85 | where | 85 | where |
| 86 | M: RawMutex, | 86 | M: RawMutex, |
| 87 | BUS: embedded_hal_02::blocking::i2c::Write<Error = E>, | 87 | BUS: embedded_hal_02::blocking::i2c::Write<Error = E>, |
| 88 | { | 88 | { |
| 89 | type Error = I2cDeviceError<E>; | 89 | type Error = I2cDeviceError<E>; |
| 90 | 90 | ||
| 91 | fn write<'w>(&mut self, addr: u8, bytes: &'w [u8]) -> Result<(), Self::Error> { | 91 | fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> { |
| 92 | self.bus | 92 | self.bus |
| 93 | .lock(|bus| bus.borrow_mut().write(addr, bytes).map_err(I2cDeviceError::I2c)) | 93 | .lock(|bus| bus.borrow_mut().write(addr, bytes).map_err(I2cDeviceError::I2c)) |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | impl<'a, M, BUS, E> embedded_hal_02::blocking::i2c::Read for I2cDevice<'_, M, BUS> | 97 | impl<M, BUS, E> embedded_hal_02::blocking::i2c::Read for I2cDevice<'_, M, BUS> |
| 98 | where | 98 | where |
| 99 | M: RawMutex, | 99 | M: RawMutex, |
| 100 | BUS: embedded_hal_02::blocking::i2c::Read<Error = E>, | 100 | BUS: embedded_hal_02::blocking::i2c::Read<Error = E>, |
| 101 | { | 101 | { |
| 102 | type Error = I2cDeviceError<E>; | 102 | type Error = I2cDeviceError<E>; |
| 103 | 103 | ||
| 104 | fn read<'w>(&mut self, addr: u8, bytes: &'w mut [u8]) -> Result<(), Self::Error> { | 104 | fn read(&mut self, addr: u8, bytes: &mut [u8]) -> Result<(), Self::Error> { |
| 105 | self.bus | 105 | self.bus |
| 106 | .lock(|bus| bus.borrow_mut().read(addr, bytes).map_err(I2cDeviceError::I2c)) | 106 | .lock(|bus| bus.borrow_mut().read(addr, bytes).map_err(I2cDeviceError::I2c)) |
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | impl<'a, M, BUS, E> embedded_hal_02::blocking::i2c::WriteRead for I2cDevice<'_, M, BUS> | 110 | impl<M, BUS, E> embedded_hal_02::blocking::i2c::WriteRead for I2cDevice<'_, M, BUS> |
| 111 | where | 111 | where |
| 112 | M: RawMutex, | 112 | M: RawMutex, |
| 113 | BUS: embedded_hal_02::blocking::i2c::WriteRead<Error = E>, | 113 | BUS: embedded_hal_02::blocking::i2c::WriteRead<Error = E>, |
diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index eb9c0c4f4..ffe2aa1c6 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs | |||
| @@ -82,11 +82,11 @@ where | |||
| 82 | let flush_res = bus.flush(); | 82 | let flush_res = bus.flush(); |
| 83 | let cs_res = self.cs.set_high(); | 83 | let cs_res = self.cs.set_high(); |
| 84 | 84 | ||
| 85 | let op_res = op_res.map_err(SpiDeviceError::Spi)?; | 85 | op_res.map_err(SpiDeviceError::Spi)?; |
| 86 | flush_res.map_err(SpiDeviceError::Spi)?; | 86 | flush_res.map_err(SpiDeviceError::Spi)?; |
| 87 | cs_res.map_err(SpiDeviceError::Cs)?; | 87 | cs_res.map_err(SpiDeviceError::Cs)?; |
| 88 | 88 | ||
| 89 | Ok(op_res) | 89 | Ok(()) |
| 90 | }) | 90 | }) |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| @@ -158,10 +158,10 @@ where | |||
| 158 | let flush_res = bus.flush(); | 158 | let flush_res = bus.flush(); |
| 159 | let cs_res = self.cs.set_high(); | 159 | let cs_res = self.cs.set_high(); |
| 160 | 160 | ||
| 161 | let op_res = op_res.map_err(SpiDeviceError::Spi)?; | 161 | op_res.map_err(SpiDeviceError::Spi)?; |
| 162 | flush_res.map_err(SpiDeviceError::Spi)?; | 162 | flush_res.map_err(SpiDeviceError::Spi)?; |
| 163 | cs_res.map_err(SpiDeviceError::Cs)?; | 163 | cs_res.map_err(SpiDeviceError::Cs)?; |
| 164 | Ok(op_res) | 164 | Ok(()) |
| 165 | }) | 165 | }) |
| 166 | } | 166 | } |
| 167 | } | 167 | } |
