@@ -249,12 +249,12 @@ pub struct DmaTransfer<'a, CH>
249249where
250250 CH : DmaChannel ,
251251{
252- channel : & ' a CH ,
252+ channel : & ' a mut CH ,
253253}
254254
255255impl < ' a , CH : DmaChannel > DmaTransfer < ' a , CH > {
256256 fn new < S , D , T > (
257- channel : & ' a CH ,
257+ channel : & ' a mut CH ,
258258 config : DmaConfig < T , S , D > ,
259259 src_ptr : * const S ,
260260 dest_ptr : * mut D ,
@@ -279,7 +279,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
279279 /// provided.
280280 pub fn memory_to_memory < S , D > (
281281 config : DmaConfig < MemoryToMemory , S :: Word , D :: Word > ,
282- channel : & ' a CH ,
282+ channel : & ' a mut CH ,
283283 source : S ,
284284 mut destination : D ,
285285 ) -> Self
@@ -321,7 +321,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
321321 /// peripheral provided.
322322 pub fn memory_to_peripheral < S , D > (
323323 config : DmaConfig < MemoryToPeripheral , S :: Word , D :: Word > ,
324- channel : & ' a CH ,
324+ channel : & ' a mut CH ,
325325 source : S ,
326326 mut destination : D ,
327327 ) -> Self
@@ -343,7 +343,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
343343 /// destination buffer provided.
344344 pub fn peripheral_to_memory < S , D > (
345345 config : DmaConfig < PeripheralToMemory , S :: Word , D :: Word > ,
346- channel : & ' a CH ,
346+ channel : & ' a mut CH ,
347347 source : S ,
348348 mut destination : D ,
349349 ) -> Self
@@ -367,7 +367,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
367367 /// provided.
368368 pub fn peripheral_to_peripheral < S , D , T > (
369369 config : DmaConfig < PeripheralToPeripheral < T > , S :: Word , D :: Word > ,
370- channel : & ' a CH ,
370+ channel : & ' a mut CH ,
371371 source : S ,
372372 mut destination : D ,
373373 ) -> Self
@@ -414,7 +414,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
414414}
415415
416416impl < ' a , CH : DmaChannel > DmaTransfer < ' a , CH > {
417- fn start_transfer_internal ( & self ) {
417+ fn start_transfer_internal ( & mut self ) {
418418 // Preserve the instruction and bus ordering of preceding buffer access
419419 // to the subsequent access by the DMA peripheral due to enabling it.
420420 fence ( Ordering :: SeqCst ) ;
@@ -424,13 +424,13 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
424424
425425 /// Start a transfer. Does not block waiting for the transfer to start and does not check for
426426 /// errors starting the transfer
427- pub fn start_nonblocking ( & self ) {
427+ pub fn start_nonblocking ( & mut self ) {
428428 self . start_transfer_internal ( ) ;
429429 }
430430
431431 /// Start a transfer and block waiting for it to start. Returns an error if one occurred
432432 /// starting the transfer.
433- pub fn start ( & self ) -> Result < ( ) , Error > {
433+ pub fn start ( & mut self ) -> Result < ( ) , Error > {
434434 self . start_nonblocking ( ) ;
435435 self . channel . wait_for_transfer_started ( )
436436 }
@@ -505,24 +505,18 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
505505
506506 /// Blocks waiting for the half transfer complete event. Returns an error if one occurred during
507507 /// the transfer.
508- pub fn wait_for_half_transfer_complete ( self ) -> Result < ( ) , Error > {
509- let result = self . channel . wait_for_half_transfer_complete ( ) ;
510- // Preserve the instruction and bus sequence of the preceding operation and
511- // the subsequent buffer access.
512- fence ( Ordering :: SeqCst ) ;
513-
514- core:: mem:: forget ( self ) ; // Prevents self from being dropped and attempting to abort
515- result
508+ pub fn wait_for_half_transfer_complete ( & mut self ) -> Result < ( ) , Error > {
509+ self . channel . wait_for_half_transfer_complete ( )
516510 }
517511
518512 /// Enable interrupts for this transfer. This will enable the transfer complete and half
519513 /// transfer complete interrupts, as well as error interrupts.
520- pub fn enable_interrupts ( & self ) {
514+ pub fn enable_interrupts ( & mut self ) {
521515 self . channel . enable_transfer_interrupts ( ) ;
522516 }
523517
524518 /// Disable interrupts for this transfer.
525- pub fn disable_interrupts ( & self ) {
519+ pub fn disable_interrupts ( & mut self ) {
526520 self . channel . disable_transfer_interrupts ( ) ;
527521 }
528522
0 commit comments