@@ -57,6 +57,7 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
5757 }
5858 Target :: Msp430 => {
5959 items. push ( quote ! {
60+ extern crate msp430;
6061 #[ macro_reexport( default_handler) ]
6162 #[ cfg( feature = "rt" ) ]
6263 extern crate msp430_rt;
@@ -142,6 +143,24 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
142143 exprs. push ( quote ! ( #id: #id { _marker: PhantomData } ) ) ;
143144 }
144145
146+ let take = match * target {
147+ Target :: CortexM => Some ( Ident :: new ( "cortex_m" ) ) ,
148+ Target :: Msp430 => Some ( Ident :: new ( "msp430" ) ) ,
149+ Target :: None => None ,
150+ } . map ( |krate| quote ! {
151+ /// Returns all the peripherals *once*
152+ #[ inline]
153+ pub fn take( ) -> Option <Self > {
154+ #krate:: interrupt:: free( |_| {
155+ if unsafe { DEVICE_PERIPHERALS } {
156+ None
157+ } else {
158+ Some ( unsafe { Peripherals :: steal( ) } )
159+ }
160+ } )
161+ }
162+ } ) ;
163+
145164 items. push ( quote ! {
146165 // NOTE `no_mangle` is used here to prevent linking different minor versions of the device
147166 // crate as that would let you `take` the device peripherals more than once (one per minor
@@ -156,17 +175,7 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
156175 }
157176
158177 impl Peripherals {
159- /// Returns all the peripherals *once*
160- #[ inline( always) ]
161- pub fn take( ) -> Option <Self > {
162- cortex_m:: interrupt:: free( |_| {
163- if unsafe { DEVICE_PERIPHERALS } {
164- None
165- } else {
166- Some ( unsafe { Peripherals :: steal( ) } )
167- }
168- } )
169- }
178+ #take
170179
171180 /// Unchecked version of `Peripherals::take`
172181 pub unsafe fn steal( ) -> Self {
0 commit comments