File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,21 @@ pub enum LowPowerMode {
100100 Enabled ,
101101}
102102
103+ /// A Token to represent a peripheral has been enabled
104+ pub struct Token < P > {
105+ ph : PhantomData < P > ,
106+ }
107+
108+ /// A trait to represent that a peripheral can be turned into a token
109+ pub trait RecTokenizer : ResetEnable + Sized {
110+ /// Turns the ResetEnable into a token
111+ fn tokenize ( self ) -> Token < Self > {
112+ self . enable ( ) . reset ( ) ;
113+
114+ Token { ph : PhantomData { } }
115+ }
116+ }
117+
103118impl Rcc {
104119 /// Returns all the peripherals resets / enables / kernel clocks.
105120 ///
@@ -459,6 +474,14 @@ macro_rules! variant_return_type {
459474 } ;
460475}
461476
477+ macro_rules! tokenable {
478+ ( $( $TK: ty) ,* ) => {
479+ $(
480+ impl RecTokenizer for $TK { }
481+ ) *
482+ } ;
483+ }
484+
462485// Enumerate all peripherals and optional clock multiplexers
463486//
464487// Peripherals are grouped by bus for convenience. Each bus is specified like:
@@ -646,3 +669,5 @@ peripheral_reset_and_enable_control! {
646669 I3c2 [ kernel clk: I3c2 ( Variant ) I3C ccipr4 "I3C2" ]
647670 ] ;
648671}
672+
673+ tokenable ! ( Fdcan ) ;
You can’t perform that action at this time.
0 commit comments