tm4c129x/hib/
tpstat.rs

1#[doc = "Reader of register TPSTAT"]
2pub type R = crate::R<u32, super::TPSTAT>;
3#[doc = "Writer for register TPSTAT"]
4pub type W = crate::W<u32, super::TPSTAT>;
5#[doc = "Register TPSTAT `reset()`'s with value 0"]
6impl crate::ResetValue for super::TPSTAT {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `XOSCFAIL`"]
14pub type XOSCFAIL_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `XOSCFAIL`"]
16pub struct XOSCFAIL_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> XOSCFAIL_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) | ((value as u32) & 0x01);
34        self.w
35    }
36}
37#[doc = "Reader of field `XOSCST`"]
38pub type XOSCST_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `XOSCST`"]
40pub struct XOSCST_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> XOSCST_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 << 1)) | (((value as u32) & 0x01) << 1);
58        self.w
59    }
60}
61#[doc = "Tamper Module Status\n\nValue on reset: 0"]
62#[derive(Clone, Copy, Debug, PartialEq)]
63#[repr(u8)]
64pub enum STATE_A {
65    #[doc = "0: Tamper disabled"]
66    DISABLED = 0,
67    #[doc = "1: Tamper configured"]
68    CONFIGED = 1,
69    #[doc = "2: Tamper pin event occurred"]
70    ERROR = 2,
71}
72impl From<STATE_A> for u8 {
73    #[inline(always)]
74    fn from(variant: STATE_A) -> Self {
75        variant as _
76    }
77}
78#[doc = "Reader of field `STATE`"]
79pub type STATE_R = crate::R<u8, STATE_A>;
80impl STATE_R {
81    #[doc = r"Get enumerated values variant"]
82    #[inline(always)]
83    pub fn variant(&self) -> crate::Variant<u8, STATE_A> {
84        use crate::Variant::*;
85        match self.bits {
86            0 => Val(STATE_A::DISABLED),
87            1 => Val(STATE_A::CONFIGED),
88            2 => Val(STATE_A::ERROR),
89            i => Res(i),
90        }
91    }
92    #[doc = "Checks if the value of the field is `DISABLED`"]
93    #[inline(always)]
94    pub fn is_disabled(&self) -> bool {
95        *self == STATE_A::DISABLED
96    }
97    #[doc = "Checks if the value of the field is `CONFIGED`"]
98    #[inline(always)]
99    pub fn is_configed(&self) -> bool {
100        *self == STATE_A::CONFIGED
101    }
102    #[doc = "Checks if the value of the field is `ERROR`"]
103    #[inline(always)]
104    pub fn is_error(&self) -> bool {
105        *self == STATE_A::ERROR
106    }
107}
108#[doc = "Write proxy for field `STATE`"]
109pub struct STATE_W<'a> {
110    w: &'a mut W,
111}
112impl<'a> STATE_W<'a> {
113    #[doc = r"Writes `variant` to the field"]
114    #[inline(always)]
115    pub fn variant(self, variant: STATE_A) -> &'a mut W {
116        unsafe { self.bits(variant.into()) }
117    }
118    #[doc = "Tamper disabled"]
119    #[inline(always)]
120    pub fn disabled(self) -> &'a mut W {
121        self.variant(STATE_A::DISABLED)
122    }
123    #[doc = "Tamper configured"]
124    #[inline(always)]
125    pub fn configed(self) -> &'a mut W {
126        self.variant(STATE_A::CONFIGED)
127    }
128    #[doc = "Tamper pin event occurred"]
129    #[inline(always)]
130    pub fn error(self) -> &'a mut W {
131        self.variant(STATE_A::ERROR)
132    }
133    #[doc = r"Writes raw bits to the field"]
134    #[inline(always)]
135    pub unsafe fn bits(self, value: u8) -> &'a mut W {
136        self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u32) & 0x03) << 2);
137        self.w
138    }
139}
140impl R {
141    #[doc = "Bit 0 - External Oscillator Failure"]
142    #[inline(always)]
143    pub fn xoscfail(&self) -> XOSCFAIL_R {
144        XOSCFAIL_R::new((self.bits & 0x01) != 0)
145    }
146    #[doc = "Bit 1 - External Oscillator Status"]
147    #[inline(always)]
148    pub fn xoscst(&self) -> XOSCST_R {
149        XOSCST_R::new(((self.bits >> 1) & 0x01) != 0)
150    }
151    #[doc = "Bits 2:3 - Tamper Module Status"]
152    #[inline(always)]
153    pub fn state(&self) -> STATE_R {
154        STATE_R::new(((self.bits >> 2) & 0x03) as u8)
155    }
156}
157impl W {
158    #[doc = "Bit 0 - External Oscillator Failure"]
159    #[inline(always)]
160    pub fn xoscfail(&mut self) -> XOSCFAIL_W {
161        XOSCFAIL_W { w: self }
162    }
163    #[doc = "Bit 1 - External Oscillator Status"]
164    #[inline(always)]
165    pub fn xoscst(&mut self) -> XOSCST_W {
166        XOSCST_W { w: self }
167    }
168    #[doc = "Bits 2:3 - Tamper Module Status"]
169    #[inline(always)]
170    pub fn state(&mut self) -> STATE_W {
171        STATE_W { w: self }
172    }
173}