rtc_hal/
nvram.rs

1//! Traits for RTC with non-volatile memory (NVRAM/SRAM) access
2
3use crate::rtc::Rtc;
4
5/// RTC with non-volatile memory (NVRAM/SRAM) access
6pub trait RtcNvram: Rtc {
7    /// Read data from NVRAM starting at the given offset
8    ///
9    /// # Parameters
10    /// * `offset` - NVRAM offset (0 = first NVRAM byte, up to device-specific max)
11    /// * `buffer` - Buffer to store the read data
12    ///
13    /// # Returns
14    /// * `Ok(())` on success
15    /// * `Err(Self::Error)` if offset or length is invalid, or read fails
16    fn read_nvram(&mut self, offset: u8, buffer: &mut [u8]) -> Result<(), Self::Error>;
17
18    /// Write data to NVRAM starting at the given offset
19    ///
20    /// # Parameters
21    /// * `offset` - NVRAM offset (0 = first NVRAM byte, up to device-specific max)
22    /// * `data` - Data to write to NVRAM
23    ///
24    /// # Returns
25    /// * `Ok(())` on success
26    /// * `Err(Self::Error)` if offset or length is invalid, or write fails
27    fn write_nvram(&mut self, offset: u8, data: &[u8]) -> Result<(), Self::Error>;
28
29    /// Get the size of available NVRAM in bytes
30    ///
31    /// # Returns
32    /// Total NVRAM size (e.g., 56 for DS1307, 0 for DS3231)
33    fn nvram_size(&self) -> u16;
34}