@@ -250,6 +250,10 @@ impl<'c> Radio<'c> {
250
250
pub fn recv ( & mut self , packet : & mut Packet ) -> Result < u16 , u16 > {
251
251
// NOTE we do NOT check the address of `packet`; see comment in `Packet::new` for details
252
252
253
+ // clear related events
254
+ self . radio . events_phyend . reset ( ) ;
255
+ self . radio . events_end . reset ( ) ;
256
+
253
257
// go to the RXIDLE state
254
258
self . enable_rx ( ) ;
255
259
@@ -268,8 +272,6 @@ impl<'c> Radio<'c> {
268
272
// wait until we have received something
269
273
self . wait_for_event ( Event :: End ) ;
270
274
dma_end_fence ( ) ;
271
- // also clear the PHYEND event
272
- self . radio . events_phyend . reset ( ) ;
273
275
274
276
let crc = self . radio . rxcrc . read ( ) . rxcrc ( ) . bits ( ) as u16 ;
275
277
if self . radio . crcstatus . read ( ) . crcstatus ( ) . bit_is_set ( ) {
@@ -285,6 +287,10 @@ impl<'c> Radio<'c> {
285
287
/// channel is observed to be *clear* (no transmission is currently ongoing), otherwise no
286
288
/// packet is transmitted and the `Err` variant is returned
287
289
pub fn try_send ( & mut self , packet : & Packet ) -> Result < ( ) , ( ) > {
290
+ // clear related events
291
+ self . radio . events_phyend . reset ( ) ;
292
+ self . radio . events_end . reset ( ) ;
293
+
288
294
// NOTE we do NOT check the address of `packet`; see comment in `Packet::new` for details
289
295
// go to the RXIDLE state
290
296
self . enable_rx ( ) ;
@@ -337,8 +343,6 @@ impl<'c> Radio<'c> {
337
343
// until the PHYEND event is raised
338
344
self . wait_for_event ( Event :: PhyEnd ) ;
339
345
dma_end_fence ( ) ;
340
- // also clear the END event
341
- self . radio . events_end . reset ( ) ;
342
346
343
347
Ok ( ( ) )
344
348
}
@@ -351,6 +355,10 @@ impl<'c> Radio<'c> {
351
355
pub fn send ( & mut self , packet : & Packet ) {
352
356
// NOTE we do NOT check the address of `packet`; see comment in `Packet::new` for details
353
357
358
+ // clear related events
359
+ self . radio . events_phyend . reset ( ) ;
360
+ self . radio . events_end . reset ( ) ;
361
+
354
362
self . radio . shorts . modify ( |_, w| w. ccaidle_txen ( ) . set_bit ( ) ) ;
355
363
356
364
// go to the RXIDLE state
@@ -403,8 +411,6 @@ impl<'c> Radio<'c> {
403
411
// until the PHYEND event is raised
404
412
self . wait_for_event ( Event :: PhyEnd ) ;
405
413
dma_end_fence ( ) ;
406
- // also clear the END event
407
- self . radio . events_end . reset ( ) ;
408
414
409
415
self . radio
410
416
. shorts
0 commit comments