Skip to content
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

Removed device from init context in preparation for its disapearance #720

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions rtic-macros/src/codegen/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
pub core: rtic::export::Peripherals
));

if app.args.peripherals {
let device = &app.args.device;

fields.push(quote!(
/// Device peripherals (PAC)
pub device: #device::Peripherals
));

values.push(quote!(device: #device::Peripherals::steal()));
}

fields.push(quote!(
/// Critical section token for init
pub cs: rtic::export::CriticalSection<'a>
Expand Down
3 changes: 0 additions & 3 deletions rtic-macros/src/syntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ pub struct AppArgs {
/// Device
pub device: Path,

/// Peripherals
pub peripherals: bool,

/// Interrupts used to dispatch software tasks
pub dispatchers: Dispatchers,
}
Expand Down
15 changes: 1 addition & 14 deletions rtic-macros/src/syntax/parse/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use proc_macro2::TokenStream as TokenStream2;
use syn::{
parse::{self, ParseStream, Parser},
spanned::Spanned,
Expr, ExprArray, Fields, ForeignItem, Ident, Item, LitBool, Path, Token, Visibility,
Expr, ExprArray, Fields, ForeignItem, Ident, Item, Path, Token, Visibility,
};

use super::Input;
Expand All @@ -23,7 +23,6 @@ impl AppArgs {
(|input: ParseStream<'_>| -> parse::Result<Self> {
let mut custom = Set::new();
let mut device = None;
let mut peripherals = true;
let mut dispatchers = Dispatchers::new();

loop {
Expand Down Expand Up @@ -58,17 +57,6 @@ impl AppArgs {
}
}

"peripherals" => {
if let Ok(p) = input.parse::<LitBool>() {
peripherals = p.value;
} else {
return Err(parse::Error::new(
ident.span(),
"unexpected argument value; this should be a boolean",
));
}
}

"dispatchers" => {
if let Ok(p) = input.parse::<ExprArray>() {
for e in p.elems {
Expand Down Expand Up @@ -133,7 +121,6 @@ impl AppArgs {

Ok(AppArgs {
device,
peripherals,
dispatchers,
})
})
Expand Down
2 changes: 2 additions & 0 deletions rtic/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!

### Changed

- `peripherals = ...` is removed
- The context in init has removed `cx.device`
- `cortex-m` set as an optional dependency
- Moved `cortex-m`-related utilities from `rtic/lib.rs` to `rtic/export.rs`
- Make async task priorities start at 0, instead of 1, to always start at the lowest priority
Expand Down
2 changes: 1 addition & 1 deletion rtic/examples/async-delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use panic_semihosting as _;

#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0], peripherals = true)]
#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0])]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use rtic_monotonics::systick::*;
Expand Down
2 changes: 1 addition & 1 deletion rtic/examples/async-task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use panic_semihosting as _;
// task can have a mutable reference stored.
// - Spawning an async task equates to it being polled once.

#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0], peripherals = true)]
#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0])]
mod app {
use cortex_m_semihosting::{debug, hprintln};

Expand Down
2 changes: 1 addition & 1 deletion rtic/examples/async-timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
use rtic_monotonics::systick::*;

#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0], peripherals = true)]
#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0])]
mod app {
use super::*;
use futures::{future::FutureExt, select_biased};
Expand Down
5 changes: 1 addition & 4 deletions rtic/examples/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use panic_semihosting as _;

#[rtic::app(device = lm3s6965, peripherals = true)]
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};

Expand All @@ -23,9 +23,6 @@ mod app {
// Cortex-M peripherals
let _core: cortex_m::Peripherals = cx.core;

// Device specific peripherals
let _device: lm3s6965::Peripherals = cx.device;

// Locals in `init` have 'static lifetime
let _x: &'static mut u32 = cx.local.x;

Expand Down
2 changes: 1 addition & 1 deletion rtic/examples/zero-prio-task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct NotSend {
_0: PhantomData<*const ()>,
}

#[rtic::app(device = lm3s6965, peripherals = true)]
#[rtic::app(device = lm3s6965)]
mod app {
use super::NotSend;
use core::marker::PhantomData;
Expand Down