pub struct Ft24c64<'peripherals, IM: MasterMode> {
i2c: I2c<'peripherals, Async, IM>,
wp: Flex<'peripherals>,
}Expand description
Driver for the FT24C64 64-Kbit (8 K × 8) I²C EEPROM.
Fields§
§i2c: I2c<'peripherals, Async, IM>I²C peripheral used for all device communication.
wp: Flex<'peripherals>Write-protect pin managed as input pull-up when idle, output-low when writing.
Implementations§
Source§impl<'peripherals, IM: MasterMode> Ft24c64<'peripherals, IM>
impl<'peripherals, IM: MasterMode> Ft24c64<'peripherals, IM>
Sourcepub fn new(i2c: I2c<'peripherals, Async, IM>, wp: Flex<'peripherals>) -> Self
pub fn new(i2c: I2c<'peripherals, Async, IM>, wp: Flex<'peripherals>) -> Self
Create a new driver.
Sourceasync fn poll_until_ready(&mut self, max_attempts: u8) -> Result<(), Error>
async fn poll_until_ready(&mut self, max_attempts: u8) -> Result<(), Error>
Poll the device with a zero-length write until it ACKs, indicating
the internal write cycle has completed. Retries up to max_attempts
times with a short yield between each attempt.
Returns Ok(()) as soon as the device acknowledges. Returns
[Error] if the device does not become ready within max_attempts.
Sourcepub async fn read(&mut self, addr: u16, buf: &mut [u8]) -> Result<(), Error>
pub async fn read(&mut self, addr: u16, buf: &mut [u8]) -> Result<(), Error>
Read buf.len() bytes starting at 16-bit word address addr.
Sourcepub async fn write(&mut self, start_addr: u16, data: &[u8]) -> Result<(), Error>
pub async fn write(&mut self, start_addr: u16, data: &[u8]) -> Result<(), Error>
Write data starting at 16-bit word address start_addr.
Sourcepub async fn zero_out(&mut self) -> Result<(), Error>
pub async fn zero_out(&mut self) -> Result<(), Error>
Erase the entire EEPROM by writing 0xFF to all 8 192 bytes.
Pages are written sequentially from address 0x0000 to 0x1FFF (256
pages × 32 bytes). After each page write, the driver waits for the
device to become ready again using the polling-based readiness check
before continuing with the next page.
Call this once on first boot before starting a calibration run to guarantee no stale data survives in any region of the device.
§Errors
Returns the first [Error] encountered. Any pages written before the
failure are not rolled back.