@@ -59,20 +59,14 @@ pub trait FieldSpec: Sized {
59
59
/// Trait implemented by readable registers to enable the `read` method.
60
60
///
61
61
/// Registers marked with `Writable` can be also be `modify`'ed.
62
- pub trait Readable : RegisterSpec {
63
- /// Result from a call to `read` and argument to `modify`.
64
- type Reader : From < R < Self > > + core:: ops:: Deref < Target = R < Self > > ;
65
- }
62
+ pub trait Readable : RegisterSpec { }
66
63
67
64
/// Trait implemented by writeable registers.
68
65
///
69
66
/// This enables the `write`, `write_with_zero` and `reset` methods.
70
67
///
71
68
/// Registers marked with `Readable` can be also be `modify`'ed.
72
69
pub trait Writable : RegisterSpec {
73
- /// Writer type argument to `write`, et al.
74
- type Writer : From < W < Self > > + core:: ops:: DerefMut < Target = W < Self > > ;
75
-
76
70
/// Specifies the register bits that are not changed if you pass `1` and are changed if you pass `0`
77
71
const ZERO_TO_MODIFY_FIELDS_BITMAP : Self :: Ux ;
78
72
@@ -130,11 +124,11 @@ impl<REG: Readable> Reg<REG> {
130
124
/// let flag = reader.field2().bit_is_set();
131
125
/// ```
132
126
#[ inline( always) ]
133
- pub fn read ( & self ) -> REG :: Reader {
134
- REG :: Reader :: from ( R {
127
+ pub fn read ( & self ) -> R < REG > {
128
+ R {
135
129
bits : self . register . get ( ) ,
136
130
_reg : marker:: PhantomData ,
137
- } )
131
+ }
138
132
}
139
133
}
140
134
@@ -173,14 +167,14 @@ impl<REG: Resettable + Writable> Reg<REG> {
173
167
#[ inline( always) ]
174
168
pub fn write < F > ( & self , f : F )
175
169
where
176
- F : FnOnce ( & mut REG :: Writer ) -> & mut W < REG > ,
170
+ F : FnOnce ( & mut W < REG > ) -> & mut W < REG > ,
177
171
{
178
172
self . register . set (
179
- f ( & mut REG :: Writer :: from ( W {
173
+ f ( & mut W {
180
174
bits : REG :: RESET_VALUE & !REG :: ONE_TO_MODIFY_FIELDS_BITMAP
181
175
| REG :: ZERO_TO_MODIFY_FIELDS_BITMAP ,
182
176
_reg : marker:: PhantomData ,
183
- } ) )
177
+ } )
184
178
. bits ,
185
179
) ;
186
180
}
@@ -197,13 +191,13 @@ impl<REG: Writable> Reg<REG> {
197
191
#[ inline( always) ]
198
192
pub unsafe fn write_with_zero < F > ( & self , f : F )
199
193
where
200
- F : FnOnce ( & mut REG :: Writer ) -> & mut W < REG > ,
194
+ F : FnOnce ( & mut W < REG > ) -> & mut W < REG > ,
201
195
{
202
196
self . register . set (
203
- f ( & mut REG :: Writer :: from ( W {
197
+ f ( & mut W {
204
198
bits : REG :: Ux :: default ( ) ,
205
199
_reg : marker:: PhantomData ,
206
- } ) )
200
+ } )
207
201
. bits ,
208
202
) ;
209
203
}
@@ -238,20 +232,20 @@ impl<REG: Readable + Writable> Reg<REG> {
238
232
#[ inline( always) ]
239
233
pub fn modify < F > ( & self , f : F )
240
234
where
241
- for < ' w > F : FnOnce ( & REG :: Reader , & ' w mut REG :: Writer ) -> & ' w mut W < REG > ,
235
+ for < ' w > F : FnOnce ( & R < REG > , & ' w mut W < REG > ) -> & ' w mut W < REG > ,
242
236
{
243
237
let bits = self . register . get ( ) ;
244
238
self . register . set (
245
239
f (
246
- & REG :: Reader :: from ( R {
240
+ & R {
247
241
bits,
248
242
_reg : marker:: PhantomData ,
249
- } ) ,
250
- & mut REG :: Writer :: from ( W {
243
+ } ,
244
+ & mut W {
251
245
bits : bits & !REG :: ONE_TO_MODIFY_FIELDS_BITMAP
252
246
| REG :: ZERO_TO_MODIFY_FIELDS_BITMAP ,
253
247
_reg : marker:: PhantomData ,
254
- } ) ,
248
+ } ,
255
249
)
256
250
. bits ,
257
251
) ;
@@ -414,7 +408,7 @@ where
414
408
REG : Writable + RegisterSpec ,
415
409
FI : FieldSpec ,
416
410
{
417
- pub ( crate ) w : & ' a mut REG :: Writer ,
411
+ pub ( crate ) w : & ' a mut W < REG > ,
418
412
_field : marker:: PhantomData < ( FI , Safety ) > ,
419
413
}
420
414
@@ -427,7 +421,7 @@ where
427
421
/// Creates a new instance of the writer
428
422
#[ allow( unused) ]
429
423
#[ inline( always) ]
430
- pub ( crate ) fn new ( w : & ' a mut REG :: Writer ) -> Self {
424
+ pub ( crate ) fn new ( w : & ' a mut W < REG > ) -> Self {
431
425
Self {
432
426
w,
433
427
_field : marker:: PhantomData ,
@@ -441,7 +435,7 @@ where
441
435
REG : Writable + RegisterSpec ,
442
436
bool : From < FI > ,
443
437
{
444
- pub ( crate ) w : & ' a mut REG :: Writer ,
438
+ pub ( crate ) w : & ' a mut W < REG > ,
445
439
_field : marker:: PhantomData < ( FI , M ) > ,
446
440
}
447
441
@@ -453,7 +447,7 @@ where
453
447
/// Creates a new instance of the writer
454
448
#[ allow( unused) ]
455
449
#[ inline( always) ]
456
- pub ( crate ) fn new ( w : & ' a mut REG :: Writer ) -> Self {
450
+ pub ( crate ) fn new ( w : & ' a mut W < REG > ) -> Self {
457
451
Self {
458
452
w,
459
453
_field : marker:: PhantomData ,
@@ -514,14 +508,14 @@ macro_rules! impl_bit_proxy {
514
508
{
515
509
/// Writes bit to the field
516
510
#[ inline( always) ]
517
- pub fn bit( self , value: bool ) -> & ' a mut REG :: Writer {
511
+ pub fn bit( self , value: bool ) -> & ' a mut W < REG > {
518
512
self . w. bits &= !( REG :: Ux :: one( ) << OF ) ;
519
513
self . w. bits |= ( REG :: Ux :: from( value) & REG :: Ux :: one( ) ) << OF ;
520
514
self . w
521
515
}
522
516
/// Writes `variant` to the field
523
517
#[ inline( always) ]
524
- pub fn variant( self , variant: FI ) -> & ' a mut REG :: Writer {
518
+ pub fn variant( self , variant: FI ) -> & ' a mut W < REG > {
525
519
self . bit( bool :: from( variant) )
526
520
}
527
521
}
@@ -548,14 +542,14 @@ where
548
542
///
549
543
/// Passing incorrect value can cause undefined behaviour. See reference manual
550
544
#[ inline( always) ]
551
- pub unsafe fn bits ( self , value : FI :: Ux ) -> & ' a mut REG :: Writer {
545
+ pub unsafe fn bits ( self , value : FI :: Ux ) -> & ' a mut W < REG > {
552
546
self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
553
547
self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
554
548
self . w
555
549
}
556
550
/// Writes `variant` to the field
557
551
#[ inline( always) ]
558
- pub fn variant ( self , variant : FI ) -> & ' a mut REG :: Writer {
552
+ pub fn variant ( self , variant : FI ) -> & ' a mut W < REG > {
559
553
unsafe { self . bits ( FI :: Ux :: from ( variant) ) }
560
554
}
561
555
}
@@ -567,14 +561,14 @@ where
567
561
{
568
562
/// Writes raw bits to the field
569
563
#[ inline( always) ]
570
- pub fn bits ( self , value : FI :: Ux ) -> & ' a mut REG :: Writer {
564
+ pub fn bits ( self , value : FI :: Ux ) -> & ' a mut W < REG > {
571
565
self . w . bits &= !( REG :: Ux :: mask :: < WI > ( ) << OF ) ;
572
566
self . w . bits |= ( REG :: Ux :: from ( value) & REG :: Ux :: mask :: < WI > ( ) ) << OF ;
573
567
self . w
574
568
}
575
569
/// Writes `variant` to the field
576
570
#[ inline( always) ]
577
- pub fn variant ( self , variant : FI ) -> & ' a mut REG :: Writer {
571
+ pub fn variant ( self , variant : FI ) -> & ' a mut W < REG > {
578
572
self . bits ( FI :: Ux :: from ( variant) )
579
573
}
580
574
}
@@ -594,13 +588,13 @@ where
594
588
{
595
589
/// Sets the field bit
596
590
#[ inline( always) ]
597
- pub fn set_bit ( self ) -> & ' a mut REG :: Writer {
591
+ pub fn set_bit ( self ) -> & ' a mut W < REG > {
598
592
self . w . bits |= REG :: Ux :: one ( ) << OF ;
599
593
self . w
600
594
}
601
595
/// Clears the field bit
602
596
#[ inline( always) ]
603
- pub fn clear_bit ( self ) -> & ' a mut REG :: Writer {
597
+ pub fn clear_bit ( self ) -> & ' a mut W < REG > {
604
598
self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
605
599
self . w
606
600
}
@@ -613,7 +607,7 @@ where
613
607
{
614
608
/// Sets the field bit
615
609
#[ inline( always) ]
616
- pub fn set_bit ( self ) -> & ' a mut REG :: Writer {
610
+ pub fn set_bit ( self ) -> & ' a mut W < REG > {
617
611
self . w . bits |= REG :: Ux :: one ( ) << OF ;
618
612
self . w
619
613
}
@@ -626,7 +620,7 @@ where
626
620
{
627
621
/// Clears the field bit
628
622
#[ inline( always) ]
629
- pub fn clear_bit ( self ) -> & ' a mut REG :: Writer {
623
+ pub fn clear_bit ( self ) -> & ' a mut W < REG > {
630
624
self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
631
625
self . w
632
626
}
@@ -639,7 +633,7 @@ where
639
633
{
640
634
///Clears the field bit by passing one
641
635
#[ inline( always) ]
642
- pub fn clear_bit_by_one ( self ) -> & ' a mut REG :: Writer {
636
+ pub fn clear_bit_by_one ( self ) -> & ' a mut W < REG > {
643
637
self . w . bits |= REG :: Ux :: one ( ) << OF ;
644
638
self . w
645
639
}
@@ -652,7 +646,7 @@ where
652
646
{
653
647
///Sets the field bit by passing zero
654
648
#[ inline( always) ]
655
- pub fn set_bit_by_zero ( self ) -> & ' a mut REG :: Writer {
649
+ pub fn set_bit_by_zero ( self ) -> & ' a mut W < REG > {
656
650
self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
657
651
self . w
658
652
}
@@ -665,7 +659,7 @@ where
665
659
{
666
660
///Toggle the field bit by passing one
667
661
#[ inline( always) ]
668
- pub fn toggle_bit ( self ) -> & ' a mut REG :: Writer {
662
+ pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
669
663
self . w . bits |= REG :: Ux :: one ( ) << OF ;
670
664
self . w
671
665
}
@@ -678,7 +672,7 @@ where
678
672
{
679
673
///Toggle the field bit by passing zero
680
674
#[ inline( always) ]
681
- pub fn toggle_bit ( self ) -> & ' a mut REG :: Writer {
675
+ pub fn toggle_bit ( self ) -> & ' a mut W < REG > {
682
676
self . w . bits &= !( REG :: Ux :: one ( ) << OF ) ;
683
677
self . w
684
678
}
0 commit comments