nrf52840_pac/radio/
pcnf1.rs

1#[doc = "Register `PCNF1` reader"]
2pub struct R(crate::R<PCNF1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PCNF1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PCNF1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PCNF1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PCNF1` writer"]
17pub struct W(crate::W<PCNF1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PCNF1_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<PCNF1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PCNF1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `MAXLEN` reader - Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN."]
38pub type MAXLEN_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `MAXLEN` writer - Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN."]
40pub type MAXLEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCNF1_SPEC, u8, u8, 8, O>;
41#[doc = "Field `STATLEN` reader - Static length in number of bytes"]
42pub type STATLEN_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `STATLEN` writer - Static length in number of bytes"]
44pub type STATLEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCNF1_SPEC, u8, u8, 8, O>;
45#[doc = "Field `BALEN` reader - Base address length in number of bytes"]
46pub type BALEN_R = crate::FieldReader<u8, u8>;
47#[doc = "Field `BALEN` writer - Base address length in number of bytes"]
48pub type BALEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PCNF1_SPEC, u8, u8, 3, O>;
49#[doc = "Field `ENDIAN` reader - On air endianness of packet, this applies to the S0, LENGTH, S1 and the PAYLOAD fields."]
50pub type ENDIAN_R = crate::BitReader<ENDIAN_A>;
51#[doc = "On air endianness of packet, this applies to the S0, LENGTH, S1 and the PAYLOAD fields.\n\nValue on reset: 0"]
52#[derive(Clone, Copy, Debug, PartialEq)]
53pub enum ENDIAN_A {
54    #[doc = "0: Least significant bit on air first"]
55    LITTLE = 0,
56    #[doc = "1: Most significant bit on air first"]
57    BIG = 1,
58}
59impl From<ENDIAN_A> for bool {
60    #[inline(always)]
61    fn from(variant: ENDIAN_A) -> Self {
62        variant as u8 != 0
63    }
64}
65impl ENDIAN_R {
66    #[doc = "Get enumerated values variant"]
67    #[inline(always)]
68    pub fn variant(&self) -> ENDIAN_A {
69        match self.bits {
70            false => ENDIAN_A::LITTLE,
71            true => ENDIAN_A::BIG,
72        }
73    }
74    #[doc = "Checks if the value of the field is `LITTLE`"]
75    #[inline(always)]
76    pub fn is_little(&self) -> bool {
77        *self == ENDIAN_A::LITTLE
78    }
79    #[doc = "Checks if the value of the field is `BIG`"]
80    #[inline(always)]
81    pub fn is_big(&self) -> bool {
82        *self == ENDIAN_A::BIG
83    }
84}
85#[doc = "Field `ENDIAN` writer - On air endianness of packet, this applies to the S0, LENGTH, S1 and the PAYLOAD fields."]
86pub type ENDIAN_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCNF1_SPEC, ENDIAN_A, O>;
87impl<'a, const O: u8> ENDIAN_W<'a, O> {
88    #[doc = "Least significant bit on air first"]
89    #[inline(always)]
90    pub fn little(self) -> &'a mut W {
91        self.variant(ENDIAN_A::LITTLE)
92    }
93    #[doc = "Most significant bit on air first"]
94    #[inline(always)]
95    pub fn big(self) -> &'a mut W {
96        self.variant(ENDIAN_A::BIG)
97    }
98}
99#[doc = "Field `WHITEEN` reader - Enable or disable packet whitening"]
100pub type WHITEEN_R = crate::BitReader<WHITEEN_A>;
101#[doc = "Enable or disable packet whitening\n\nValue on reset: 0"]
102#[derive(Clone, Copy, Debug, PartialEq)]
103pub enum WHITEEN_A {
104    #[doc = "0: Disable"]
105    DISABLED = 0,
106    #[doc = "1: Enable"]
107    ENABLED = 1,
108}
109impl From<WHITEEN_A> for bool {
110    #[inline(always)]
111    fn from(variant: WHITEEN_A) -> Self {
112        variant as u8 != 0
113    }
114}
115impl WHITEEN_R {
116    #[doc = "Get enumerated values variant"]
117    #[inline(always)]
118    pub fn variant(&self) -> WHITEEN_A {
119        match self.bits {
120            false => WHITEEN_A::DISABLED,
121            true => WHITEEN_A::ENABLED,
122        }
123    }
124    #[doc = "Checks if the value of the field is `DISABLED`"]
125    #[inline(always)]
126    pub fn is_disabled(&self) -> bool {
127        *self == WHITEEN_A::DISABLED
128    }
129    #[doc = "Checks if the value of the field is `ENABLED`"]
130    #[inline(always)]
131    pub fn is_enabled(&self) -> bool {
132        *self == WHITEEN_A::ENABLED
133    }
134}
135#[doc = "Field `WHITEEN` writer - Enable or disable packet whitening"]
136pub type WHITEEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, PCNF1_SPEC, WHITEEN_A, O>;
137impl<'a, const O: u8> WHITEEN_W<'a, O> {
138    #[doc = "Disable"]
139    #[inline(always)]
140    pub fn disabled(self) -> &'a mut W {
141        self.variant(WHITEEN_A::DISABLED)
142    }
143    #[doc = "Enable"]
144    #[inline(always)]
145    pub fn enabled(self) -> &'a mut W {
146        self.variant(WHITEEN_A::ENABLED)
147    }
148}
149impl R {
150    #[doc = "Bits 0:7 - Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN."]
151    #[inline(always)]
152    pub fn maxlen(&self) -> MAXLEN_R {
153        MAXLEN_R::new((self.bits & 0xff) as u8)
154    }
155    #[doc = "Bits 8:15 - Static length in number of bytes"]
156    #[inline(always)]
157    pub fn statlen(&self) -> STATLEN_R {
158        STATLEN_R::new(((self.bits >> 8) & 0xff) as u8)
159    }
160    #[doc = "Bits 16:18 - Base address length in number of bytes"]
161    #[inline(always)]
162    pub fn balen(&self) -> BALEN_R {
163        BALEN_R::new(((self.bits >> 16) & 7) as u8)
164    }
165    #[doc = "Bit 24 - On air endianness of packet, this applies to the S0, LENGTH, S1 and the PAYLOAD fields."]
166    #[inline(always)]
167    pub fn endian(&self) -> ENDIAN_R {
168        ENDIAN_R::new(((self.bits >> 24) & 1) != 0)
169    }
170    #[doc = "Bit 25 - Enable or disable packet whitening"]
171    #[inline(always)]
172    pub fn whiteen(&self) -> WHITEEN_R {
173        WHITEEN_R::new(((self.bits >> 25) & 1) != 0)
174    }
175}
176impl W {
177    #[doc = "Bits 0:7 - Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN."]
178    #[inline(always)]
179    pub fn maxlen(&mut self) -> MAXLEN_W<0> {
180        MAXLEN_W::new(self)
181    }
182    #[doc = "Bits 8:15 - Static length in number of bytes"]
183    #[inline(always)]
184    pub fn statlen(&mut self) -> STATLEN_W<8> {
185        STATLEN_W::new(self)
186    }
187    #[doc = "Bits 16:18 - Base address length in number of bytes"]
188    #[inline(always)]
189    pub fn balen(&mut self) -> BALEN_W<16> {
190        BALEN_W::new(self)
191    }
192    #[doc = "Bit 24 - On air endianness of packet, this applies to the S0, LENGTH, S1 and the PAYLOAD fields."]
193    #[inline(always)]
194    pub fn endian(&mut self) -> ENDIAN_W<24> {
195        ENDIAN_W::new(self)
196    }
197    #[doc = "Bit 25 - Enable or disable packet whitening"]
198    #[inline(always)]
199    pub fn whiteen(&mut self) -> WHITEEN_W<25> {
200        WHITEEN_W::new(self)
201    }
202    #[doc = "Writes raw bits to the register."]
203    #[inline(always)]
204    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
205        self.0.bits(bits);
206        self
207    }
208}
209#[doc = "Packet configuration register 1\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 [pcnf1](index.html) module"]
210pub struct PCNF1_SPEC;
211impl crate::RegisterSpec for PCNF1_SPEC {
212    type Ux = u32;
213}
214#[doc = "`read()` method returns [pcnf1::R](R) reader structure"]
215impl crate::Readable for PCNF1_SPEC {
216    type Reader = R;
217}
218#[doc = "`write(|w| ..)` method takes [pcnf1::W](W) writer structure"]
219impl crate::Writable for PCNF1_SPEC {
220    type Writer = W;
221}
222#[doc = "`reset()` method sets PCNF1 to value 0"]
223impl crate::Resettable for PCNF1_SPEC {
224    #[inline(always)]
225    fn reset_value() -> Self::Ux {
226        0
227    }
228}