pub fn read_timestamp(&self) -> Option<NaiveDateTime> {
        if !self.reg.isr.read().tsf().bit_is_clear() {
            return None;
        }

        // Timestamp doesn't include year, get it from the main calendar
        let data = self.reg.dr.read();
        let year = 2000 + i32(data.yt().bits()) * 10 + i32(data.yu().bits());

        let data = self.reg.tsdr.read();
        let month = data.mt().bits() as u8 * 10 + data.mu().bits();
        let day = data.dt().bits() * 10 + data.du().bits();
        let date = NaiveDate::from_ymd_opt(year, u32(month), u32(day))?;

        let data = self.reg.tstr.read();
        let mut hour = data.ht().bits() * 10 + data.hu().bits();
        if data.pm().bit_is_set() {
            hour += 12; // Shouldn't be configured this way, but handle it anyway
        }
        let minute = data.mnt().bits() * 10 + data.mnu().bits();
        let second = data.st().bits() * 10 + data.su().bits();
        let micro = self.ss_to_us(self.reg.tsssr.read().ss().bits());
        let time = NaiveTime::from_hms_micro_opt(
            u32(hour),
            u32(minute),
            u32(second),
            u32(micro),
        )?;

        // Clear timestamp interrupt and internal timestamp interrupt (VBat transition)
        // TODO: Timestamp overflow flag
        self.reg
            .isr
            .modify(|_, w| w.tsf().clear_bit().itsf().clear_bit());

        Some(date.and_time(time))
    }
/// Reads the stored value of the timestamp if present
///
/// Clears the timestamp interrupt flags.
Reads the stored value of the timestamp if present
Clears the timestamp interrupt flags.
Reads the stored value of the timestamp if present Clears the timestamp interrupt flags .
pub fn read_timestamp(&self) -> Option<NaiveDateTime> {
        if !self.reg.isr.read().tsf().bit_is_clear() {
            return None;
        }
        // Timestamp doesn't include year, get it from the main calendar
        let data = self.reg.dr.read();
        let year = 2000 + i32(data.yt().bits()) * 10 + i32(data.yu().bits());
        let data = self.reg.tsdr.read();
        let month = data.mt().bits() as u8 * 10 + data.mu().bits();
        let day = data.dt().bits() * 10 + data.du().bits();
        let date = NaiveDate::from_ymd_opt(year, u32(month), u32(day))?;
        let data = self.reg.tstr.read();
        let mut hour = data.ht().bits() * 10 + data.hu().bits();
        if data.pm().bit_is_set() {
            hour += 12; // Shouldn't be configured this way, but handle it anyway
        }
        let minute = data.mnt().bits() * 10 + data.mnu().bits();
        let second = data.st().bits() * 10 + data.su().bits();
        let micro = self.ss_to_us(self.reg.tsssr.read().ss().bits());
        let time = NaiveTime::from_hms_micro_opt(
            u32(hour),
            u32(minute),
            u32(second),
            u32(micro),
        )?;
        // Clear timestamp interrupt and internal timestamp interrupt (VBat transition)
        // TODO: Timestamp overflow flag
        self.reg
            .isr
            .modify(|_, w| w.tsf().clear_bit().itsf().clear_bit());
        Some(date.and_time(time))
    }
pub fn read_timestamp ( & self ) -> Option < NaiveDateTime > { if ! self . reg . isr . read ( ) . tsf ( ) . bit_is_clear ( ) { return None ; } // Timestamp doesn't include year, get it from the main calendar let data = self . reg . dr . read ( ) ; let year = 2000 + i32 ( data . yt ( ) . bits ( ) ) * 10 + i32 ( data . yu ( ) . bits ( ) ) ; let data = self . reg . tsdr . read ( ) ; let month = data . mt ( ) . bits ( ) as u8 * 10 + data . mu ( ) . bits ( ) ; let day = data . dt ( ) . bits ( ) * 10 + data . du ( ) . bits ( ) ; let date = NaiveDate :: from_ymd_opt ( year , u32 ( month ) , u32 ( day ) ) ? ; let data = self . reg . tstr . read ( ) ; let mut hour = data . ht ( ) . bits ( ) * 10 + data . hu ( ) . bits ( ) ; if data . pm ( ) . bit_is_set ( ) { hour += 12 ; // Shouldn't be configured this way, but handle it anyway } let minute = data . mnt ( ) . bits ( ) * 10 + data . mnu ( ) . bits ( ) ; let second = data . st ( ) . bits ( ) * 10 + data . su ( ) . bits ( ) ; let micro = self . ss_to_us ( self . reg . tsssr . read ( ) . ss ( ) . bits ( ) ) ; let time = NaiveTime :: from_hms_micro_opt ( u32 ( hour ) , u32 ( minute ) , u32 ( second ) , u32 ( micro ) , ) ? ; // Clear timestamp interrupt and internal timestamp interrupt (VBat transition) // TODO: Timestamp overflow flag self . reg . isr . modify ( | _ , w | w . tsf ( ) . clear_bit ( ) . itsf ( ) . clear_bit ( ) ) ; Some ( date . and_time ( time ) ) }
Reads the stored value of the timestamp if present
Clears the timestamp interrupt flags.
Reads the stored value of the timestamp if present Clears the timestamp interrupt flags .
&self
&self