nrf52840_pac/radio/
ccactrl.rs

1#[doc = "Register `CCACTRL` reader"]
2pub struct R(crate::R<CCACTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CCACTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CCACTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CCACTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CCACTRL` writer"]
17pub struct W(crate::W<CCACTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CCACTRL_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<CCACTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CCACTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CCAMODE` reader - CCA mode of operation"]
38pub type CCAMODE_R = crate::FieldReader<u8, CCAMODE_A>;
39#[doc = "CCA mode of operation\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum CCAMODE_A {
43    #[doc = "0: Energy above threshold"]
44    ED_MODE = 0,
45    #[doc = "1: Carrier seen"]
46    CARRIER_MODE = 1,
47    #[doc = "2: Energy above threshold AND carrier seen"]
48    CARRIER_AND_ED_MODE = 2,
49    #[doc = "3: Energy above threshold OR carrier seen"]
50    CARRIER_OR_ED_MODE = 3,
51    #[doc = "4: Energy above threshold test mode that will abort when first ED measurement over threshold is seen. No averaging."]
52    ED_MODE_TEST1 = 4,
53}
54impl From<CCAMODE_A> for u8 {
55    #[inline(always)]
56    fn from(variant: CCAMODE_A) -> Self {
57        variant as _
58    }
59}
60impl CCAMODE_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<CCAMODE_A> {
64        match self.bits {
65            0 => Some(CCAMODE_A::ED_MODE),
66            1 => Some(CCAMODE_A::CARRIER_MODE),
67            2 => Some(CCAMODE_A::CARRIER_AND_ED_MODE),
68            3 => Some(CCAMODE_A::CARRIER_OR_ED_MODE),
69            4 => Some(CCAMODE_A::ED_MODE_TEST1),
70            _ => None,
71        }
72    }
73    #[doc = "Checks if the value of the field is `ED_MODE`"]
74    #[inline(always)]
75    pub fn is_ed_mode(&self) -> bool {
76        *self == CCAMODE_A::ED_MODE
77    }
78    #[doc = "Checks if the value of the field is `CARRIER_MODE`"]
79    #[inline(always)]
80    pub fn is_carrier_mode(&self) -> bool {
81        *self == CCAMODE_A::CARRIER_MODE
82    }
83    #[doc = "Checks if the value of the field is `CARRIER_AND_ED_MODE`"]
84    #[inline(always)]
85    pub fn is_carrier_and_ed_mode(&self) -> bool {
86        *self == CCAMODE_A::CARRIER_AND_ED_MODE
87    }
88    #[doc = "Checks if the value of the field is `CARRIER_OR_ED_MODE`"]
89    #[inline(always)]
90    pub fn is_carrier_or_ed_mode(&self) -> bool {
91        *self == CCAMODE_A::CARRIER_OR_ED_MODE
92    }
93    #[doc = "Checks if the value of the field is `ED_MODE_TEST1`"]
94    #[inline(always)]
95    pub fn is_ed_mode_test1(&self) -> bool {
96        *self == CCAMODE_A::ED_MODE_TEST1
97    }
98}
99#[doc = "Field `CCAMODE` writer - CCA mode of operation"]
100pub type CCAMODE_W<'a, const O: u8> =
101    crate::FieldWriter<'a, u32, CCACTRL_SPEC, u8, CCAMODE_A, 3, O>;
102impl<'a, const O: u8> CCAMODE_W<'a, O> {
103    #[doc = "Energy above threshold"]
104    #[inline(always)]
105    pub fn ed_mode(self) -> &'a mut W {
106        self.variant(CCAMODE_A::ED_MODE)
107    }
108    #[doc = "Carrier seen"]
109    #[inline(always)]
110    pub fn carrier_mode(self) -> &'a mut W {
111        self.variant(CCAMODE_A::CARRIER_MODE)
112    }
113    #[doc = "Energy above threshold AND carrier seen"]
114    #[inline(always)]
115    pub fn carrier_and_ed_mode(self) -> &'a mut W {
116        self.variant(CCAMODE_A::CARRIER_AND_ED_MODE)
117    }
118    #[doc = "Energy above threshold OR carrier seen"]
119    #[inline(always)]
120    pub fn carrier_or_ed_mode(self) -> &'a mut W {
121        self.variant(CCAMODE_A::CARRIER_OR_ED_MODE)
122    }
123    #[doc = "Energy above threshold test mode that will abort when first ED measurement over threshold is seen. No averaging."]
124    #[inline(always)]
125    pub fn ed_mode_test1(self) -> &'a mut W {
126        self.variant(CCAMODE_A::ED_MODE_TEST1)
127    }
128}
129#[doc = "Field `CCAEDTHRES` reader - CCA energy busy threshold. Used in all the CCA modes except CarrierMode."]
130pub type CCAEDTHRES_R = crate::FieldReader<u8, u8>;
131#[doc = "Field `CCAEDTHRES` writer - CCA energy busy threshold. Used in all the CCA modes except CarrierMode."]
132pub type CCAEDTHRES_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCACTRL_SPEC, u8, u8, 8, O>;
133#[doc = "Field `CCACORRTHRES` reader - CCA correlator busy threshold. Only relevant to CarrierMode, CarrierAndEdMode and CarrierOrEdMode."]
134pub type CCACORRTHRES_R = crate::FieldReader<u8, u8>;
135#[doc = "Field `CCACORRTHRES` writer - CCA correlator busy threshold. Only relevant to CarrierMode, CarrierAndEdMode and CarrierOrEdMode."]
136pub type CCACORRTHRES_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCACTRL_SPEC, u8, u8, 8, O>;
137#[doc = "Field `CCACORRCNT` reader - Limit for occurances above CCACORRTHRES. When not equal to zero the corrolator based signal detect is enabled."]
138pub type CCACORRCNT_R = crate::FieldReader<u8, u8>;
139#[doc = "Field `CCACORRCNT` writer - Limit for occurances above CCACORRTHRES. When not equal to zero the corrolator based signal detect is enabled."]
140pub type CCACORRCNT_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCACTRL_SPEC, u8, u8, 8, O>;
141impl R {
142    #[doc = "Bits 0:2 - CCA mode of operation"]
143    #[inline(always)]
144    pub fn ccamode(&self) -> CCAMODE_R {
145        CCAMODE_R::new((self.bits & 7) as u8)
146    }
147    #[doc = "Bits 8:15 - CCA energy busy threshold. Used in all the CCA modes except CarrierMode."]
148    #[inline(always)]
149    pub fn ccaedthres(&self) -> CCAEDTHRES_R {
150        CCAEDTHRES_R::new(((self.bits >> 8) & 0xff) as u8)
151    }
152    #[doc = "Bits 16:23 - CCA correlator busy threshold. Only relevant to CarrierMode, CarrierAndEdMode and CarrierOrEdMode."]
153    #[inline(always)]
154    pub fn ccacorrthres(&self) -> CCACORRTHRES_R {
155        CCACORRTHRES_R::new(((self.bits >> 16) & 0xff) as u8)
156    }
157    #[doc = "Bits 24:31 - Limit for occurances above CCACORRTHRES. When not equal to zero the corrolator based signal detect is enabled."]
158    #[inline(always)]
159    pub fn ccacorrcnt(&self) -> CCACORRCNT_R {
160        CCACORRCNT_R::new(((self.bits >> 24) & 0xff) as u8)
161    }
162}
163impl W {
164    #[doc = "Bits 0:2 - CCA mode of operation"]
165    #[inline(always)]
166    pub fn ccamode(&mut self) -> CCAMODE_W<0> {
167        CCAMODE_W::new(self)
168    }
169    #[doc = "Bits 8:15 - CCA energy busy threshold. Used in all the CCA modes except CarrierMode."]
170    #[inline(always)]
171    pub fn ccaedthres(&mut self) -> CCAEDTHRES_W<8> {
172        CCAEDTHRES_W::new(self)
173    }
174    #[doc = "Bits 16:23 - CCA correlator busy threshold. Only relevant to CarrierMode, CarrierAndEdMode and CarrierOrEdMode."]
175    #[inline(always)]
176    pub fn ccacorrthres(&mut self) -> CCACORRTHRES_W<16> {
177        CCACORRTHRES_W::new(self)
178    }
179    #[doc = "Bits 24:31 - Limit for occurances above CCACORRTHRES. When not equal to zero the corrolator based signal detect is enabled."]
180    #[inline(always)]
181    pub fn ccacorrcnt(&mut self) -> CCACORRCNT_W<24> {
182        CCACORRCNT_W::new(self)
183    }
184    #[doc = "Writes raw bits to the register."]
185    #[inline(always)]
186    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
187        self.0.bits(bits);
188        self
189    }
190}
191#[doc = "IEEE 802.15.4 clear channel assessment control\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 [ccactrl](index.html) module"]
192pub struct CCACTRL_SPEC;
193impl crate::RegisterSpec for CCACTRL_SPEC {
194    type Ux = u32;
195}
196#[doc = "`read()` method returns [ccactrl::R](R) reader structure"]
197impl crate::Readable for CCACTRL_SPEC {
198    type Reader = R;
199}
200#[doc = "`write(|w| ..)` method takes [ccactrl::W](W) writer structure"]
201impl crate::Writable for CCACTRL_SPEC {
202    type Writer = W;
203}
204#[doc = "`reset()` method sets CCACTRL to value 0"]
205impl crate::Resettable for CCACTRL_SPEC {
206    #[inline(always)]
207    fn reset_value() -> Self::Ux {
208        0
209    }
210}