File tree 3 files changed +13
-19
lines changed
3 files changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
8
8
## [ Unreleased]
9
9
10
+ - removed register writer & reader wrappers, generic ` REG ` in field writers (#731 )
11
+
10
12
## [ v0.29.0] - 2023-06-05
11
13
12
14
- ` FieldFpec ` instead or ` fty ` generic (#722 )
Original file line number Diff line number Diff line change @@ -256,7 +256,10 @@ impl<REG: Readable + Writable> Reg<REG> {
256
256
///
257
257
/// Result of the `read` methods of registers. Also used as a closure argument in the `modify`
258
258
/// method.
259
- pub struct R < REG : RegisterSpec + ?Sized > {
259
+ pub type R < REG > = RRaw < REG > ;
260
+
261
+ #[ doc( hidden) ]
262
+ pub struct RRaw < REG : RegisterSpec > {
260
263
pub ( crate ) bits : REG :: Ux ,
261
264
_reg : marker:: PhantomData < REG > ,
262
265
}
@@ -284,25 +287,15 @@ where
284
287
/// Register writer.
285
288
///
286
289
/// Used as an argument to the closures in the `write` and `modify` methods of the register.
287
- pub struct W < REG : RegisterSpec + ?Sized > {
290
+ pub type W < REG > = WRaw < REG > ;
291
+
292
+ #[ doc( hidden) ]
293
+ pub struct WRaw < REG : RegisterSpec > {
288
294
///Writable bits
289
295
pub ( crate ) bits : REG :: Ux ,
290
296
_reg : marker:: PhantomData < REG > ,
291
297
}
292
298
293
- impl < REG : RegisterSpec > W < REG > {
294
- /// Writes raw bits to the register.
295
- ///
296
- /// # Safety
297
- ///
298
- /// Read datasheet or reference manual to find what values are allowed to pass.
299
- #[ inline( always) ]
300
- pub unsafe fn bits ( & mut self , bits : REG :: Ux ) -> & mut Self {
301
- self . bits = bits;
302
- self
303
- }
304
- }
305
-
306
299
#[ doc( hidden) ]
307
300
pub struct FieldReaderRaw < FI = u8 >
308
301
where
Original file line number Diff line number Diff line change @@ -273,7 +273,6 @@ pub fn render_register_mod(
273
273
274
274
mod_items. extend ( w_impl_items) ;
275
275
276
- /*
277
276
// the writer can be safe if:
278
277
// * there is a single field that covers the entire register
279
278
// * that field can represent all values
@@ -293,7 +292,7 @@ pub fn render_register_mod(
293
292
#[ doc = "Writes raw bits to the register." ]
294
293
#[ inline( always) ]
295
294
pub fn bits( & mut self , bits: #rty) -> & mut Self {
296
- unsafe { self.0. bits(bits) } ;
295
+ self . bits = bits ;
297
296
self
298
297
}
299
298
} ) ;
@@ -302,11 +301,11 @@ pub fn render_register_mod(
302
301
#[ doc = "Writes raw bits to the register." ]
303
302
#[ inline( always) ]
304
303
pub unsafe fn bits( & mut self , bits: #rty) -> & mut Self {
305
- self.0. bits( bits) ;
304
+ self . bits = bits;
306
305
self
307
306
}
308
307
} ) ;
309
- }*/
308
+ }
310
309
311
310
close. to_tokens ( & mut mod_items) ;
312
311
}
You can’t perform that action at this time.
0 commit comments