nrf52840_pac/ccm/
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 - The mode of operation to be used. The settings in this register apply whenever either the KSGEN or CRYPT tasks are triggered."]
38pub type MODE_R = crate::BitReader<MODE_A>;
39#[doc = "The mode of operation to be used. The settings in this register apply whenever either the KSGEN or CRYPT tasks are triggered.\n\nValue on reset: 1"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub enum MODE_A {
42 #[doc = "0: AES CCM packet encryption mode"]
43 ENCRYPTION = 0,
44 #[doc = "1: AES CCM packet decryption mode"]
45 DECRYPTION = 1,
46}
47impl From<MODE_A> for bool {
48 #[inline(always)]
49 fn from(variant: MODE_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl MODE_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> MODE_A {
57 match self.bits {
58 false => MODE_A::ENCRYPTION,
59 true => MODE_A::DECRYPTION,
60 }
61 }
62 #[doc = "Checks if the value of the field is `ENCRYPTION`"]
63 #[inline(always)]
64 pub fn is_encryption(&self) -> bool {
65 *self == MODE_A::ENCRYPTION
66 }
67 #[doc = "Checks if the value of the field is `DECRYPTION`"]
68 #[inline(always)]
69 pub fn is_decryption(&self) -> bool {
70 *self == MODE_A::DECRYPTION
71 }
72}
73#[doc = "Field `MODE` writer - The mode of operation to be used. The settings in this register apply whenever either the KSGEN or CRYPT tasks are triggered."]
74pub type MODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE_SPEC, MODE_A, O>;
75impl<'a, const O: u8> MODE_W<'a, O> {
76 #[doc = "AES CCM packet encryption mode"]
77 #[inline(always)]
78 pub fn encryption(self) -> &'a mut W {
79 self.variant(MODE_A::ENCRYPTION)
80 }
81 #[doc = "AES CCM packet decryption mode"]
82 #[inline(always)]
83 pub fn decryption(self) -> &'a mut W {
84 self.variant(MODE_A::DECRYPTION)
85 }
86}
87#[doc = "Field `DATARATE` reader - Radio data rate that the CCM shall run synchronous with"]
88pub type DATARATE_R = crate::FieldReader<u8, DATARATE_A>;
89#[doc = "Radio data rate that the CCM shall run synchronous with\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq)]
91#[repr(u8)]
92pub enum DATARATE_A {
93 #[doc = "0: 1 Mbps"]
94 _1MBIT = 0,
95 #[doc = "1: 2 Mbps"]
96 _2MBIT = 1,
97 #[doc = "2: 125 Kbps"]
98 _125KBPS = 2,
99 #[doc = "3: 500 Kbps"]
100 _500KBPS = 3,
101}
102impl From<DATARATE_A> for u8 {
103 #[inline(always)]
104 fn from(variant: DATARATE_A) -> Self {
105 variant as _
106 }
107}
108impl DATARATE_R {
109 #[doc = "Get enumerated values variant"]
110 #[inline(always)]
111 pub fn variant(&self) -> DATARATE_A {
112 match self.bits {
113 0 => DATARATE_A::_1MBIT,
114 1 => DATARATE_A::_2MBIT,
115 2 => DATARATE_A::_125KBPS,
116 3 => DATARATE_A::_500KBPS,
117 _ => unreachable!(),
118 }
119 }
120 #[doc = "Checks if the value of the field is `_1MBIT`"]
121 #[inline(always)]
122 pub fn is_1mbit(&self) -> bool {
123 *self == DATARATE_A::_1MBIT
124 }
125 #[doc = "Checks if the value of the field is `_2MBIT`"]
126 #[inline(always)]
127 pub fn is_2mbit(&self) -> bool {
128 *self == DATARATE_A::_2MBIT
129 }
130 #[doc = "Checks if the value of the field is `_125KBPS`"]
131 #[inline(always)]
132 pub fn is_125kbps(&self) -> bool {
133 *self == DATARATE_A::_125KBPS
134 }
135 #[doc = "Checks if the value of the field is `_500KBPS`"]
136 #[inline(always)]
137 pub fn is_500kbps(&self) -> bool {
138 *self == DATARATE_A::_500KBPS
139 }
140}
141#[doc = "Field `DATARATE` writer - Radio data rate that the CCM shall run synchronous with"]
142pub type DATARATE_W<'a, const O: u8> =
143 crate::FieldWriterSafe<'a, u32, MODE_SPEC, u8, DATARATE_A, 2, O>;
144impl<'a, const O: u8> DATARATE_W<'a, O> {
145 #[doc = "1 Mbps"]
146 #[inline(always)]
147 pub fn _1mbit(self) -> &'a mut W {
148 self.variant(DATARATE_A::_1MBIT)
149 }
150 #[doc = "2 Mbps"]
151 #[inline(always)]
152 pub fn _2mbit(self) -> &'a mut W {
153 self.variant(DATARATE_A::_2MBIT)
154 }
155 #[doc = "125 Kbps"]
156 #[inline(always)]
157 pub fn _125kbps(self) -> &'a mut W {
158 self.variant(DATARATE_A::_125KBPS)
159 }
160 #[doc = "500 Kbps"]
161 #[inline(always)]
162 pub fn _500kbps(self) -> &'a mut W {
163 self.variant(DATARATE_A::_500KBPS)
164 }
165}
166#[doc = "Field `LENGTH` reader - Packet length configuration"]
167pub type LENGTH_R = crate::BitReader<LENGTH_A>;
168#[doc = "Packet length configuration\n\nValue on reset: 0"]
169#[derive(Clone, Copy, Debug, PartialEq)]
170pub enum LENGTH_A {
171 #[doc = "0: Default length. Effective length of LENGTH field in encrypted/decrypted packet is 5 bits. A key-stream for packet payloads up to 27 bytes will be generated."]
172 DEFAULT = 0,
173 #[doc = "1: Extended length. Effective length of LENGTH field in encrypted/decrypted packet is 8 bits. A key-stream for packet payloads up to MAXPACKETSIZE bytes will be generated."]
174 EXTENDED = 1,
175}
176impl From<LENGTH_A> for bool {
177 #[inline(always)]
178 fn from(variant: LENGTH_A) -> Self {
179 variant as u8 != 0
180 }
181}
182impl LENGTH_R {
183 #[doc = "Get enumerated values variant"]
184 #[inline(always)]
185 pub fn variant(&self) -> LENGTH_A {
186 match self.bits {
187 false => LENGTH_A::DEFAULT,
188 true => LENGTH_A::EXTENDED,
189 }
190 }
191 #[doc = "Checks if the value of the field is `DEFAULT`"]
192 #[inline(always)]
193 pub fn is_default(&self) -> bool {
194 *self == LENGTH_A::DEFAULT
195 }
196 #[doc = "Checks if the value of the field is `EXTENDED`"]
197 #[inline(always)]
198 pub fn is_extended(&self) -> bool {
199 *self == LENGTH_A::EXTENDED
200 }
201}
202#[doc = "Field `LENGTH` writer - Packet length configuration"]
203pub type LENGTH_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE_SPEC, LENGTH_A, O>;
204impl<'a, const O: u8> LENGTH_W<'a, O> {
205 #[doc = "Default length. Effective length of LENGTH field in encrypted/decrypted packet is 5 bits. A key-stream for packet payloads up to 27 bytes will be generated."]
206 #[inline(always)]
207 pub fn default(self) -> &'a mut W {
208 self.variant(LENGTH_A::DEFAULT)
209 }
210 #[doc = "Extended length. Effective length of LENGTH field in encrypted/decrypted packet is 8 bits. A key-stream for packet payloads up to MAXPACKETSIZE bytes will be generated."]
211 #[inline(always)]
212 pub fn extended(self) -> &'a mut W {
213 self.variant(LENGTH_A::EXTENDED)
214 }
215}
216impl R {
217 #[doc = "Bit 0 - The mode of operation to be used. The settings in this register apply whenever either the KSGEN or CRYPT tasks are triggered."]
218 #[inline(always)]
219 pub fn mode(&self) -> MODE_R {
220 MODE_R::new((self.bits & 1) != 0)
221 }
222 #[doc = "Bits 16:17 - Radio data rate that the CCM shall run synchronous with"]
223 #[inline(always)]
224 pub fn datarate(&self) -> DATARATE_R {
225 DATARATE_R::new(((self.bits >> 16) & 3) as u8)
226 }
227 #[doc = "Bit 24 - Packet length configuration"]
228 #[inline(always)]
229 pub fn length(&self) -> LENGTH_R {
230 LENGTH_R::new(((self.bits >> 24) & 1) != 0)
231 }
232}
233impl W {
234 #[doc = "Bit 0 - The mode of operation to be used. The settings in this register apply whenever either the KSGEN or CRYPT tasks are triggered."]
235 #[inline(always)]
236 pub fn mode(&mut self) -> MODE_W<0> {
237 MODE_W::new(self)
238 }
239 #[doc = "Bits 16:17 - Radio data rate that the CCM shall run synchronous with"]
240 #[inline(always)]
241 pub fn datarate(&mut self) -> DATARATE_W<16> {
242 DATARATE_W::new(self)
243 }
244 #[doc = "Bit 24 - Packet length configuration"]
245 #[inline(always)]
246 pub fn length(&mut self) -> LENGTH_W<24> {
247 LENGTH_W::new(self)
248 }
249 #[doc = "Writes raw bits to the register."]
250 #[inline(always)]
251 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
252 self.0.bits(bits);
253 self
254 }
255}
256#[doc = "Operation mode\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"]
257pub struct MODE_SPEC;
258impl crate::RegisterSpec for MODE_SPEC {
259 type Ux = u32;
260}
261#[doc = "`read()` method returns [mode::R](R) reader structure"]
262impl crate::Readable for MODE_SPEC {
263 type Reader = R;
264}
265#[doc = "`write(|w| ..)` method takes [mode::W](W) writer structure"]
266impl crate::Writable for MODE_SPEC {
267 type Writer = W;
268}
269#[doc = "`reset()` method sets MODE to value 0x01"]
270impl crate::Resettable for MODE_SPEC {
271 #[inline(always)]
272 fn reset_value() -> Self::Ux {
273 0x01
274 }
275}