Skip to content

Commit b064ab0

Browse files
Merge #460
460: Rework `Interrupt` enum for MSP430 r=adamgreig a=therealprof This also removes the `bare-metal` dependency from PACs created for MSP430, as requested in #455 (comment) Signed-off-by: Daniel Egger <[email protected]> Co-authored-by: Daniel Egger <[email protected]>
2 parents fbf0750 + 1512a6f commit b064ab0

File tree

4 files changed

+46
-34
lines changed

4 files changed

+46
-34
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2828
use the `msp430_rt::interrupt` attribute macro and `device.x` for interrupt
2929
support. The `INTERRUPT` array has been renamed `__INTERRUPT`.
3030

31+
- Documented the nature of the `Interrupt` enum on MSP430 and consequently
32+
removed all use of `bare-metal` from that architecture
33+
3134
- Don't generate pre Edition 2018 `extern crate` statements anymore
3235

3336
## [v0.17.0] - 2019-12-31

ci/script.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,6 @@ main() {
493493

494494
# test other targets (architectures)
495495
OTHER)
496-
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
497-
echo 'version = "0.1.0"' >> $td/Cargo.toml
498-
499496
echo '[dependencies.msp430]' >> $td/Cargo.toml
500497
echo 'version = "0.2.2"' >> $td/Cargo.toml
501498

src/generate/interrupt.rs

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -160,41 +160,54 @@ pub fn render(
160160
(quote!(#[repr(u8)]), quote!(*#self_token as u8))
161161
};
162162

163-
let interrupt_enum = quote! {
164-
///Enumeration of all the interrupts
165-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
166-
#enum_repr
167-
pub enum Interrupt {
168-
#variants
169-
}
170-
171-
unsafe impl bare_metal::Nr for Interrupt {
172-
#[inline(always)]
173-
fn nr(&#self_token) -> u8 {
174-
#nr_expr
163+
if target == Target::Msp430 {
164+
let interrupt_enum = quote! {
165+
///Enumeration of all the interrupts. This enum is seldom used in application or library crates. It is present primarily for documenting the device's implemented interrupts.
166+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
167+
#enum_repr
168+
pub enum Interrupt {
169+
#variants
175170
}
176-
}
177-
};
171+
};
178172

179-
if target == Target::CortexM || target == Target::Msp430 {
180173
root.extend(interrupt_enum);
181174
} else {
182-
mod_items.extend(quote! {
183-
#interrupt_enum
184-
185-
#[derive(Debug, Copy, Clone)]
186-
pub struct TryFromInterruptError(());
187-
188-
impl Interrupt {
189-
#[inline]
190-
pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
191-
match value {
192-
#from_arms
193-
_ => Err(TryFromInterruptError(())),
194-
}
175+
let interrupt_enum = quote! {
176+
///Enumeration of all the interrupts
177+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
178+
#enum_repr
179+
pub enum Interrupt {
180+
#variants
181+
}
182+
183+
unsafe impl bare_metal::Nr for Interrupt {
184+
#[inline(always)]
185+
fn nr(&#self_token) -> u8 {
186+
#nr_expr
195187
}
196188
}
197-
});
189+
};
190+
191+
if target == Target::CortexM {
192+
root.extend(interrupt_enum);
193+
} else {
194+
mod_items.extend(quote! {
195+
#interrupt_enum
196+
197+
#[derive(Debug, Copy, Clone)]
198+
pub struct TryFromInterruptError(());
199+
200+
impl Interrupt {
201+
#[inline]
202+
pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
203+
match value {
204+
#from_arms
205+
_ => Err(TryFromInterruptError(())),
206+
}
207+
}
208+
}
209+
});
210+
}
198211
}
199212

200213
if target != Target::None {

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,12 @@
106106
//! ```
107107
//!
108108
//! The resulting crate must provide an opt-in "rt" feature and depend on these crates:
109-
//! `bare-metal` v0.2.x, `msp430` v0.2.x, `msp430-rt` v0.2.x and `vcell` v0.1.x. Furthermore
109+
//! `msp430` v0.2.x, `msp430-rt` v0.2.x and `vcell` v0.1.x. Furthermore
110110
//! the "device" feature of `msp430-rt` must be enabled when the "rt" feature is enabled. The
111111
//! `Cargo.toml` of the device crate will look like this:
112112
//!
113113
//! ``` toml
114114
//! [dependencies]
115-
//! bare-metal = "0.2.0"
116115
//! msp430 = "0.2.0"
117116
//! vcell = "0.1.0"
118117
//!

0 commit comments

Comments
 (0)