@@ -176,7 +176,7 @@ impl<I: Instance> StreamsTuple<I> {
176
176
// the stream
177
177
macro_rules! dma_stream {
178
178
( $( ( $name: ident, $number: expr,
179
- regs => $ccr : ident , $cparX : ident , $cmarX : ident , $cndtrX : ident,
179
+ regs => $chX : ident,
180
180
fields => $tcif: ident, $htif: ident, $teif: ident, $gif: ident, $tcisr: ident, $htisr: ident, $teisr: ident, $gisr: ident,
181
181
dmamux => $cXcr: ident, )
182
182
) ,+$( , ) * ) => {
@@ -253,28 +253,28 @@ macro_rules! dma_stream {
253
253
#[ inline( always) ]
254
254
unsafe fn enable( & mut self ) {
255
255
//NOTE(unsafe) We only access the registers that belongs to the StreamX
256
- let dma = & * I :: ptr( ) ;
257
- dma . $ccr . modify( |_, w| w. en( ) . set_bit( ) ) ;
256
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
257
+ dma_ch . cr . modify( |_, w| w. en( ) . set_bit( ) ) ;
258
258
}
259
259
260
260
#[ inline( always) ]
261
261
fn is_enabled( ) -> bool {
262
262
//NOTE(unsafe) Atomic read with no side effects
263
- let dma = unsafe { & * I :: ptr( ) } ;
264
- dma . $ccr . read( ) . en( ) . bit_is_set( )
263
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
264
+ dma_ch . cr . read( ) . en( ) . bit_is_set( )
265
265
}
266
266
267
267
fn disable( & mut self ) {
268
268
if Self :: is_enabled( ) {
269
269
//NOTE(unsafe) We only access the registers that belongs to the StreamX
270
- let dma = unsafe { & * I :: ptr( ) } ;
270
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
271
271
272
272
// Aborting an on-going transfer might cause interrupts to fire, disable
273
273
// them
274
274
let interrupts = Self :: get_interrupts_enable( ) ;
275
275
self . disable_interrupts( ) ;
276
276
277
- dma . $ccr . modify( |_, w| w. en( ) . clear_bit( ) ) ;
277
+ dma_ch . cr . modify( |_, w| w. en( ) . clear_bit( ) ) ;
278
278
while Self :: is_enabled( ) { }
279
279
280
280
self . clear_interrupts( ) ;
@@ -295,14 +295,14 @@ macro_rules! dma_stream {
295
295
#[ inline( always) ]
296
296
fn set_priority( & mut self , priority: config:: Priority ) {
297
297
//NOTE(unsafe) We only access the registers that belongs to the StreamX
298
- let dma = unsafe { & * I :: ptr( ) } ;
299
- dma . $ccr . modify( |_, w| unsafe { w. pl( ) . bits( priority. bits( ) ) } ) ;
298
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
299
+ dma_ch . cr . modify( |_, w| unsafe { w. pl( ) . bits( priority. bits( ) ) } ) ;
300
300
}
301
301
302
302
#[ inline( always) ]
303
303
fn disable_interrupts( & mut self ) {
304
304
//NOTE(unsafe) We only access the registers that belongs to the StreamX
305
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
305
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
306
306
dmacr. modify( |_, w| w
307
307
. tcie( ) . clear_bit( )
308
308
. teie( ) . clear_bit( )
@@ -314,8 +314,8 @@ macro_rules! dma_stream {
314
314
#[ inline( always) ]
315
315
fn enable_interrupts( & mut self , interrupt: Self :: Interrupts ) {
316
316
//NOTE(unsafe) We only access the registers that belongs to the StreamX
317
- let dma = unsafe { & * I :: ptr( ) } ;
318
- dma . $ccr . modify( |_, w| w
317
+ let dma_ch = & unsafe { & * I :: ptr( ) } . $chX ( ) ;
318
+ dma_ch . cr . modify( |_, w| w
319
319
. tcie( ) . bit( interrupt. transfer_complete)
320
320
. teie( ) . bit( interrupt. transfer_error)
321
321
. htie( ) . bit( interrupt. half_transfer)
@@ -325,8 +325,8 @@ macro_rules! dma_stream {
325
325
#[ inline( always) ]
326
326
fn get_interrupts_enable( ) -> Self :: Interrupts {
327
327
//NOTE(unsafe) We only access the registers that belongs to the StreamX
328
- let dma = unsafe { & * I :: ptr( ) } ;
329
- let cr = dma . $ccr . read( ) ;
328
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
329
+ let cr = dma_ch . cr . read( ) ;
330
330
331
331
DmaInterrupts {
332
332
transfer_complete: cr. tcie( ) . bit_is_set( ) ,
@@ -339,7 +339,7 @@ macro_rules! dma_stream {
339
339
#[ inline( always) ]
340
340
fn set_transfer_complete_interrupt_enable( & mut self , transfer_complete_interrupt: bool ) {
341
341
//NOTE(unsafe) We only access the registers that belongs to the StreamX
342
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
342
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
343
343
dmacr. modify( |_, w| w. tcie( ) . bit( transfer_complete_interrupt) ) ;
344
344
let _ = dmacr. read( ) ;
345
345
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -348,7 +348,7 @@ macro_rules! dma_stream {
348
348
#[ inline( always) ]
349
349
fn set_transfer_error_interrupt_enable( & mut self , transfer_error_interrupt: bool ) {
350
350
//NOTE(unsafe) We only access the registers that belongs to the StreamX
351
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
351
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
352
352
dmacr. modify( |_, w| w. teie( ) . bit( transfer_error_interrupt) ) ;
353
353
let _ = dmacr. read( ) ;
354
354
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -357,7 +357,7 @@ macro_rules! dma_stream {
357
357
#[ inline( always) ]
358
358
fn set_half_transfer_interrupt_enable( & mut self , half_transfer_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. htie( ) . bit( half_transfer_interrupt) ) ;
362
362
let _ = dmacr. read( ) ;
363
363
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -383,70 +383,70 @@ macro_rules! dma_stream {
383
383
#[ inline( always) ]
384
384
unsafe fn set_peripheral_address( & mut self , value: u32 ) {
385
385
//NOTE(unsafe) We only access the registers that belongs to the StreamX
386
- let dma = & * I :: ptr( ) ;
387
- dma . $cparX . write( |w| w. pa( ) . bits( value) ) ;
386
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
387
+ dma_ch . par . write( |w| w. pa( ) . bits( value) ) ;
388
388
}
389
389
390
390
#[ inline( always) ]
391
391
unsafe fn set_memory_address( & mut self , value: u32 ) {
392
392
//NOTE(unsafe) We only access the registers that belongs to the StreamX
393
- let dma = & * I :: ptr( ) ;
394
- dma . $cmarX . write( |w| w. ma( ) . bits( value) ) ;
393
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
394
+ dma_ch . mar . write( |w| w. ma( ) . bits( value) ) ;
395
395
}
396
396
397
397
#[ inline( always) ]
398
398
fn get_memory_address( & self ) -> u32 {
399
399
//NOTE(unsafe) We only access the registers that belongs to the StreamX
400
- let dma = unsafe { & * I :: ptr( ) } ;
401
- dma . $cmarX . read( ) . ma( ) . bits( )
400
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
401
+ dma_ch . mar . read( ) . ma( ) . bits( )
402
402
}
403
403
404
404
#[ inline( always) ]
405
405
fn set_number_of_transfers( & mut self , value: u16 ) {
406
406
//NOTE(unsafe) We only access the registers that belongs to the StreamX
407
- let dma = unsafe { & * I :: ptr( ) } ;
408
- dma . $cndtrX . write( |w| unsafe { w. ndt( ) . bits( value) } ) ;
407
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
408
+ dma_ch . ndtr . write( |w| unsafe { w. ndt( ) . bits( value) } ) ;
409
409
}
410
410
411
411
#[ inline( always) ]
412
412
fn get_number_of_transfers( ) -> u16 {
413
413
//NOTE(unsafe) We only access the registers that belongs to the StreamX
414
- let dma = unsafe { & * I :: ptr( ) } ;
415
- dma . $cndtrX . read( ) . ndt( ) . bits( )
414
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
415
+ dma_ch . ndtr . read( ) . ndt( ) . bits( )
416
416
}
417
417
#[ inline( always) ]
418
418
unsafe fn set_memory_size( & mut self , size: u8 ) {
419
419
//NOTE(unsafe) We only access the registers that belongs to the StreamX
420
- let dma = & * I :: ptr( ) ;
421
- dma . $ccr . modify( |_, w| w. msize( ) . bits( size) ) ;
420
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
421
+ dma_ch . cr . modify( |_, w| w. msize( ) . bits( size) ) ;
422
422
}
423
423
424
424
#[ inline( always) ]
425
425
unsafe fn set_peripheral_size( & mut self , size: u8 ) {
426
426
//NOTE(unsafe) We only access the registers that belongs to the StreamX
427
- let dma = & * I :: ptr( ) ;
428
- dma . $ccr . modify( |_, w| w. psize( ) . bits( size) ) ;
427
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
428
+ dma_ch . cr . modify( |_, w| w. psize( ) . bits( size) ) ;
429
429
}
430
430
431
431
#[ inline( always) ]
432
432
fn set_memory_increment( & mut self , increment: bool ) {
433
433
//NOTE(unsafe) We only access the registers that belongs to the StreamX
434
- let dma = unsafe { & * I :: ptr( ) } ;
435
- dma . $ccr . modify( |_, w| w. minc( ) . bit( increment) ) ;
434
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
435
+ dma_ch . cr . modify( |_, w| w. minc( ) . bit( increment) ) ;
436
436
}
437
437
438
438
#[ inline( always) ]
439
439
fn set_peripheral_increment( & mut self , increment: bool ) {
440
440
//NOTE(unsafe) We only access the registers that belongs to the StreamX
441
- let dma = unsafe { & * I :: ptr( ) } ;
442
- dma . $ccr . modify( |_, w| w. pinc( ) . bit( increment) ) ;
441
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
442
+ dma_ch . cr . modify( |_, w| w. pinc( ) . bit( increment) ) ;
443
443
}
444
444
445
445
#[ inline( always) ]
446
446
fn set_direction( & mut self , direction: DmaDirection ) {
447
447
//NOTE(unsafe) We only access the registers that belongs to the StreamX
448
- let dma = unsafe { & * I :: ptr( ) } ;
449
- dma . $ccr . modify( |_, w| {
448
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
449
+ dma_ch . cr . modify( |_, w| {
450
450
match direction {
451
451
DmaDirection :: PeripheralToMemory =>
452
452
w. dir( ) . clear_bit( ) . mem2mem( ) . clear_bit( ) ,
@@ -461,8 +461,8 @@ macro_rules! dma_stream {
461
461
#[ inline( always) ]
462
462
fn set_circular_buffer( & mut self , circular_buffer: bool ) {
463
463
//NOTE(unsafe) We only access the registers that belongs to the StreamX
464
- let dma = unsafe { & * I :: ptr( ) } ;
465
- dma . $ccr . modify( |_, w| w. circ( ) . bit( circular_buffer) ) ;
464
+ let dma_ch = unsafe { & * I :: ptr( ) } . $chX ( ) ;
465
+ dma_ch . cr . modify( |_, w| w. circ( ) . bit( circular_buffer) ) ;
466
466
}
467
467
}
468
468
@@ -487,7 +487,7 @@ macro_rules! dma_stream {
487
487
#[ inline( always) ]
488
488
pub fn set_half_transfer_interrupt_enable( & mut self , half_transfer_interrupt: bool ) {
489
489
//NOTE(unsafe) We only access the registers that belongs to the StreamX
490
- let dmacr = & unsafe { & * I :: ptr( ) } . $ccr ;
490
+ let dmacr = & unsafe { & * I :: ptr( ) } . $chX ( ) . cr ;
491
491
dmacr. modify( |_, w| w. htie( ) . bit( half_transfer_interrupt) ) ;
492
492
let _ = dmacr. read( ) ;
493
493
let _ = dmacr. read( ) ; // Delay 2 peripheral clocks
@@ -502,49 +502,49 @@ dma_stream!(
502
502
// zero. May need updating if it gets fixed upstream.
503
503
(
504
504
Stream0 , 0 ,
505
- regs => ccr1 , cpar1 , cmar1 , cndtr1 ,
505
+ regs => ch1 ,
506
506
fields => tcif1, htif1, teif1, gif1, tcif1, htif1, teif1, gif1,
507
507
dmamux => c0cr,
508
508
) ,
509
509
(
510
510
Stream1 , 1 ,
511
- regs => ccr2 , cpar2 , cmar2 , cndtr2 ,
511
+ regs => ch2 ,
512
512
fields => tcif2, htif2, teif2, gif2, tcif2, htif2, teif2, gif2,
513
513
dmamux => c1cr,
514
514
) ,
515
515
(
516
516
Stream2 , 2 ,
517
- regs => ccr3 , cpar3 , cmar3 , cndtr3 ,
517
+ regs => ch3 ,
518
518
fields => tcif3, htif3, teif3, gif3, tcif3, htif3, teif3, gif3,
519
519
dmamux => c2cr,
520
520
) ,
521
521
(
522
522
Stream3 , 3 ,
523
- regs => ccr4 , cpar4 , cmar4 , cndtr4 ,
523
+ regs => ch4 ,
524
524
fields => tcif4, htif4, teif4, gif4, tcif4, htif4, teif4, gif4,
525
525
dmamux => c3cr,
526
526
) ,
527
527
(
528
528
Stream4 , 4 ,
529
- regs => ccr5 , cpar5 , cmar5 , cndtr5 ,
529
+ regs => ch5 ,
530
530
fields => tcif5, htif5, teif5, gif5, tcif5, htif5, teif5, gif5,
531
531
dmamux => c4cr,
532
532
) ,
533
533
(
534
534
Stream5 , 5 ,
535
- regs => ccr6 , cpar6 , cmar6 , cndtr6 ,
535
+ regs => ch6 ,
536
536
fields => tcif6, htif6, teif6, gif6, tcif6, htif6, teif6, gif6,
537
537
dmamux => c5cr,
538
538
) ,
539
539
(
540
540
Stream6 , 6 ,
541
- regs => ccr7 , cpar7 , cmar7 , cndtr7 ,
541
+ regs => ch7 ,
542
542
fields => tcif7, htif7, teif7, gif7, tcif7, htif7, teif7, gif7,
543
543
dmamux => c6cr,
544
544
) ,
545
545
(
546
546
Stream7 , 7 ,
547
- regs => ccr8 , cpar8 , cmar8 , cndtr8 ,
547
+ regs => ch8 ,
548
548
fields => tcif8, htif8, teif8, gif8, tcif8, htif8, teif8, gif8,
549
549
dmamux => c7cr,
550
550
) ,
0 commit comments