pub struct Atecc<H>where
H: AteccHal,{
hal: H,
device_addr: u8,
}Expand description
Driver handle owning the HAL.
Does not, by itself, expose any chip command. Use Self::open_channel
to wake the chip and obtain an AteccChannel on which the command
API lives.
Fields§
§hal: H§device_addr: u8Implementations§
Source§impl<H> Atecc<H>where
H: AteccHal,
impl<H> Atecc<H>where
H: AteccHal,
Sourcepub fn new(hal: H) -> Self
pub fn new(hal: H) -> Self
Build a new driver around an existing HAL, using the chip’s default
I2C address (I2C_ADDRESS).
Sourcepub(crate) fn with_address(hal: H, addr: u8) -> Self
pub(crate) fn with_address(hal: H, addr: u8) -> Self
Build a new driver against a chip with a non-default I2C address.
Sourcepub async fn open_channel(
&mut self,
) -> Result<AteccChannel<'_, H>, AteccError<H::Error>>
pub async fn open_channel( &mut self, ) -> Result<AteccChannel<'_, H>, AteccError<H::Error>>
Open a communication channel with the chip.
Performs the wake sequence and returns an AteccChannel that
exposes the typed command API. The channel borrows self mutably
for as long as it exists, which prevents accidentally opening two
channels concurrently.
The caller is expected to close the channel via
AteccChannel::close when finished. Dropping a channel without
closing leaves the chip awake; its watchdog will eventually idle it,
but the next Self::open_channel call may observe a transient
state. A defmt::warn! is emitted in that case to flag the
protocol violation.
§Errors
Forwards every variant from crate::wake::wake.