efm32pg12_pac/lesense/
st20_tconfb.rs

1#[doc = "Reader of register ST20_TCONFB"]
2pub type R = crate::R<u32, super::ST20_TCONFB>;
3#[doc = "Writer for register ST20_TCONFB"]
4pub type W = crate::W<u32, super::ST20_TCONFB>;
5#[doc = "Register ST20_TCONFB `reset()`'s with value 0"]
6impl crate::ResetValue for super::ST20_TCONFB {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `COMP`"]
14pub type COMP_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `COMP`"]
16pub struct COMP_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> COMP_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
24        self.w
25    }
26}
27#[doc = "Reader of field `MASK`"]
28pub type MASK_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `MASK`"]
30pub struct MASK_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> MASK_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u8) -> &'a mut W {
37        self.w.bits = (self.w.bits & !(0x0f << 4)) | (((value as u32) & 0x0f) << 4);
38        self.w
39    }
40}
41#[doc = "Reader of field `NEXTSTATE`"]
42pub type NEXTSTATE_R = crate::R<u8, u8>;
43#[doc = "Write proxy for field `NEXTSTATE`"]
44pub struct NEXTSTATE_W<'a> {
45    w: &'a mut W,
46}
47impl<'a> NEXTSTATE_W<'a> {
48    #[doc = r"Writes raw bits to the field"]
49    #[inline(always)]
50    pub unsafe fn bits(self, value: u8) -> &'a mut W {
51        self.w.bits = (self.w.bits & !(0x1f << 8)) | (((value as u32) & 0x1f) << 8);
52        self.w
53    }
54}
55#[doc = "Reader of field `SETIF`"]
56pub type SETIF_R = crate::R<bool, bool>;
57#[doc = "Write proxy for field `SETIF`"]
58pub struct SETIF_W<'a> {
59    w: &'a mut W,
60}
61impl<'a> SETIF_W<'a> {
62    #[doc = r"Sets the field bit"]
63    #[inline(always)]
64    pub fn set_bit(self) -> &'a mut W {
65        self.bit(true)
66    }
67    #[doc = r"Clears the field bit"]
68    #[inline(always)]
69    pub fn clear_bit(self) -> &'a mut W {
70        self.bit(false)
71    }
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub fn bit(self, value: bool) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
76        self.w
77    }
78}
79#[doc = "Reader of field `PRSACT`"]
80pub type PRSACT_R = crate::R<u8, u8>;
81#[doc = "Write proxy for field `PRSACT`"]
82pub struct PRSACT_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> PRSACT_W<'a> {
86    #[doc = r"Writes raw bits to the field"]
87    #[inline(always)]
88    pub unsafe fn bits(self, value: u8) -> &'a mut W {
89        self.w.bits = (self.w.bits & !(0x07 << 16)) | (((value as u32) & 0x07) << 16);
90        self.w
91    }
92}
93impl R {
94    #[doc = "Bits 0:3 - Sensor Compare Value"]
95    #[inline(always)]
96    pub fn comp(&self) -> COMP_R {
97        COMP_R::new((self.bits & 0x0f) as u8)
98    }
99    #[doc = "Bits 4:7 - Sensor Mask"]
100    #[inline(always)]
101    pub fn mask(&self) -> MASK_R {
102        MASK_R::new(((self.bits >> 4) & 0x0f) as u8)
103    }
104    #[doc = "Bits 8:12 - Next State Index"]
105    #[inline(always)]
106    pub fn nextstate(&self) -> NEXTSTATE_R {
107        NEXTSTATE_R::new(((self.bits >> 8) & 0x1f) as u8)
108    }
109    #[doc = "Bit 15 - Set Interrupt Flag"]
110    #[inline(always)]
111    pub fn setif(&self) -> SETIF_R {
112        SETIF_R::new(((self.bits >> 15) & 0x01) != 0)
113    }
114    #[doc = "Bits 16:18 - Configure Transition Action"]
115    #[inline(always)]
116    pub fn prsact(&self) -> PRSACT_R {
117        PRSACT_R::new(((self.bits >> 16) & 0x07) as u8)
118    }
119}
120impl W {
121    #[doc = "Bits 0:3 - Sensor Compare Value"]
122    #[inline(always)]
123    pub fn comp(&mut self) -> COMP_W {
124        COMP_W { w: self }
125    }
126    #[doc = "Bits 4:7 - Sensor Mask"]
127    #[inline(always)]
128    pub fn mask(&mut self) -> MASK_W {
129        MASK_W { w: self }
130    }
131    #[doc = "Bits 8:12 - Next State Index"]
132    #[inline(always)]
133    pub fn nextstate(&mut self) -> NEXTSTATE_W {
134        NEXTSTATE_W { w: self }
135    }
136    #[doc = "Bit 15 - Set Interrupt Flag"]
137    #[inline(always)]
138    pub fn setif(&mut self) -> SETIF_W {
139        SETIF_W { w: self }
140    }
141    #[doc = "Bits 16:18 - Configure Transition Action"]
142    #[inline(always)]
143    pub fn prsact(&mut self) -> PRSACT_W {
144        PRSACT_W { w: self }
145    }
146}