tmc2209_uart/registers/
pwm_auto.rs1use super::{Address, ReadableRegister, Register};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11pub struct PwmAuto(u32);
12
13impl PwmAuto {
14 pub fn new() -> Self {
16 Self(0)
17 }
18
19 pub fn pwm_ofs_auto(&self) -> u8 {
24 (self.0 & 0xFF) as u8
25 }
26
27 pub fn pwm_grad_auto(&self) -> u8 {
32 ((self.0 >> 16) & 0xFF) as u8
33 }
34
35 pub fn raw(&self) -> u32 {
37 self.0
38 }
39
40 pub fn from_raw(value: u32) -> Self {
42 Self(value)
43 }
44}
45
46impl Default for PwmAuto {
47 fn default() -> Self {
48 Self::new()
49 }
50}
51
52impl Register for PwmAuto {
53 const ADDRESS: Address = Address::PwmAuto;
54}
55
56impl ReadableRegister for PwmAuto {}
57
58impl From<u32> for PwmAuto {
59 fn from(value: u32) -> Self {
60 Self(value)
61 }
62}
63
64impl From<PwmAuto> for u32 {
65 fn from(reg: PwmAuto) -> u32 {
66 reg.0
67 }
68}