ra6m2/rtc/
radj.rs

1#[doc = "Register `RADJ` reader"]
2pub struct R(crate::R<RADJ_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<RADJ_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<RADJ_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<RADJ_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `RADJ` writer"]
17pub struct W(crate::W<RADJ_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<RADJ_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<RADJ_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<RADJ_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ADJ` reader - Adjustment Value These bits specify the adjustment value from the prescaler."]
38pub type ADJ_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `ADJ` writer - Adjustment Value These bits specify the adjustment value from the prescaler."]
40pub type ADJ_W<'a, const O: u8> = crate::FieldWriter<'a, u8, RADJ_SPEC, u8, u8, 6, O>;
41#[doc = "Field `PMADJ` reader - Plus-Minus"]
42pub type PMADJ_R = crate::FieldReader<u8, PMADJ_A>;
43#[doc = "Plus-Minus\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum PMADJ_A {
47    #[doc = "0: Adjustment is not performed."]
48    _00 = 0,
49    #[doc = "1: Adjustment is performed by the addition to the prescaler."]
50    _01 = 1,
51    #[doc = "2: Adjustment is performed by the subtraction from the prescaler."]
52    _10 = 2,
53    #[doc = "3: Setting prohibited"]
54    _11 = 3,
55}
56impl From<PMADJ_A> for u8 {
57    #[inline(always)]
58    fn from(variant: PMADJ_A) -> Self {
59        variant as _
60    }
61}
62impl PMADJ_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> PMADJ_A {
66        match self.bits {
67            0 => PMADJ_A::_00,
68            1 => PMADJ_A::_01,
69            2 => PMADJ_A::_10,
70            3 => PMADJ_A::_11,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `_00`"]
75    #[inline(always)]
76    pub fn is_00(&self) -> bool {
77        *self == PMADJ_A::_00
78    }
79    #[doc = "Checks if the value of the field is `_01`"]
80    #[inline(always)]
81    pub fn is_01(&self) -> bool {
82        *self == PMADJ_A::_01
83    }
84    #[doc = "Checks if the value of the field is `_10`"]
85    #[inline(always)]
86    pub fn is_10(&self) -> bool {
87        *self == PMADJ_A::_10
88    }
89    #[doc = "Checks if the value of the field is `_11`"]
90    #[inline(always)]
91    pub fn is_11(&self) -> bool {
92        *self == PMADJ_A::_11
93    }
94}
95#[doc = "Field `PMADJ` writer - Plus-Minus"]
96pub type PMADJ_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, RADJ_SPEC, u8, PMADJ_A, 2, O>;
97impl<'a, const O: u8> PMADJ_W<'a, O> {
98    #[doc = "Adjustment is not performed."]
99    #[inline(always)]
100    pub fn _00(self) -> &'a mut W {
101        self.variant(PMADJ_A::_00)
102    }
103    #[doc = "Adjustment is performed by the addition to the prescaler."]
104    #[inline(always)]
105    pub fn _01(self) -> &'a mut W {
106        self.variant(PMADJ_A::_01)
107    }
108    #[doc = "Adjustment is performed by the subtraction from the prescaler."]
109    #[inline(always)]
110    pub fn _10(self) -> &'a mut W {
111        self.variant(PMADJ_A::_10)
112    }
113    #[doc = "Setting prohibited"]
114    #[inline(always)]
115    pub fn _11(self) -> &'a mut W {
116        self.variant(PMADJ_A::_11)
117    }
118}
119impl R {
120    #[doc = "Bits 0:5 - Adjustment Value These bits specify the adjustment value from the prescaler."]
121    #[inline(always)]
122    pub fn adj(&self) -> ADJ_R {
123        ADJ_R::new(self.bits & 0x3f)
124    }
125    #[doc = "Bits 6:7 - Plus-Minus"]
126    #[inline(always)]
127    pub fn pmadj(&self) -> PMADJ_R {
128        PMADJ_R::new((self.bits >> 6) & 3)
129    }
130}
131impl W {
132    #[doc = "Bits 0:5 - Adjustment Value These bits specify the adjustment value from the prescaler."]
133    #[inline(always)]
134    #[must_use]
135    pub fn adj(&mut self) -> ADJ_W<0> {
136        ADJ_W::new(self)
137    }
138    #[doc = "Bits 6:7 - Plus-Minus"]
139    #[inline(always)]
140    #[must_use]
141    pub fn pmadj(&mut self) -> PMADJ_W<6> {
142        PMADJ_W::new(self)
143    }
144    #[doc = "Writes raw bits to the register."]
145    #[inline(always)]
146    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
147        self.0.bits(bits);
148        self
149    }
150}
151#[doc = "Time Error Adjustment Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [radj](index.html) module"]
152pub struct RADJ_SPEC;
153impl crate::RegisterSpec for RADJ_SPEC {
154    type Ux = u8;
155}
156#[doc = "`read()` method returns [radj::R](R) reader structure"]
157impl crate::Readable for RADJ_SPEC {
158    type Reader = R;
159}
160#[doc = "`write(|w| ..)` method takes [radj::W](W) writer structure"]
161impl crate::Writable for RADJ_SPEC {
162    type Writer = W;
163    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
164    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
165}
166#[doc = "`reset()` method sets RADJ to value 0"]
167impl crate::Resettable for RADJ_SPEC {
168    const RESET_VALUE: Self::Ux = 0;
169}