nrf52840_pac/radio/
mode.rs

1#[doc = "Register `MODE` reader"]
2pub struct R(crate::R<MODE_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MODE_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MODE_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MODE_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MODE` writer"]
17pub struct W(crate::W<MODE_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MODE_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<MODE_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MODE_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `MODE` reader - Radio data rate and modulation setting. The radio supports frequency-shift keying (FSK) modulation."]
38pub type MODE_R = crate::FieldReader<u8, MODE_A>;
39#[doc = "Radio data rate and modulation setting. The radio supports frequency-shift keying (FSK) modulation.\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum MODE_A {
43    #[doc = "0: 1 Mbit/s Nordic proprietary radio mode"]
44    NRF_1MBIT = 0,
45    #[doc = "1: 2 Mbit/s Nordic proprietary radio mode"]
46    NRF_2MBIT = 1,
47    #[doc = "3: 1 Mbit/s BLE"]
48    BLE_1MBIT = 3,
49    #[doc = "4: 2 Mbit/s BLE"]
50    BLE_2MBIT = 4,
51    #[doc = "5: Long range 125 kbit/s TX, 125 kbit/s and 500 kbit/s RX"]
52    BLE_LR125KBIT = 5,
53    #[doc = "6: Long range 500 kbit/s TX, 125 kbit/s and 500 kbit/s RX"]
54    BLE_LR500KBIT = 6,
55    #[doc = "15: IEEE 802.15.4-2006 250 kbit/s"]
56    IEEE802154_250KBIT = 15,
57}
58impl From<MODE_A> for u8 {
59    #[inline(always)]
60    fn from(variant: MODE_A) -> Self {
61        variant as _
62    }
63}
64impl MODE_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<MODE_A> {
68        match self.bits {
69            0 => Some(MODE_A::NRF_1MBIT),
70            1 => Some(MODE_A::NRF_2MBIT),
71            3 => Some(MODE_A::BLE_1MBIT),
72            4 => Some(MODE_A::BLE_2MBIT),
73            5 => Some(MODE_A::BLE_LR125KBIT),
74            6 => Some(MODE_A::BLE_LR500KBIT),
75            15 => Some(MODE_A::IEEE802154_250KBIT),
76            _ => None,
77        }
78    }
79    #[doc = "Checks if the value of the field is `NRF_1MBIT`"]
80    #[inline(always)]
81    pub fn is_nrf_1mbit(&self) -> bool {
82        *self == MODE_A::NRF_1MBIT
83    }
84    #[doc = "Checks if the value of the field is `NRF_2MBIT`"]
85    #[inline(always)]
86    pub fn is_nrf_2mbit(&self) -> bool {
87        *self == MODE_A::NRF_2MBIT
88    }
89    #[doc = "Checks if the value of the field is `BLE_1MBIT`"]
90    #[inline(always)]
91    pub fn is_ble_1mbit(&self) -> bool {
92        *self == MODE_A::BLE_1MBIT
93    }
94    #[doc = "Checks if the value of the field is `BLE_2MBIT`"]
95    #[inline(always)]
96    pub fn is_ble_2mbit(&self) -> bool {
97        *self == MODE_A::BLE_2MBIT
98    }
99    #[doc = "Checks if the value of the field is `BLE_LR125KBIT`"]
100    #[inline(always)]
101    pub fn is_ble_lr125kbit(&self) -> bool {
102        *self == MODE_A::BLE_LR125KBIT
103    }
104    #[doc = "Checks if the value of the field is `BLE_LR500KBIT`"]
105    #[inline(always)]
106    pub fn is_ble_lr500kbit(&self) -> bool {
107        *self == MODE_A::BLE_LR500KBIT
108    }
109    #[doc = "Checks if the value of the field is `IEEE802154_250KBIT`"]
110    #[inline(always)]
111    pub fn is_ieee802154_250kbit(&self) -> bool {
112        *self == MODE_A::IEEE802154_250KBIT
113    }
114}
115#[doc = "Field `MODE` writer - Radio data rate and modulation setting. The radio supports frequency-shift keying (FSK) modulation."]
116pub type MODE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MODE_SPEC, u8, MODE_A, 4, O>;
117impl<'a, const O: u8> MODE_W<'a, O> {
118    #[doc = "1 Mbit/s Nordic proprietary radio mode"]
119    #[inline(always)]
120    pub fn nrf_1mbit(self) -> &'a mut W {
121        self.variant(MODE_A::NRF_1MBIT)
122    }
123    #[doc = "2 Mbit/s Nordic proprietary radio mode"]
124    #[inline(always)]
125    pub fn nrf_2mbit(self) -> &'a mut W {
126        self.variant(MODE_A::NRF_2MBIT)
127    }
128    #[doc = "1 Mbit/s BLE"]
129    #[inline(always)]
130    pub fn ble_1mbit(self) -> &'a mut W {
131        self.variant(MODE_A::BLE_1MBIT)
132    }
133    #[doc = "2 Mbit/s BLE"]
134    #[inline(always)]
135    pub fn ble_2mbit(self) -> &'a mut W {
136        self.variant(MODE_A::BLE_2MBIT)
137    }
138    #[doc = "Long range 125 kbit/s TX, 125 kbit/s and 500 kbit/s RX"]
139    #[inline(always)]
140    pub fn ble_lr125kbit(self) -> &'a mut W {
141        self.variant(MODE_A::BLE_LR125KBIT)
142    }
143    #[doc = "Long range 500 kbit/s TX, 125 kbit/s and 500 kbit/s RX"]
144    #[inline(always)]
145    pub fn ble_lr500kbit(self) -> &'a mut W {
146        self.variant(MODE_A::BLE_LR500KBIT)
147    }
148    #[doc = "IEEE 802.15.4-2006 250 kbit/s"]
149    #[inline(always)]
150    pub fn ieee802154_250kbit(self) -> &'a mut W {
151        self.variant(MODE_A::IEEE802154_250KBIT)
152    }
153}
154impl R {
155    #[doc = "Bits 0:3 - Radio data rate and modulation setting. The radio supports frequency-shift keying (FSK) modulation."]
156    #[inline(always)]
157    pub fn mode(&self) -> MODE_R {
158        MODE_R::new((self.bits & 0x0f) as u8)
159    }
160}
161impl W {
162    #[doc = "Bits 0:3 - Radio data rate and modulation setting. The radio supports frequency-shift keying (FSK) modulation."]
163    #[inline(always)]
164    pub fn mode(&mut self) -> MODE_W<0> {
165        MODE_W::new(self)
166    }
167    #[doc = "Writes raw bits to the register."]
168    #[inline(always)]
169    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
170        self.0.bits(bits);
171        self
172    }
173}
174#[doc = "Data rate and modulation\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 [mode](index.html) module"]
175pub struct MODE_SPEC;
176impl crate::RegisterSpec for MODE_SPEC {
177    type Ux = u32;
178}
179#[doc = "`read()` method returns [mode::R](R) reader structure"]
180impl crate::Readable for MODE_SPEC {
181    type Reader = R;
182}
183#[doc = "`write(|w| ..)` method takes [mode::W](W) writer structure"]
184impl crate::Writable for MODE_SPEC {
185    type Writer = W;
186}
187#[doc = "`reset()` method sets MODE to value 0"]
188impl crate::Resettable for MODE_SPEC {
189    #[inline(always)]
190    fn reset_value() -> Self::Ux {
191        0
192    }
193}