11use core:: marker;
22
3- /// Generic peripheral accessor
4- pub struct Periph < PER : PeripheralSpec > {
5- _marker : marker:: PhantomData < PER > ,
6- }
7-
8- /// Peripheral data
9- pub trait PeripheralSpec {
10- /// RegisterBlock associated with peripheral
11- type RB ;
12- /// Address of the register block
13- const ADDRESS : usize ;
14- /// Debug name
15- const NAME : & ' static str ;
16- }
17-
183unsafe impl < PER : PeripheralSpec > Send for Periph < PER > { }
194
205impl < PER : PeripheralSpec > core:: fmt:: Debug for Periph < PER > {
@@ -32,34 +17,6 @@ impl<PER: PeripheralSpec> Periph<PER> {
3217 pub const fn ptr ( ) -> * const PER :: RB {
3318 Self :: PTR
3419 }
35-
36- /// Steal an instance of this peripheral
37- ///
38- /// # Safety
39- ///
40- /// Ensure that the new instance of the peripheral cannot be used in a way
41- /// that may race with any existing instances, for example by only
42- /// accessing read-only or write-only registers, or by consuming the
43- /// original peripheral and using critical sections to coordinate
44- /// access between multiple new instances.
45- ///
46- /// Additionally, other software such as HALs may rely on only one
47- /// peripheral instance existing to ensure memory safety; ensure
48- /// no stolen instances are passed to such software.
49- pub unsafe fn steal ( ) -> Self {
50- Self {
51- _marker : marker:: PhantomData ,
52- }
53- }
54- }
55-
56- impl < PER : PeripheralSpec > core:: ops:: Deref for Periph < PER > {
57- type Target = PER :: RB ;
58-
59- #[ inline( always) ]
60- fn deref ( & self ) -> & Self :: Target {
61- unsafe { & * Self :: PTR }
62- }
6320}
6421
6522/// Raw register type (`u8`, `u16`, `u32`, ...)
0 commit comments