efm32gg11b/lesense/
st25_tconfb.rs

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