pub trait AteccHal {
type Error: Debug;
// Required methods
async fn i2c_write(
&mut self,
device_addr: u8,
data: &[u8],
) -> Result<(), Self::Error>;
async fn i2c_read(
&mut self,
device_addr: u8,
buf: &mut [u8],
) -> Result<(), Self::Error>;
async fn pulse_sda_low(
&mut self,
duration_us: u32,
) -> Result<(), Self::Error>;
async fn delay_us(&mut self, duration_us: u32);
async fn delay_ms(&mut self, duration_ms: u32);
}Expand description
Hardware operations the driver needs.
All operations are async to play nicely with Embassy. A backend that runs
on a blocking platform can return core::future::ready(_).
async fn in a public trait normally triggers a lint because the returned
future is not Send and the caller has no way to add that bound. We
silence it deliberately. The driver and its backends are all consumed by a
single-threaded Embassy executor, where Send is irrelevant.
Required Associated Types§
Required Methods§
Sourceasync fn i2c_write(
&mut self,
device_addr: u8,
data: &[u8],
) -> Result<(), Self::Error>
async fn i2c_write( &mut self, device_addr: u8, data: &[u8], ) -> Result<(), Self::Error>
Write a buffer to the chip over I2C.
device_addr is the 7-bit slave address (typically 0x60 for the
ATECC608B-SSHDA at default factory configuration).
Sourceasync fn i2c_read(
&mut self,
device_addr: u8,
buf: &mut [u8],
) -> Result<(), Self::Error>
async fn i2c_read( &mut self, device_addr: u8, buf: &mut [u8], ) -> Result<(), Self::Error>
Read a buffer from the chip over I2C. buf is filled exactly to its
length.
Sourceasync fn pulse_sda_low(&mut self, duration_us: u32) -> Result<(), Self::Error>
async fn pulse_sda_low(&mut self, duration_us: u32) -> Result<(), Self::Error>
Pull the SDA line low for duration_us microseconds.
This is the wake pulse. The ATECC608B leaves deep sleep when SDA is
held low for at least tWLO (about 60 us). The backend is responsible
for temporarily detaching SDA from the I2C controller, driving it as a
plain GPIO output, then restoring it. Callers must follow this with a
1.5 ms delay before issuing the first I2C transfer (see crate::wake).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.