Struct Eeprom

Source
pub struct Eeprom<'a, I2C> {
    i2c: I2C,
    config: EepromConfig,
    busy: bool,
    _phantom: PhantomData<&'a ()>,
}
Expand description

EEPROM driver handle

Fields§

§i2c: I2C§config: EepromConfig§busy: bool§_phantom: PhantomData<&'a ()>

Implementations§

Source§

impl<'a, I2C> Eeprom<'a, I2C>
where I2C: I2c<'a>,

Source

pub fn new(i2c: I2C, config: EepromConfig) -> Result<Self, EepromError>

Create a new EEPROM driver instance

Source

pub fn is_device_ready(&mut self) -> Result<(), EepromError>

Check if the EEPROM device is ready

Source

pub fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), EepromError>

Read data from EEPROM

Source

pub fn write(&mut self, address: u32, data: &[u8]) -> Result<(), EepromError>

Write data to EEPROM

Source

fn write_pages(&mut self, address: u32, data: &[u8]) -> Result<(), EepromError>

Write data with page boundary handling

Source

fn write_chunk(&mut self, address: u32, data: &[u8]) -> Result<(), EepromError>

Write a single chunk (within page boundary)

Source

fn read_with_8bit_address( &mut self, address: u32, data: &mut [u8], ) -> Result<(), EepromError>

Read with 8-bit addressing

Source

fn read_with_16bit_address( &mut self, address: u32, data: &mut [u8], ) -> Result<(), EepromError>

Read with 16-bit addressing

Source

fn read_4kbit( &mut self, address: u32, data: &mut [u8], ) -> Result<(), EepromError>

Read from 4Kbit EEPROM (uses device address bits)

Source

fn read_8kbit( &mut self, address: u32, data: &mut [u8], ) -> Result<(), EepromError>

Read from 8Kbit EEPROM (uses device address bits)

Source

fn read_16kbit( &mut self, address: u32, data: &mut [u8], ) -> Result<(), EepromError>

Read from 16Kbit EEPROM (uses device address bits)

Source

fn write_with_8bit_address( &mut self, address: u32, data: &[u8], ) -> Result<(), EepromError>

Write with 8-bit addressing

Source

fn write_with_16bit_address( &mut self, address: u32, data: &[u8], ) -> Result<(), EepromError>

Write with 16-bit addressing

Source

fn write_4kbit(&mut self, address: u32, data: &[u8]) -> Result<(), EepromError>

Write to 4Kbit EEPROM

Source

fn write_8kbit(&mut self, address: u32, data: &[u8]) -> Result<(), EepromError>

Write to 8Kbit EEPROM

Source

fn write_16kbit(&mut self, address: u32, data: &[u8]) -> Result<(), EepromError>

Write to 16Kbit EEPROM

Source

fn delay_ms(&self, _ms: u32)

Simple delay function - in real implementation, this would use the system timer

Source

pub fn config(&self) -> &EepromConfig

Get the EEPROM configuration

Source

pub fn is_busy(&self) -> bool

Check if the driver is busy

Source§

impl<'a, I2C> Eeprom<'a, I2C>
where I2C: I2c<'a>,

Convenience functions for common operations

Source

pub fn read_byte(&mut self, address: u32) -> Result<u8, EepromError>

Read a single byte

Source

pub fn write_byte(&mut self, address: u32, data: u8) -> Result<(), EepromError>

Write a single byte

Source

pub fn read_u16(&mut self, address: u32) -> Result<u16, EepromError>

Read a u16 value (big-endian)

Source

pub fn write_u16(&mut self, address: u32, data: u16) -> Result<(), EepromError>

Write a u16 value (big-endian)

Source

pub fn read_u32(&mut self, address: u32) -> Result<u32, EepromError>

Read a u32 value (big-endian)

Source

pub fn write_u32(&mut self, address: u32, data: u32) -> Result<(), EepromError>

Write a u32 value (big-endian)

Source

pub fn clear_range( &mut self, start_address: u32, length: u32, ) -> Result<(), EepromError>

Clear (fill with 0xFF) a range of EEPROM

Auto Trait Implementations§

§

impl<'a, I2C> Freeze for Eeprom<'a, I2C>
where I2C: Freeze,

§

impl<'a, I2C> RefUnwindSafe for Eeprom<'a, I2C>
where I2C: RefUnwindSafe,

§

impl<'a, I2C> Send for Eeprom<'a, I2C>
where I2C: Send,

§

impl<'a, I2C> Sync for Eeprom<'a, I2C>
where I2C: Sync,

§

impl<'a, I2C> Unpin for Eeprom<'a, I2C>
where I2C: Unpin,

§

impl<'a, I2C> UnwindSafe for Eeprom<'a, I2C>
where I2C: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.