@@ -342,31 +342,30 @@ impl<FI> BitReaderRaw<FI> {
342
342
/// Field reader.
343
343
///
344
344
/// Result of the `read` methods of fields.
345
- pub type FieldReader < U = u8 , FI = u8 > = FieldReaderRaw < U , FI > ;
345
+ pub type FieldReader < N = u8 , FI = u8 > = FieldReaderRaw < N , FI > ;
346
346
347
347
/// Bit-wise field reader
348
348
pub type BitReader < FI = bool > = BitReaderRaw < FI > ;
349
349
350
- impl < U , FI > FieldReader < U , FI >
350
+ impl < N , FI > FieldReader < N , FI >
351
351
where
352
- U : Copy ,
352
+ N : Copy ,
353
353
{
354
354
/// Reads raw bits from field.
355
355
#[ inline( always) ]
356
- pub fn bits ( & self ) -> U {
356
+ pub fn bits ( & self ) -> N {
357
357
self . bits
358
358
}
359
359
}
360
360
361
- impl < U , FI > PartialEq < FI > for FieldReader < U , FI >
361
+ impl < N , FI > PartialEq < FI > for FieldReader < N , FI >
362
362
where
363
- U : PartialEq ,
364
363
FI : Copy ,
365
- U : From < FI > ,
364
+ N : PartialEq + From < FI > ,
366
365
{
367
366
#[ inline( always) ]
368
367
fn eq ( & self , other : & FI ) -> bool {
369
- self . bits . eq ( & U :: from ( * other) )
368
+ self . bits . eq ( & N :: from ( * other) )
370
369
}
371
370
}
372
371
@@ -405,19 +404,19 @@ pub struct Safe;
405
404
pub struct Unsafe ;
406
405
407
406
#[ doc( hidden) ]
408
- pub struct FieldWriterRaw < ' a , U , REG , const WI : u8 , const O : u8 , N , FI , Safety >
407
+ pub struct FieldWriterRaw < ' a , REG , const WI : u8 , const O : u8 , N , FI , Safety >
409
408
where
410
- REG : Writable + RegisterSpec < Ux = U > ,
409
+ REG : Writable + RegisterSpec ,
411
410
N : From < FI > ,
412
411
{
413
412
pub ( crate ) w : & ' a mut REG :: Writer ,
414
413
_field : marker:: PhantomData < ( N , FI , Safety ) > ,
415
414
}
416
415
417
- impl < ' a , U , REG , const WI : u8 , const O : u8 , N , FI , Safety >
418
- FieldWriterRaw < ' a , U , REG , WI , O , N , FI , Safety >
416
+ impl < ' a , REG , const WI : u8 , const O : u8 , N , FI , Safety >
417
+ FieldWriterRaw < ' a , REG , WI , O , N , FI , Safety >
419
418
where
420
- REG : Writable + RegisterSpec < Ux = U > ,
419
+ REG : Writable + RegisterSpec ,
421
420
N : From < FI > ,
422
421
{
423
422
/// Creates a new instance of the writer
@@ -432,18 +431,18 @@ where
432
431
}
433
432
434
433
#[ doc( hidden) ]
435
- pub struct BitWriterRaw < ' a , U , REG , const O : u8 , FI , M >
434
+ pub struct BitWriterRaw < ' a , REG , const O : u8 , FI , M >
436
435
where
437
- REG : Writable + RegisterSpec < Ux = U > ,
436
+ REG : Writable + RegisterSpec ,
438
437
bool : From < FI > ,
439
438
{
440
439
pub ( crate ) w : & ' a mut REG :: Writer ,
441
440
_field : marker:: PhantomData < ( FI , M ) > ,
442
441
}
443
442
444
- impl < ' a , U , REG , const O : u8 , FI , M > BitWriterRaw < ' a , U , REG , O , FI , M >
443
+ impl < ' a , REG , const O : u8 , FI , M > BitWriterRaw < ' a , REG , O , FI , M >
445
444
where
446
- REG : Writable + RegisterSpec < Ux = U > ,
445
+ REG : Writable + RegisterSpec ,
447
446
bool : From < FI > ,
448
447
{
449
448
/// Creates a new instance of the writer
@@ -458,24 +457,24 @@ where
458
457
}
459
458
460
459
/// Write field Proxy with unsafe `bits`
461
- pub type FieldWriter < ' a , U , REG , const WI : u8 , const O : u8 , N = u8 , FI = u8 > =
462
- FieldWriterRaw < ' a , U , REG , WI , O , N , FI , Unsafe > ;
460
+ pub type FieldWriter < ' a , REG , const WI : u8 , const O : u8 , N = u8 , FI = u8 > =
461
+ FieldWriterRaw < ' a , REG , WI , O , N , FI , Unsafe > ;
463
462
/// Write field Proxy with safe `bits`
464
- pub type FieldWriterSafe < ' a , U , REG , const WI : u8 , const O : u8 , N = u8 , FI = u8 > =
465
- FieldWriterRaw < ' a , U , REG , WI , O , N , FI , Safe > ;
463
+ pub type FieldWriterSafe < ' a , REG , const WI : u8 , const O : u8 , N = u8 , FI = u8 > =
464
+ FieldWriterRaw < ' a , REG , WI , O , N , FI , Safe > ;
466
465
467
- impl < ' a , U , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriter < ' a , U , REG , WI , OF , N , FI >
466
+ impl < ' a , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriter < ' a , REG , WI , OF , N , FI >
468
467
where
469
- REG : Writable + RegisterSpec < Ux = U > ,
468
+ REG : Writable + RegisterSpec ,
470
469
N : From < FI > ,
471
470
{
472
471
/// Field width
473
472
pub const WIDTH : u8 = WI ;
474
473
}
475
474
476
- impl < ' a , U , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriterSafe < ' a , U , REG , WI , OF , N , FI >
475
+ impl < ' a , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriterSafe < ' a , REG , WI , OF , N , FI >
477
476
where
478
- REG : Writable + RegisterSpec < Ux = U > ,
477
+ REG : Writable + RegisterSpec ,
479
478
N : From < FI > ,
480
479
{
481
480
/// Field width
@@ -488,11 +487,11 @@ macro_rules! bit_proxy {
488
487
pub struct $mwv;
489
488
490
489
/// Bit-wise write field proxy
491
- pub type $writer<' a, U , REG , const O : u8 , FI = bool > = BitWriterRaw <' a, U , REG , O , FI , $mwv>;
490
+ pub type $writer<' a, REG , const O : u8 , FI = bool > = BitWriterRaw <' a, REG , O , FI , $mwv>;
492
491
493
- impl <' a, U , REG , const OF : u8 , FI > $writer<' a, U , REG , OF , FI >
492
+ impl <' a, REG , const OF : u8 , FI > $writer<' a, REG , OF , FI >
494
493
where
495
- REG : Writable + RegisterSpec < Ux = U > ,
494
+ REG : Writable + RegisterSpec ,
496
495
bool : From <FI >,
497
496
{
498
497
/// Field width
@@ -503,17 +502,16 @@ macro_rules! bit_proxy {
503
502
504
503
macro_rules! impl_bit_proxy {
505
504
( $writer: ident) => {
506
- impl <' a, U , REG , const OF : u8 , FI > $writer<' a, U , REG , OF , FI >
505
+ impl <' a, REG , const OF : u8 , FI > $writer<' a, REG , OF , FI >
507
506
where
508
- REG : Writable + RegisterSpec <Ux = U >,
509
- U : RawReg ,
507
+ REG : Writable + RegisterSpec ,
510
508
bool : From <FI >,
511
509
{
512
510
/// Writes bit to the field
513
511
#[ inline( always) ]
514
512
pub fn bit( self , value: bool ) -> & ' a mut REG :: Writer {
515
- self . w. bits &= !( U :: one( ) << OF ) ;
516
- self . w. bits |= ( U :: from( value) & U :: one( ) ) << OF ;
513
+ self . w. bits &= !( REG :: Ux :: one( ) << OF ) ;
514
+ self . w. bits |= ( REG :: Ux :: from( value) & REG :: Ux :: one( ) ) << OF ;
517
515
self . w
518
516
}
519
517
/// Writes `variant` to the field
@@ -533,10 +531,10 @@ bit_proxy!(BitWriter0S, Bit0S);
533
531
bit_proxy ! ( BitWriter1T , Bit1T ) ;
534
532
bit_proxy ! ( BitWriter0T , Bit0T ) ;
535
533
536
- impl < ' a , U , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriter < ' a , U , REG , WI , OF , N , FI >
534
+ impl < ' a , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriter < ' a , REG , WI , OF , N , FI >
537
535
where
538
- REG : Writable + RegisterSpec < Ux = U > ,
539
- U : RawReg + From < N > ,
536
+ REG : Writable + RegisterSpec ,
537
+ REG :: Ux : From < N > ,
540
538
N : From < FI > ,
541
539
{
542
540
/// Writes raw bits to the field
@@ -546,8 +544,8 @@ where
546
544
/// Passing incorrect value can cause undefined behaviour. See reference manual
547
545
#[ inline( always) ]
548
546
pub unsafe fn bits ( self , value : N ) -> & ' a mut REG :: Writer {
549
- self . w . bits &= !( U :: mask :: < WI > ( ) << OF ) ;
550
- self . w . bits |= ( U :: from ( value) & U :: mask :: < WI > ( ) ) << OF ;
547
+ self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
548
+ self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
551
549
self . w
552
550
}
553
551
/// Writes `variant` to the field
@@ -556,17 +554,17 @@ where
556
554
unsafe { self . bits ( N :: from ( variant) ) }
557
555
}
558
556
}
559
- impl < ' a , U , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriterSafe < ' a , U , REG , WI , OF , N , FI >
557
+ impl < ' a , REG , const WI : u8 , const OF : u8 , N , FI > FieldWriterSafe < ' a , REG , WI , OF , N , FI >
560
558
where
561
- REG : Writable + RegisterSpec < Ux = U > ,
562
- U : RawReg + From < N > ,
559
+ REG : Writable + RegisterSpec ,
560
+ REG :: Ux : From < N > ,
563
561
N : From < FI > ,
564
562
{
565
563
/// Writes raw bits to the field
566
564
#[ inline( always) ]
567
565
pub fn bits ( self , value : N ) -> & ' a mut REG :: Writer {
568
- self . w . bits &= !( U :: mask :: < WI > ( ) << OF ) ;
569
- self . w . bits |= ( U :: from ( value) & U :: mask :: < WI > ( ) ) << OF ;
566
+ self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
567
+ self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
570
568
self . w
571
569
}
572
570
/// Writes `variant` to the field
@@ -584,106 +582,99 @@ impl_bit_proxy!(BitWriter0S);
584
582
impl_bit_proxy ! ( BitWriter1T ) ;
585
583
impl_bit_proxy ! ( BitWriter0T ) ;
586
584
587
- impl < ' a , U , REG , const OF : u8 , FI > BitWriter < ' a , U , REG , OF , FI >
585
+ impl < ' a , REG , const OF : u8 , FI > BitWriter < ' a , REG , OF , FI >
588
586
where
589
- REG : Writable + RegisterSpec < Ux = U > ,
590
- U : RawReg ,
587
+ REG : Writable + RegisterSpec ,
591
588
bool : From < FI > ,
592
589
{
593
590
/// Sets the field bit
594
591
#[ inline( always) ]
595
592
pub fn set_bit ( self ) -> & ' a mut REG :: Writer {
596
- self . w . bits |= U :: one ( ) << OF ;
593
+ self . w . bits |= REG :: Ux :: one ( ) << OF ;
597
594
self . w
598
595
}
599
596
/// Clears the field bit
600
597
#[ inline( always) ]
601
598
pub fn clear_bit ( self ) -> & ' a mut REG :: Writer {
602
- self . w . bits &= !( U :: one ( ) << OF ) ;
599
+ self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
603
600
self . w
604
601
}
605
602
}
606
603
607
- impl < ' a , U , REG , const OF : u8 , FI > BitWriter1S < ' a , U , REG , OF , FI >
604
+ impl < ' a , REG , const OF : u8 , FI > BitWriter1S < ' a , REG , OF , FI >
608
605
where
609
- REG : Writable + RegisterSpec < Ux = U > ,
610
- U : RawReg ,
606
+ REG : Writable + RegisterSpec ,
611
607
bool : From < FI > ,
612
608
{
613
609
/// Sets the field bit
614
610
#[ inline( always) ]
615
611
pub fn set_bit ( self ) -> & ' a mut REG :: Writer {
616
- self . w . bits |= U :: one ( ) << OF ;
612
+ self . w . bits |= REG :: Ux :: one ( ) << OF ;
617
613
self . w
618
614
}
619
615
}
620
616
621
- impl < ' a , U , REG , const OF : u8 , FI > BitWriter0C < ' a , U , REG , OF , FI >
617
+ impl < ' a , REG , const OF : u8 , FI > BitWriter0C < ' a , REG , OF , FI >
622
618
where
623
- REG : Writable + RegisterSpec < Ux = U > ,
624
- U : RawReg ,
619
+ REG : Writable + RegisterSpec ,
625
620
bool : From < FI > ,
626
621
{
627
622
/// Clears the field bit
628
623
#[ inline( always) ]
629
624
pub fn clear_bit ( self ) -> & ' a mut REG :: Writer {
630
- self . w . bits &= !( U :: one ( ) << OF ) ;
625
+ self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
631
626
self . w
632
627
}
633
628
}
634
629
635
- impl < ' a , U , REG , const OF : u8 , FI > BitWriter1C < ' a , U , REG , OF , FI >
630
+ impl < ' a , REG , const OF : u8 , FI > BitWriter1C < ' a , REG , OF , FI >
636
631
where
637
- REG : Writable + RegisterSpec < Ux = U > ,
638
- U : RawReg ,
632
+ REG : Writable + RegisterSpec ,
639
633
bool : From < FI > ,
640
634
{
641
635
///Clears the field bit by passing one
642
636
#[ inline( always) ]
643
637
pub fn clear_bit_by_one ( self ) -> & ' a mut REG :: Writer {
644
- self . w . bits |= U :: one ( ) << OF ;
638
+ self . w . bits |= REG :: Ux :: one ( ) << OF ;
645
639
self . w
646
640
}
647
641
}
648
642
649
- impl < ' a , U , REG , const OF : u8 , FI > BitWriter0S < ' a , U , REG , OF , FI >
643
+ impl < ' a , REG , const OF : u8 , FI > BitWriter0S < ' a , REG , OF , FI >
650
644
where
651
- REG : Writable + RegisterSpec < Ux = U > ,
652
- U : RawReg ,
645
+ REG : Writable + RegisterSpec ,
653
646
bool : From < FI > ,
654
647
{
655
648
///Sets the field bit by passing zero
656
649
#[ inline( always) ]
657
650
pub fn set_bit_by_zero ( self ) -> & ' a mut REG :: Writer {
658
- self . w . bits &= !( U :: one ( ) << OF ) ;
651
+ self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
659
652
self . w
660
653
}
661
654
}
662
655
663
- impl < ' a , U , REG , const OF : u8 , FI > BitWriter1T < ' a , U , REG , OF , FI >
656
+ impl < ' a , REG , const OF : u8 , FI > BitWriter1T < ' a , REG , OF , FI >
664
657
where
665
- REG : Writable + RegisterSpec < Ux = U > ,
666
- U : RawReg ,
658
+ REG : Writable + RegisterSpec ,
667
659
bool : From < FI > ,
668
660
{
669
661
///Toggle the field bit by passing one
670
662
#[ inline( always) ]
671
663
pub fn toggle_bit ( self ) -> & ' a mut REG :: Writer {
672
- self . w . bits |= U :: one ( ) << OF ;
664
+ self . w . bits |= REG :: Ux :: one ( ) << OF ;
673
665
self . w
674
666
}
675
667
}
676
668
677
- impl < ' a , U , REG , const OF : u8 , FI > BitWriter0T < ' a , U , REG , OF , FI >
669
+ impl < ' a , REG , const OF : u8 , FI > BitWriter0T < ' a , REG , OF , FI >
678
670
where
679
- REG : Writable + RegisterSpec < Ux = U > ,
680
- U : RawReg ,
671
+ REG : Writable + RegisterSpec ,
681
672
bool : From < FI > ,
682
673
{
683
674
///Toggle the field bit by passing zero
684
675
#[ inline( always) ]
685
676
pub fn toggle_bit ( self ) -> & ' a mut REG :: Writer {
686
- self . w . bits &= !( U :: one ( ) << OF ) ;
677
+ self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
687
678
self . w
688
679
}
689
680
}
0 commit comments