@@ -609,18 +609,20 @@ impl<'a, C: Channel, W: Word> Drop for DoubleBuffered<'a, C, W> {
609
609
610
610
// ==============================
611
611
612
- impl < C : Channel > DmaCtrl for C {
612
+ struct DmaCtrlImpl < ' a , C : Channel > ( PeripheralRef < ' a , C > ) ;
613
+
614
+ impl < ' a , C : Channel > DmaCtrl for DmaCtrlImpl < ' a , C > {
613
615
fn ndtr ( & self ) -> usize {
614
- let ch = self . regs ( ) . st ( self . num ( ) ) ;
616
+ let ch = self . 0 . regs ( ) . st ( self . 0 . num ( ) ) ;
615
617
unsafe { ch. ndtr ( ) . read ( ) } . ndt ( ) as usize
616
618
}
617
619
618
620
fn get_complete_count ( & self ) -> usize {
619
- STATE . complete_count [ self . index ( ) ] . load ( Ordering :: Acquire )
621
+ STATE . complete_count [ self . 0 . index ( ) ] . load ( Ordering :: Acquire )
620
622
}
621
623
622
624
fn reset_complete_count ( & mut self ) -> usize {
623
- STATE . complete_count [ self . index ( ) ] . swap ( 0 , Ordering :: AcqRel )
625
+ STATE . complete_count [ self . 0 . index ( ) ] . swap ( 0 , Ordering :: AcqRel )
624
626
}
625
627
}
626
628
@@ -707,13 +709,13 @@ impl<'a, C: Channel, W: Word> RingBuffer<'a, C, W> {
707
709
}
708
710
709
711
pub fn clear ( & mut self ) {
710
- self . ringbuf . clear ( & mut * self . channel ) ;
712
+ self . ringbuf . clear ( DmaCtrlImpl ( self . channel . reborrow ( ) ) ) ;
711
713
}
712
714
713
715
/// Read bytes from the ring buffer
714
716
/// OverrunError is returned if the portion to be read was overwritten by the DMA controller.
715
717
pub fn read ( & mut self , buf : & mut [ W ] ) -> Result < usize , OverrunError > {
716
- self . ringbuf . read ( & mut * self . channel , buf)
718
+ self . ringbuf . read ( DmaCtrlImpl ( self . channel . reborrow ( ) ) , buf)
717
719
}
718
720
719
721
pub fn is_empty ( & self ) -> bool {
0 commit comments