@@ -307,8 +307,10 @@ impl<'rx, 'tx> EthernetDMA<'rx, 'tx> {
307
307
}
308
308
309
309
/// Calls [`eth_interrupt_handler()`](fn.eth_interrupt_handler.html)
310
- pub fn interrupt_handler ( & self ) {
310
+ pub fn interrupt_handler ( & self ) -> InterruptReasonSummary {
311
+ let status = eth_interrupt_handler ( & self . eth_dma ) ;
311
312
eth_interrupt_handler ( & self . eth_dma ) ;
313
+ status
312
314
}
313
315
314
316
/// Is Rx DMA currently running?
@@ -364,19 +366,35 @@ impl EthernetMAC {
364
366
}
365
367
}
366
368
369
+ /// A summary of the reasons for the interrupt
370
+ /// that occured
371
+ pub struct InterruptReasonSummary {
372
+ pub is_rx : bool ,
373
+ pub is_tx : bool ,
374
+ pub is_error : bool ,
375
+ }
376
+
367
377
/// Call in interrupt handler to clear interrupt reason, when
368
378
/// [`enable_interrupt()`](struct.EthernetDMA.html#method.enable_interrupt).
369
379
///
370
380
/// There are two ways to call this:
371
381
///
372
382
/// * Via the [`EthernetDMA`](struct.EthernetDMA.html) driver instance that your interrupt handler has access to.
373
383
/// * By unsafely getting `Peripherals`.
374
- ///
375
- /// TODO: could return interrupt reason
376
- pub fn eth_interrupt_handler ( eth_dma : & ETHERNET_DMA ) {
384
+ pub fn eth_interrupt_handler ( eth_dma : & ETHERNET_DMA ) -> InterruptReasonSummary {
385
+ let status = eth_dma. dmasr . read ( ) ;
386
+
387
+ let status = InterruptReasonSummary {
388
+ is_rx : status. rs ( ) . bit_is_set ( ) ,
389
+ is_tx : status. ts ( ) . bit_is_set ( ) ,
390
+ is_error : status. ais ( ) . bit_is_set ( ) ,
391
+ } ;
392
+
377
393
eth_dma
378
394
. dmasr
379
- . write ( |w| w. nis ( ) . set_bit ( ) . rs ( ) . set_bit ( ) . ts ( ) . set_bit ( ) ) ;
395
+ . write ( |w| w. nis ( ) . set_bit ( ) . ts ( ) . set_bit ( ) . rs ( ) . set_bit ( ) ) ;
396
+
397
+ status
380
398
}
381
399
382
400
/// This block ensures that README.md is checked when `cargo test` is run.
0 commit comments