efm32pg12_pac/lesense/
biasctrl.rs

1#[doc = "Reader of register BIASCTRL"]
2pub type R = crate::R<u32, super::BIASCTRL>;
3#[doc = "Writer for register BIASCTRL"]
4pub type W = crate::W<u32, super::BIASCTRL>;
5#[doc = "Register BIASCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::BIASCTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Select Bias Mode\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum BIASMODE_A {
17    #[doc = "0: Bias module is controlled by the EMU and is not affected by LESENSE"]
18    DONTTOUCH = 0,
19    #[doc = "1: Bias module duty cycled between low power and high accuracy mode"]
20    DUTYCYCLE = 1,
21    #[doc = "2: Bias module always in high accuracy mode"]
22    HIGHACC = 2,
23}
24impl From<BIASMODE_A> for u8 {
25    #[inline(always)]
26    fn from(variant: BIASMODE_A) -> Self {
27        variant as _
28    }
29}
30#[doc = "Reader of field `BIASMODE`"]
31pub type BIASMODE_R = crate::R<u8, BIASMODE_A>;
32impl BIASMODE_R {
33    #[doc = r"Get enumerated values variant"]
34    #[inline(always)]
35    pub fn variant(&self) -> crate::Variant<u8, BIASMODE_A> {
36        use crate::Variant::*;
37        match self.bits {
38            0 => Val(BIASMODE_A::DONTTOUCH),
39            1 => Val(BIASMODE_A::DUTYCYCLE),
40            2 => Val(BIASMODE_A::HIGHACC),
41            i => Res(i),
42        }
43    }
44    #[doc = "Checks if the value of the field is `DONTTOUCH`"]
45    #[inline(always)]
46    pub fn is_donttouch(&self) -> bool {
47        *self == BIASMODE_A::DONTTOUCH
48    }
49    #[doc = "Checks if the value of the field is `DUTYCYCLE`"]
50    #[inline(always)]
51    pub fn is_dutycycle(&self) -> bool {
52        *self == BIASMODE_A::DUTYCYCLE
53    }
54    #[doc = "Checks if the value of the field is `HIGHACC`"]
55    #[inline(always)]
56    pub fn is_highacc(&self) -> bool {
57        *self == BIASMODE_A::HIGHACC
58    }
59}
60#[doc = "Write proxy for field `BIASMODE`"]
61pub struct BIASMODE_W<'a> {
62    w: &'a mut W,
63}
64impl<'a> BIASMODE_W<'a> {
65    #[doc = r"Writes `variant` to the field"]
66    #[inline(always)]
67    pub fn variant(self, variant: BIASMODE_A) -> &'a mut W {
68        unsafe { self.bits(variant.into()) }
69    }
70    #[doc = "Bias module is controlled by the EMU and is not affected by LESENSE"]
71    #[inline(always)]
72    pub fn donttouch(self) -> &'a mut W {
73        self.variant(BIASMODE_A::DONTTOUCH)
74    }
75    #[doc = "Bias module duty cycled between low power and high accuracy mode"]
76    #[inline(always)]
77    pub fn dutycycle(self) -> &'a mut W {
78        self.variant(BIASMODE_A::DUTYCYCLE)
79    }
80    #[doc = "Bias module always in high accuracy mode"]
81    #[inline(always)]
82    pub fn highacc(self) -> &'a mut W {
83        self.variant(BIASMODE_A::HIGHACC)
84    }
85    #[doc = r"Writes raw bits to the field"]
86    #[inline(always)]
87    pub unsafe fn bits(self, value: u8) -> &'a mut W {
88        self.w.bits = (self.w.bits & !0x03) | ((value as u32) & 0x03);
89        self.w
90    }
91}
92impl R {
93    #[doc = "Bits 0:1 - Select Bias Mode"]
94    #[inline(always)]
95    pub fn biasmode(&self) -> BIASMODE_R {
96        BIASMODE_R::new((self.bits & 0x03) as u8)
97    }
98}
99impl W {
100    #[doc = "Bits 0:1 - Select Bias Mode"]
101    #[inline(always)]
102    pub fn biasmode(&mut self) -> BIASMODE_W {
103        BIASMODE_W { w: self }
104    }
105}