nrf52840_pac/radio/
pcnf0.rs

1#[doc = "Register `PCNF0` reader"]
2pub struct R(crate::R<PCNF0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PCNF0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PCNF0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PCNF0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PCNF0` writer"]
17pub struct W(crate::W<PCNF0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PCNF0_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<PCNF0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PCNF0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `LFLEN` reader - Length on air of LENGTH field in number of bits."]
38pub type LFLEN_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `LFLEN` writer - Length on air of LENGTH field in number of bits."]
40pub type LFLEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCNF0_SPEC, u8, u8, 4, O>;
41#[doc = "Field `S0LEN` reader - Length on air of S0 field in number of bytes."]
42pub type S0LEN_R = crate::BitReader<bool>;
43#[doc = "Field `S0LEN` writer - Length on air of S0 field in number of bytes."]
44pub type S0LEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCNF0_SPEC, bool, O>;
45#[doc = "Field `S1LEN` reader - Length on air of S1 field in number of bits."]
46pub type S1LEN_R = crate::FieldReader<u8, u8>;
47#[doc = "Field `S1LEN` writer - Length on air of S1 field in number of bits."]
48pub type S1LEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCNF0_SPEC, u8, u8, 4, O>;
49#[doc = "Field `S1INCL` reader - Include or exclude S1 field in RAM"]
50pub type S1INCL_R = crate::BitReader<S1INCL_A>;
51#[doc = "Include or exclude S1 field in RAM\n\nValue on reset: 0"]
52#[derive(Clone, Copy, Debug, PartialEq)]
53pub enum S1INCL_A {
54    #[doc = "0: Include S1 field in RAM only if S1LEN &gt; 0"]
55    AUTOMATIC = 0,
56    #[doc = "1: Always include S1 field in RAM independent of S1LEN"]
57    INCLUDE = 1,
58}
59impl From<S1INCL_A> for bool {
60    #[inline(always)]
61    fn from(variant: S1INCL_A) -> Self {
62        variant as u8 != 0
63    }
64}
65impl S1INCL_R {
66    #[doc = "Get enumerated values variant"]
67    #[inline(always)]
68    pub fn variant(&self) -> S1INCL_A {
69        match self.bits {
70            false => S1INCL_A::AUTOMATIC,
71            true => S1INCL_A::INCLUDE,
72        }
73    }
74    #[doc = "Checks if the value of the field is `AUTOMATIC`"]
75    #[inline(always)]
76    pub fn is_automatic(&self) -> bool {
77        *self == S1INCL_A::AUTOMATIC
78    }
79    #[doc = "Checks if the value of the field is `INCLUDE`"]
80    #[inline(always)]
81    pub fn is_include(&self) -> bool {
82        *self == S1INCL_A::INCLUDE
83    }
84}
85#[doc = "Field `S1INCL` writer - Include or exclude S1 field in RAM"]
86pub type S1INCL_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCNF0_SPEC, S1INCL_A, O>;
87impl<'a, const O: u8> S1INCL_W<'a, O> {
88    #[doc = "Include S1 field in RAM only if S1LEN &gt; 0"]
89    #[inline(always)]
90    pub fn automatic(self) -> &'a mut W {
91        self.variant(S1INCL_A::AUTOMATIC)
92    }
93    #[doc = "Always include S1 field in RAM independent of S1LEN"]
94    #[inline(always)]
95    pub fn include(self) -> &'a mut W {
96        self.variant(S1INCL_A::INCLUDE)
97    }
98}
99#[doc = "Field `CILEN` reader - Length of code indicator - long range"]
100pub type CILEN_R = crate::FieldReader<u8, u8>;
101#[doc = "Field `CILEN` writer - Length of code indicator - long range"]
102pub type CILEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCNF0_SPEC, u8, u8, 2, O>;
103#[doc = "Field `PLEN` reader - Length of preamble on air. Decision point: TASKS_START task"]
104pub type PLEN_R = crate::FieldReader<u8, PLEN_A>;
105#[doc = "Length of preamble on air. Decision point: TASKS_START task\n\nValue on reset: 0"]
106#[derive(Clone, Copy, Debug, PartialEq)]
107#[repr(u8)]
108pub enum PLEN_A {
109    #[doc = "0: 8-bit preamble"]
110    _8BIT = 0,
111    #[doc = "1: 16-bit preamble"]
112    _16BIT = 1,
113    #[doc = "2: 32-bit zero preamble - used for IEEE 802.15.4"]
114    _32BIT_ZERO = 2,
115    #[doc = "3: Preamble - used for BLE long range"]
116    LONG_RANGE = 3,
117}
118impl From<PLEN_A> for u8 {
119    #[inline(always)]
120    fn from(variant: PLEN_A) -> Self {
121        variant as _
122    }
123}
124impl PLEN_R {
125    #[doc = "Get enumerated values variant"]
126    #[inline(always)]
127    pub fn variant(&self) -> PLEN_A {
128        match self.bits {
129            0 => PLEN_A::_8BIT,
130            1 => PLEN_A::_16BIT,
131            2 => PLEN_A::_32BIT_ZERO,
132            3 => PLEN_A::LONG_RANGE,
133            _ => unreachable!(),
134        }
135    }
136    #[doc = "Checks if the value of the field is `_8BIT`"]
137    #[inline(always)]
138    pub fn is_8bit(&self) -> bool {
139        *self == PLEN_A::_8BIT
140    }
141    #[doc = "Checks if the value of the field is `_16BIT`"]
142    #[inline(always)]
143    pub fn is_16bit(&self) -> bool {
144        *self == PLEN_A::_16BIT
145    }
146    #[doc = "Checks if the value of the field is `_32BIT_ZERO`"]
147    #[inline(always)]
148    pub fn is_32bit_zero(&self) -> bool {
149        *self == PLEN_A::_32BIT_ZERO
150    }
151    #[doc = "Checks if the value of the field is `LONG_RANGE`"]
152    #[inline(always)]
153    pub fn is_long_range(&self) -> bool {
154        *self == PLEN_A::LONG_RANGE
155    }
156}
157#[doc = "Field `PLEN` writer - Length of preamble on air. Decision point: TASKS_START task"]
158pub type PLEN_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, PCNF0_SPEC, u8, PLEN_A, 2, O>;
159impl<'a, const O: u8> PLEN_W<'a, O> {
160    #[doc = "8-bit preamble"]
161    #[inline(always)]
162    pub fn _8bit(self) -> &'a mut W {
163        self.variant(PLEN_A::_8BIT)
164    }
165    #[doc = "16-bit preamble"]
166    #[inline(always)]
167    pub fn _16bit(self) -> &'a mut W {
168        self.variant(PLEN_A::_16BIT)
169    }
170    #[doc = "32-bit zero preamble - used for IEEE 802.15.4"]
171    #[inline(always)]
172    pub fn _32bit_zero(self) -> &'a mut W {
173        self.variant(PLEN_A::_32BIT_ZERO)
174    }
175    #[doc = "Preamble - used for BLE long range"]
176    #[inline(always)]
177    pub fn long_range(self) -> &'a mut W {
178        self.variant(PLEN_A::LONG_RANGE)
179    }
180}
181#[doc = "Field `CRCINC` reader - Indicates if LENGTH field contains CRC or not"]
182pub type CRCINC_R = crate::BitReader<CRCINC_A>;
183#[doc = "Indicates if LENGTH field contains CRC or not\n\nValue on reset: 0"]
184#[derive(Clone, Copy, Debug, PartialEq)]
185pub enum CRCINC_A {
186    #[doc = "0: LENGTH does not contain CRC"]
187    EXCLUDE = 0,
188    #[doc = "1: LENGTH includes CRC"]
189    INCLUDE = 1,
190}
191impl From<CRCINC_A> for bool {
192    #[inline(always)]
193    fn from(variant: CRCINC_A) -> Self {
194        variant as u8 != 0
195    }
196}
197impl CRCINC_R {
198    #[doc = "Get enumerated values variant"]
199    #[inline(always)]
200    pub fn variant(&self) -> CRCINC_A {
201        match self.bits {
202            false => CRCINC_A::EXCLUDE,
203            true => CRCINC_A::INCLUDE,
204        }
205    }
206    #[doc = "Checks if the value of the field is `EXCLUDE`"]
207    #[inline(always)]
208    pub fn is_exclude(&self) -> bool {
209        *self == CRCINC_A::EXCLUDE
210    }
211    #[doc = "Checks if the value of the field is `INCLUDE`"]
212    #[inline(always)]
213    pub fn is_include(&self) -> bool {
214        *self == CRCINC_A::INCLUDE
215    }
216}
217#[doc = "Field `CRCINC` writer - Indicates if LENGTH field contains CRC or not"]
218pub type CRCINC_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCNF0_SPEC, CRCINC_A, O>;
219impl<'a, const O: u8> CRCINC_W<'a, O> {
220    #[doc = "LENGTH does not contain CRC"]
221    #[inline(always)]
222    pub fn exclude(self) -> &'a mut W {
223        self.variant(CRCINC_A::EXCLUDE)
224    }
225    #[doc = "LENGTH includes CRC"]
226    #[inline(always)]
227    pub fn include(self) -> &'a mut W {
228        self.variant(CRCINC_A::INCLUDE)
229    }
230}
231#[doc = "Field `TERMLEN` reader - Length of TERM field in Long Range operation"]
232pub type TERMLEN_R = crate::FieldReader<u8, u8>;
233#[doc = "Field `TERMLEN` writer - Length of TERM field in Long Range operation"]
234pub type TERMLEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCNF0_SPEC, u8, u8, 2, O>;
235impl R {
236    #[doc = "Bits 0:3 - Length on air of LENGTH field in number of bits."]
237    #[inline(always)]
238    pub fn lflen(&self) -> LFLEN_R {
239        LFLEN_R::new((self.bits & 0x0f) as u8)
240    }
241    #[doc = "Bit 8 - Length on air of S0 field in number of bytes."]
242    #[inline(always)]
243    pub fn s0len(&self) -> S0LEN_R {
244        S0LEN_R::new(((self.bits >> 8) & 1) != 0)
245    }
246    #[doc = "Bits 16:19 - Length on air of S1 field in number of bits."]
247    #[inline(always)]
248    pub fn s1len(&self) -> S1LEN_R {
249        S1LEN_R::new(((self.bits >> 16) & 0x0f) as u8)
250    }
251    #[doc = "Bit 20 - Include or exclude S1 field in RAM"]
252    #[inline(always)]
253    pub fn s1incl(&self) -> S1INCL_R {
254        S1INCL_R::new(((self.bits >> 20) & 1) != 0)
255    }
256    #[doc = "Bits 22:23 - Length of code indicator - long range"]
257    #[inline(always)]
258    pub fn cilen(&self) -> CILEN_R {
259        CILEN_R::new(((self.bits >> 22) & 3) as u8)
260    }
261    #[doc = "Bits 24:25 - Length of preamble on air. Decision point: TASKS_START task"]
262    #[inline(always)]
263    pub fn plen(&self) -> PLEN_R {
264        PLEN_R::new(((self.bits >> 24) & 3) as u8)
265    }
266    #[doc = "Bit 26 - Indicates if LENGTH field contains CRC or not"]
267    #[inline(always)]
268    pub fn crcinc(&self) -> CRCINC_R {
269        CRCINC_R::new(((self.bits >> 26) & 1) != 0)
270    }
271    #[doc = "Bits 29:30 - Length of TERM field in Long Range operation"]
272    #[inline(always)]
273    pub fn termlen(&self) -> TERMLEN_R {
274        TERMLEN_R::new(((self.bits >> 29) & 3) as u8)
275    }
276}
277impl W {
278    #[doc = "Bits 0:3 - Length on air of LENGTH field in number of bits."]
279    #[inline(always)]
280    pub fn lflen(&mut self) -> LFLEN_W<0> {
281        LFLEN_W::new(self)
282    }
283    #[doc = "Bit 8 - Length on air of S0 field in number of bytes."]
284    #[inline(always)]
285    pub fn s0len(&mut self) -> S0LEN_W<8> {
286        S0LEN_W::new(self)
287    }
288    #[doc = "Bits 16:19 - Length on air of S1 field in number of bits."]
289    #[inline(always)]
290    pub fn s1len(&mut self) -> S1LEN_W<16> {
291        S1LEN_W::new(self)
292    }
293    #[doc = "Bit 20 - Include or exclude S1 field in RAM"]
294    #[inline(always)]
295    pub fn s1incl(&mut self) -> S1INCL_W<20> {
296        S1INCL_W::new(self)
297    }
298    #[doc = "Bits 22:23 - Length of code indicator - long range"]
299    #[inline(always)]
300    pub fn cilen(&mut self) -> CILEN_W<22> {
301        CILEN_W::new(self)
302    }
303    #[doc = "Bits 24:25 - Length of preamble on air. Decision point: TASKS_START task"]
304    #[inline(always)]
305    pub fn plen(&mut self) -> PLEN_W<24> {
306        PLEN_W::new(self)
307    }
308    #[doc = "Bit 26 - Indicates if LENGTH field contains CRC or not"]
309    #[inline(always)]
310    pub fn crcinc(&mut self) -> CRCINC_W<26> {
311        CRCINC_W::new(self)
312    }
313    #[doc = "Bits 29:30 - Length of TERM field in Long Range operation"]
314    #[inline(always)]
315    pub fn termlen(&mut self) -> TERMLEN_W<29> {
316        TERMLEN_W::new(self)
317    }
318    #[doc = "Writes raw bits to the register."]
319    #[inline(always)]
320    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
321        self.0.bits(bits);
322        self
323    }
324}
325#[doc = "Packet configuration register 0\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 [pcnf0](index.html) module"]
326pub struct PCNF0_SPEC;
327impl crate::RegisterSpec for PCNF0_SPEC {
328    type Ux = u32;
329}
330#[doc = "`read()` method returns [pcnf0::R](R) reader structure"]
331impl crate::Readable for PCNF0_SPEC {
332    type Reader = R;
333}
334#[doc = "`write(|w| ..)` method takes [pcnf0::W](W) writer structure"]
335impl crate::Writable for PCNF0_SPEC {
336    type Writer = W;
337}
338#[doc = "`reset()` method sets PCNF0 to value 0"]
339impl crate::Resettable for PCNF0_SPEC {
340    #[inline(always)]
341    fn reset_value() -> Self::Ux {
342        0
343    }
344}