nrf52840_pac/radio/
txpower.rs

1#[doc = "Register `TXPOWER` reader"]
2pub struct R(crate::R<TXPOWER_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TXPOWER_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TXPOWER_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TXPOWER_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TXPOWER` writer"]
17pub struct W(crate::W<TXPOWER_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TXPOWER_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<TXPOWER_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TXPOWER_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TXPOWER` reader - RADIO output power"]
38pub type TXPOWER_R = crate::FieldReader<u8, TXPOWER_A>;
39#[doc = "RADIO output power\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum TXPOWER_A {
43    #[doc = "8: +8 dBm"]
44    POS8D_BM = 8,
45    #[doc = "7: +7 dBm"]
46    POS7D_BM = 7,
47    #[doc = "6: +6 dBm"]
48    POS6D_BM = 6,
49    #[doc = "5: +5 dBm"]
50    POS5D_BM = 5,
51    #[doc = "4: +4 dBm"]
52    POS4D_BM = 4,
53    #[doc = "3: +3 dBm"]
54    POS3D_BM = 3,
55    #[doc = "2: +2 dBm"]
56    POS2D_BM = 2,
57    #[doc = "0: 0 dBm"]
58    _0D_BM = 0,
59    #[doc = "252: -4 dBm"]
60    NEG4D_BM = 252,
61    #[doc = "248: -8 dBm"]
62    NEG8D_BM = 248,
63    #[doc = "244: -12 dBm"]
64    NEG12D_BM = 244,
65    #[doc = "240: -16 dBm"]
66    NEG16D_BM = 240,
67    #[doc = "236: -20 dBm"]
68    NEG20D_BM = 236,
69    #[doc = "255: Deprecated enumerator - -40 dBm"]
70    NEG30D_BM = 255,
71    #[doc = "216: -40 dBm"]
72    NEG40D_BM = 216,
73}
74impl From<TXPOWER_A> for u8 {
75    #[inline(always)]
76    fn from(variant: TXPOWER_A) -> Self {
77        variant as _
78    }
79}
80impl TXPOWER_R {
81    #[doc = "Get enumerated values variant"]
82    #[inline(always)]
83    pub fn variant(&self) -> Option<TXPOWER_A> {
84        match self.bits {
85            8 => Some(TXPOWER_A::POS8D_BM),
86            7 => Some(TXPOWER_A::POS7D_BM),
87            6 => Some(TXPOWER_A::POS6D_BM),
88            5 => Some(TXPOWER_A::POS5D_BM),
89            4 => Some(TXPOWER_A::POS4D_BM),
90            3 => Some(TXPOWER_A::POS3D_BM),
91            2 => Some(TXPOWER_A::POS2D_BM),
92            0 => Some(TXPOWER_A::_0D_BM),
93            252 => Some(TXPOWER_A::NEG4D_BM),
94            248 => Some(TXPOWER_A::NEG8D_BM),
95            244 => Some(TXPOWER_A::NEG12D_BM),
96            240 => Some(TXPOWER_A::NEG16D_BM),
97            236 => Some(TXPOWER_A::NEG20D_BM),
98            255 => Some(TXPOWER_A::NEG30D_BM),
99            216 => Some(TXPOWER_A::NEG40D_BM),
100            _ => None,
101        }
102    }
103    #[doc = "Checks if the value of the field is `POS8D_BM`"]
104    #[inline(always)]
105    pub fn is_pos8d_bm(&self) -> bool {
106        *self == TXPOWER_A::POS8D_BM
107    }
108    #[doc = "Checks if the value of the field is `POS7D_BM`"]
109    #[inline(always)]
110    pub fn is_pos7d_bm(&self) -> bool {
111        *self == TXPOWER_A::POS7D_BM
112    }
113    #[doc = "Checks if the value of the field is `POS6D_BM`"]
114    #[inline(always)]
115    pub fn is_pos6d_bm(&self) -> bool {
116        *self == TXPOWER_A::POS6D_BM
117    }
118    #[doc = "Checks if the value of the field is `POS5D_BM`"]
119    #[inline(always)]
120    pub fn is_pos5d_bm(&self) -> bool {
121        *self == TXPOWER_A::POS5D_BM
122    }
123    #[doc = "Checks if the value of the field is `POS4D_BM`"]
124    #[inline(always)]
125    pub fn is_pos4d_bm(&self) -> bool {
126        *self == TXPOWER_A::POS4D_BM
127    }
128    #[doc = "Checks if the value of the field is `POS3D_BM`"]
129    #[inline(always)]
130    pub fn is_pos3d_bm(&self) -> bool {
131        *self == TXPOWER_A::POS3D_BM
132    }
133    #[doc = "Checks if the value of the field is `POS2D_BM`"]
134    #[inline(always)]
135    pub fn is_pos2d_bm(&self) -> bool {
136        *self == TXPOWER_A::POS2D_BM
137    }
138    #[doc = "Checks if the value of the field is `_0D_BM`"]
139    #[inline(always)]
140    pub fn is_0d_bm(&self) -> bool {
141        *self == TXPOWER_A::_0D_BM
142    }
143    #[doc = "Checks if the value of the field is `NEG4D_BM`"]
144    #[inline(always)]
145    pub fn is_neg4d_bm(&self) -> bool {
146        *self == TXPOWER_A::NEG4D_BM
147    }
148    #[doc = "Checks if the value of the field is `NEG8D_BM`"]
149    #[inline(always)]
150    pub fn is_neg8d_bm(&self) -> bool {
151        *self == TXPOWER_A::NEG8D_BM
152    }
153    #[doc = "Checks if the value of the field is `NEG12D_BM`"]
154    #[inline(always)]
155    pub fn is_neg12d_bm(&self) -> bool {
156        *self == TXPOWER_A::NEG12D_BM
157    }
158    #[doc = "Checks if the value of the field is `NEG16D_BM`"]
159    #[inline(always)]
160    pub fn is_neg16d_bm(&self) -> bool {
161        *self == TXPOWER_A::NEG16D_BM
162    }
163    #[doc = "Checks if the value of the field is `NEG20D_BM`"]
164    #[inline(always)]
165    pub fn is_neg20d_bm(&self) -> bool {
166        *self == TXPOWER_A::NEG20D_BM
167    }
168    #[doc = "Checks if the value of the field is `NEG30D_BM`"]
169    #[inline(always)]
170    pub fn is_neg30d_bm(&self) -> bool {
171        *self == TXPOWER_A::NEG30D_BM
172    }
173    #[doc = "Checks if the value of the field is `NEG40D_BM`"]
174    #[inline(always)]
175    pub fn is_neg40d_bm(&self) -> bool {
176        *self == TXPOWER_A::NEG40D_BM
177    }
178}
179#[doc = "Field `TXPOWER` writer - RADIO output power"]
180pub type TXPOWER_W<'a, const O: u8> =
181    crate::FieldWriter<'a, u32, TXPOWER_SPEC, u8, TXPOWER_A, 8, O>;
182impl<'a, const O: u8> TXPOWER_W<'a, O> {
183    #[doc = "+8 dBm"]
184    #[inline(always)]
185    pub fn pos8d_bm(self) -> &'a mut W {
186        self.variant(TXPOWER_A::POS8D_BM)
187    }
188    #[doc = "+7 dBm"]
189    #[inline(always)]
190    pub fn pos7d_bm(self) -> &'a mut W {
191        self.variant(TXPOWER_A::POS7D_BM)
192    }
193    #[doc = "+6 dBm"]
194    #[inline(always)]
195    pub fn pos6d_bm(self) -> &'a mut W {
196        self.variant(TXPOWER_A::POS6D_BM)
197    }
198    #[doc = "+5 dBm"]
199    #[inline(always)]
200    pub fn pos5d_bm(self) -> &'a mut W {
201        self.variant(TXPOWER_A::POS5D_BM)
202    }
203    #[doc = "+4 dBm"]
204    #[inline(always)]
205    pub fn pos4d_bm(self) -> &'a mut W {
206        self.variant(TXPOWER_A::POS4D_BM)
207    }
208    #[doc = "+3 dBm"]
209    #[inline(always)]
210    pub fn pos3d_bm(self) -> &'a mut W {
211        self.variant(TXPOWER_A::POS3D_BM)
212    }
213    #[doc = "+2 dBm"]
214    #[inline(always)]
215    pub fn pos2d_bm(self) -> &'a mut W {
216        self.variant(TXPOWER_A::POS2D_BM)
217    }
218    #[doc = "0 dBm"]
219    #[inline(always)]
220    pub fn _0d_bm(self) -> &'a mut W {
221        self.variant(TXPOWER_A::_0D_BM)
222    }
223    #[doc = "-4 dBm"]
224    #[inline(always)]
225    pub fn neg4d_bm(self) -> &'a mut W {
226        self.variant(TXPOWER_A::NEG4D_BM)
227    }
228    #[doc = "-8 dBm"]
229    #[inline(always)]
230    pub fn neg8d_bm(self) -> &'a mut W {
231        self.variant(TXPOWER_A::NEG8D_BM)
232    }
233    #[doc = "-12 dBm"]
234    #[inline(always)]
235    pub fn neg12d_bm(self) -> &'a mut W {
236        self.variant(TXPOWER_A::NEG12D_BM)
237    }
238    #[doc = "-16 dBm"]
239    #[inline(always)]
240    pub fn neg16d_bm(self) -> &'a mut W {
241        self.variant(TXPOWER_A::NEG16D_BM)
242    }
243    #[doc = "-20 dBm"]
244    #[inline(always)]
245    pub fn neg20d_bm(self) -> &'a mut W {
246        self.variant(TXPOWER_A::NEG20D_BM)
247    }
248    #[doc = "Deprecated enumerator - -40 dBm"]
249    #[inline(always)]
250    pub fn neg30d_bm(self) -> &'a mut W {
251        self.variant(TXPOWER_A::NEG30D_BM)
252    }
253    #[doc = "-40 dBm"]
254    #[inline(always)]
255    pub fn neg40d_bm(self) -> &'a mut W {
256        self.variant(TXPOWER_A::NEG40D_BM)
257    }
258}
259impl R {
260    #[doc = "Bits 0:7 - RADIO output power"]
261    #[inline(always)]
262    pub fn txpower(&self) -> TXPOWER_R {
263        TXPOWER_R::new((self.bits & 0xff) as u8)
264    }
265}
266impl W {
267    #[doc = "Bits 0:7 - RADIO output power"]
268    #[inline(always)]
269    pub fn txpower(&mut self) -> TXPOWER_W<0> {
270        TXPOWER_W::new(self)
271    }
272    #[doc = "Writes raw bits to the register."]
273    #[inline(always)]
274    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
275        self.0.bits(bits);
276        self
277    }
278}
279#[doc = "Output power\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 [txpower](index.html) module"]
280pub struct TXPOWER_SPEC;
281impl crate::RegisterSpec for TXPOWER_SPEC {
282    type Ux = u32;
283}
284#[doc = "`read()` method returns [txpower::R](R) reader structure"]
285impl crate::Readable for TXPOWER_SPEC {
286    type Reader = R;
287}
288#[doc = "`write(|w| ..)` method takes [txpower::W](W) writer structure"]
289impl crate::Writable for TXPOWER_SPEC {
290    type Writer = W;
291}
292#[doc = "`reset()` method sets TXPOWER to value 0"]
293impl crate::Resettable for TXPOWER_SPEC {
294    #[inline(always)]
295    fn reset_value() -> Self::Ux {
296        0
297    }
298}