diff options
-rw-r--r-- | macros/src/lib.rs | 186 | ||||
-rw-r--r-- | ui/single/locals-cfg.stderr | 4 | ||||
-rw-r--r-- | ui/single/resources-cfg.stderr | 34 | ||||
-rw-r--r-- | ui/single/task-priority-too-high.stderr | 2 |
4 files changed, 21 insertions, 205 deletions
diff --git a/macros/src/lib.rs b/macros/src/lib.rs index b39cf0b8..dc37eaea 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -15,191 +15,7 @@ mod tests; /// Attribute used to declare a RTIC application /// -/// This attribute must be applied to a module block that contains items commonly found in modules, -/// like functions and `static` variables. -/// -/// The `app` attribute has one mandatory argument: -/// -/// - `device = <path>`. The path must point to a device crate generated using [`svd2rust`] -/// **v0.14.x** or newer. -/// -/// [`svd2rust`]: https://crates.io/crates/svd2rust -/// -/// and a few optional arguments: -/// -/// - `peripherals = <bool>`. Indicates whether the runtime takes the device peripherals and makes -/// them available to the `init` context. -/// -/// - `monotonic = <path>`. This is a path to a zero-sized structure (e.g. `struct Foo;`) that -/// implements the `Monotonic` trait. This argument must be provided to use the `schedule` API. -/// -/// The items allowed in the module block are specified below: -/// -/// # 1. `#[resources] struct <resource-name>` -/// -/// This structure contains the declaration of all the resources used by the application. Each field -/// in this structure corresponds to a different resource. Each resource may optionally be given an -/// initial value using the `#[init(<value>)]` attribute. Resources with no compile-time initial -/// value as referred to as *late* resources. -/// -/// # 2. `fn` -/// -/// Functions must contain *one* of the following attributes: `init`, `idle` or `task`. The -/// attribute defines the role of the function in the application. -/// -/// ## a. `#[init]` -/// -/// This attribute indicates that the function is to be used as the *initialization function*. There -/// must be exactly one instance of the `init` attribute inside the `app` pseudo-module. The -/// signature of the `init` function must be `fn (<fn-name>::Context) [-> <fn-name>::LateResources]` -/// where `<fn-name>` is the name of the function adorned with the `#[init]` attribute. -/// -/// The `init` function runs after memory (RAM) is initialized and runs with interrupts disabled. -/// Interrupts are re-enabled after `init` returns. -/// -/// The `init` attribute accepts the following optional arguments: -/// -/// - `resources = [resource_a, resource_b, ..]`. This is the list of resources this context has -/// access to. -/// -/// - `schedule = [task_a, task_b, ..]`. This is the list of *software* tasks that this context can -/// schedule to run in the future. *IMPORTANT*: This argument is accepted only if the `monotonic` -/// argument is passed to the `#[app]` attribute. -/// -/// - `spawn = [task_a, task_b, ..]`. This is the list of *software* tasks that this context can -/// immediately spawn. -/// -/// The first argument of the function, `<fn-name>::Context`, is a structure that contains the -/// following fields: -/// -/// - `core`. Exclusive access to core peripherals. The type of this field is [`rtic::Peripherals`] -/// when the `schedule` API is used and [`cortex_m::Peripherals`] when it's not. -/// -/// [`rtic::Peripherals`]: ../rtic/struct.Peripherals.html -/// [`cortex_m::Peripherals`]: https://docs.rs/cortex-m/0.6/cortex_m/peripheral/struct.Peripherals.html -/// -/// - `device: <device>::Peripherals`. Exclusive access to device-specific peripherals. This -/// field is only present when the `peripherals` argument of the `#[app]` attribute is set to -/// `true`. `<device>` is the path to the device crate specified in the top `app` attribute. -/// -/// - `start: <Instant>`. The `start` time of the system: `<Instant>::zero()`. `<Instant>` is the -/// `Instant` type associated to the `Monotonic` implementation specified in the top `#[app]` -/// attribute. **NOTE**: this field is only present when the `schedule` is used. -/// -/// - `resources: <fn-name>::Resources`. A `struct` that contains all the resources that can be -/// accessed from this context. Each field is a different resource; each resource may appear as a -/// reference (`&[mut]-`) or as proxy structure that implements the [`rftm::Mutex`][rtic-mutex] trait. -/// -/// [rtic-mutex]: ../rtic/trait.Mutex.html -/// -/// - `schedule: <fn-name>::Schedule`. A `struct` that can be used to schedule *software* tasks. -/// -/// - `spawn: <fn-name>::Spawn`. A `struct` that can be used to spawn *software* tasks. -/// -/// The return type `<fn-name>::LateResources` must only be specified when late resources, resources -/// with no initial value declared at compile time, are used. `<fn-name>::LateResources` is a -/// structure where each field corresponds to a different late resource. The -/// `<fn-name>::LateResources` value returned by the `#[init]` function is used to initialize the -/// late resources before `idle` or any task can start. -/// -/// Other properties: -/// -/// - The `static mut` variables declared at the beginning of this function will be transformed into -/// `&'static mut` references that are safe to access. For example, `static mut FOO: u32 = 0` will -/// become `FOO: &'static mut u32`. -/// -/// ## b. `#[idle]` -/// -/// This attribute indicates that the function is to be used as the *idle task*. There can be at -/// most once instance of the `idle` attribute inside the `app` pseudo-module. The signature of the -/// `idle` function must be `fn(<fn-name>::Context) -> !` where `<fn-name>` is the name of the -/// function adorned with the `#[idle]` attribute. -/// -/// The `idle` task is a special task that always runs in the background. The `idle` task runs at -/// the lowest priority of `0`. If the `idle` task is not defined then the runtime sets the -/// [SLEEPONEXIT] bit after executing `init`. -/// -/// [SLEEPONEXIT]: https://developer.arm.com/products/architecture/cpu-architecture/m-profile/docs/100737/0100/power-management/sleep-mode/sleep-on-exit-bit -/// -/// The `idle` attribute accepts the following optional arguments: -/// -/// - `resources = (..)`. Same meaning / function as [`#[init].resources`](#a-init). -/// -/// - `schedule = (..)`. Same meaning / function as [`#[init].schedule`](#a-init). -/// -/// - `spawn = (..)`. Same meaning / function as [`#[init].spawn`](#a-init). -/// -/// The first argument of the function, `idle::Context`, is a structure that contains the following -/// fields: -/// -/// - `resources: _`. Same meaning / function as [`<init>::Context.resources`](#a-init). -/// -/// - `schedule: idle::Schedule`. Same meaning / function as [`<init>::Context.schedule`](#a-init). -/// -/// - `spawn: idle::Spawn`. Same meaning / function as [`<init>::Context.spawn`](#a-init). -/// -/// Other properties: -/// -/// - The `static mut` variables declared at the beginning of this function will be transformed into -/// `&'static mut` references that are safe to access. For example, `static mut FOO: u32 = 0` will -/// become `FOO: &'static mut u32`. -/// -/// ## c. `#[task]` -/// -/// This attribute indicates that the function is either a hardware task or a software task. The -/// signature of hardware tasks must be `fn(<fn-name>::Context)` whereas the signature of software -/// tasks must be `fn(<fn-name>::Context, <inputs>)`. `<fn-name>` refers to the name of the function -/// adorned with the `#[task]` attribute. -/// -/// The `task` attribute accepts the following optional arguments. -/// -/// - `binds = <interrupt-name>`. Binds this task to a particular interrupt. When this argument is -/// present the task is treated as a hardware task; when it's omitted the task treated is treated as -/// a software task. -/// -/// - `priority = <integer>`. This is the static priority of the exception handler. The value must -/// be in the range `1..=(1 << <device-path>::NVIC_PRIO_BITS)` where `<device-path>` is the path to -/// the device crate specified in the top `app` attribute. If this argument is omitted the priority -/// is assumed to be 1. -/// -/// - `resources = (..)`. Same meaning / function as [`#[init].resources`](#a-init). -/// -/// - `schedule = (..)`. Same meaning / function as [`#[init].schedule`](#a-init). -/// -/// - `spawn = (..)`. Same meaning / function as [`#[init].spawn`](#a-init). -/// -/// The first argument of the function, `<fn-name>::Context`, is a structure that contains the -/// following fields: -/// -/// - `start: <Instant>`. For hardware tasks this is the time at which this handler started -/// executing. For software tasks this is the time at which the task was scheduled to run. **NOTE**: -/// only present when the `schedule` API is used. -/// -/// - `resources: _`. Same meaning / function as [`<init>::Context.resources`](#a-init). -/// -/// - `schedule: <exception-name>::Schedule`. Same meaning / function as -/// [`<init>::Context.schedule`](#a-init). -/// -/// - `spawn: <exception-name>::Spawn`. Same meaning / function as -/// [`<init>::Context.spawn`](#a-init). -/// -/// Other properties / constraints: -/// -/// - The `static mut` variables declared at the beginning of this function will be transformed into -/// *non*-static `&mut` references that are safe to access. For example, `static mut FOO: u32 = 0` -/// will become `FOO: &mut u32`. -/// -/// # 3. `extern` block -/// -/// This `extern` block contains a list of interrupts which are *not* used by the application as -/// hardware tasks. These interrupts will be used to dispatch software tasks. Each interrupt will be -/// used to dispatch *multiple* software tasks *at the same priority level*. -/// -/// This `extern` block must only contain functions with signature `fn ()`. The names of these -/// functions must match the names of the target device interrupts. -/// -/// Attributes can be applied to the functions inside this block. These attributes will be forwarded -/// to the interrupt handlers generated by the `app` attribute. +/// For user documentation see the [RTIC book](https://rtic.rs) #[proc_macro_attribute] pub fn app(args: TokenStream, input: TokenStream) -> TokenStream { diff --git a/ui/single/locals-cfg.stderr b/ui/single/locals-cfg.stderr index 0af1293f..9319ab46 100644 --- a/ui/single/locals-cfg.stderr +++ b/ui/single/locals-cfg.stderr @@ -31,5 +31,5 @@ error[E0425]: cannot find value `FOO` in this scope error: duplicate lang item in crate `panic_halt` (which `$CRATE` depends on): `panic_impl`. | = note: the lang item is first defined in crate `std` (which `$CRATE` depends on) - = note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-f14aca24435a5414.rlib - = note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-33949299fdfa2375.rmeta + = note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-93cbfed54dd1bac8.rlib + = note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-e17d79bd6be439e3.rmeta diff --git a/ui/single/resources-cfg.stderr b/ui/single/resources-cfg.stderr index f47b1353..e0b82b93 100644 --- a/ui/single/resources-cfg.stderr +++ b/ui/single/resources-cfg.stderr @@ -1,10 +1,10 @@ error: duplicate lang item in crate `panic_halt` (which `$CRATE` depends on): `panic_impl`. | = note: the lang item is first defined in crate `std` (which `$CRATE` depends on) - = note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-f14aca24435a5414.rlib - = note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-33949299fdfa2375.rmeta + = note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-93cbfed54dd1bac8.rlib + = note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-e17d79bd6be439e3.rmeta -error[E0609]: no field `o1` on type `app::initResources<'_>` +error[E0609]: no field `o1` on type `initResources<'_>` --> $DIR/resources-cfg.rs:47:21 | 47 | c.resources.o1; @@ -12,7 +12,7 @@ error[E0609]: no field `o1` on type `app::initResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `o4` on type `app::initResources<'_>` +error[E0609]: no field `o4` on type `initResources<'_>` --> $DIR/resources-cfg.rs:48:21 | 48 | c.resources.o4; @@ -20,7 +20,7 @@ error[E0609]: no field `o4` on type `app::initResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `o5` on type `app::initResources<'_>` +error[E0609]: no field `o5` on type `initResources<'_>` --> $DIR/resources-cfg.rs:49:21 | 49 | c.resources.o5; @@ -28,7 +28,7 @@ error[E0609]: no field `o5` on type `app::initResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `o6` on type `app::initResources<'_>` +error[E0609]: no field `o6` on type `initResources<'_>` --> $DIR/resources-cfg.rs:50:21 | 50 | c.resources.o6; @@ -36,7 +36,7 @@ error[E0609]: no field `o6` on type `app::initResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `s3` on type `app::initResources<'_>` +error[E0609]: no field `s3` on type `initResources<'_>` --> $DIR/resources-cfg.rs:51:21 | 51 | c.resources.s3; @@ -44,7 +44,7 @@ error[E0609]: no field `s3` on type `app::initResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `o2` on type `app::idleResources<'_>` +error[E0609]: no field `o2` on type `idleResources<'_>` --> $DIR/resources-cfg.rs:58:21 | 58 | c.resources.o2; @@ -52,7 +52,7 @@ error[E0609]: no field `o2` on type `app::idleResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `o4` on type `app::idleResources<'_>` +error[E0609]: no field `o4` on type `idleResources<'_>` --> $DIR/resources-cfg.rs:59:21 | 59 | c.resources.o4; @@ -60,7 +60,7 @@ error[E0609]: no field `o4` on type `app::idleResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `s1` on type `app::idleResources<'_>` +error[E0609]: no field `s1` on type `idleResources<'_>` --> $DIR/resources-cfg.rs:60:21 | 60 | c.resources.s1; @@ -68,7 +68,7 @@ error[E0609]: no field `s1` on type `app::idleResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `s3` on type `app::idleResources<'_>` +error[E0609]: no field `s3` on type `idleResources<'_>` --> $DIR/resources-cfg.rs:61:21 | 61 | c.resources.s3; @@ -76,7 +76,7 @@ error[E0609]: no field `s3` on type `app::idleResources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `o3` on type `app::uart0Resources<'_>` +error[E0609]: no field `o3` on type `uart0Resources<'_>` --> $DIR/resources-cfg.rs:68:21 | 68 | c.resources.o3; @@ -84,7 +84,7 @@ error[E0609]: no field `o3` on type `app::uart0Resources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `s1` on type `app::uart0Resources<'_>` +error[E0609]: no field `s1` on type `uart0Resources<'_>` --> $DIR/resources-cfg.rs:69:21 | 69 | c.resources.s1; @@ -92,7 +92,7 @@ error[E0609]: no field `s1` on type `app::uart0Resources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `s2` on type `app::uart0Resources<'_>` +error[E0609]: no field `s2` on type `uart0Resources<'_>` --> $DIR/resources-cfg.rs:70:21 | 70 | c.resources.s2; @@ -100,7 +100,7 @@ error[E0609]: no field `s2` on type `app::uart0Resources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `s3` on type `app::uart0Resources<'_>` +error[E0609]: no field `s3` on type `uart0Resources<'_>` --> $DIR/resources-cfg.rs:71:21 | 71 | c.resources.s3; @@ -108,7 +108,7 @@ error[E0609]: no field `s3` on type `app::uart0Resources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `s2` on type `app::uart1Resources<'_>` +error[E0609]: no field `s2` on type `uart1Resources<'_>` --> $DIR/resources-cfg.rs:76:21 | 76 | c.resources.s2; @@ -116,7 +116,7 @@ error[E0609]: no field `s2` on type `app::uart1Resources<'_>` | = note: available fields are: `__marker__` -error[E0609]: no field `o5` on type `app::uart1Resources<'_>` +error[E0609]: no field `o5` on type `uart1Resources<'_>` --> $DIR/resources-cfg.rs:77:21 | 77 | c.resources.o5; diff --git a/ui/single/task-priority-too-high.stderr b/ui/single/task-priority-too-high.stderr index e84ddd3c..984d3fac 100644 --- a/ui/single/task-priority-too-high.stderr +++ b/ui/single/task-priority-too-high.stderr @@ -2,6 +2,6 @@ error[E0080]: evaluation of constant value failed --> $DIR/task-priority-too-high.rs:3:1 | 3 | #[rtic::app(device = lm3s6965)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `8_usize - 9_usize` which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `8_usize - 9_usize`, which would overflow | = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) |