Skip to content

Commit 9c9546c

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

File tree

2 files changed

+61
-27
lines changed

2 files changed

+61
-27
lines changed

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: 59 additions & 25 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
223-
224-
#[derive(Debug, Copy, Clone)]
225-
pub struct TryFromInterruptError(());
226232

227-
impl Interrupt {
228-
#[inline]
229-
pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
230-
match value {
231-
#from_arms
232-
_ => Err(TryFromInterruptError(())),
233+
/// TryFromInterruptError
234+
#[derive(Debug, Copy, Clone)]
235+
pub struct TryFromInterruptError(());
236+
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,7 @@ pub fn render(
330364
}
331365
}
332366

333-
if !interrupts.is_empty() && target != Target::CortexM && target != Target::Msp430 {
367+
if !interrupts.is_empty() && target != Target::CortexM && target != Target::XtensaLX && target != Target::Msp430 {
334368
root.extend(quote! {
335369
#[doc(hidden)]
336370
pub mod interrupt {

0 commit comments

Comments
 (0)