1#[doc = r" Value read from the register"]
2pub struct R {
3 bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7 bits: u32,
8}
9impl super::GAINR {
10 #[doc = r" Modifies the contents of the register"]
11 #[inline]
12 pub fn modify<F>(&self, f: F)
13 where
14 for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15 {
16 let bits = self.register.get();
17 let r = R { bits: bits };
18 let mut w = W { bits: bits };
19 f(&r, &mut w);
20 self.register.set(w.bits);
21 }
22 #[doc = r" Reads the contents of the register"]
23 #[inline]
24 pub fn read(&self) -> R {
25 R {
26 bits: self.register.get(),
27 }
28 }
29 #[doc = r" Writes to the register"]
30 #[inline]
31 pub fn write<F>(&self, f: F)
32 where
33 F: FnOnce(&mut W) -> &mut W,
34 {
35 let mut w = W::reset_value();
36 f(&mut w);
37 self.register.set(w.bits);
38 }
39 #[doc = r" Writes the reset value to the register"]
40 #[inline]
41 pub fn reset(&self) {
42 self.write(|w| w)
43 }
44}
45#[doc = "Possible values of the field `GAINR`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum GAINRR {
48 #[doc = "-20dB gain adjustment (minimum)"]
49 MINGAIN,
50 #[doc = "0dB gain adjustment ('2500 RMS' requirement)"]
51 DEFAULTGAIN,
52 #[doc = "+20dB gain adjustment (maximum)"]
53 MAXGAIN,
54 #[doc = r" Reserved"]
55 _Reserved(u8),
56}
57impl GAINRR {
58 #[doc = r" Value of the field as raw bits"]
59 #[inline]
60 pub fn bits(&self) -> u8 {
61 match *self {
62 GAINRR::MINGAIN => 0,
63 GAINRR::DEFAULTGAIN => 40,
64 GAINRR::MAXGAIN => 80,
65 GAINRR::_Reserved(bits) => bits,
66 }
67 }
68 #[allow(missing_docs)]
69 #[doc(hidden)]
70 #[inline]
71 pub fn _from(value: u8) -> GAINRR {
72 match value {
73 0 => GAINRR::MINGAIN,
74 40 => GAINRR::DEFAULTGAIN,
75 80 => GAINRR::MAXGAIN,
76 i => GAINRR::_Reserved(i),
77 }
78 }
79 #[doc = "Checks if the value of the field is `MINGAIN`"]
80 #[inline]
81 pub fn is_min_gain(&self) -> bool {
82 *self == GAINRR::MINGAIN
83 }
84 #[doc = "Checks if the value of the field is `DEFAULTGAIN`"]
85 #[inline]
86 pub fn is_default_gain(&self) -> bool {
87 *self == GAINRR::DEFAULTGAIN
88 }
89 #[doc = "Checks if the value of the field is `MAXGAIN`"]
90 #[inline]
91 pub fn is_max_gain(&self) -> bool {
92 *self == GAINRR::MAXGAIN
93 }
94}
95#[doc = "Values that can be written to the field `GAINR`"]
96pub enum GAINRW {
97 #[doc = "-20dB gain adjustment (minimum)"]
98 MINGAIN,
99 #[doc = "0dB gain adjustment ('2500 RMS' requirement)"]
100 DEFAULTGAIN,
101 #[doc = "+20dB gain adjustment (maximum)"]
102 MAXGAIN,
103}
104impl GAINRW {
105 #[allow(missing_docs)]
106 #[doc(hidden)]
107 #[inline]
108 pub fn _bits(&self) -> u8 {
109 match *self {
110 GAINRW::MINGAIN => 0,
111 GAINRW::DEFAULTGAIN => 40,
112 GAINRW::MAXGAIN => 80,
113 }
114 }
115}
116#[doc = r" Proxy"]
117pub struct _GAINRW<'a> {
118 w: &'a mut W,
119}
120impl<'a> _GAINRW<'a> {
121 #[doc = r" Writes `variant` to the field"]
122 #[inline]
123 pub fn variant(self, variant: GAINRW) -> &'a mut W {
124 unsafe { self.bits(variant._bits()) }
125 }
126 #[doc = "-20dB gain adjustment (minimum)"]
127 #[inline]
128 pub fn min_gain(self) -> &'a mut W {
129 self.variant(GAINRW::MINGAIN)
130 }
131 #[doc = "0dB gain adjustment ('2500 RMS' requirement)"]
132 #[inline]
133 pub fn default_gain(self) -> &'a mut W {
134 self.variant(GAINRW::DEFAULTGAIN)
135 }
136 #[doc = "+20dB gain adjustment (maximum)"]
137 #[inline]
138 pub fn max_gain(self) -> &'a mut W {
139 self.variant(GAINRW::MAXGAIN)
140 }
141 #[doc = r" Writes raw bits to the field"]
142 #[inline]
143 pub unsafe fn bits(self, value: u8) -> &'a mut W {
144 const MASK: u8 = 255;
145 const OFFSET: u8 = 0;
146 self.w.bits &= !((MASK as u32) << OFFSET);
147 self.w.bits |= ((value & MASK) as u32) << OFFSET;
148 self.w
149 }
150}
151impl R {
152 #[doc = r" Value of the register as raw bits"]
153 #[inline]
154 pub fn bits(&self) -> u32 {
155 self.bits
156 }
157 #[doc = "Bits 0:7 - Right output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters)"]
158 #[inline]
159 pub fn gainr(&self) -> GAINRR {
160 GAINRR::_from({
161 const MASK: u8 = 255;
162 const OFFSET: u8 = 0;
163 ((self.bits >> OFFSET) & MASK as u32) as u8
164 })
165 }
166}
167impl W {
168 #[doc = r" Reset value of the register"]
169 #[inline]
170 pub fn reset_value() -> W {
171 W { bits: 40 }
172 }
173 #[doc = r" Writes raw bits to the register"]
174 #[inline]
175 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
176 self.bits = bits;
177 self
178 }
179 #[doc = "Bits 0:7 - Right output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters)"]
180 #[inline]
181 pub fn gainr(&mut self) -> _GAINRW {
182 _GAINRW { w: self }
183 }
184}