diff options
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | book/en/src/by-example/app.md | 2 | ||||
-rw-r--r-- | book/ru/src/by-example/app.md | 2 | ||||
-rw-r--r-- | macros/src/codegen/pre_init.rs | 11 | ||||
-rw-r--r-- | ui/unknown-interrupt.rs | 15 | ||||
-rw-r--r-- | ui/unknown-interrupt.stderr | 5 |
6 files changed, 39 insertions, 6 deletions
@@ -52,6 +52,16 @@ Formerly known as Real-Time For the Masses. - Applications must be written using the 2018 edition. +### Crate `cortex-m` 0.6 vs 0.7 in RTIC 0.5.x + +The crate `cortex-m` 0.7 started using trait `InterruptNumber` for interrupts instead of `Nr` from `bare-metal`. In order to preserve backwards compatibility, RTIC 0.5.x will keep using `cortex-m` 0.6 by default. `cortex-m` 0.7 can be enabled using the feature `cortex-m-7` and disabling default features: + +``` +cortex-m-rtic = { version = "0.5.8", default-features = false, features = ["cortex-m-7"] } +``` + +RTIC 0.6 already uses `cortex-m` 0.7 by default. + ## [User documentation](https://rtic.rs) - [(Development version)](https://rtic.rs/dev) ## [API reference](https://rtic.rs/stable/api/) diff --git a/book/en/src/by-example/app.md b/book/en/src/by-example/app.md index 5fd1c250..04535c14 100644 --- a/book/en/src/by-example/app.md +++ b/book/en/src/by-example/app.md @@ -72,7 +72,7 @@ so it must run forever. When no `idle` function is declared, the runtime sets the [SLEEPONEXIT] bit and then sends the microcontroller to sleep after running `init`. -[SLEEPONEXIT]: https://developer.arm.com/docs/100737/0100/power-management/sleep-mode/sleep-on-exit-bit +[SLEEPONEXIT]: https://developer.arm.com/docs/100737/0100/Power-management/Sleep-mode/Sleep-on-exit-bit Like in `init`, `static mut` variables will be transformed into `&'static mut` references that are safe to access. Notice, this feature may be deprecated in the next release, see `task_local` resources. diff --git a/book/ru/src/by-example/app.md b/book/ru/src/by-example/app.md index 5beca239..c2b518fd 100644 --- a/book/ru/src/by-example/app.md +++ b/book/ru/src/by-example/app.md @@ -73,7 +73,7 @@ $ cargo run --example init Если функция `idle` не определена, среда вполнения устанавливает бит [SLEEPONEXIT], а затем отправляет микроконтроллер в сон после запуска `init`. -[SLEEPONEXIT]: https://developer.arm.com/docs/100737/0100/power-management/sleep-mode/sleep-on-exit-bit +[SLEEPONEXIT]: https://developer.arm.com/docs/100737/0100/Power-management/Sleep-mode/Sleep-on-exit-bit Как и в `init`, `static mut` переменные будут трансформированы в `&'static mut` ссылки, безопасные для доступа. Обратите внимание, данная возможность может diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs index d3c4f54d..69f16fe3 100644 --- a/macros/src/codegen/pre_init.rs +++ b/macros/src/codegen/pre_init.rs @@ -31,6 +31,13 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream let device = &extra.device; let nvic_prio_bits = quote!(#device::NVIC_PRIO_BITS); + // check that all dispatchers exists in the `Interrupt` enumeration regardless of whether + // they are used or not + let interrupt = util::interrupt_ident(); + for name in app.args.extern_interrupts.keys() { + stmts.push(quote!(let _ = #rt_err::#interrupt::#name;)); + } + let interrupt_ids = analysis.interrupts.iter().map(|(p, (id, _))| (p, id)); // Unmask interrupts and set their priorities @@ -45,8 +52,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream // Compile time assert that this priority is supported by the device stmts.push(quote!(let _ = [(); ((1 << #nvic_prio_bits) - #priority as usize)];)); - // NOTE this also checks that the interrupt exists in the `Interrupt` enumeration - let interrupt = util::interrupt_ident(); stmts.push(quote!( core.NVIC.set_priority( #rt_err::#interrupt::#name, @@ -100,8 +105,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream } )); } else { - // NOTE this also checks that the interrupt exists in the `Interrupt` enumeration - let interrupt = util::interrupt_ident(); stmts.push(quote!( core.NVIC.set_priority( #rt_err::#interrupt::#binds, diff --git a/ui/unknown-interrupt.rs b/ui/unknown-interrupt.rs new file mode 100644 index 00000000..f2bc6295 --- /dev/null +++ b/ui/unknown-interrupt.rs @@ -0,0 +1,15 @@ +#![no_main] + +#[rtic::app(device = lm3s6965, dispatchers = [UnknownInterrupt])] +mod app { + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { + (Shared {}, Local {}, init::Monotonics()) + } +} diff --git a/ui/unknown-interrupt.stderr b/ui/unknown-interrupt.stderr new file mode 100644 index 00000000..c7d32699 --- /dev/null +++ b/ui/unknown-interrupt.stderr @@ -0,0 +1,5 @@ +error[E0599]: no variant or associated item named `UnknownInterrupt` found for enum `Interrupt` in the current scope + --> $DIR/unknown-interrupt.rs:3:47 + | +3 | #[rtic::app(device = lm3s6965, dispatchers = [UnknownInterrupt])] + | ^^^^^^^^^^^^^^^^ variant or associated item not found in `Interrupt` |