no-std microchip-eeprom-25lcxx

A platform agnostic driver to interface with the Microchip 25LCxx EEPROM through SPI

1 unstable release

0.1.0 Jul 14, 2020

#986 in Hardware support

MIT/Apache

14KB
200 lines

Microchip 25LCxx embedded-hal SPI driver crate

Rust HAL implementation (using SPI drivers) for Microchip's 25 series EEPROM chips.

Supported models:

Model Datasheet Density (bits) Page size (bytes)
25LC080C Link 8k 16
25LC080D Link 8k 32
25LC160C Link 16k 16
25LC160D Link 16k 32
25LC320A Link 32k 32
25LC640A Link 64k 32
25LC128 Link 128k 64
25LC256 Link 256k 64
25LC512 Link 512k 128
25LC1024 Link 1024k 256

Usage

Include library as a dependency in your Cargo.toml

[dependencies.microchip-eeprom-25lcxx]
version = "<version>"

        let mut e25x = microchip_eeprom_25lcxx::Eeprom25x::new(spi, cs, wp ,hold)?;
        e25x.release_from_deep_sleep_and_get_manufacturer_id();
        // 24 bit address
        let address = 0x55aa00u32;
        let write_reg = microchip_eeprom_25lcxx::e25x_write_from_address_command(address);
        let write_reg: [u8; 4] = write_reg.to_be_bytes();
        let mut buffer = [write_reg[0], write_reg[1], write_reg[2], write_reg[3], 0xFF, 0x10, 0xAA];
        // Set up write latch
        e25x.write_enable();
        let result = e25x.transfer(&mut buffer);
        let read_reg = microchip_eeprom_25lcxx::e25x_read_from_address_command(0x55aa00u32);
        let read_reg: [u8; 4] = read_reg.to_be_bytes();
        let mut read_buffer = [read_reg[0], read_reg[1], read_reg[2], read_reg[3], 0, 0, 0];
        e25x.transfer(&mut buffer)?;
        assert_eq!(read_buffer[4], 0xFF);
        assert_eq!(read_buffer[5], 0x10);
        assert_eq!(read_buffer[6], 0xAA);

Use embedded-hal implementation to get SPI and a GPIO OutputPin for the hold line, write protect line and chip select.

Dependencies

~100KB