Skip to main content

Ft24c64

Struct Ft24c64 

Source
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>

Source

pub fn new(i2c: I2c<'peripherals, Async, IM>, wp: Flex<'peripherals>) -> Self

Create a new driver.

Source

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.

Source

pub async fn read(&mut self, addr: u16, buf: &mut [u8]) -> Result<(), Error>

Read buf.len() bytes starting at 16-bit word address addr.

Source

pub async fn write(&mut self, start_addr: u16, data: &[u8]) -> Result<(), Error>

Write data starting at 16-bit word address start_addr.

Source

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.

Auto Trait Implementations§

§

impl<'peripherals, IM> Freeze for Ft24c64<'peripherals, IM>

§

impl<'peripherals, IM> !RefUnwindSafe for Ft24c64<'peripherals, IM>

§

impl<'peripherals, IM> Send for Ft24c64<'peripherals, IM>
where IM: Send,

§

impl<'peripherals, IM> Sync for Ft24c64<'peripherals, IM>
where IM: Sync,

§

impl<'peripherals, IM> Unpin for Ft24c64<'peripherals, IM>
where IM: Unpin,

§

impl<'peripherals, IM> UnsafeUnpin for Ft24c64<'peripherals, IM>

§

impl<'peripherals, IM> !UnwindSafe for Ft24c64<'peripherals, IM>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.