@@ -57,6 +57,7 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
57
57
}
58
58
Target :: Msp430 => {
59
59
items. push ( quote ! {
60
+ extern crate msp430;
60
61
#[ macro_reexport( default_handler) ]
61
62
#[ cfg( feature = "rt" ) ]
62
63
extern crate msp430_rt;
@@ -142,6 +143,24 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
142
143
exprs. push ( quote ! ( #id: #id { _marker: PhantomData } ) ) ;
143
144
}
144
145
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
+
145
164
items. push ( quote ! {
146
165
// NOTE `no_mangle` is used here to prevent linking different minor versions of the device
147
166
// 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<()
156
175
}
157
176
158
177
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
170
179
171
180
/// Unchecked version of `Peripherals::take`
172
181
pub unsafe fn steal( ) -> Self {
0 commit comments