[−][src]Struct eeprom25aa02e48::Eeprom25aa02e48
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]
SPI: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
CS: OutputPin<Error = PinError>,
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]
&mut self,
address: u8,
data: &mut [u8]
) -> Result<(), Error<SpiError, PinError>>
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]
&mut self,
address: u8,
data: u8
) -> Result<(), Error<SpiError, PinError>>
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]
&mut self,
address: u8,
data: &[u8; 16]
) -> Result<(), Error<SpiError, PinError>>
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]
&mut self,
eui48: &mut [u8; 6]
) -> Result<(), Error<SpiError, PinError>>
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]
fn default() -> Eeprom25aa02e48<SPI, CS>
[src]
Auto Trait Implementations
impl<SPI, CS> Send for Eeprom25aa02e48<SPI, CS> where
CS: Send,
SPI: Send,
CS: Send,
SPI: Send,
impl<SPI, CS> Sync for Eeprom25aa02e48<SPI, CS> where
CS: Sync,
SPI: Sync,
CS: Sync,
SPI: Sync,
impl<SPI, CS> Unpin for Eeprom25aa02e48<SPI, CS> where
CS: Unpin,
SPI: Unpin,
CS: Unpin,
SPI: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
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>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,