Crates.io | m24c64-driver |
lib.rs | m24c64-driver |
version | 0.0.2 |
source | src |
created_at | 2024-11-24 11:39:56.867815 |
updated_at | 2024-12-09 10:15:42.801893 |
description | A Rust embedded-hal(-async) driver for the M24C64 I2C EEPROM |
homepage | |
repository | https://github.com/Christopher-06/m24c64-driver |
max_upload_size | |
id | 1459169 |
size | 43,485 |
A Rust embedded-hal(-async) driver for the M24C64 I2C EEPROM, featuring arbitrary-length read/writes, timeout behaviour and asynchronous actions.
cargo add m24c64-driver
Synchronous API with STM32F4XX-hal crate. All examples only work with correctly configured controllers and projects. More details can be found in the corresponding HAL documentation
use m24c64_driver::M24C64;
let mut delay = cp.SYST.delay(&clocks); // stm32f4xx-hal
// let mut delay = embassy_time::Delay; // embassy-time
let eeprom = M24C64::new_blocking(i2c, 0b000);
eeprom.write_blocking(0xA0, &[0x00, 0x01, 0x02, 0x03], &delay);
let mut my_buf = [0u8; 4];
eeprom.read_blocking(0xA0, &mut my_buf);
// my_buf = [0x00, 0x01, 0x02, 0x03]
Note the use of [embedded_hal::blocking::delay::DelayMs
], which is used to retry the write every 1ms until it either succeeds, or 10ms has passed (2*t_w in the M24C64 datasheet).