@@ -30,7 +30,7 @@ use crate::{
30
30
i2c,
31
31
pac:: {
32
32
self ,
33
- dma1:: ccr1 ,
33
+ dma1:: ch :: cr ,
34
34
I2C1 ,
35
35
I2C2 ,
36
36
I2C3 ,
@@ -222,37 +222,37 @@ impl<T, C, B> fmt::Debug for TransferResources<T, C, B> {
222
222
223
223
224
224
/// The priority of the DMA transfer
225
- pub struct Priority ( ccr1 :: PLW ) ;
225
+ pub struct Priority ( cr :: PL_A ) ;
226
226
227
227
impl Priority {
228
228
pub fn low ( ) -> Self {
229
- Self ( ccr1 :: PLW :: LOW )
229
+ Self ( cr :: PL_A :: LOW )
230
230
}
231
231
232
232
pub fn medium ( ) -> Self {
233
- Self ( ccr1 :: PLW :: MEDIUM )
233
+ Self ( cr :: PL_A :: MEDIUM )
234
234
}
235
235
236
236
pub fn high ( ) -> Self {
237
- Self ( ccr1 :: PLW :: HIGH )
237
+ Self ( cr :: PL_A :: HIGH )
238
238
}
239
239
240
240
pub fn very_high ( ) -> Self {
241
- Self ( ccr1 :: PLW :: VERYHIGH )
241
+ Self ( cr :: PL_A :: VERYHIGH )
242
242
}
243
243
}
244
244
245
245
246
246
/// The direction of the DMA transfer
247
- pub ( crate ) struct Direction ( ccr1 :: DIRW ) ;
247
+ pub ( crate ) struct Direction ( cr :: DIR_A ) ;
248
248
249
249
impl Direction {
250
250
pub fn memory_to_peripheral ( ) -> Self {
251
- Self ( ccr1 :: DIRW :: FROMMEMORY )
251
+ Self ( cr :: DIR_A :: FROMMEMORY )
252
252
}
253
253
254
254
pub fn peripheral_to_memory ( ) -> Self {
255
- Self ( ccr1 :: DIRW :: FROMPERIPHERAL )
255
+ Self ( cr :: DIR_A :: FROMPERIPHERAL )
256
256
}
257
257
}
258
258
@@ -268,8 +268,8 @@ pub trait Channel: Sized {
268
268
fn set_transfer_len ( & self , _: & mut Handle , len : u16 ) ;
269
269
fn configure < Word > ( & self ,
270
270
_: & mut Handle ,
271
- priority : ccr1 :: PLW ,
272
- dir : ccr1 :: DIRW ,
271
+ priority : cr :: PL_A ,
272
+ dir : cr :: DIR_A ,
273
273
)
274
274
where Word : SupportedWordSize ;
275
275
fn enable_interrupts ( & self , interrupts : Interrupts ) ;
@@ -284,11 +284,8 @@ macro_rules! impl_channel {
284
284
$(
285
285
$channel: ident,
286
286
$field: ident,
287
+ $chfield: ident,
287
288
$cxs: ident,
288
- $cpar: ident,
289
- $cmar: ident,
290
- $cndtr: ident,
291
- $ccr: ident,
292
289
$tcif: ident,
293
290
$teif: ident,
294
291
$ctcif: ident,
@@ -322,51 +319,51 @@ macro_rules! impl_channel {
322
319
handle: & mut Handle ,
323
320
address: u32 ,
324
321
) {
325
- handle. dma. $cpar . write( |w| w. pa( ) . bits( address) ) ;
322
+ handle. dma. $chfield . par . write( |w| w. pa( ) . bits( address) ) ;
326
323
}
327
324
328
325
fn set_memory_address( & self ,
329
326
handle: & mut Handle ,
330
327
address: u32 ,
331
328
) {
332
- handle. dma. $cmar . write( |w| w. ma( ) . bits( address) ) ;
329
+ handle. dma. $chfield . mar . write( |w| w. ma( ) . bits( address) ) ;
333
330
}
334
331
335
332
fn set_transfer_len( & self , handle: & mut Handle , len: u16 ) {
336
- handle. dma. $cndtr . write( |w| w. ndt( ) . bits( len) ) ;
333
+ handle. dma. $chfield . ndtr . write( |w| w. ndt( ) . bits( len) ) ;
337
334
}
338
335
339
336
fn configure<Word >( & self ,
340
337
handle: & mut Handle ,
341
- priority: ccr1 :: PLW ,
342
- dir: ccr1 :: DIRW ,
338
+ priority: cr :: PL_A ,
339
+ dir: cr :: DIR_A ,
343
340
)
344
341
where Word : SupportedWordSize
345
342
{
346
- handle. dma. $ccr . write( |w| {
343
+ handle. dma. $chfield . cr . write( |w| {
347
344
// Safe, as the enum we use should only provide valid
348
345
// bit patterns.
349
346
let w = unsafe {
350
347
w
351
348
// Word size in memory
352
- . msize( ) . bits ( Word :: size( ) . _bits ( ) )
349
+ . msize( ) . variant ( Word :: size( ) )
353
350
// Word size in peripheral
354
- . psize( ) . bits ( Word :: size( ) . _bits ( ) )
351
+ . psize( ) . variant ( Word :: size( ) )
355
352
} ;
356
353
357
354
w
358
355
// Memory-to-memory mode disabled
359
356
. mem2mem( ) . disabled( )
360
357
// Priority level
361
- . pl( ) . bits ( priority. _bits ( ) )
358
+ . pl( ) . variant ( priority)
362
359
// Increment memory pointer
363
360
. minc( ) . enabled( )
364
361
// Don't increment peripheral pointer
365
362
. pinc( ) . disabled( )
366
363
// Circular mode disabled
367
364
. circ( ) . disabled( )
368
365
// Data transfer direction
369
- . dir( ) . bit ( dir. _bits ( ) )
366
+ . dir( ) . variant ( dir)
370
367
// Disable interrupts
371
368
. teie( ) . disabled( )
372
369
. htie( ) . disabled( )
@@ -377,7 +374,7 @@ macro_rules! impl_channel {
377
374
fn enable_interrupts( & self , interrupts: Interrupts ) {
378
375
// Safe, because we're only accessing a register that this
379
376
// channel has exclusive access to.
380
- let ccr = & unsafe { & * pac:: DMA1 :: ptr( ) } . $ccr ;
377
+ let ccr = & unsafe { & * pac:: DMA1 :: ptr( ) } . $chfield . cr ;
381
378
382
379
ccr. modify( |_, w|
383
380
w
@@ -390,7 +387,7 @@ macro_rules! impl_channel {
390
387
fn start( & self ) {
391
388
// Safe, because we're only accessing a register that this
392
389
// channel has exclusive access to.
393
- let ccr = & unsafe { & * pac:: DMA1 :: ptr( ) } . $ccr ;
390
+ let ccr = & unsafe { & * pac:: DMA1 :: ptr( ) } . $chfield . cr ;
394
391
395
392
// Start transfer
396
393
ccr. modify( |_, w| w. en( ) . enabled( ) ) ;
@@ -419,7 +416,7 @@ macro_rules! impl_channel {
419
416
420
417
if dma. isr. read( ) . $tcif( ) . is_complete( ) {
421
418
dma. ifcr. write( |w| w. $ctcif( ) . set_bit( ) ) ;
422
- dma. $ccr . modify( |_, w| w. en( ) . disabled( ) ) ;
419
+ dma. $chfield . cr . modify( |_, w| w. en( ) . disabled( ) ) ;
423
420
}
424
421
}
425
422
@@ -444,27 +441,20 @@ macro_rules! impl_channel {
444
441
}
445
442
446
443
impl_channel ! (
447
- Channel1 , channel1,
448
- c1s, cpar1, cmar1, cndtr1, ccr1,
449
- tcif1, teif1, ctcif1, cteif1;
450
- Channel2 , channel2,
451
- c2s, cpar2, cmar2, cndtr2, ccr2,
452
- tcif2, teif2, ctcif2, cteif2;
453
- Channel3 , channel3,
454
- c3s, cpar3, cmar3, cndtr3, ccr3,
455
- tcif3, teif3, ctcif3, cteif3;
456
- Channel4 , channel4,
457
- c4s, cpar4, cmar4, cndtr4, ccr4,
458
- tcif4, teif4, ctcif4, cteif4;
459
- Channel5 , channel5,
460
- c5s, cpar5, cmar5, cndtr5, ccr5,
461
- tcif5, teif5, ctcif5, cteif5;
462
- Channel6 , channel6,
463
- c6s, cpar6, cmar6, cndtr6, ccr6,
464
- tcif6, teif6, ctcif6, cteif6;
465
- Channel7 , channel7,
466
- c7s, cpar7, cmar7, cndtr7, ccr7,
467
- tcif7, teif7, ctcif7, cteif7;
444
+ Channel1 , channel1, ch1,
445
+ c1s, tcif1, teif1, ctcif1, cteif1;
446
+ Channel2 , channel2, ch2,
447
+ c2s, tcif2, teif2, ctcif2, cteif2;
448
+ Channel3 , channel3, ch3,
449
+ c3s, tcif3, teif3, ctcif3, cteif3;
450
+ Channel4 , channel4, ch4,
451
+ c4s, tcif4, teif4, ctcif4, cteif4;
452
+ Channel5 , channel5, ch5,
453
+ c5s, tcif5, teif5, ctcif5, cteif5;
454
+ Channel6 , channel6, ch6,
455
+ c6s, tcif6, teif6, ctcif6, cteif6;
456
+ Channel7 , channel7, ch7,
457
+ c7s, tcif7, teif7, ctcif7, cteif7;
468
458
) ;
469
459
470
460
@@ -580,24 +570,24 @@ impl<Word> Buffer<Word> for PtrBuffer<Word> {
580
570
581
571
582
572
pub trait SupportedWordSize {
583
- fn size ( ) -> ccr1 :: MSIZEW ;
573
+ fn size ( ) -> cr :: MSIZE_A ;
584
574
}
585
575
586
576
impl SupportedWordSize for u8 {
587
- fn size ( ) -> ccr1 :: MSIZEW {
588
- ccr1 :: MSIZEW :: BITS8
577
+ fn size ( ) -> cr :: MSIZE_A {
578
+ cr :: MSIZE_A :: BITS8
589
579
}
590
580
}
591
581
592
582
impl SupportedWordSize for u16 {
593
- fn size ( ) -> ccr1 :: MSIZEW {
594
- ccr1 :: MSIZEW :: BITS16
583
+ fn size ( ) -> cr :: MSIZE_A {
584
+ cr :: MSIZE_A :: BITS16
595
585
}
596
586
}
597
587
598
588
impl SupportedWordSize for u32 {
599
- fn size ( ) -> ccr1 :: MSIZEW {
600
- ccr1 :: MSIZEW :: BITS32
589
+ fn size ( ) -> cr :: MSIZE_A {
590
+ cr :: MSIZE_A :: BITS32
601
591
}
602
592
}
603
593
0 commit comments