Skip to content

Commit 495c0ec

Browse files
committed
Xtensa updates
* Switch to bare-metal 1.0.0 * Use xtensa-lx `InterruptNumber` trait * Update CI script
1 parent ead1f51 commit 495c0ec

File tree

3 files changed

+65
-26
lines changed

3 files changed

+65
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- More Cluster arrays are now emitted as an array rather than a list of
1313
elements. An `ArrayProxy` wrapper is used when a Rust built-in array does not
1414
match the cluster layout. Requires the `--const_generic` command line option.
15+
- Bumped `xtensa-lx` and add `xtensa_lx::interrupt::InterruptNumber` implementation.
1516

1617
## [v0.19.0] - 2021-05-26
1718

ci/script.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,11 @@ main() {
590590
echo 'version = "1.0.0"' >> $td/Cargo.toml
591591

592592
echo '[dependencies.xtensa-lx]' >> $td/Cargo.toml
593-
echo 'version = "0.3.0"' >> $td/Cargo.toml
593+
echo 'version = "0.4.0"' >> $td/Cargo.toml
594594
echo 'features = ["lx6"]' >> $td/Cargo.toml
595595

596596
echo '[dependencies.xtensa-lx-rt]' >> $td/Cargo.toml
597-
echo 'version = "0.5.0"' >> $td/Cargo.toml
597+
echo 'version = "0.7.0"' >> $td/Cargo.toml
598598
echo 'features = ["lx6"]' >> $td/Cargo.toml
599599

600600
test_svd_for_target xtensa-lx https://raw.githubusercontent.com/esp-rs/esp32/master/svd/esp32.svd

src/generate/interrupt.rs

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -206,34 +206,68 @@ pub fn render(
206206
}
207207
};
208208

209-
if target == Target::CortexM {
210-
root.extend(quote! {
211-
#interrupt_enum
212-
213-
unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
214-
#[inline(always)]
215-
fn number(#self_token) -> u16 {
216-
#nr_expr
209+
match target {
210+
Target::CortexM => {
211+
root.extend(quote! {
212+
#interrupt_enum
213+
214+
unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
215+
#[inline(always)]
216+
fn number(#self_token) -> u16 {
217+
#nr_expr
218+
}
219+
}
220+
});
221+
}
222+
Target::XtensaLX => {
223+
root.extend(quote! {
224+
#interrupt_enum
225+
226+
unsafe impl xtensa_lx::interrupt::InterruptNumber for Interrupt {
227+
#[inline(always)]
228+
fn number(#self_token) -> u16 {
229+
#nr_expr
230+
}
217231
}
218-
}
219-
});
220-
} else {
221-
mod_items.extend(quote! {
222-
#interrupt_enum
223232

224-
#[derive(Debug, Copy, Clone)]
225-
pub struct TryFromInterruptError(());
233+
/// TryFromInterruptError
234+
#[derive(Debug, Copy, Clone)]
235+
pub struct TryFromInterruptError(());
226236

227-
impl Interrupt {
228-
#[inline]
229-
pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
230-
match value {
231-
#from_arms
232-
_ => Err(TryFromInterruptError(())),
237+
impl Interrupt {
238+
239+
/// Attempt to convert a given value into an `Interrupt`
240+
#[inline]
241+
pub fn try_from(value: u16) -> Result<Self, TryFromInterruptError> {
242+
match value {
243+
#from_arms
244+
_ => Err(TryFromInterruptError(())),
245+
}
233246
}
234247
}
235-
}
236-
});
248+
});
249+
}
250+
_ => {
251+
mod_items.extend(quote! {
252+
#interrupt_enum
253+
254+
/// TryFromInterruptError
255+
#[derive(Debug, Copy, Clone)]
256+
pub struct TryFromInterruptError(());
257+
258+
impl Interrupt {
259+
260+
/// Attempt to convert a given value into an `Interrupt`
261+
#[inline]
262+
pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
263+
match value {
264+
#from_arms
265+
_ => Err(TryFromInterruptError(())),
266+
}
267+
}
268+
}
269+
});
270+
}
237271
}
238272
}
239273

@@ -330,7 +364,11 @@ pub fn render(
330364
}
331365
}
332366

333-
if !interrupts.is_empty() && target != Target::CortexM && target != Target::Msp430 {
367+
if !interrupts.is_empty()
368+
&& target != Target::CortexM
369+
&& target != Target::XtensaLX
370+
&& target != Target::Msp430
371+
{
334372
root.extend(quote! {
335373
#[doc(hidden)]
336374
pub mod interrupt {

0 commit comments

Comments
 (0)