efm32pg22_pac/efm32pg22c200/iadc0_ns/
scale1.rs1#[doc = "Register `SCALE1` reader"]
2pub struct R(crate::R<SCALE1_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<SCALE1_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<SCALE1_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<SCALE1_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `SCALE1` writer"]
17pub struct W(crate::W<SCALE1_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<SCALE1_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<SCALE1_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<SCALE1_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `OFFSET` reader - Offset"]
38pub type OFFSET_R = crate::FieldReader<u32, u32>;
39#[doc = "Field `OFFSET` writer - Offset"]
40pub type OFFSET_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SCALE1_SPEC, u32, u32, 18, O>;
41#[doc = "Field `GAIN13LSB` reader - Gain 13 LSBs"]
42pub type GAIN13LSB_R = crate::FieldReader<u16, u16>;
43#[doc = "Field `GAIN13LSB` writer - Gain 13 LSBs"]
44pub type GAIN13LSB_W<'a, const O: u8> = crate::FieldWriter<'a, u32, SCALE1_SPEC, u16, u16, 13, O>;
45#[doc = "Field `GAIN3MSB` reader - Gain 3 MSBs"]
46pub type GAIN3MSB_R = crate::BitReader<GAIN3MSB_A>;
47#[doc = "Gain 3 MSBs\n\nValue on reset: 1"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49pub enum GAIN3MSB_A {
50 #[doc = "0: Upper 3 bits of gain = 011 (0.75x)"]
51 GAIN011 = 0,
52 #[doc = "1: Upper 3 bits of gain = 100 (1.00x)"]
53 GAIN100 = 1,
54}
55impl From<GAIN3MSB_A> for bool {
56 #[inline(always)]
57 fn from(variant: GAIN3MSB_A) -> Self {
58 variant as u8 != 0
59 }
60}
61impl GAIN3MSB_R {
62 #[doc = "Get enumerated values variant"]
63 #[inline(always)]
64 pub fn variant(&self) -> GAIN3MSB_A {
65 match self.bits {
66 false => GAIN3MSB_A::GAIN011,
67 true => GAIN3MSB_A::GAIN100,
68 }
69 }
70 #[doc = "Checks if the value of the field is `GAIN011`"]
71 #[inline(always)]
72 pub fn is_gain011(&self) -> bool {
73 *self == GAIN3MSB_A::GAIN011
74 }
75 #[doc = "Checks if the value of the field is `GAIN100`"]
76 #[inline(always)]
77 pub fn is_gain100(&self) -> bool {
78 *self == GAIN3MSB_A::GAIN100
79 }
80}
81#[doc = "Field `GAIN3MSB` writer - Gain 3 MSBs"]
82pub type GAIN3MSB_W<'a, const O: u8> = crate::BitWriter<'a, u32, SCALE1_SPEC, GAIN3MSB_A, O>;
83impl<'a, const O: u8> GAIN3MSB_W<'a, O> {
84 #[doc = "Upper 3 bits of gain = 011 (0.75x)"]
85 #[inline(always)]
86 pub fn gain011(self) -> &'a mut W {
87 self.variant(GAIN3MSB_A::GAIN011)
88 }
89 #[doc = "Upper 3 bits of gain = 100 (1.00x)"]
90 #[inline(always)]
91 pub fn gain100(self) -> &'a mut W {
92 self.variant(GAIN3MSB_A::GAIN100)
93 }
94}
95impl R {
96 #[doc = "Bits 0:17 - Offset"]
97 #[inline(always)]
98 pub fn offset(&self) -> OFFSET_R {
99 OFFSET_R::new(self.bits & 0x0003_ffff)
100 }
101 #[doc = "Bits 18:30 - Gain 13 LSBs"]
102 #[inline(always)]
103 pub fn gain13lsb(&self) -> GAIN13LSB_R {
104 GAIN13LSB_R::new(((self.bits >> 18) & 0x1fff) as u16)
105 }
106 #[doc = "Bit 31 - Gain 3 MSBs"]
107 #[inline(always)]
108 pub fn gain3msb(&self) -> GAIN3MSB_R {
109 GAIN3MSB_R::new(((self.bits >> 31) & 1) != 0)
110 }
111}
112impl W {
113 #[doc = "Bits 0:17 - Offset"]
114 #[inline(always)]
115 #[must_use]
116 pub fn offset(&mut self) -> OFFSET_W<0> {
117 OFFSET_W::new(self)
118 }
119 #[doc = "Bits 18:30 - Gain 13 LSBs"]
120 #[inline(always)]
121 #[must_use]
122 pub fn gain13lsb(&mut self) -> GAIN13LSB_W<18> {
123 GAIN13LSB_W::new(self)
124 }
125 #[doc = "Bit 31 - Gain 3 MSBs"]
126 #[inline(always)]
127 #[must_use]
128 pub fn gain3msb(&mut self) -> GAIN3MSB_W<31> {
129 GAIN3MSB_W::new(self)
130 }
131 #[doc = "Writes raw bits to the register."]
132 #[inline(always)]
133 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
134 self.0.bits(bits);
135 self
136 }
137}
138#[doc = "Scale\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 [scale1](index.html) module"]
139pub struct SCALE1_SPEC;
140impl crate::RegisterSpec for SCALE1_SPEC {
141 type Ux = u32;
142}
143#[doc = "`read()` method returns [scale1::R](R) reader structure"]
144impl crate::Readable for SCALE1_SPEC {
145 type Reader = R;
146}
147#[doc = "`write(|w| ..)` method takes [scale1::W](W) writer structure"]
148impl crate::Writable for SCALE1_SPEC {
149 type Writer = W;
150 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
151 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
152}
153#[doc = "`reset()` method sets SCALE1 to value 0x8002_c000"]
154impl crate::Resettable for SCALE1_SPEC {
155 const RESET_VALUE: Self::Ux = 0x8002_c000;
156}