Crates.io | microchip-eeprom-25x |
lib.rs | microchip-eeprom-25x |
version | 0.1.0 |
source | src |
created_at | 2020-07-14 22:51:45.690137 |
updated_at | 2020-07-14 22:51:45.690137 |
description | A platform agnostic driver to interface with the Microchip 25xxxx EEPROM through SPI |
homepage | |
repository | https://github.com/mvniekerk/microchip-eeprom-25x |
max_upload_size | |
id | 265251 |
size | 24,465 |
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 |
Include library as a dependency in your Cargo.toml
[dependencies.microchip-eeprom-25x]
version = "<version>"
let mut e25x = microchip_eeprom_25x::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_25x::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_25x::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.