@@ -182,7 +182,7 @@ impl<I: Instance> StreamsTuple<I> {
182
182
// the stream
183
183
macro_rules! dma_stream {
184
184
( $( ( $name: ident, $number: expr,
185
- regs => $ccr : ident , $cparX : ident , $cmarX : ident , $cndtrX : ident,
185
+ regs => $chX : ident,
186
186
fields => $tcif: ident, $htif: ident, $teif: ident, $gif: ident, $tcisr: ident, $htisr: ident, $teisr: ident, $gisr: ident,
187
187
dmamux => $dma1_cXcr: ident, $dma2_cXcr: ident, )
188
188
) ,+$( , ) * ) => {
@@ -266,28 +266,28 @@ macro_rules! dma_stream {
266
266
#[ inline( always) ]
267
267
unsafe fn enable( & mut self ) {
268
268
//NOTE(unsafe) We only access the registers that belongs to the StreamX
269
- let dma = & * I :: ptr( ) ;
270
- dma . $ccr . modify( |_, w| w. en( ) . set_bit( ) ) ;
269
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
270
+ dma_ch . cr . modify( |_, w| w. en( ) . set_bit( ) ) ;
271
271
}
272
272
273
273
#[ inline( always) ]
274
274
fn is_enabled( ) -> bool {
275
275
//NOTE(unsafe) Atomic read with no side effects
276
- let dma = unsafe { & * I :: ptr( ) } ;
277
- dma . $ccr . read( ) . en( ) . bit_is_set( )
276
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
277
+ dma_ch . cr . read( ) . en( ) . bit_is_set( )
278
278
}
279
279
280
280
fn disable( & mut self ) {
281
281
if Self :: is_enabled( ) {
282
282
//NOTE(unsafe) We only access the registers that belongs to the StreamX
283
- let dma = unsafe { & * I :: ptr( ) } ;
283
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
284
284
285
285
// Aborting an on-going transfer might cause interrupts to fire, disable
286
286
// them
287
287
let interrupts = Self :: get_interrupts_enable( ) ;
288
288
self . disable_interrupts( ) ;
289
289
290
- dma . $ccr . modify( |_, w| w. en( ) . clear_bit( ) ) ;
290
+ dma_ch . cr . modify( |_, w| w. en( ) . clear_bit( ) ) ;
291
291
while Self :: is_enabled( ) { }
292
292
293
293
self . clear_interrupts( ) ;
@@ -313,14 +313,14 @@ macro_rules! dma_stream {
313
313
#[ inline( always) ]
314
314
fn set_priority( & mut self , priority: config:: Priority ) {
315
315
//NOTE(unsafe) We only access the registers that belongs to the StreamX
316
- let dma = unsafe { & * I :: ptr( ) } ;
317
- dma . $ccr . modify( |_, w| unsafe { w. pl( ) . bits( priority. bits( ) ) } ) ;
316
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
317
+ dma_ch . cr . modify( |_, w| unsafe { w. pl( ) . bits( priority. bits( ) ) } ) ;
318
318
}
319
319
320
320
#[ inline( always) ]
321
321
fn disable_interrupts( & mut self ) {
322
322
//NOTE(unsafe) We only access the registers that belongs to the StreamX
323
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
323
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
324
324
dmacr. modify( |_, w| w
325
325
. tcie( ) . clear_bit( )
326
326
. teie( ) . clear_bit( )
@@ -332,8 +332,8 @@ macro_rules! dma_stream {
332
332
#[ inline( always) ]
333
333
fn enable_interrupts( & mut self , interrupt: Self :: Interrupts ) {
334
334
//NOTE(unsafe) We only access the registers that belongs to the StreamX
335
- let dma = unsafe { & * I :: ptr( ) } ;
336
- dma . $ccr . modify( |_, w| w
335
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
336
+ dma_ch . cr . modify( |_, w| w
337
337
. tcie( ) . bit( interrupt. transfer_complete)
338
338
. teie( ) . bit( interrupt. transfer_error)
339
339
. htie( ) . bit( interrupt. half_transfer)
@@ -343,8 +343,8 @@ macro_rules! dma_stream {
343
343
#[ inline( always) ]
344
344
fn get_interrupts_enable( ) -> Self :: Interrupts {
345
345
//NOTE(unsafe) We only access the registers that belongs to the StreamX
346
- let dma = unsafe { & * I :: ptr( ) } ;
347
- let cr = dma . $ccr . read( ) ;
346
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
347
+ let cr = dma_ch . cr . read( ) ;
348
348
349
349
DmaInterrupts {
350
350
transfer_complete: cr. tcie( ) . bit_is_set( ) ,
@@ -357,7 +357,7 @@ macro_rules! dma_stream {
357
357
#[ inline( always) ]
358
358
fn set_transfer_complete_interrupt_enable( & mut self , transfer_complete_interrupt: bool ) {
359
359
//NOTE(unsafe) We only access the registers that belongs to the StreamX
360
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
360
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
361
361
dmacr. modify( |_, w| w. tcie( ) . bit( transfer_complete_interrupt) ) ;
362
362
let _ = dmacr. read( ) ;
363
363
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -366,7 +366,7 @@ macro_rules! dma_stream {
366
366
#[ inline( always) ]
367
367
fn set_transfer_error_interrupt_enable( & mut self , transfer_error_interrupt: bool ) {
368
368
//NOTE(unsafe) We only access the registers that belongs to the StreamX
369
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
369
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
370
370
dmacr. modify( |_, w| w. teie( ) . bit( transfer_error_interrupt) ) ;
371
371
let _ = dmacr. read( ) ;
372
372
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -375,7 +375,7 @@ macro_rules! dma_stream {
375
375
#[ inline( always) ]
376
376
fn set_half_transfer_interrupt_enable( & mut self , half_transfer_interrupt: bool ) {
377
377
//NOTE(unsafe) We only access the registers that belongs to the StreamX
378
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
378
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
379
379
dmacr. modify( |_, w| w. htie( ) . bit( half_transfer_interrupt) ) ;
380
380
let _ = dmacr. read( ) ;
381
381
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -401,70 +401,70 @@ macro_rules! dma_stream {
401
401
#[ inline( always) ]
402
402
unsafe fn set_peripheral_address( & mut self , value: u32 ) {
403
403
//NOTE(unsafe) We only access the registers that belongs to the StreamX
404
- let dma = & * I :: ptr( ) ;
405
- dma . $cparX . write( |w| w. pa( ) . bits( value) ) ;
404
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
405
+ dma_ch . par . write( |w| w. pa( ) . bits( value) ) ;
406
406
}
407
407
408
408
#[ inline( always) ]
409
409
unsafe fn set_memory_address( & mut self , value: u32 ) {
410
410
//NOTE(unsafe) We only access the registers that belongs to the StreamX
411
- let dma = & * I :: ptr( ) ;
412
- dma . $cmarX . write( |w| w. ma( ) . bits( value) ) ;
411
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
412
+ dma_ch . mar . write( |w| w. ma( ) . bits( value) ) ;
413
413
}
414
414
415
415
#[ inline( always) ]
416
416
fn get_memory_address( & self ) -> u32 {
417
417
//NOTE(unsafe) We only access the registers that belongs to the StreamX
418
- let dma = unsafe { & * I :: ptr( ) } ;
419
- dma . $cmarX . read( ) . ma( ) . bits( )
418
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
419
+ dma_ch . mar . read( ) . ma( ) . bits( )
420
420
}
421
421
422
422
#[ inline( always) ]
423
423
fn set_number_of_transfers( & mut self , value: u16 ) {
424
424
//NOTE(unsafe) We only access the registers that belongs to the StreamX
425
- let dma = unsafe { & * I :: ptr( ) } ;
426
- dma . $cndtrX . write( |w| unsafe { w. ndt( ) . bits( value) } ) ;
425
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
426
+ dma_ch . ndtr . write( |w| unsafe { w. ndt( ) . bits( value) } ) ;
427
427
}
428
428
429
429
#[ inline( always) ]
430
430
fn get_number_of_transfers( ) -> u16 {
431
431
//NOTE(unsafe) We only access the registers that belongs to the StreamX
432
- let dma = unsafe { & * I :: ptr( ) } ;
433
- dma . $cndtrX . read( ) . ndt( ) . bits( )
432
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
433
+ dma_ch . ndtr . read( ) . ndt( ) . bits( )
434
434
}
435
435
#[ inline( always) ]
436
436
unsafe fn set_memory_size( & mut self , size: u8 ) {
437
437
//NOTE(unsafe) We only access the registers that belongs to the StreamX
438
- let dma = & * I :: ptr( ) ;
439
- dma . $ccr . modify( |_, w| w. msize( ) . bits( size) ) ;
438
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
439
+ dma_ch . cr . modify( |_, w| w. msize( ) . bits( size) ) ;
440
440
}
441
441
442
442
#[ inline( always) ]
443
443
unsafe fn set_peripheral_size( & mut self , size: u8 ) {
444
444
//NOTE(unsafe) We only access the registers that belongs to the StreamX
445
- let dma = & * I :: ptr( ) ;
446
- dma . $ccr . modify( |_, w| w. psize( ) . bits( size) ) ;
445
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
446
+ dma_ch . cr . modify( |_, w| w. psize( ) . bits( size) ) ;
447
447
}
448
448
449
449
#[ inline( always) ]
450
450
fn set_memory_increment( & mut self , increment: bool ) {
451
451
//NOTE(unsafe) We only access the registers that belongs to the StreamX
452
- let dma = unsafe { & * I :: ptr( ) } ;
453
- dma . $ccr . modify( |_, w| w. minc( ) . bit( increment) ) ;
452
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
453
+ dma_ch . cr . modify( |_, w| w. minc( ) . bit( increment) ) ;
454
454
}
455
455
456
456
#[ inline( always) ]
457
457
fn set_peripheral_increment( & mut self , increment: bool ) {
458
458
//NOTE(unsafe) We only access the registers that belongs to the StreamX
459
- let dma = unsafe { & * I :: ptr( ) } ;
460
- dma . $ccr . modify( |_, w| w. pinc( ) . bit( increment) ) ;
459
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
460
+ dma_ch . cr . modify( |_, w| w. pinc( ) . bit( increment) ) ;
461
461
}
462
462
463
463
#[ inline( always) ]
464
464
fn set_direction( & mut self , direction: DmaDirection ) {
465
465
//NOTE(unsafe) We only access the registers that belongs to the StreamX
466
- let dma = unsafe { & * I :: ptr( ) } ;
467
- dma . $ccr . modify( |_, w| {
466
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
467
+ dma_ch . cr . modify( |_, w| {
468
468
match direction {
469
469
DmaDirection :: PeripheralToMemory =>
470
470
w. dir( ) . clear_bit( ) . mem2mem( ) . clear_bit( ) ,
@@ -479,8 +479,8 @@ macro_rules! dma_stream {
479
479
#[ inline( always) ]
480
480
fn set_circular_buffer( & mut self , circular_buffer: bool ) {
481
481
//NOTE(unsafe) We only access the registers that belongs to the StreamX
482
- let dma = unsafe { & * I :: ptr( ) } ;
483
- dma . $ccr . modify( |_, w| w. circ( ) . bit( circular_buffer) ) ;
482
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
483
+ dma_ch . cr . modify( |_, w| w. circ( ) . bit( circular_buffer) ) ;
484
484
}
485
485
}
486
486
@@ -505,7 +505,7 @@ macro_rules! dma_stream {
505
505
#[ inline( always) ]
506
506
pub fn set_half_transfer_interrupt_enable( & mut self , half_transfer_interrupt: bool ) {
507
507
//NOTE(unsafe) We only access the registers that belongs to the StreamX
508
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
508
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
509
509
dmacr. modify( |_, w| w. htie( ) . bit( half_transfer_interrupt) ) ;
510
510
let _ = dmacr. read( ) ;
511
511
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -530,49 +530,49 @@ dma_stream!(
530
530
// zero. May need updating if it gets fixed upstream.
531
531
(
532
532
Stream0 , 0 ,
533
- regs => ccr1 , cpar1 , cmar1 , cndtr1 ,
533
+ regs => ch1 ,
534
534
fields => tcif1, htif1, teif1, gif1, tcif1, htif1, teif1, gif1,
535
535
dmamux => c0cr, c8cr,
536
536
) ,
537
537
(
538
538
Stream1 , 1 ,
539
- regs => ccr2 , cpar2 , cmar2 , cndtr2 ,
539
+ regs => ch2 ,
540
540
fields => tcif2, htif2, teif2, gif2, tcif2, htif2, teif2, gif2,
541
541
dmamux => c1cr, c9cr,
542
542
) ,
543
543
(
544
544
Stream2 , 2 ,
545
- regs => ccr3 , cpar3 , cmar3 , cndtr3 ,
545
+ regs => ch3 ,
546
546
fields => tcif3, htif3, teif3, gif3, tcif3, htif3, teif3, gif3,
547
547
dmamux => c2cr, c10cr,
548
548
) ,
549
549
(
550
550
Stream3 , 3 ,
551
- regs => ccr4 , cpar4 , cmar4 , cndtr4 ,
551
+ regs => ch4 ,
552
552
fields => tcif4, htif4, teif4, gif4, tcif4, htif4, teif4, gif4,
553
553
dmamux => c3cr, c11cr,
554
554
) ,
555
555
(
556
556
Stream4 , 4 ,
557
- regs => ccr5 , cpar5 , cmar5 , cndtr5 ,
557
+ regs => ch5 ,
558
558
fields => tcif5, htif5, teif5, gif5, tcif5, htif5, teif5, gif5,
559
559
dmamux => c4cr, c12cr,
560
560
) ,
561
561
(
562
562
Stream5 , 5 ,
563
- regs => ccr6 , cpar6 , cmar6 , cndtr6 ,
563
+ regs => ch6 ,
564
564
fields => tcif6, htif6, teif6, gif6, tcif6, htif6, teif6, gif6,
565
565
dmamux => c5cr, c13cr,
566
566
) ,
567
567
(
568
568
Stream6 , 6 ,
569
- regs => ccr7 , cpar7 , cmar7 , cndtr7 ,
569
+ regs => ch7 ,
570
570
fields => tcif7, htif7, teif7, gif7, tcif7, htif7, teif7, gif7,
571
571
dmamux => c6cr, c14cr,
572
572
) ,
573
573
(
574
574
Stream7 , 7 ,
575
- regs => ccr8 , cpar8 , cmar8 , cndtr8 ,
575
+ regs => ch8 ,
576
576
fields => tcif8, htif8, teif8, gif8, tcif8, htif8, teif8, gif8,
577
577
dmamux => c7cr, c15cr,
578
578
) ,
0 commit comments