Removed device from init context in preparation for its disapearance

This commit is contained in:
Emil Fresk 2023-03-31 20:42:14 +02:00
parent 064cf19265
commit 7f61392a63
9 changed files with 8 additions and 36 deletions

View file

@ -21,17 +21,6 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
pub core: rtic::export::Peripherals 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!( fields.push(quote!(
/// Critical section token for init /// Critical section token for init
pub cs: rtic::export::CriticalSection<'a> pub cs: rtic::export::CriticalSection<'a>

View file

@ -56,9 +56,6 @@ pub struct AppArgs {
/// Device /// Device
pub device: Path, pub device: Path,
/// Peripherals
pub peripherals: bool,
/// Interrupts used to dispatch software tasks /// Interrupts used to dispatch software tasks
pub dispatchers: Dispatchers, pub dispatchers: Dispatchers,
} }

View file

@ -5,7 +5,7 @@ use proc_macro2::TokenStream as TokenStream2;
use syn::{ use syn::{
parse::{self, ParseStream, Parser}, parse::{self, ParseStream, Parser},
spanned::Spanned, spanned::Spanned,
Expr, ExprArray, Fields, ForeignItem, Ident, Item, LitBool, Path, Token, Visibility, Expr, ExprArray, Fields, ForeignItem, Ident, Item, Path, Token, Visibility,
}; };
use super::Input; use super::Input;
@ -23,7 +23,6 @@ impl AppArgs {
(|input: ParseStream<'_>| -> parse::Result<Self> { (|input: ParseStream<'_>| -> parse::Result<Self> {
let mut custom = Set::new(); let mut custom = Set::new();
let mut device = None; let mut device = None;
let mut peripherals = true;
let mut dispatchers = Dispatchers::new(); let mut dispatchers = Dispatchers::new();
loop { loop {
@ -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" => { "dispatchers" => {
if let Ok(p) = input.parse::<ExprArray>() { if let Ok(p) = input.parse::<ExprArray>() {
for e in p.elems { for e in p.elems {
@ -133,7 +121,6 @@ impl AppArgs {
Ok(AppArgs { Ok(AppArgs {
device, device,
peripherals,
dispatchers, dispatchers,
}) })
}) })

View file

@ -13,6 +13,8 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
### Changed ### Changed
- `peripherals = ...` is removed
- The context in init has removed `cx.device`
- `cortex-m` set as an optional dependency - `cortex-m` set as an optional dependency
- Moved `cortex-m`-related utilities from `rtic/lib.rs` to `rtic/export.rs` - 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 - Make async task priorities start at 0, instead of 1, to always start at the lowest priority

View file

@ -9,7 +9,7 @@
use panic_semihosting as _; use panic_semihosting as _;
#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0], peripherals = true)] #[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0])]
mod app { mod app {
use cortex_m_semihosting::{debug, hprintln}; use cortex_m_semihosting::{debug, hprintln};
use rtic_monotonics::systick::*; use rtic_monotonics::systick::*;

View file

@ -15,7 +15,7 @@ use panic_semihosting as _;
// task can have a mutable reference stored. // task can have a mutable reference stored.
// - Spawning an async task equates to it being polled once. // - 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 { mod app {
use cortex_m_semihosting::{debug, hprintln}; use cortex_m_semihosting::{debug, hprintln};

View file

@ -11,7 +11,7 @@ use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _; use panic_semihosting as _;
use rtic_monotonics::systick::*; use rtic_monotonics::systick::*;
#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0], peripherals = true)] #[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0])]
mod app { mod app {
use super::*; use super::*;
use futures::{future::FutureExt, select_biased}; use futures::{future::FutureExt, select_biased};

View file

@ -8,7 +8,7 @@
use panic_semihosting as _; use panic_semihosting as _;
#[rtic::app(device = lm3s6965, peripherals = true)] #[rtic::app(device = lm3s6965)]
mod app { mod app {
use cortex_m_semihosting::{debug, hprintln}; use cortex_m_semihosting::{debug, hprintln};
@ -23,9 +23,6 @@ mod app {
// Cortex-M peripherals // Cortex-M peripherals
let _core: cortex_m::Peripherals = cx.core; let _core: cortex_m::Peripherals = cx.core;
// Device specific peripherals
let _device: lm3s6965::Peripherals = cx.device;
// Locals in `init` have 'static lifetime // Locals in `init` have 'static lifetime
let _x: &'static mut u32 = cx.local.x; let _x: &'static mut u32 = cx.local.x;

View file

@ -15,7 +15,7 @@ pub struct NotSend {
_0: PhantomData<*const ()>, _0: PhantomData<*const ()>,
} }
#[rtic::app(device = lm3s6965, peripherals = true)] #[rtic::app(device = lm3s6965)]
mod app { mod app {
use super::NotSend; use super::NotSend;
use core::marker::PhantomData; use core::marker::PhantomData;