[][src]Struct eeprom25aa02e48::Eeprom25aa02e48

pub struct Eeprom25aa02e48<SPI, CS> { /* fields omitted */ }

Eeprom25aa02e48 driver.

Implementations

impl<SPI, CS, SpiError, PinError> Eeprom25aa02e48<SPI, CS> where
    SPI: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
    CS: OutputPin<Error = PinError>, 
[src]

pub fn new(spi: SPI, cs: CS) -> Self[src]

Creates a new Eeprom25aa02e48 driver from a SPI peripheral and a chip select digital I/O pin.

Example

The spi and pin variables in this example will be provided by your device-specific hal crate.

use eeprom25aa02e48::Eeprom25aa02e48;

let mut eeprom = Eeprom25aa02e48::new(spi, pin);

pub fn read_data(
    &mut self,
    address: u8,
    data: &mut [u8]
) -> Result<(), Error<SpiError, PinError>>
[src]

Read from the EEPROM.

The size of the data buffer determines the number of bytes read.

Example

use eeprom25aa02e48::Eeprom25aa02e48;

let mut some_big_buf: [u8; 1024] = [0; 1024];
let mut eeprom = Eeprom25aa02e48::new(spi, pin);
// read 64 bytes starting at EEPROM address 0x0
eeprom.read_data(0x0, &mut some_big_buf[..63])?;

pub fn write_byte(
    &mut self,
    address: u8,
    data: u8
) -> Result<(), Error<SpiError, PinError>>
[src]

Write a byte to the EEPROM.

Example

use eeprom25aa02e48::Eeprom25aa02e48;

const ADDRESS: u8 = 0x10;
const DATA: u8 = 0x42;

let mut eeprom = Eeprom25aa02e48::new(spi, pin);
eeprom.write_byte(ADDRESS, DATA)?;

pub fn write_page(
    &mut self,
    address: u8,
    data: &[u8; 16]
) -> Result<(), Error<SpiError, PinError>>
[src]

Write a page to the EEPROM.

Note: The address must be page aligned.

Example

use eeprom25aa02e48::Eeprom25aa02e48;

let data: [u8; 16] = [0x12; 16];
let mut eeprom = Eeprom25aa02e48::new(spi, pin);
eeprom.write_page(0x0, &data)?;

pub fn read_eui48(
    &mut self,
    eui48: &mut [u8; 6]
) -> Result<(), Error<SpiError, PinError>>
[src]

Read the EUI48 MAC address from the EEPROM.

Example

use eeprom25aa02e48::Eeprom25aa02e48;

let mut eeprom = Eeprom25aa02e48::new(spi, pin);
let mut eui48: [u8; 6] = [0; 6];
eeprom.read_eui48(&mut eui48)?;

Trait Implementations

impl<SPI: Default, CS: Default> Default for Eeprom25aa02e48<SPI, CS>[src]

Auto Trait Implementations

impl<SPI, CS> Send for Eeprom25aa02e48<SPI, CS> where
    CS: Send,
    SPI: Send

impl<SPI, CS> Sync for Eeprom25aa02e48<SPI, CS> where
    CS: Sync,
    SPI: Sync

impl<SPI, CS> Unpin for Eeprom25aa02e48<SPI, CS> where
    CS: Unpin,
    SPI: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.