@@ -249,12 +249,12 @@ pub struct DmaTransfer<'a, CH>
249
249
where
250
250
CH : DmaChannel ,
251
251
{
252
- channel : & ' a CH ,
252
+ channel : & ' a mut CH ,
253
253
}
254
254
255
255
impl < ' a , CH : DmaChannel > DmaTransfer < ' a , CH > {
256
256
fn new < S , D , T > (
257
- channel : & ' a CH ,
257
+ channel : & ' a mut CH ,
258
258
config : DmaConfig < T , S , D > ,
259
259
src_ptr : * const S ,
260
260
dest_ptr : * mut D ,
@@ -279,7 +279,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
279
279
/// provided.
280
280
pub fn memory_to_memory < S , D > (
281
281
config : DmaConfig < MemoryToMemory , S :: Word , D :: Word > ,
282
- channel : & ' a CH ,
282
+ channel : & ' a mut CH ,
283
283
source : S ,
284
284
mut destination : D ,
285
285
) -> Self
@@ -321,7 +321,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
321
321
/// peripheral provided.
322
322
pub fn memory_to_peripheral < S , D > (
323
323
config : DmaConfig < MemoryToPeripheral , S :: Word , D :: Word > ,
324
- channel : & ' a CH ,
324
+ channel : & ' a mut CH ,
325
325
source : S ,
326
326
mut destination : D ,
327
327
) -> Self
@@ -343,7 +343,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
343
343
/// destination buffer provided.
344
344
pub fn peripheral_to_memory < S , D > (
345
345
config : DmaConfig < PeripheralToMemory , S :: Word , D :: Word > ,
346
- channel : & ' a CH ,
346
+ channel : & ' a mut CH ,
347
347
source : S ,
348
348
mut destination : D ,
349
349
) -> Self
@@ -367,7 +367,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
367
367
/// provided.
368
368
pub fn peripheral_to_peripheral < S , D , T > (
369
369
config : DmaConfig < PeripheralToPeripheral < T > , S :: Word , D :: Word > ,
370
- channel : & ' a CH ,
370
+ channel : & ' a mut CH ,
371
371
source : S ,
372
372
mut destination : D ,
373
373
) -> Self
@@ -414,7 +414,7 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
414
414
}
415
415
416
416
impl < ' a , CH : DmaChannel > DmaTransfer < ' a , CH > {
417
- fn start_transfer_internal ( & self ) {
417
+ fn start_transfer_internal ( & mut self ) {
418
418
// Preserve the instruction and bus ordering of preceding buffer access
419
419
// to the subsequent access by the DMA peripheral due to enabling it.
420
420
fence ( Ordering :: SeqCst ) ;
@@ -424,13 +424,13 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
424
424
425
425
/// Start a transfer. Does not block waiting for the transfer to start and does not check for
426
426
/// errors starting the transfer
427
- pub fn start_nonblocking ( & self ) {
427
+ pub fn start_nonblocking ( & mut self ) {
428
428
self . start_transfer_internal ( ) ;
429
429
}
430
430
431
431
/// Start a transfer and block waiting for it to start. Returns an error if one occurred
432
432
/// starting the transfer.
433
- pub fn start ( & self ) -> Result < ( ) , Error > {
433
+ pub fn start ( & mut self ) -> Result < ( ) , Error > {
434
434
self . start_nonblocking ( ) ;
435
435
self . channel . wait_for_transfer_started ( )
436
436
}
@@ -505,24 +505,18 @@ impl<'a, CH: DmaChannel> DmaTransfer<'a, CH> {
505
505
506
506
/// Blocks waiting for the half transfer complete event. Returns an error if one occurred during
507
507
/// 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 ( )
516
510
}
517
511
518
512
/// Enable interrupts for this transfer. This will enable the transfer complete and half
519
513
/// transfer complete interrupts, as well as error interrupts.
520
- pub fn enable_interrupts ( & self ) {
514
+ pub fn enable_interrupts ( & mut self ) {
521
515
self . channel . enable_transfer_interrupts ( ) ;
522
516
}
523
517
524
518
/// Disable interrupts for this transfer.
525
- pub fn disable_interrupts ( & self ) {
519
+ pub fn disable_interrupts ( & mut self ) {
526
520
self . channel . disable_transfer_interrupts ( ) ;
527
521
}
528
522
0 commit comments