Skip to content

Commit

Permalink
enhance(i2c): partial eh-async impls, leaving transaction todo
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Jul 14, 2024
1 parent e961e60 commit 8bb8d86
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ This crate is a working-in-progress and not ready for use.

| MCU Family | PAC | Demo | Embassy | SYSCTL | GPIO | UART | I2C | SPI | DMA | TMR | ADC | USB |
|------------|-----|------|---------|--------|------|------|-----|-----|-----|-----|-----|-----|
| HPM6700 ||||| ✓+ | ✓+ | || ✓+ | | | |
| HPM6700 ||||| ✓+ | ✓+ |+ || ✓+ | | | |
| HPM6300 ||||| | | | | | | | |
| HPM6200 || | | | | | | | | | | |
| HPM5300 ||||| ✓+ | ✓+ | || ✓+ | | | |
| HPM5300 ||||| ✓+ | ✓+ |+ || ✓+ | | | |
| HPM6800 || | | | | | | | | | | |
| HPM6E00 ||||| ✓+ | ✓+ | ? || ✓+ | | | |

Expand Down Expand Up @@ -46,7 +46,7 @@ This crate is a working-in-progress and not ready for use.
- [ ] Ring buffer based async
- [x] I2C
- [x] Blocking driver
- [ ] Async driver
- [x] Async driver
- [x] MBX
- [x] blocking and async, message mode and fifo mode
- [ ] DMA driver?
Expand Down
22 changes: 22 additions & 0 deletions src/i2c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,28 @@ impl<'d, M: Mode> embedded_hal::i2c::I2c for I2c<'d, M> {
}
}

impl<'d> embedded_hal_async::i2c::I2c for I2c<'d, Async> {
async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> {
self.read(address, read).await
}

async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> {
self.write(address, write).await
}

async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
self.write_read(address, write, read).await
}

async fn transaction(
&mut self,
_address: u8,
_operations: &mut [embedded_hal::i2c::Operation<'_>],
) -> Result<(), Self::Error> {
unimplemented!("async transaction")
}
}

// ==========
// frame options

Expand Down

0 comments on commit 8bb8d86

Please sign in to comment.