@@ -307,8 +307,10 @@ impl<'rx, 'tx> EthernetDMA<'rx, 'tx> {
307307 }
308308
309309 /// 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 ) ;
311312 eth_interrupt_handler ( & self . eth_dma ) ;
313+ status
312314 }
313315
314316 /// Is Rx DMA currently running?
@@ -364,19 +366,35 @@ impl EthernetMAC {
364366 }
365367}
366368
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+
367377/// Call in interrupt handler to clear interrupt reason, when
368378/// [`enable_interrupt()`](struct.EthernetDMA.html#method.enable_interrupt).
369379///
370380/// There are two ways to call this:
371381///
372382/// * Via the [`EthernetDMA`](struct.EthernetDMA.html) driver instance that your interrupt handler has access to.
373383/// * 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+
377393 eth_dma
378394 . 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
380398}
381399
382400/// This block ensures that README.md is checked when `cargo test` is run.
0 commit comments