tmc2209_uart/registers/
ifcnt.rs

1//! IFCNT - Interface transmission counter (0x02)
2
3use super::{Address, ReadableRegister, Register};
4
5/// Interface transmission counter.
6///
7/// This register is incremented with each successful UART write access.
8/// Read to check serial transmission for lost data.
9/// Wraps around from 255 to 0.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
11#[cfg_attr(feature = "defmt", derive(defmt::Format))]
12pub struct Ifcnt(u32);
13
14impl Ifcnt {
15    /// Get the interface counter value (0-255).
16    pub fn count(&self) -> u8 {
17        (self.0 & 0xFF) as u8
18    }
19
20    /// Get the raw register value.
21    pub fn raw(&self) -> u32 {
22        self.0
23    }
24
25    /// Create from raw value.
26    pub fn from_raw(value: u32) -> Self {
27        Self(value)
28    }
29}
30
31impl Register for Ifcnt {
32    const ADDRESS: Address = Address::Ifcnt;
33}
34
35impl ReadableRegister for Ifcnt {}
36
37impl From<u32> for Ifcnt {
38    fn from(value: u32) -> Self {
39        Self(value)
40    }
41}
42
43impl From<Ifcnt> for u32 {
44    fn from(reg: Ifcnt) -> u32 {
45        reg.0
46    }
47}