Skip to content

Xtensa updates #536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ status = [
"ci-linux (stable, Spansion, x86_64-unknown-linux-gnu, linux)",
"ci-linux (stable, STMicro, x86_64-unknown-linux-gnu, linux)",
"ci-linux (stable, Toshiba, x86_64-unknown-linux-gnu, linux)",
"ci-linux (1.40.0, Nordic, x86_64-unknown-linux-gnu, linux)",
"ci-linux (1.46.0, Nordic, x86_64-unknown-linux-gnu, linux)",
"ci-linux (stable, x86_64-apple-darwin, osx)",
"ci-linux (stable, x86_64-pc-windows-msvc, windows)",
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

include:
# Test MSRV
- rust: 1.40.0
- rust: 1.46.0
VENDOR: Nordic
TARGET: x86_64-unknown-linux-gnu
TRAVIS_OS_NAME: linux
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- More Cluster arrays are now emitted as an array rather than a list of
elements. An `ArrayProxy` wrapper is used when a Rust built-in array does not
match the cluster layout. Requires the `--const_generic` command line option.
- Bumped `xtensa-lx` and add `xtensa_lx::interrupt::InterruptNumber` implementation.

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

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ This project is developed and maintained by the [Tools team][team].

## Minimum Supported Rust Version (MSRV)

The **generated code** is guaranteed to compile on stable Rust 1.40.0 and up.
The **generated code** is guaranteed to compile on stable Rust 1.46.0 and up.

If you encounter compilation errors on any stable version newer than 1.40.0, please open an issue.
If you encounter compilation errors on any stable version newer than 1.46.0, please open an issue.

# Testing Locally

Expand Down
4 changes: 2 additions & 2 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,11 @@ main() {
echo 'version = "1.0.0"' >> $td/Cargo.toml

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

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

test_svd_for_target xtensa-lx https://raw.githubusercontent.com/esp-rs/esp32/master/svd/esp32.svd
Expand Down
86 changes: 62 additions & 24 deletions src/generate/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,34 +206,68 @@ pub fn render(
}
};

if target == Target::CortexM {
root.extend(quote! {
#interrupt_enum

unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
#[inline(always)]
fn number(#self_token) -> u16 {
#nr_expr
match target {
Target::CortexM => {
root.extend(quote! {
#interrupt_enum

unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
#[inline(always)]
fn number(#self_token) -> u16 {
#nr_expr
}
}
});
}
Target::XtensaLX => {
root.extend(quote! {
#interrupt_enum

unsafe impl xtensa_lx::interrupt::InterruptNumber for Interrupt {
#[inline(always)]
fn number(#self_token) -> u16 {
#nr_expr
}
}
}
});
} else {
mod_items.extend(quote! {
#interrupt_enum

#[derive(Debug, Copy, Clone)]
pub struct TryFromInterruptError(());
/// TryFromInterruptError
#[derive(Debug, Copy, Clone)]
pub struct TryFromInterruptError(());

impl Interrupt {
#[inline]
pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
match value {
#from_arms
_ => Err(TryFromInterruptError(())),
impl Interrupt {

/// Attempt to convert a given value into an `Interrupt`
#[inline]
pub fn try_from(value: u16) -> Result<Self, TryFromInterruptError> {
match value {
#from_arms
_ => Err(TryFromInterruptError(())),
}
}
}
}
});
});
}
_ => {
mod_items.extend(quote! {
#interrupt_enum

/// TryFromInterruptError
#[derive(Debug, Copy, Clone)]
pub struct TryFromInterruptError(());

impl Interrupt {

/// Attempt to convert a given value into an `Interrupt`
#[inline]
pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
match value {
#from_arms
_ => Err(TryFromInterruptError(())),
}
}
}
});
}
}
}

Expand Down Expand Up @@ -330,7 +364,11 @@ pub fn render(
}
}

if !interrupts.is_empty() && target != Target::CortexM && target != Target::Msp430 {
if !interrupts.is_empty()
&& target != Target::CortexM
&& target != Target::XtensaLX
&& target != Target::Msp430
{
root.extend(quote! {
#[doc(hidden)]
pub mod interrupt {
Expand Down