aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Bånvik <[email protected]>2024-02-29 09:50:28 +0100
committerErik Bånvik <[email protected]>2024-02-29 09:50:28 +0100
commit8eac5d07f65e642ca4ad763ffe90bad97803089c (patch)
tree009f73f51656090b49444df35ad59e3afae089e3
parentf0753998bc9379bdb19ef4fcddf96ff19487a52d (diff)
Remove Event, which was mostly used for debugging
-rw-r--r--embassy-nrf/src/radio/event.rs333
-rw-r--r--embassy-nrf/src/radio/ieee802154.rs3
-rw-r--r--embassy-nrf/src/radio/mod.rs3
3 files changed, 1 insertions, 338 deletions
diff --git a/embassy-nrf/src/radio/event.rs b/embassy-nrf/src/radio/event.rs
deleted file mode 100644
index 8fb0958d5..000000000
--- a/embassy-nrf/src/radio/event.rs
+++ /dev/null
@@ -1,333 +0,0 @@
1use crate::pac;
2use bitflags;
3
4bitflags::bitflags! {
5 /// Event as bit flags
6 pub struct Event : u32 {
7 /// Radio ready
8 const READY = 1u32 << 0;
9 /// Address operation done
10 const ADDRESS = 1u32 << 1;
11 /// Payload operation done
12 const PAYLOAD = 1u32 << 2;
13 /// Packet operation done
14 const END = 1u32 << 3;
15 /// Radio has been disabled
16 const DISABLED = 1u32 << 4;
17 /// Device address match in last received packet
18 const DEV_MATCH = 1u32 << 5;
19 /// No device address match in last received packet
20 const DEV_MISS = 1u32 << 6;
21 /// RSSI sampling complete
22 const RSSI_END = 1u32 << 7;
23 /// Bit counter reached target
24 const BC_MATCH = 1u32 << 10;
25 /// CRC ok in last received packet
26 const CRC_OK = 1u32 << 12;
27 /// CRC error in last received packet
28 const CRC_ERROR = 1u32 << 13;
29 /// IEEE 802.15.4 length field received
30 const FRAME_START = 1u32 << 14;
31 /// Sampling of energy detect complete
32 const ED_END = 1u32 << 15;
33 /// Sampling of energy detect stopped
34 const ED_STOPPED = 1u32 << 16;
35 /// Wireless medium in idle, ready to sent
36 const CCA_IDLE = 1u32 << 17;
37 /// Wireless medium busy, do not send
38 const CCA_BUSY = 1u32 << 18;
39 /// Clear channel assessment stopped
40 const CCA_STOPPED = 1u32 << 19;
41 /// BLE LR rate boost received
42 const RATE_BOOST = 1u32 << 20;
43 /// Radio has ramped up transmitter
44 const TX_READY = 1u32 << 21;
45 /// Radio has ramped up receiver
46 const RX_READY = 1u32 << 22;
47 /// MAC header match found
48 const MHR_MATCH = 1u32 << 23;
49 /// Preamble received, possible false triggering
50 const SYNC = 1u32 << 26;
51 /// Last bit sent / received
52 const PHY_END = 1u32 << 27;
53 /// Continuous tone extension is present
54 const CTE_PRESENT = 1u32 << 28;
55 }
56}
57
58impl Event {
59 /// Read events from radio
60 #[cfg(not(feature = "nrf52832"))]
61 pub fn from_radio(radio: &pac::radio::RegisterBlock) -> Self {
62 let mut value = Self::empty();
63 if radio.events_ready.read().events_ready().bit_is_set() {
64 value |= Self::READY;
65 }
66 if radio.events_address.read().events_address().bit_is_set() {
67 value |= Self::ADDRESS;
68 }
69 if radio.events_payload.read().events_payload().bit_is_set() {
70 value |= Self::PAYLOAD;
71 }
72 if radio.events_end.read().events_end().bit_is_set() {
73 value |= Self::END;
74 }
75 if radio.events_disabled.read().events_disabled().bit_is_set() {
76 value |= Self::DISABLED;
77 }
78 if radio.events_devmatch.read().events_devmatch().bit_is_set() {
79 value |= Self::DEV_MATCH;
80 }
81 if radio.events_devmiss.read().events_devmiss().bit_is_set() {
82 value |= Self::DEV_MISS;
83 }
84 if radio.events_rssiend.read().events_rssiend().bit_is_set() {
85 value |= Self::RSSI_END;
86 }
87 if radio.events_bcmatch.read().events_bcmatch().bit_is_set() {
88 value |= Self::BC_MATCH;
89 }
90 if radio.events_crcok.read().events_crcok().bit_is_set() {
91 value |= Self::CRC_OK;
92 }
93 if radio.events_crcerror.read().events_crcerror().bit_is_set() {
94 value |= Self::CRC_ERROR;
95 }
96 #[cfg(any(
97 feature = "nrf52811",
98 feature = "nrf52820",
99 feature = "nrf52833",
100 feature = "nrf52840",
101 feature = "_nrf5340-net"
102 ))]
103 if radio.events_framestart.read().events_framestart().bit_is_set() {
104 value |= Self::FRAME_START;
105 }
106 #[cfg(any(
107 feature = "nrf52811",
108 feature = "nrf52820",
109 feature = "nrf52833",
110 feature = "nrf52840",
111 feature = "_nrf5340-net"
112 ))]
113 if radio.events_edend.read().events_edend().bit_is_set() {
114 value |= Self::ED_END;
115 }
116 #[cfg(any(
117 feature = "nrf52811",
118 feature = "nrf52820",
119 feature = "nrf52833",
120 feature = "nrf52840",
121 feature = "_nrf5340-net"
122 ))]
123 if radio.events_edstopped.read().events_edstopped().bit_is_set() {
124 value |= Self::ED_STOPPED;
125 }
126 #[cfg(any(
127 feature = "nrf52820",
128 feature = "nrf52833",
129 feature = "nrf52840",
130 feature = "_nrf5340-net"
131 ))]
132 if radio.events_ccaidle.read().events_ccaidle().bit_is_set() {
133 value |= Self::CCA_IDLE;
134 }
135 #[cfg(any(
136 feature = "nrf52820",
137 feature = "nrf52833",
138 feature = "nrf52840",
139 feature = "_nrf5340-net"
140 ))]
141 if radio.events_ccabusy.read().events_ccabusy().bit_is_set() {
142 value |= Self::CCA_BUSY;
143 }
144 #[cfg(any(
145 feature = "nrf52820",
146 feature = "nrf52833",
147 feature = "nrf52840",
148 feature = "_nrf5340-net"
149 ))]
150 if radio.events_ccastopped.read().events_ccastopped().bit_is_set() {
151 value |= Self::CCA_STOPPED;
152 }
153 #[cfg(any(
154 feature = "nrf52811",
155 feature = "nrf52820",
156 feature = "nrf52833",
157 feature = "nrf52840",
158 feature = "_nrf5340-net"
159 ))]
160 if radio.events_rateboost.read().events_rateboost().bit_is_set() {
161 value |= Self::RATE_BOOST;
162 }
163 #[cfg(any(
164 feature = "nrf52805",
165 feature = "nrf52811",
166 feature = "nrf52820",
167 feature = "nrf52833",
168 feature = "nrf52840",
169 feature = "_nrf5340-net"
170 ))]
171 if radio.events_txready.read().events_txready().bit_is_set() {
172 value |= Self::TX_READY;
173 }
174 #[cfg(any(
175 feature = "nrf52805",
176 feature = "nrf52811",
177 feature = "nrf52820",
178 feature = "nrf52833",
179 feature = "nrf52840",
180 feature = "_nrf5340-net"
181 ))]
182 if radio.events_rxready.read().events_rxready().bit_is_set() {
183 value |= Self::RX_READY;
184 }
185 #[cfg(any(
186 feature = "nrf52811",
187 feature = "nrf52820",
188 feature = "nrf52833",
189 feature = "nrf52840",
190 feature = "_nrf5340-net"
191 ))]
192 if radio.events_mhrmatch.read().events_mhrmatch().bit_is_set() {
193 value |= Self::MHR_MATCH;
194 }
195 #[cfg(any(feature = "nrf52820", feature = "nrf52833", feature = "_nrf5340-net"))]
196 if radio.events_sync.read().events_sync().bit_is_set() {
197 value |= Self::SYNC;
198 }
199 #[cfg(any(
200 feature = "nrf52805",
201 feature = "nrf52811",
202 feature = "nrf52820",
203 feature = "nrf52833",
204 feature = "nrf52840",
205 feature = "_nrf5340-net"
206 ))]
207 if radio.events_phyend.read().events_phyend().bit_is_set() {
208 value |= Self::PHY_END;
209 }
210 #[cfg(any(
211 feature = "nrf52811",
212 feature = "nrf52820",
213 feature = "nrf52833",
214 feature = "_nrf5340-net"
215 ))]
216 if radio.events_ctepresent.read().events_ctepresent().bit_is_set() {
217 value |= Self::CTE_PRESENT;
218 }
219 value
220 }
221 // The nRF52832 SVD probably is a bit broken
222 /// Read events from radio
223 #[cfg(feature = "nrf52832")]
224 pub fn from_radio(radio: &pac::radio::RegisterBlock) -> Self {
225 let mut value = Self::empty();
226 if radio.events_ready.read().bits() == 1 {
227 value |= Self::READY;
228 }
229 if radio.events_address.read().bits() == 1 {
230 value |= Self::ADDRESS;
231 }
232 if radio.events_payload.read().bits() == 1 {
233 value |= Self::PAYLOAD;
234 }
235 if radio.events_end.read().bits() == 1 {
236 value |= Self::END;
237 }
238 if radio.events_disabled.read().bits() == 1 {
239 value |= Self::DISABLED;
240 }
241 if radio.events_devmatch.read().bits() == 1 {
242 value |= Self::DEV_MATCH;
243 }
244 if radio.events_devmiss.read().bits() == 1 {
245 value |= Self::DEV_MISS;
246 }
247 if radio.events_rssiend.read().bits() == 1 {
248 value |= Self::RSSI_END;
249 }
250 if radio.events_bcmatch.read().bits() == 1 {
251 value |= Self::BC_MATCH;
252 }
253 if radio.events_crcok.read().bits() == 1 {
254 value |= Self::CRC_OK;
255 }
256 if radio.events_crcerror.read().bits() == 1 {
257 value |= Self::CRC_ERROR;
258 }
259 value
260 }
261
262 /// Read events from radio, mask with set interrupts
263 pub fn from_radio_masked(radio: &pac::radio::RegisterBlock) -> Self {
264 Self::from_radio(radio) & Self::from_bits_truncate(radio.intenset.read().bits())
265 }
266}
267
268#[cfg(feature = "defmt")]
269impl defmt::Format for Event {
270 fn format(&self, fmt: defmt::Formatter) {
271 defmt::write!(
272 fmt,
273 "{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}",
274 if self.contains(Self::READY) { "RD" } else { "__" },
275 if self.contains(Self::ADDRESS) { "AD" } else { "__" },
276 if self.contains(Self::PAYLOAD) { "PL" } else { "__" },
277 if self.contains(Self::END) { " E" } else { "__" },
278 if self.contains(Self::DISABLED) { "DI" } else { "__" },
279 if self.contains(Self::DEV_MATCH) { "D+" } else { "__" },
280 if self.contains(Self::DEV_MISS) { "D-" } else { "__" },
281 if self.contains(Self::RSSI_END) { "RE" } else { "__" },
282 if self.contains(Self::BC_MATCH) { "CM" } else { "__" },
283 if self.contains(Self::CRC_OK) { "CO" } else { "__" },
284 if self.contains(Self::CRC_ERROR) { "CE" } else { "__" },
285 if self.contains(Self::FRAME_START) { "FS" } else { "__" },
286 if self.contains(Self::ED_END) { "EE" } else { "__" },
287 if self.contains(Self::ED_STOPPED) { "ES" } else { "__" },
288 if self.contains(Self::CCA_IDLE) { "CI" } else { "__" },
289 if self.contains(Self::CCA_BUSY) { "CB" } else { "__" },
290 if self.contains(Self::CCA_STOPPED) { "CS" } else { "__" },
291 if self.contains(Self::RATE_BOOST) { "RB" } else { "__" },
292 if self.contains(Self::TX_READY) { "TX" } else { "__" },
293 if self.contains(Self::RX_READY) { "RX" } else { "__" },
294 if self.contains(Self::MHR_MATCH) { "MM" } else { "__" },
295 if self.contains(Self::SYNC) { "SY" } else { "__" },
296 if self.contains(Self::PHY_END) { "PE" } else { "__" },
297 if self.contains(Self::CTE_PRESENT) { "CP" } else { "__" },
298 )
299 }
300}
301
302impl core::fmt::Display for Event {
303 fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
304 write!(
305 fmt,
306 "{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}",
307 if self.contains(Self::READY) { "RD" } else { "__" },
308 if self.contains(Self::ADDRESS) { "AD" } else { "__" },
309 if self.contains(Self::PAYLOAD) { "PL" } else { "__" },
310 if self.contains(Self::END) { " E" } else { "__" },
311 if self.contains(Self::DISABLED) { "DI" } else { "__" },
312 if self.contains(Self::DEV_MATCH) { "D+" } else { "__" },
313 if self.contains(Self::DEV_MISS) { "D-" } else { "__" },
314 if self.contains(Self::RSSI_END) { "RE" } else { "__" },
315 if self.contains(Self::BC_MATCH) { "CM" } else { "__" },
316 if self.contains(Self::CRC_OK) { "CO" } else { "__" },
317 if self.contains(Self::CRC_ERROR) { "CE" } else { "__" },
318 if self.contains(Self::FRAME_START) { "FS" } else { "__" },
319 if self.contains(Self::ED_END) { "EE" } else { "__" },
320 if self.contains(Self::ED_STOPPED) { "ES" } else { "__" },
321 if self.contains(Self::CCA_IDLE) { "CI" } else { "__" },
322 if self.contains(Self::CCA_BUSY) { "CB" } else { "__" },
323 if self.contains(Self::CCA_STOPPED) { "CS" } else { "__" },
324 if self.contains(Self::RATE_BOOST) { "RB" } else { "__" },
325 if self.contains(Self::TX_READY) { "TX" } else { "__" },
326 if self.contains(Self::RX_READY) { "RX" } else { "__" },
327 if self.contains(Self::MHR_MATCH) { "MM" } else { "__" },
328 if self.contains(Self::SYNC) { "SY" } else { "__" },
329 if self.contains(Self::PHY_END) { "PE" } else { "__" },
330 if self.contains(Self::CTE_PRESENT) { "CP" } else { "__" },
331 )
332 }
333}
diff --git a/embassy-nrf/src/radio/ieee802154.rs b/embassy-nrf/src/radio/ieee802154.rs
index adc6f8aaa..32951421b 100644
--- a/embassy-nrf/src/radio/ieee802154.rs
+++ b/embassy-nrf/src/radio/ieee802154.rs
@@ -3,7 +3,7 @@
3use core::sync::atomic::{compiler_fence, Ordering}; 3use core::sync::atomic::{compiler_fence, Ordering};
4use core::task::Poll; 4use core::task::Poll;
5 5
6use super::{Error, Event, Instance, InterruptHandler}; 6use super::{Error, Instance, InterruptHandler};
7use crate::{ 7use crate::{
8 interrupt::{self, typelevel::Interrupt}, 8 interrupt::{self, typelevel::Interrupt},
9 pac, Peripheral, 9 pac, Peripheral,
@@ -319,7 +319,6 @@ impl<'d, T: Instance> Radio<'d, T> {
319 r.shorts.reset(); 319 r.shorts.reset();
320 if r.events_framestart.read().events_framestart().bit_is_set() { 320 if r.events_framestart.read().events_framestart().bit_is_set() {
321 // TODO: Is there a way to finish receiving this frame 321 // TODO: Is there a way to finish receiving this frame
322 trace!("EVENTS {}", Event::from_radio(r));
323 } 322 }
324 r.tasks_stop.write(|w| w.tasks_stop().set_bit()); 323 r.tasks_stop.write(|w| w.tasks_stop().set_bit());
325 loop { 324 loop {
diff --git a/embassy-nrf/src/radio/mod.rs b/embassy-nrf/src/radio/mod.rs
index 914e6c438..9b3a6cf49 100644
--- a/embassy-nrf/src/radio/mod.rs
+++ b/embassy-nrf/src/radio/mod.rs
@@ -7,13 +7,10 @@
7 7
8/// Bluetooth Low Energy Radio driver. 8/// Bluetooth Low Energy Radio driver.
9pub mod ble; 9pub mod ble;
10mod event;
11#[cfg(any(feature = "nrf52840", feature = "nrf52833", feature = "_nrf5340-net"))] 10#[cfg(any(feature = "nrf52840", feature = "nrf52833", feature = "_nrf5340-net"))]
12/// IEEE 802.15.4 11/// IEEE 802.15.4
13pub mod ieee802154; 12pub mod ieee802154;
14 13
15pub use event::Event;
16
17use core::marker::PhantomData; 14use core::marker::PhantomData;
18 15
19use crate::{interrupt, pac, Peripheral}; 16use crate::{interrupt, pac, Peripheral};