stm32f3_copterust/stm32f3x8/adc1/
ofr4.rs1#[doc = "Reader of register OFR4"]
2pub type R = crate::R<u32, super::OFR4>;
3#[doc = "Writer for register OFR4"]
4pub type W = crate::W<u32, super::OFR4>;
5#[doc = "Register OFR4 `reset()`'s with value 0"]
6impl crate::ResetValue for super::OFR4 {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "OFFSET4_EN\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum OFFSET4_EN_A {
16 #[doc = "0: Offset disabled"]
17 DISABLED = 0,
18 #[doc = "1: Offset enabled"]
19 ENABLED = 1,
20}
21impl From<OFFSET4_EN_A> for bool {
22 #[inline(always)]
23 fn from(variant: OFFSET4_EN_A) -> Self {
24 variant as u8 != 0
25 }
26}
27#[doc = "Reader of field `OFFSET4_EN`"]
28pub type OFFSET4_EN_R = crate::R<bool, OFFSET4_EN_A>;
29impl OFFSET4_EN_R {
30 #[doc = r"Get enumerated values variant"]
31 #[inline(always)]
32 pub fn variant(&self) -> OFFSET4_EN_A {
33 match self.bits {
34 false => OFFSET4_EN_A::DISABLED,
35 true => OFFSET4_EN_A::ENABLED,
36 }
37 }
38 #[doc = "Checks if the value of the field is `DISABLED`"]
39 #[inline(always)]
40 pub fn is_disabled(&self) -> bool {
41 *self == OFFSET4_EN_A::DISABLED
42 }
43 #[doc = "Checks if the value of the field is `ENABLED`"]
44 #[inline(always)]
45 pub fn is_enabled(&self) -> bool {
46 *self == OFFSET4_EN_A::ENABLED
47 }
48}
49#[doc = "Write proxy for field `OFFSET4_EN`"]
50pub struct OFFSET4_EN_W<'a> {
51 w: &'a mut W,
52}
53impl<'a> OFFSET4_EN_W<'a> {
54 #[doc = r"Writes `variant` to the field"]
55 #[inline(always)]
56 pub fn variant(self, variant: OFFSET4_EN_A) -> &'a mut W {
57 {
58 self.bit(variant.into())
59 }
60 }
61 #[doc = "Offset disabled"]
62 #[inline(always)]
63 pub fn disabled(self) -> &'a mut W {
64 self.variant(OFFSET4_EN_A::DISABLED)
65 }
66 #[doc = "Offset enabled"]
67 #[inline(always)]
68 pub fn enabled(self) -> &'a mut W {
69 self.variant(OFFSET4_EN_A::ENABLED)
70 }
71 #[doc = r"Sets the field bit"]
72 #[inline(always)]
73 pub fn set_bit(self) -> &'a mut W {
74 self.bit(true)
75 }
76 #[doc = r"Clears the field bit"]
77 #[inline(always)]
78 pub fn clear_bit(self) -> &'a mut W {
79 self.bit(false)
80 }
81 #[doc = r"Writes raw bits to the field"]
82 #[inline(always)]
83 pub fn bit(self, value: bool) -> &'a mut W {
84 self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
85 self.w
86 }
87}
88#[doc = "Reader of field `OFFSET4_CH`"]
89pub type OFFSET4_CH_R = crate::R<u8, u8>;
90#[doc = "Write proxy for field `OFFSET4_CH`"]
91pub struct OFFSET4_CH_W<'a> {
92 w: &'a mut W,
93}
94impl<'a> OFFSET4_CH_W<'a> {
95 #[doc = r"Writes raw bits to the field"]
96 #[inline(always)]
97 pub fn bits(self, value: u8) -> &'a mut W {
98 self.w.bits = (self.w.bits & !(0x1f << 26)) | (((value as u32) & 0x1f) << 26);
99 self.w
100 }
101}
102#[doc = "Reader of field `OFFSET4`"]
103pub type OFFSET4_R = crate::R<u16, u16>;
104#[doc = "Write proxy for field `OFFSET4`"]
105pub struct OFFSET4_W<'a> {
106 w: &'a mut W,
107}
108impl<'a> OFFSET4_W<'a> {
109 #[doc = r"Writes raw bits to the field"]
110 #[inline(always)]
111 pub fn bits(self, value: u16) -> &'a mut W {
112 self.w.bits = (self.w.bits & !0x0fff) | ((value as u32) & 0x0fff);
113 self.w
114 }
115}
116impl R {
117 #[doc = "Bit 31 - OFFSET4_EN"]
118 #[inline(always)]
119 pub fn offset4_en(&self) -> OFFSET4_EN_R {
120 OFFSET4_EN_R::new(((self.bits >> 31) & 0x01) != 0)
121 }
122 #[doc = "Bits 26:30 - OFFSET4_CH"]
123 #[inline(always)]
124 pub fn offset4_ch(&self) -> OFFSET4_CH_R {
125 OFFSET4_CH_R::new(((self.bits >> 26) & 0x1f) as u8)
126 }
127 #[doc = "Bits 0:11 - OFFSET4"]
128 #[inline(always)]
129 pub fn offset4(&self) -> OFFSET4_R {
130 OFFSET4_R::new((self.bits & 0x0fff) as u16)
131 }
132}
133impl W {
134 #[doc = "Bit 31 - OFFSET4_EN"]
135 #[inline(always)]
136 pub fn offset4_en(&mut self) -> OFFSET4_EN_W {
137 OFFSET4_EN_W { w: self }
138 }
139 #[doc = "Bits 26:30 - OFFSET4_CH"]
140 #[inline(always)]
141 pub fn offset4_ch(&mut self) -> OFFSET4_CH_W {
142 OFFSET4_CH_W { w: self }
143 }
144 #[doc = "Bits 0:11 - OFFSET4"]
145 #[inline(always)]
146 pub fn offset4(&mut self) -> OFFSET4_W {
147 OFFSET4_W { w: self }
148 }
149}