@@ -309,7 +309,10 @@ impl<'c> Radio<'c> {
309
309
/// will be updated with the received packet's data
310
310
pub fn recv ( & mut self , packet : & mut Packet ) -> Result < u16 , u16 > {
311
311
// Start the read
312
- self . start_recv ( packet) ;
312
+ // NOTE(unsafe) We block until reception completes or errors
313
+ unsafe {
314
+ self . start_recv ( packet) ;
315
+ }
313
316
314
317
// wait until we have received something
315
318
self . wait_for_event ( Event :: End ) ;
@@ -348,7 +351,10 @@ impl<'c> Radio<'c> {
348
351
timer. start ( microseconds) ;
349
352
350
353
// Start the read
351
- self . start_recv ( packet) ;
354
+ // NOTE(unsafe) We block until reception completes or errors
355
+ unsafe {
356
+ self . start_recv ( packet) ;
357
+ }
352
358
353
359
// Wait for transmission to end
354
360
let mut recv_completed = false ;
@@ -381,7 +387,7 @@ impl<'c> Radio<'c> {
381
387
}
382
388
}
383
389
384
- fn start_recv ( & mut self , packet : & mut Packet ) {
390
+ unsafe fn start_recv ( & mut self , packet : & mut Packet ) {
385
391
// NOTE we do NOT check the address of `packet` because the mutable reference ensures it's
386
392
// allocated in RAM
387
393
@@ -393,11 +399,9 @@ impl<'c> Radio<'c> {
393
399
394
400
// NOTE(unsafe) DMA transfer has not yet started
395
401
// set up RX buffer
396
- unsafe {
397
- self . radio
398
- . packetptr
399
- . write ( |w| w. packetptr ( ) . bits ( packet. buffer . as_mut_ptr ( ) as u32 ) ) ;
400
- }
402
+ self . radio
403
+ . packetptr
404
+ . write ( |w| w. packetptr ( ) . bits ( packet. buffer . as_mut_ptr ( ) as u32 ) ) ;
401
405
402
406
// start transfer
403
407
dma_start_fence ( ) ;
0 commit comments