stm32wb_pac/rtc/
calr.rs

1#[doc = "Reader of register CALR"]
2pub type R = crate::R<u32, super::CALR>;
3#[doc = "Writer for register CALR"]
4pub type W = crate::W<u32, super::CALR>;
5#[doc = "Register CALR `reset()`'s with value 0"]
6impl crate::ResetValue for super::CALR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `CALP`"]
14pub type CALP_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `CALP`"]
16pub struct CALP_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> CALP_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
34        self.w
35    }
36}
37#[doc = "Reader of field `CALW8`"]
38pub type CALW8_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `CALW8`"]
40pub struct CALW8_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> CALW8_W<'a> {
44    #[doc = r"Sets the field bit"]
45    #[inline(always)]
46    pub fn set_bit(self) -> &'a mut W {
47        self.bit(true)
48    }
49    #[doc = r"Clears the field bit"]
50    #[inline(always)]
51    pub fn clear_bit(self) -> &'a mut W {
52        self.bit(false)
53    }
54    #[doc = r"Writes raw bits to the field"]
55    #[inline(always)]
56    pub fn bit(self, value: bool) -> &'a mut W {
57        self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u32) & 0x01) << 14);
58        self.w
59    }
60}
61#[doc = "Reader of field `CALW16`"]
62pub type CALW16_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `CALW16`"]
64pub struct CALW16_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> CALW16_W<'a> {
68    #[doc = r"Sets the field bit"]
69    #[inline(always)]
70    pub fn set_bit(self) -> &'a mut W {
71        self.bit(true)
72    }
73    #[doc = r"Clears the field bit"]
74    #[inline(always)]
75    pub fn clear_bit(self) -> &'a mut W {
76        self.bit(false)
77    }
78    #[doc = r"Writes raw bits to the field"]
79    #[inline(always)]
80    pub fn bit(self, value: bool) -> &'a mut W {
81        self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13);
82        self.w
83    }
84}
85#[doc = "Reader of field `CALM`"]
86pub type CALM_R = crate::R<u16, u16>;
87#[doc = "Write proxy for field `CALM`"]
88pub struct CALM_W<'a> {
89    w: &'a mut W,
90}
91impl<'a> CALM_W<'a> {
92    #[doc = r"Writes raw bits to the field"]
93    #[inline(always)]
94    pub unsafe fn bits(self, value: u16) -> &'a mut W {
95        self.w.bits = (self.w.bits & !0x01ff) | ((value as u32) & 0x01ff);
96        self.w
97    }
98}
99impl R {
100    #[doc = "Bit 15 - Increase frequency of RTC by 488.5 ppm"]
101    #[inline(always)]
102    pub fn calp(&self) -> CALP_R {
103        CALP_R::new(((self.bits >> 15) & 0x01) != 0)
104    }
105    #[doc = "Bit 14 - Use an 8-second calibration cycle period"]
106    #[inline(always)]
107    pub fn calw8(&self) -> CALW8_R {
108        CALW8_R::new(((self.bits >> 14) & 0x01) != 0)
109    }
110    #[doc = "Bit 13 - Use a 16-second calibration cycle period"]
111    #[inline(always)]
112    pub fn calw16(&self) -> CALW16_R {
113        CALW16_R::new(((self.bits >> 13) & 0x01) != 0)
114    }
115    #[doc = "Bits 0:8 - Calibration minus"]
116    #[inline(always)]
117    pub fn calm(&self) -> CALM_R {
118        CALM_R::new((self.bits & 0x01ff) as u16)
119    }
120}
121impl W {
122    #[doc = "Bit 15 - Increase frequency of RTC by 488.5 ppm"]
123    #[inline(always)]
124    pub fn calp(&mut self) -> CALP_W {
125        CALP_W { w: self }
126    }
127    #[doc = "Bit 14 - Use an 8-second calibration cycle period"]
128    #[inline(always)]
129    pub fn calw8(&mut self) -> CALW8_W {
130        CALW8_W { w: self }
131    }
132    #[doc = "Bit 13 - Use a 16-second calibration cycle period"]
133    #[inline(always)]
134    pub fn calw16(&mut self) -> CALW16_W {
135        CALW16_W { w: self }
136    }
137    #[doc = "Bits 0:8 - Calibration minus"]
138    #[inline(always)]
139    pub fn calm(&mut self) -> CALM_W {
140        CALM_W { w: self }
141    }
142}