@@ -719,17 +719,14 @@ impl<Id: ChId> Channel<Id, ReadyFuture> {
719
719
720
720
self . configure_trigger ( trig_src, trig_act) ;
721
721
722
- transfer_future:: TransferFuture :: new ( self , trig_src) . await ;
722
+ transfer_future:: TransferFuture :: new ( self , trig_src) . await
723
723
724
- // No need to defensively disable channel here; it's automatically stopped when
725
- // TransferFuture is dropped. Even though `stop()` is implicitly called
726
- // through TransferFuture::drop, it *absolutely* must be called before
727
- // this function is returned, because it emits the compiler fence which ensures
728
- // memory operations aren't reordered beyond the DMA transfer's bounds.
729
-
730
- // TODO currently this will always return Ok(()) since we unconditionally clear
731
- // ERROR
732
- self . xfer_success ( )
724
+ // No need to defensively disable channel here; it's automatically
725
+ // stopped when TransferFuture is dropped. Even though `stop()`
726
+ // is implicitly called through TransferFuture::drop, it
727
+ // *absolutely* must be called before this function is returned,
728
+ // because it emits the compiler fence which ensures memory operations
729
+ // aren't reordered beyond the DMA transfer's bounds.
733
730
}
734
731
}
735
732
@@ -769,7 +766,7 @@ mod transfer_future {
769
766
}
770
767
771
768
impl < Id : ChId > core:: future:: Future for TransferFuture < ' _ , Id > {
772
- type Output = ( ) ;
769
+ type Output = Result < ( ) , super :: Error > ;
773
770
774
771
fn poll (
775
772
mut self : core:: pin:: Pin < & mut Self > ,
@@ -778,29 +775,25 @@ mod transfer_future {
778
775
use crate :: dmac:: waker:: WAKERS ;
779
776
use core:: task:: Poll ;
780
777
781
- self . chan . _enable_private ( ) ;
782
-
783
- if !self . triggered && self . trig_src == TriggerSource :: Disable {
784
- self . triggered = true ;
785
- self . chan . _trigger_private ( ) ;
786
- }
787
-
788
778
let flags_to_check = InterruptFlags :: new ( ) . with_tcmpl ( true ) . with_terr ( true ) ;
789
-
790
- if self . chan . check_and_clear_interrupts ( flags_to_check) . tcmpl ( ) {
791
- return Poll :: Ready ( ( ) ) ;
779
+ let triggered_flags = self . chan . check_and_clear_interrupts ( flags_to_check) ;
780
+
781
+ if triggered_flags. tcmpl ( ) {
782
+ Poll :: Ready ( Ok ( ( ) ) )
783
+ } else if triggered_flags. terr ( ) {
784
+ Poll :: Ready ( Err ( super :: Error :: TransferError ) )
785
+ } else {
786
+ WAKERS [ Id :: USIZE ] . register ( cx. waker ( ) ) ;
787
+ self . chan . enable_interrupts ( flags_to_check) ;
788
+ self . chan . _enable_private ( ) ;
789
+
790
+ if !self . triggered && self . trig_src == TriggerSource :: Disable {
791
+ self . triggered = true ;
792
+ self . chan . _trigger_private ( ) ;
793
+ }
794
+
795
+ Poll :: Pending
792
796
}
793
-
794
- WAKERS [ Id :: USIZE ] . register ( cx. waker ( ) ) ;
795
- self . chan . enable_interrupts ( flags_to_check) ;
796
-
797
- if self . chan . check_and_clear_interrupts ( flags_to_check) . tcmpl ( ) {
798
- self . chan . disable_interrupts ( flags_to_check) ;
799
-
800
- return Poll :: Ready ( ( ) ) ;
801
- }
802
-
803
- Poll :: Pending
804
797
}
805
798
}
806
799
}
0 commit comments