aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml19
-rw-r--r--Cargo.toml21
-rw-r--r--book/en/src/by-example/resources.md10
-rw-r--r--ci/script.sh16
-rw-r--r--examples/periodic.rs2
-rw-r--r--examples/t-cfg-resources.rs52
-rw-r--r--examples/t-htask-main.rs20
-rw-r--r--examples/t-idle-main.rs20
-rw-r--r--examples/t-init-main.rs15
-rw-r--r--examples/t-stask-main.rs24
-rw-r--r--macros/src/codegen.rs2
-rw-r--r--macros/src/codegen/dispatchers.rs2
-rw-r--r--macros/src/codegen/idle.rs2
-rw-r--r--macros/src/codegen/init.rs2
-rw-r--r--src/lib.rs1
15 files changed, 170 insertions, 38 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e6abe374..00086ff5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -59,6 +59,10 @@ jobs:
target: ${{ matrix.target }}
override: true
+ - name: Disable optimisation profiles
+ if: matrix.toolchain == '1.36.0'
+ run: sed -i '/^\[profile.*build-override]$/,/^$/{/^#/!{/^$/!d}}' Cargo.toml
+
- name: cargo check
uses: actions-rs/cargo@v1
with:
@@ -90,7 +94,7 @@ jobs:
with:
use-cross: false
command: check
- args: --examples --target=${{ matrix.target }}
+ args: --examples --target=${{ matrix.target }} --features __min_r1_43
- name: cargo check -p homogeneous
uses: actions-rs/cargo@v1
@@ -268,6 +272,11 @@ jobs:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
override: true
+
+ - name: Disable optimisation profiles
+ if: matrix.toolchain == '1.36.0'
+ run: sed -i '/^\[profile.*build-override]$/,/^$/{/^#/!{/^$/!d}}' Cargo.toml
+
- name: cargo check
uses: actions-rs/cargo@v1
with:
@@ -287,6 +296,10 @@ jobs:
toolchain: 1.36.0
target: thumbv7m-none-eabi
override: true
+
+ - name: Disable optimisation profiles
+ run: sed -i '/^\[profile.*build-override]$/,/^$/{/^#/!{/^$/!d}}' Cargo.toml
+
- uses: actions-rs/cargo@v1
with:
use-cross: false
@@ -305,6 +318,10 @@ jobs:
toolchain: 1.36.0
target: thumbv6m-none-eabi
override: true
+
+ - name: Disable optimisation profiles
+ run: sed -i '/^\[profile.*build-override]$/,/^$/{/^#/!{/^$/!d}}' Cargo.toml
+
- uses: actions-rs/cargo@v1
with:
use-cross: false
diff --git a/Cargo.toml b/Cargo.toml
index 603129a2..41e54020 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -39,6 +39,10 @@ name = "t-cfg"
required-features = ["__v7"]
[[example]]
+name = "t-cfg-resources"
+required-features = ["__min_r1_43"]
+
+[[example]]
name = "t-schedule"
required-features = ["__v7"]
@@ -77,6 +81,7 @@ heterogeneous = ["cortex-m-rtfm-macros/heterogeneous", "microamp"]
homogeneous = ["cortex-m-rtfm-macros/homogeneous"]
# used for testing this crate; do not use in applications
__v7 =[]
+__min_r1_43 =[]
[profile.release]
codegen-units = 1
@@ -88,3 +93,19 @@ members = [
"homogeneous",
"macros",
]
+
+# do not optimize proc-macro deps or build scripts
+[profile.dev.build-override]
+codegen-units = 16
+debug = false
+debug-assertions = false
+opt-level = 0
+overflow-checks = false
+
+
+[profile.release.build-override]
+codegen-units = 16
+debug = false
+debug-assertions = false
+opt-level = 0
+overflow-checks = false
diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md
index b33ca9bb..db7630ea 100644
--- a/book/en/src/by-example/resources.md
+++ b/book/en/src/by-example/resources.md
@@ -11,7 +11,7 @@ All resources are declared as a single `struct` within the `#[app]`
pseudo-module. Each field in the structure corresponds to a different resource.
Resources can optionally be given an initial value using the `#[init]`
attribute. Resources that are not given an initial value are referred to as
-*late* resources and are covered in more detail in a follow up section in this
+*late* resources and are covered in more detail in a follow-up section in this
page.
Each context (task handler, `init` or `idle`) must declare the resources it
@@ -31,7 +31,7 @@ access to a resource named `shared`.
$ cargo run --example resource
{{#include ../../../../ci/expected/resource.run}}```
-Note that the `shared` resource cannot accessed from `idle`. Attempting to do
+Note that the `shared` resource cannot be accessed from `idle`. Attempting to do
so results in a compile error.
## `lock`
@@ -75,14 +75,14 @@ $ cargo run --example lock
## Late resources
-Late resources are resources that are not given an initial value at compile
-using the `#[init]` attribute but instead are initialized are runtime using the
+Late resources are resources that are not given an initial value at compile time
+using the `#[init]` attribute but instead are initialized at runtime using the
`init::LateResources` values returned by the `init` function.
Late resources are useful for *moving* (as in transferring the ownership of)
peripherals initialized in `init` into interrupt handlers.
-The example below uses late resources to stablish a lockless, one-way channel
+The example below uses late resources to establish a lockless, one-way channel
between the `UART0` interrupt handler and the `idle` task. A single producer
single consumer [`Queue`] is used as the channel. The queue is split into
consumer and producer end points in `init` and then each end point is stored
diff --git a/ci/script.sh b/ci/script.sh
index 7b86e52a..7743b8ba 100644
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -36,6 +36,12 @@ main() {
mkdir -p ci/builds
+ # Current MSRV cannot handle profiles, remove compilation optimisations
+ if [[ $TRAVIS_RUST_VERSION == 1.*.* ]]; then
+ echo "Removing optimisation profiles"
+ sed -i '/^\[profile.*build-override]$/,/^$/{/^#/!{/^$/!d}}' Cargo.toml
+ fi
+
if [ $T = x86_64-unknown-linux-gnu ]; then
if [[ $TRAVIS_RUST_VERSION == 1.*.* ]]; then
# test on a fixed version (MSRV) to avoid problems with changes in rustc diagnostics
@@ -96,8 +102,18 @@ main() {
if [ $TARGET = thumbv6m-none-eabi ]; then
cargo check --target $T --examples
+
+ # Check examples with specific features not compatible with MSRV
+ if [[ $TRAVIS_RUST_VERSION != 1.*.* ]]; then
+ cargo check --target $T --examples --features __min_r1_43
+ fi
else
cargo check --target $T --examples --features __v7
+
+ # Check examples with specific features not compatible with MSRV
+ if [[ $TRAVIS_RUST_VERSION != 1.*.* ]]; then
+ cargo check --target $T --examples --features __v7,__min_r1_43
+ fi
fi
cargo check -p homogeneous --target $T --examples
diff --git a/examples/periodic.rs b/examples/periodic.rs
index dca0ad56..3d32bc21 100644
--- a/examples/periodic.rs
+++ b/examples/periodic.rs
@@ -18,7 +18,7 @@ const APP: () = {
fn init(cx: init::Context) {
// omitted: initialization of `CYCCNT`
- cx.schedule.foo(Instant::now() + PERIOD.cycles()).unwrap();
+ cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap();
}
#[task(schedule = [foo])]
diff --git a/examples/t-cfg-resources.rs b/examples/t-cfg-resources.rs
index 63c41245..a8efe79e 100644
--- a/examples/t-cfg-resources.rs
+++ b/examples/t-cfg-resources.rs
@@ -5,36 +5,32 @@
use panic_halt as _;
-#[cfg(rustc_is_nightly)]
-mod example {
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ struct Resources {
+ // A resource
+ #[init(0)]
+ shared: u32,
- #[rtfm::app(device = lm3s6965)]
- const APP: () = {
- struct Resources {
- // A resource
- #[init(0)]
- shared: u32,
+ // A conditionally compiled resource behind feature_x
+ #[cfg(feature = "feature_x")]
+ x: u32,
- // A conditionally compiled resource behind feature_x
- #[cfg(feature = "feature_x")]
- x: u32,
-
- dummy: (),
- }
+ dummy: (),
+ }
- #[init]
- fn init(_: init::Context) -> init::LateResources {
- init::LateResources {
- // The feature needs to be applied everywhere x is defined or used
- #[cfg(feature = "feature_x")]
- x: 0,
- dummy: (), // dummy such that we have at least one late resource
- }
+ #[init]
+ fn init(_: init::Context) -> init::LateResources {
+ init::LateResources {
+ // The feature needs to be applied everywhere x is defined or used
+ #[cfg(feature = "feature_x")]
+ x: 0,
+ dummy: (), // dummy such that we have at least one late resource
}
+ }
- #[idle]
- fn idle(_cx: idle::Context) -> ! {
- loop {}
- }
- };
-}
+ #[idle]
+ fn idle(_cx: idle::Context) -> ! {
+ loop {}
+ }
+};
diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs
new file mode 100644
index 00000000..d229d818
--- /dev/null
+++ b/examples/t-htask-main.rs
@@ -0,0 +1,20 @@
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use cortex_m_semihosting::debug;
+use panic_semihosting as _;
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ #[init]
+ fn init(_: init::Context) {
+ rtfm::pend(lm3s6965::Interrupt::UART0)
+ }
+
+ #[task(binds = UART0)]
+ fn main(_: main::Context) {
+ debug::exit(debug::EXIT_SUCCESS);
+ }
+};
diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs
new file mode 100644
index 00000000..d1bb1483
--- /dev/null
+++ b/examples/t-idle-main.rs
@@ -0,0 +1,20 @@
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use cortex_m_semihosting::debug;
+use panic_semihosting as _;
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ #[init]
+ fn init(_: init::Context) {
+ }
+
+ #[idle]
+ fn main(_: main::Context) -> ! {
+ debug::exit(debug::EXIT_SUCCESS);
+ loop {}
+ }
+};
diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs
new file mode 100644
index 00000000..e0d94d5f
--- /dev/null
+++ b/examples/t-init-main.rs
@@ -0,0 +1,15 @@
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use cortex_m_semihosting::debug;
+use panic_semihosting as _;
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ #[init]
+ fn main(_: main::Context) {
+ debug::exit(debug::EXIT_SUCCESS);
+ }
+};
diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs
new file mode 100644
index 00000000..b55161ea
--- /dev/null
+++ b/examples/t-stask-main.rs
@@ -0,0 +1,24 @@
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use cortex_m_semihosting::debug;
+use panic_semihosting as _;
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ #[init(spawn = [main])]
+ fn init(cx: init::Context) {
+ cx.spawn.main().ok();
+ }
+
+ #[task]
+ fn main(_: main::Context) {
+ debug::exit(debug::EXIT_SUCCESS);
+ }
+
+ extern "C" {
+ fn UART0();
+ }
+};
diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs
index 60074849..80e65cd4 100644
--- a/macros/src/codegen.rs
+++ b/macros/src/codegen.rs
@@ -75,6 +75,8 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
#section
#cfg_core
unsafe extern "C" fn #main() -> ! {
+ let _TODO: () = ();
+
#(#assertion_stmts)*
#(#pre_init_stmts)*
diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs
index 9a9cb102..1400786b 100644
--- a/macros/src/codegen/dispatchers.rs
+++ b/macros/src/codegen/dispatchers.rs
@@ -141,7 +141,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
#let_instant
#fq.split().0.enqueue_unchecked(index);
let priority = &rtfm::export::Priority::new(PRIORITY);
- #name(
+ crate::#name(
#locals_new
#name::Context::new(priority #instant)
#(,#pats)*
diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs
index 35a72523..72432f67 100644
--- a/macros/src/codegen/idle.rs
+++ b/macros/src/codegen/idle.rs
@@ -72,7 +72,7 @@ pub fn codegen(
));
let locals_new = locals_new.iter();
- let call_idle = quote!(#name(
+ let call_idle = quote!(crate::#name(
#(#locals_new,)*
#name::Context::new(&rtfm::export::Priority::new(0))
));
diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs
index 9e5c4798..534b79b0 100644
--- a/macros/src/codegen/init.rs
+++ b/macros/src/codegen/init.rs
@@ -109,7 +109,7 @@ pub fn codegen(
let locals_new = locals_new.iter();
let call_init =
- Some(quote!(let late = #name(#(#locals_new,)* #name::Context::new(core.into()));));
+ Some(quote!(let late = crate::#name(#(#locals_new,)* #name::Context::new(core.into()));));
root_init.push(module::codegen(Context::Init(core), needs_lt, app, extra));
diff --git a/src/lib.rs b/src/lib.rs
index 614ba853..98dd6157 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -164,6 +164,7 @@ pub trait Monotonic {
/// A marker trait that indicates that it is correct to use this type in multi-core context
pub trait MultiCore {}
+
/// Sets the given `interrupt` as pending
///
/// This is a convenience function around