m24c64_driver/
lib.rs

1// Based off the m24c64 crate, with some changes to support writing arbitrary lengths of data
2#![cfg_attr(not(test), no_std)]
3
4#![doc = include_str!("../README.md")]
5
6#[cfg(feature = "sync")]
7pub mod sync;
8#[cfg(feature = "async")]
9pub mod async_variant;
10
11/// M24C64 EEPROM Driver
12pub struct M24C64<I2C> {
13  /// I2C Interface
14  i2c: I2C,
15  /// Address set by the E pins
16  e_addr: u8,
17  /// Command Buffer
18  cmd_buf: [u8; 34]
19}
20
21impl<I2C> M24C64<I2C> {
22  /// Create a new instance of the M24C64 Driver
23  /// # Arguments
24  /// * `i2c` - I2C Interface (from the embedded-hal(-async) crate)
25  /// * `e_addr` - The address set on the E pins
26  pub fn new(i2c: I2C, e_addr: u8) -> Self {
27    Self {
28      i2c, e_addr,
29      cmd_buf: [0u8; 34]
30    }
31  }
32}