@@ -252,17 +252,114 @@ impl<REG: Readable + Writable> Reg<REG> {
252
252
}
253
253
}
254
254
255
+ #[ doc( hidden) ]
256
+ pub mod raw {
257
+ use super :: { marker, BitM , FieldSpec , RegisterSpec , Unsafe , Writable } ;
258
+
259
+ pub struct R < REG : RegisterSpec > {
260
+ pub ( crate ) bits : REG :: Ux ,
261
+ pub ( super ) _reg : marker:: PhantomData < REG > ,
262
+ }
263
+
264
+ pub struct W < REG : RegisterSpec > {
265
+ ///Writable bits
266
+ pub ( crate ) bits : REG :: Ux ,
267
+ pub ( super ) _reg : marker:: PhantomData < REG > ,
268
+ }
269
+
270
+ pub struct FieldReader < FI = u8 >
271
+ where
272
+ FI : FieldSpec ,
273
+ {
274
+ pub ( crate ) bits : FI :: Ux ,
275
+ _reg : marker:: PhantomData < FI > ,
276
+ }
277
+
278
+ impl < FI : FieldSpec > FieldReader < FI > {
279
+ /// Creates a new instance of the reader.
280
+ #[ allow( unused) ]
281
+ #[ inline( always) ]
282
+ pub ( crate ) fn new ( bits : FI :: Ux ) -> Self {
283
+ Self {
284
+ bits,
285
+ _reg : marker:: PhantomData ,
286
+ }
287
+ }
288
+ }
289
+
290
+ pub struct BitReader < FI = bool > {
291
+ pub ( crate ) bits : bool ,
292
+ _reg : marker:: PhantomData < FI > ,
293
+ }
294
+
295
+ impl < FI > BitReader < FI > {
296
+ /// Creates a new instance of the reader.
297
+ #[ allow( unused) ]
298
+ #[ inline( always) ]
299
+ pub ( crate ) fn new ( bits : bool ) -> Self {
300
+ Self {
301
+ bits,
302
+ _reg : marker:: PhantomData ,
303
+ }
304
+ }
305
+ }
306
+
307
+ pub struct FieldWriter < ' a , REG , const WI : u8 , const O : u8 , FI = u8 , Safety = Unsafe >
308
+ where
309
+ REG : Writable + RegisterSpec ,
310
+ FI : FieldSpec ,
311
+ {
312
+ pub ( crate ) w : & ' a mut W < REG > ,
313
+ _field : marker:: PhantomData < ( FI , Safety ) > ,
314
+ }
315
+
316
+ impl < ' a , REG , const WI : u8 , const O : u8 , FI , Safety > FieldWriter < ' a , REG , WI , O , FI , Safety >
317
+ where
318
+ REG : Writable + RegisterSpec ,
319
+ FI : FieldSpec ,
320
+ {
321
+ /// Creates a new instance of the writer
322
+ #[ allow( unused) ]
323
+ #[ inline( always) ]
324
+ pub ( crate ) fn new ( w : & ' a mut W < REG > ) -> Self {
325
+ Self {
326
+ w,
327
+ _field : marker:: PhantomData ,
328
+ }
329
+ }
330
+ }
331
+
332
+ pub struct BitWriter < ' a , REG , const O : u8 , FI = bool , M = BitM >
333
+ where
334
+ REG : Writable + RegisterSpec ,
335
+ bool : From < FI > ,
336
+ {
337
+ pub ( crate ) w : & ' a mut W < REG > ,
338
+ _field : marker:: PhantomData < ( FI , M ) > ,
339
+ }
340
+
341
+ impl < ' a , REG , const O : u8 , FI , M > BitWriter < ' a , REG , O , FI , M >
342
+ where
343
+ REG : Writable + RegisterSpec ,
344
+ bool : From < FI > ,
345
+ {
346
+ /// Creates a new instance of the writer
347
+ #[ allow( unused) ]
348
+ #[ inline( always) ]
349
+ pub ( crate ) fn new ( w : & ' a mut W < REG > ) -> Self {
350
+ Self {
351
+ w,
352
+ _field : marker:: PhantomData ,
353
+ }
354
+ }
355
+ }
356
+ }
357
+
255
358
/// Register reader.
256
359
///
257
360
/// Result of the `read` methods of registers. Also used as a closure argument in the `modify`
258
361
/// method.
259
- pub type R < REG > = RRaw < REG > ;
260
-
261
- #[ doc( hidden) ]
262
- pub struct RRaw < REG : RegisterSpec > {
263
- pub ( crate ) bits : REG :: Ux ,
264
- _reg : marker:: PhantomData < REG > ,
265
- }
362
+ pub type R < REG > = raw:: R < REG > ;
266
363
267
364
impl < REG : RegisterSpec > R < REG > {
268
365
/// Reads raw bits from register.
@@ -287,61 +384,15 @@ where
287
384
/// Register writer.
288
385
///
289
386
/// Used as an argument to the closures in the `write` and `modify` methods of the register.
290
- pub type W < REG > = WRaw < REG > ;
291
-
292
- #[ doc( hidden) ]
293
- pub struct WRaw < REG : RegisterSpec > {
294
- ///Writable bits
295
- pub ( crate ) bits : REG :: Ux ,
296
- _reg : marker:: PhantomData < REG > ,
297
- }
298
-
299
- #[ doc( hidden) ]
300
- pub struct FieldReaderRaw < FI = u8 >
301
- where
302
- FI : FieldSpec
303
- {
304
- pub ( crate ) bits : FI :: Ux ,
305
- _reg : marker:: PhantomData < FI > ,
306
- }
307
-
308
- impl < FI : FieldSpec > FieldReaderRaw < FI > {
309
- /// Creates a new instance of the reader.
310
- #[ allow( unused) ]
311
- #[ inline( always) ]
312
- pub ( crate ) fn new ( bits : FI :: Ux ) -> Self {
313
- Self {
314
- bits,
315
- _reg : marker:: PhantomData ,
316
- }
317
- }
318
- }
319
-
320
- #[ doc( hidden) ]
321
- pub struct BitReaderRaw < FI = bool > {
322
- pub ( crate ) bits : bool ,
323
- _reg : marker:: PhantomData < FI > ,
324
- }
325
-
326
- impl < FI > BitReaderRaw < FI > {
327
- /// Creates a new instance of the reader.
328
- #[ allow( unused) ]
329
- #[ inline( always) ]
330
- pub ( crate ) fn new ( bits : bool ) -> Self {
331
- Self {
332
- bits,
333
- _reg : marker:: PhantomData ,
334
- }
335
- }
336
- }
387
+ pub type W < REG > = raw:: W < REG > ;
337
388
338
389
/// Field reader.
339
390
///
340
391
/// Result of the `read` methods of fields.
341
- pub type FieldReader < FI = u8 > = FieldReaderRaw < FI > ;
392
+ pub type FieldReader < FI = u8 > = raw :: FieldReader < FI > ;
342
393
343
394
/// Bit-wise field reader
344
- pub type BitReader < FI = bool > = BitReaderRaw < FI > ;
395
+ pub type BitReader < FI = bool > = raw :: BitReader < FI > ;
345
396
346
397
impl < FI : FieldSpec > FieldReader < FI > {
347
398
/// Reads raw bits from field.
@@ -395,65 +446,12 @@ pub struct Safe;
395
446
#[ doc( hidden) ]
396
447
pub struct Unsafe ;
397
448
398
- #[ doc( hidden) ]
399
- pub struct FieldWriterRaw < ' a , REG , const WI : u8 , const O : u8 , FI = u8 , Safety = Unsafe >
400
- where
401
- REG : Writable + RegisterSpec ,
402
- FI : FieldSpec ,
403
- {
404
- pub ( crate ) w : & ' a mut W < REG > ,
405
- _field : marker:: PhantomData < ( FI , Safety ) > ,
406
- }
407
-
408
- impl < ' a , REG , const WI : u8 , const O : u8 , FI , Safety >
409
- FieldWriterRaw < ' a , REG , WI , O , FI , Safety >
410
- where
411
- REG : Writable + RegisterSpec ,
412
- FI : FieldSpec ,
413
- {
414
- /// Creates a new instance of the writer
415
- #[ allow( unused) ]
416
- #[ inline( always) ]
417
- pub ( crate ) fn new ( w : & ' a mut W < REG > ) -> Self {
418
- Self {
419
- w,
420
- _field : marker:: PhantomData ,
421
- }
422
- }
423
- }
424
-
425
- #[ doc( hidden) ]
426
- pub struct BitWriterRaw < ' a , REG , const O : u8 , FI = bool , M = BitM >
427
- where
428
- REG : Writable + RegisterSpec ,
429
- bool : From < FI > ,
430
- {
431
- pub ( crate ) w : & ' a mut W < REG > ,
432
- _field : marker:: PhantomData < ( FI , M ) > ,
433
- }
434
-
435
- impl < ' a , REG , const O : u8 , FI , M > BitWriterRaw < ' a , REG , O , FI , M >
436
- where
437
- REG : Writable + RegisterSpec ,
438
- bool : From < FI > ,
439
- {
440
- /// Creates a new instance of the writer
441
- #[ allow( unused) ]
442
- #[ inline( always) ]
443
- pub ( crate ) fn new ( w : & ' a mut W < REG > ) -> Self {
444
- Self {
445
- w,
446
- _field : marker:: PhantomData ,
447
- }
448
- }
449
- }
450
-
451
449
/// Write field Proxy with unsafe `bits`
452
450
pub type FieldWriter < ' a , REG , const WI : u8 , const O : u8 , FI = u8 > =
453
- FieldWriterRaw < ' a , REG , WI , O , FI , Unsafe > ;
451
+ raw :: FieldWriter < ' a , REG , WI , O , FI , Unsafe > ;
454
452
/// Write field Proxy with safe `bits`
455
453
pub type FieldWriterSafe < ' a , REG , const WI : u8 , const O : u8 , FI = u8 > =
456
- FieldWriterRaw < ' a , REG , WI , O , FI , Safe > ;
454
+ raw :: FieldWriter < ' a , REG , WI , O , FI , Safe > ;
457
455
458
456
impl < ' a , REG , const WI : u8 , const OF : u8 , FI > FieldWriter < ' a , REG , WI , OF , FI >
459
457
where
@@ -479,7 +477,7 @@ macro_rules! bit_proxy {
479
477
pub struct $mwv;
480
478
481
479
/// Bit-wise write field proxy
482
- pub type $writer<' a, REG , const O : u8 , FI = bool > = BitWriterRaw <' a, REG , O , FI , $mwv>;
480
+ pub type $writer<' a, REG , const O : u8 , FI = bool > = raw :: BitWriter <' a, REG , O , FI , $mwv>;
483
481
484
482
impl <' a, REG , const OF : u8 , FI > $writer<' a, REG , OF , FI >
485
483
where
0 commit comments