mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-29 15:04:32 +01:00
Updated examples
More work
This commit is contained in:
parent
355cb82d06
commit
f96b25fdf2
45 changed files with 176 additions and 214 deletions
|
@ -5,13 +5,14 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
// NOTE: does NOT properly work on QEMU
|
// NOTE: does NOT properly work on QEMU
|
||||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(cx: init::Context) -> init::LateResources {
|
fn init(cx: init::Context) -> init::LateResources {
|
||||||
// omitted: initialization of `CYCCNT`
|
// omitted: initialization of `CYCCNT`
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
// `examples/interrupt.rs` rewritten to use `binds`
|
// `examples/interrupt.rs` rewritten to use `binds`
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
rtic::pend(Interrupt::UART0);
|
rtic::pend(Interrupt::UART0);
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
rtic::pend(Interrupt::UART0);
|
rtic::pend(Interrupt::UART0);
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
use cortex_m_semihosting::hprintln;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
use cortex_m_semihosting::hprintln;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
|
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::hprintln;
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::hprintln;
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
// Some resources to work with
|
// Some resources to work with
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
use rtic::cyccnt::U32Ext;
|
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use rtic::cyccnt::U32Ext;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::hprintln;
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
use rtic::{Exclusive, Mutex};
|
use rtic::Mutex;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
use rtic::Exclusive;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
#[init(0)]
|
#[init(0)]
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
// Pends the UART0 interrupt but its handler won't run until *after*
|
// Pends the UART0 interrupt but its handler won't run until *after*
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
hprintln!("init").unwrap();
|
hprintln!("init").unwrap();
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965, peripherals = true)]
|
#[rtic::app(device = lm3s6965, peripherals = true)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(cx: init::Context) -> init::LateResources {
|
fn init(cx: init::Context) -> init::LateResources {
|
||||||
static mut X: u32 = 0;
|
static mut X: u32 = 0;
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
use panic_semihosting as _;
|
||||||
|
|
||||||
|
#[rtic::app(device = lm3s6965)]
|
||||||
|
mod app {
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use heapless::{
|
use heapless::{
|
||||||
consts::*,
|
consts::*,
|
||||||
|
@ -12,14 +16,7 @@ use heapless::{
|
||||||
spsc::{Consumer, Producer, Queue},
|
spsc::{Consumer, Producer, Queue},
|
||||||
};
|
};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use panic_semihosting as _;
|
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
|
||||||
mod app {
|
|
||||||
use heapless::{
|
|
||||||
consts::*,
|
|
||||||
spsc::{Consumer, Producer},
|
|
||||||
};
|
|
||||||
// Late resources
|
// Late resources
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
#[init(0)]
|
#[init(0)]
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
foo::spawn(/* no message */).unwrap();
|
foo::spawn(/* no message */).unwrap();
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
|
||||||
pub struct NotSync {
|
pub struct NotSync {
|
||||||
|
@ -18,6 +16,7 @@ pub struct NotSync {
|
||||||
mod app {
|
mod app {
|
||||||
use super::NotSync;
|
use super::NotSync;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
key: u32,
|
key: u32,
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::hprintln;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
use rtic::cyccnt::{Instant, U32Ext};
|
|
||||||
|
|
||||||
const PERIOD: u32 = 8_000_000;
|
|
||||||
|
|
||||||
// NOTE: does NOT work on QEMU!
|
// NOTE: does NOT work on QEMU!
|
||||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::hprintln;
|
||||||
|
use rtic::cyccnt::{Instant, U32Ext};
|
||||||
|
|
||||||
|
const PERIOD: u32 = 8_000_000;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(cx: init::Context) -> init::LateResources {
|
fn init(cx: init::Context) -> init::LateResources {
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
assert!(cortex_m::Peripherals::take().is_none());
|
assert!(cortex_m::Peripherals::take().is_none());
|
||||||
|
|
|
@ -5,12 +5,10 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use heapless::{
|
use heapless::{
|
||||||
pool,
|
pool,
|
||||||
pool::singleton::{Box, Pool},
|
pool::singleton::{Box, Pool},
|
||||||
};
|
};
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
use rtic::app;
|
use rtic::app;
|
||||||
|
|
||||||
|
@ -19,7 +17,9 @@ pool!(P: [u8; 128]);
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
use crate::Box;
|
use crate::{Box, Pool};
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
// Import the memory pool into scope
|
// Import the memory pool into scope
|
||||||
use super::P;
|
use super::P;
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
use rtic::app;
|
use rtic::app;
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
rtic::pend(Interrupt::GPIOA);
|
rtic::pend(Interrupt::GPIOA);
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
foo::spawn().unwrap();
|
foo::spawn().unwrap();
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
// A resource
|
// A resource
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
// A resource
|
// A resource
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m::peripheral::DWT;
|
|
||||||
use cortex_m_semihosting::hprintln;
|
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
use rtic::cyccnt::{Instant, U32Ext as _};
|
|
||||||
|
|
||||||
// NOTE: does NOT work on QEMU!
|
// NOTE: does NOT work on QEMU!
|
||||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m::peripheral::DWT;
|
||||||
|
use cortex_m_semihosting::hprintln;
|
||||||
|
use rtic::cyccnt::{Instant, U32Ext as _};
|
||||||
|
|
||||||
#[init()]
|
#[init()]
|
||||||
fn init(mut cx: init::Context) -> init::LateResources {
|
fn init(mut cx: init::Context) -> init::LateResources {
|
||||||
// Initialize (enable) the monotonic timer (CYCCNT)
|
// Initialize (enable) the monotonic timer (CYCCNT)
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use lm3s6965::Interrupt;
|
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
use rtic::app;
|
use rtic::app;
|
||||||
|
|
||||||
|
@ -14,6 +12,8 @@ pub struct MustBeSend;
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
use super::MustBeSend;
|
use super::MustBeSend;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_c: init::Context) -> init::LateResources {
|
fn init(_c: init::Context) -> init::LateResources {
|
||||||
foo::spawn(1, 2).unwrap();
|
foo::spawn(1, 2).unwrap();
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_c: init::Context) -> init::LateResources {
|
fn init(_c: init::Context) -> init::LateResources {
|
||||||
foo::spawn(1, 2).unwrap();
|
foo::spawn(1, 2).unwrap();
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
use panic_semihosting as _;
|
||||||
|
|
||||||
|
#[rtic::app(device = lm3s6965)]
|
||||||
|
mod app {
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use heapless::{
|
use heapless::{
|
||||||
consts::*,
|
consts::*,
|
||||||
|
@ -12,13 +17,6 @@ use heapless::{
|
||||||
spsc::{Consumer, Producer, Queue},
|
spsc::{Consumer, Producer, Queue},
|
||||||
};
|
};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use panic_semihosting as _;
|
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
|
||||||
mod app {
|
|
||||||
|
|
||||||
use crate::U4;
|
|
||||||
use crate::{Consumer, Producer};
|
|
||||||
|
|
||||||
// Late resources
|
// Late resources
|
||||||
#[resources]
|
#[resources]
|
||||||
|
|
|
@ -17,18 +17,18 @@ mod app {
|
||||||
// Cortex-M exception
|
// Cortex-M exception
|
||||||
#[task(binds = SVCall)]
|
#[task(binds = SVCall)]
|
||||||
fn foo(c: foo::Context) {
|
fn foo(c: foo::Context) {
|
||||||
foo_trampoline(c)
|
crate::foo_trampoline(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LM3S6965 interrupt
|
// LM3S6965 interrupt
|
||||||
#[task(binds = UART0)]
|
#[task(binds = UART0)]
|
||||||
fn bar(c: bar::Context) {
|
fn bar(c: bar::Context) {
|
||||||
bar_trampoline(c)
|
crate::bar_trampoline(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn foo_trampoline(_: foo::Context) {}
|
fn foo_trampoline(_: app::foo::Context) {}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn bar_trampoline(_: bar::Context) {}
|
fn bar_trampoline(_: app::bar::Context) {}
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
rtic::pend(lm3s6965::Interrupt::UART0);
|
rtic::pend(lm3s6965::Interrupt::UART0);
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
init::LateResources {}
|
init::LateResources {}
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub struct NotSend {
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
use super::NotSend;
|
use super::NotSend;
|
||||||
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
use rtic::cyccnt::{Instant, U32Ext as _};
|
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use rtic::cyccnt::{Instant, U32Ext as _};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(c: init::Context) -> init::LateResources {
|
fn init(c: init::Context) -> init::LateResources {
|
||||||
let _: Result<(), ()> = foo::schedule(c.start + 10.cycles());
|
let _: Result<(), ()> = foo::schedule(c.start + 10.cycles());
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
taskmain::spawn().ok();
|
taskmain::spawn().ok();
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965)]
|
#[rtic::app(device = lm3s6965)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
foo::spawn().unwrap();
|
foo::spawn().unwrap();
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
|
||||||
use panic_semihosting as _;
|
use panic_semihosting as _;
|
||||||
use rtic::cyccnt;
|
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
|
#[rtic::app(device = lm3s6965, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
|
||||||
mod app {
|
mod app {
|
||||||
|
use cortex_m_semihosting::debug;
|
||||||
|
use rtic::cyccnt;
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
#[init(0)]
|
#[init(0)]
|
||||||
|
|
|
@ -22,35 +22,20 @@ mod util;
|
||||||
// TODO document the syntax here or in `rtic-syntax`
|
// TODO document the syntax here or in `rtic-syntax`
|
||||||
pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
let mut mod_app = vec![];
|
let mut mod_app = vec![];
|
||||||
let mut mod_app_imports = vec![];
|
|
||||||
let mut mains = vec![];
|
let mut mains = vec![];
|
||||||
let mut root = vec![];
|
let mut root = vec![];
|
||||||
let mut user = vec![];
|
let mut user = vec![];
|
||||||
let mut imports = vec![];
|
|
||||||
|
|
||||||
// Generate the `main` function
|
// Generate the `main` function
|
||||||
let assertion_stmts = assertions::codegen(analysis);
|
let assertion_stmts = assertions::codegen(analysis);
|
||||||
|
|
||||||
let pre_init_stmts = pre_init::codegen(&app, analysis, extra);
|
let pre_init_stmts = pre_init::codegen(&app, analysis, extra);
|
||||||
|
|
||||||
let (mod_app_init, root_init, user_init, user_init_imports, call_init) =
|
let (mod_app_init, root_init, user_init, call_init) = init::codegen(app, analysis, extra);
|
||||||
init::codegen(app, analysis, extra);
|
|
||||||
|
|
||||||
let post_init_stmts = post_init::codegen(&app, analysis);
|
let post_init_stmts = post_init::codegen(&app, analysis);
|
||||||
|
|
||||||
let (mod_app_idle, root_idle, user_idle, user_idle_imports, call_idle) =
|
let (mod_app_idle, root_idle, user_idle, call_idle) = idle::codegen(app, analysis, extra);
|
||||||
idle::codegen(app, analysis, extra);
|
|
||||||
|
|
||||||
if user_init.is_some() {
|
|
||||||
mod_app_imports.push(quote!(
|
|
||||||
use super::init;
|
|
||||||
))
|
|
||||||
}
|
|
||||||
if user_idle.is_some() {
|
|
||||||
mod_app_imports.push(quote!(
|
|
||||||
use super::idle;
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
user.push(quote!(
|
user.push(quote!(
|
||||||
#user_init
|
#user_init
|
||||||
|
@ -58,11 +43,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
#user_idle
|
#user_idle
|
||||||
));
|
));
|
||||||
|
|
||||||
imports.push(quote!(
|
|
||||||
#(#user_init_imports)*
|
|
||||||
#(#user_idle_imports)*
|
|
||||||
));
|
|
||||||
|
|
||||||
root.push(quote!(
|
root.push(quote!(
|
||||||
#(#root_init)*
|
#(#root_init)*
|
||||||
|
|
||||||
|
@ -100,15 +80,10 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
mod_app_hardware_tasks,
|
mod_app_hardware_tasks,
|
||||||
root_hardware_tasks,
|
root_hardware_tasks,
|
||||||
user_hardware_tasks,
|
user_hardware_tasks,
|
||||||
user_hardware_tasks_imports,
|
|
||||||
) = hardware_tasks::codegen(app, analysis, extra);
|
) = hardware_tasks::codegen(app, analysis, extra);
|
||||||
|
|
||||||
let (
|
let (mod_app_software_tasks, root_software_tasks, user_software_tasks) =
|
||||||
mod_app_software_tasks,
|
software_tasks::codegen(app, analysis, extra);
|
||||||
root_software_tasks,
|
|
||||||
user_software_tasks,
|
|
||||||
user_software_tasks_imports,
|
|
||||||
) = software_tasks::codegen(app, analysis, extra);
|
|
||||||
|
|
||||||
let mod_app_dispatchers = dispatchers::codegen(app, analysis, extra);
|
let mod_app_dispatchers = dispatchers::codegen(app, analysis, extra);
|
||||||
let mod_app_timer_queue = timer_queue::codegen(app, analysis, extra);
|
let mod_app_timer_queue = timer_queue::codegen(app, analysis, extra);
|
||||||
|
@ -131,54 +106,66 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
quote!(
|
quote!(
|
||||||
#(#user)*
|
|
||||||
|
|
||||||
#(#user_hardware_tasks)*
|
|
||||||
|
|
||||||
#(#user_software_tasks)*
|
|
||||||
|
|
||||||
#(#root)*
|
|
||||||
|
|
||||||
#mod_resources
|
|
||||||
|
|
||||||
#(#root_hardware_tasks)*
|
|
||||||
|
|
||||||
#(#root_software_tasks)*
|
|
||||||
|
|
||||||
/// Unused
|
|
||||||
#(#tasks)*
|
|
||||||
|
|
||||||
/// Implementation details
|
/// Implementation details
|
||||||
mod #name {
|
mod #name {
|
||||||
/// Always include the device crate which contains the vector table
|
/// Always include the device crate which contains the vector table
|
||||||
use #device as you_must_enable_the_rt_feature_for_the_pac_in_your_cargo_toml;
|
use #device as you_must_enable_the_rt_feature_for_the_pac_in_your_cargo_toml;
|
||||||
#(#imports)*
|
|
||||||
|
/// 2
|
||||||
#(#user_imports)*
|
#(#user_imports)*
|
||||||
|
|
||||||
/// User code from within the module
|
/// User code from within the module
|
||||||
#(#user_code)*
|
#(#user_code)*
|
||||||
/// User code end
|
/// User code end
|
||||||
|
|
||||||
|
/// 3
|
||||||
|
#(#user)*
|
||||||
|
|
||||||
#(#user_hardware_tasks_imports)*
|
/// 4
|
||||||
|
#(#user_hardware_tasks)*
|
||||||
|
|
||||||
#(#user_software_tasks_imports)*
|
/// 5
|
||||||
|
#(#user_software_tasks)*
|
||||||
|
|
||||||
|
/// 6
|
||||||
|
#(#root)*
|
||||||
|
|
||||||
|
/// 7
|
||||||
|
#mod_resources
|
||||||
|
|
||||||
|
/// 8
|
||||||
|
#(#root_hardware_tasks)*
|
||||||
|
|
||||||
|
/// 9
|
||||||
|
#(#root_software_tasks)*
|
||||||
|
|
||||||
|
/// 10
|
||||||
|
/// Unused
|
||||||
|
#(#tasks)*
|
||||||
|
|
||||||
|
/// 13
|
||||||
#(#mod_resources_imports)*
|
#(#mod_resources_imports)*
|
||||||
|
|
||||||
|
/// 14
|
||||||
/// app module
|
/// app module
|
||||||
#(#mod_app)*
|
#(#mod_app)*
|
||||||
|
|
||||||
|
/// 15
|
||||||
#(#mod_app_resources)*
|
#(#mod_app_resources)*
|
||||||
|
|
||||||
|
/// 16
|
||||||
#(#mod_app_hardware_tasks)*
|
#(#mod_app_hardware_tasks)*
|
||||||
|
|
||||||
|
/// 17
|
||||||
#(#mod_app_software_tasks)*
|
#(#mod_app_software_tasks)*
|
||||||
|
|
||||||
|
/// 18
|
||||||
#(#mod_app_dispatchers)*
|
#(#mod_app_dispatchers)*
|
||||||
|
|
||||||
|
/// 19
|
||||||
#(#mod_app_timer_queue)*
|
#(#mod_app_timer_queue)*
|
||||||
|
|
||||||
|
/// 20
|
||||||
#(#mains)*
|
#(#mains)*
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -90,6 +90,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
quote!(#name::Locals::new(),)
|
quote!(#name::Locals::new(),)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let app_name = &app.name;
|
||||||
|
let app_path = quote! {crate::#app_name};
|
||||||
quote!(
|
quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#t::#name => {
|
#t::#name => {
|
||||||
|
@ -98,7 +100,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
#let_instant
|
#let_instant
|
||||||
#fq.split().0.enqueue_unchecked(index);
|
#fq.split().0.enqueue_unchecked(index);
|
||||||
let priority = &rtic::export::Priority::new(PRIORITY);
|
let priority = &rtic::export::Priority::new(PRIORITY);
|
||||||
crate::#name(
|
#app_path::#name(
|
||||||
#locals_new
|
#locals_new
|
||||||
#name::Context::new(priority #instant)
|
#name::Context::new(priority #instant)
|
||||||
#(,#pats)*
|
#(,#pats)*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{format_ident, quote};
|
use quote::quote;
|
||||||
use rtic_syntax::{ast::App, Context};
|
use rtic_syntax::{ast::App, Context};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -23,13 +23,10 @@ pub fn codegen(
|
||||||
Vec<TokenStream2>,
|
Vec<TokenStream2>,
|
||||||
// user_hardware_tasks -- the `#[task]` functions written by the user
|
// user_hardware_tasks -- the `#[task]` functions written by the user
|
||||||
Vec<TokenStream2>,
|
Vec<TokenStream2>,
|
||||||
// user_hardware_tasks_imports -- the imports for `#[task]` functions written by the user
|
|
||||||
Vec<TokenStream2>,
|
|
||||||
) {
|
) {
|
||||||
let mut mod_app = vec![];
|
let mut mod_app = vec![];
|
||||||
let mut root = vec![];
|
let mut root = vec![];
|
||||||
let mut user_tasks = vec![];
|
let mut user_tasks = vec![];
|
||||||
let mut hardware_tasks_imports = vec![];
|
|
||||||
|
|
||||||
for (name, task) in &app.hardware_tasks {
|
for (name, task) in &app.hardware_tasks {
|
||||||
let (let_instant, instant) = if let Some(m) = extra.monotonic {
|
let (let_instant, instant) = if let Some(m) = extra.monotonic {
|
||||||
|
@ -50,6 +47,8 @@ pub fn codegen(
|
||||||
let symbol = task.args.binds.clone();
|
let symbol = task.args.binds.clone();
|
||||||
let priority = task.args.priority;
|
let priority = task.args.priority;
|
||||||
|
|
||||||
|
let app_name = &app.name;
|
||||||
|
let app_path = quote! {crate::#app_name};
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -59,7 +58,7 @@ pub fn codegen(
|
||||||
#let_instant
|
#let_instant
|
||||||
|
|
||||||
rtic::export::run(PRIORITY, || {
|
rtic::export::run(PRIORITY, || {
|
||||||
crate::#name(
|
#app_path::#name(
|
||||||
#locals_new
|
#locals_new
|
||||||
#name::Context::new(&rtic::export::Priority::new(PRIORITY) #instant)
|
#name::Context::new(&rtic::export::Priority::new(PRIORITY) #instant)
|
||||||
)
|
)
|
||||||
|
@ -79,13 +78,6 @@ pub fn codegen(
|
||||||
analysis,
|
analysis,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add resources to imports
|
|
||||||
let name_res = format_ident!("{}Resources", name);
|
|
||||||
hardware_tasks_imports.push(quote!(
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name_res;
|
|
||||||
));
|
|
||||||
|
|
||||||
root.push(item);
|
root.push(item);
|
||||||
|
|
||||||
mod_app.push(constructor);
|
mod_app.push(constructor);
|
||||||
|
@ -121,13 +113,7 @@ pub fn codegen(
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
hardware_tasks_imports.push(quote!(
|
|
||||||
#(#attrs)*
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name;
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(mod_app, root, user_tasks, hardware_tasks_imports)
|
(mod_app, root, user_tasks)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{format_ident, quote};
|
use quote::quote;
|
||||||
use rtic_syntax::{ast::App, Context};
|
use rtic_syntax::{ast::App, Context};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -23,8 +23,6 @@ pub fn codegen(
|
||||||
Vec<TokenStream2>,
|
Vec<TokenStream2>,
|
||||||
// user_idle
|
// user_idle
|
||||||
Option<TokenStream2>,
|
Option<TokenStream2>,
|
||||||
// user_idle_imports
|
|
||||||
Vec<TokenStream2>,
|
|
||||||
// call_idle
|
// call_idle
|
||||||
TokenStream2,
|
TokenStream2,
|
||||||
) {
|
) {
|
||||||
|
@ -36,8 +34,6 @@ pub fn codegen(
|
||||||
let mut locals_pat = None;
|
let mut locals_pat = None;
|
||||||
let mut locals_new = None;
|
let mut locals_new = None;
|
||||||
|
|
||||||
let mut user_idle_imports = vec![];
|
|
||||||
|
|
||||||
let name = &idle.name;
|
let name = &idle.name;
|
||||||
|
|
||||||
if !idle.args.resources.is_empty() {
|
if !idle.args.resources.is_empty() {
|
||||||
|
@ -46,12 +42,6 @@ pub fn codegen(
|
||||||
|
|
||||||
root_idle.push(item);
|
root_idle.push(item);
|
||||||
mod_app = Some(constructor);
|
mod_app = Some(constructor);
|
||||||
|
|
||||||
let name_resource = format_ident!("{}Resources", name);
|
|
||||||
user_idle_imports.push(quote!(
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name_resource;
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !idle.locals.is_empty() {
|
if !idle.locals.is_empty() {
|
||||||
|
@ -83,25 +73,21 @@ pub fn codegen(
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
user_idle_imports.push(quote!(
|
|
||||||
#(#attrs)*
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name;
|
|
||||||
));
|
|
||||||
|
|
||||||
|
let app_name = &app.name;
|
||||||
|
let app_path = quote! {crate::#app_name};
|
||||||
let locals_new = locals_new.iter();
|
let locals_new = locals_new.iter();
|
||||||
let call_idle = quote!(crate::#name(
|
let call_idle = quote!(#app_path::#name(
|
||||||
#(#locals_new,)*
|
#(#locals_new,)*
|
||||||
#name::Context::new(&rtic::export::Priority::new(0))
|
#name::Context::new(&rtic::export::Priority::new(0))
|
||||||
));
|
));
|
||||||
|
|
||||||
(mod_app, root_idle, user_idle, user_idle_imports, call_idle)
|
(mod_app, root_idle, user_idle, call_idle)
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
vec![],
|
|
||||||
quote!(loop {
|
quote!(loop {
|
||||||
rtic::export::wfi()
|
rtic::export::wfi()
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{format_ident, quote};
|
use quote::quote;
|
||||||
use rtic_syntax::{ast::App, Context};
|
use rtic_syntax::{ast::App, Context};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -24,8 +24,6 @@ pub fn codegen(
|
||||||
Vec<TokenStream2>,
|
Vec<TokenStream2>,
|
||||||
// user_init -- the `#[init]` function written by the user
|
// user_init -- the `#[init]` function written by the user
|
||||||
Option<TokenStream2>,
|
Option<TokenStream2>,
|
||||||
// user_init_imports -- the imports for `#[init]` functio written by the user
|
|
||||||
Vec<TokenStream2>,
|
|
||||||
// call_init -- the call to the user `#[init]` if there's one
|
// call_init -- the call to the user `#[init]` if there's one
|
||||||
Option<TokenStream2>,
|
Option<TokenStream2>,
|
||||||
) {
|
) {
|
||||||
|
@ -52,7 +50,6 @@ pub fn codegen(
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let mut user_init_imports = vec![];
|
|
||||||
let late_resources = util::late_resources_ident(&name);
|
let late_resources = util::late_resources_ident(&name);
|
||||||
|
|
||||||
root_init.push(quote!(
|
root_init.push(quote!(
|
||||||
|
@ -63,12 +60,6 @@ pub fn codegen(
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
let name_late = format_ident!("{}LateResources", name);
|
|
||||||
user_init_imports.push(quote!(
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name_late;
|
|
||||||
));
|
|
||||||
|
|
||||||
let mut locals_pat = None;
|
let mut locals_pat = None;
|
||||||
let mut locals_new = None;
|
let mut locals_new = None;
|
||||||
if !init.locals.is_empty() {
|
if !init.locals.is_empty() {
|
||||||
|
@ -90,11 +81,6 @@ pub fn codegen(
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
user_init_imports.push(quote!(
|
|
||||||
#(#attrs)*
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name;
|
|
||||||
));
|
|
||||||
|
|
||||||
let mut mod_app = None;
|
let mut mod_app = None;
|
||||||
if !init.args.resources.is_empty() {
|
if !init.args.resources.is_empty() {
|
||||||
|
@ -103,17 +89,13 @@ pub fn codegen(
|
||||||
|
|
||||||
root_init.push(item);
|
root_init.push(item);
|
||||||
mod_app = Some(constructor);
|
mod_app = Some(constructor);
|
||||||
|
|
||||||
let name_late = format_ident!("{}Resources", name);
|
|
||||||
user_init_imports.push(quote!(
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name_late;
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let app_name = &app.name;
|
||||||
|
let app_path = quote! {crate::#app_name};
|
||||||
let locals_new = locals_new.iter();
|
let locals_new = locals_new.iter();
|
||||||
let call_init = Some(
|
let call_init = Some(
|
||||||
quote!(let late = crate::#name(#(#locals_new,)* #name::Context::new(core.into()));),
|
quote!(let late = #app_path::#name(#(#locals_new,)* #name::Context::new(core.into()));),
|
||||||
);
|
);
|
||||||
|
|
||||||
root_init.push(module::codegen(
|
root_init.push(module::codegen(
|
||||||
|
@ -124,8 +106,8 @@ pub fn codegen(
|
||||||
extra,
|
extra,
|
||||||
));
|
));
|
||||||
|
|
||||||
(mod_app, root_init, user_init, user_init_imports, call_init)
|
(mod_app, root_init, user_init, call_init)
|
||||||
} else {
|
} else {
|
||||||
(None, vec![], None, vec![], None)
|
(None, vec![], None, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub fn codegen(
|
||||||
for (name, res, expr, _) in app.resources(analysis) {
|
for (name, res, expr, _) in app.resources(analysis) {
|
||||||
let cfgs = &res.cfgs;
|
let cfgs = &res.cfgs;
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
|
let mangled_name = util::mangle_ident(&name);
|
||||||
|
|
||||||
{
|
{
|
||||||
let section = if expr.is_none() {
|
let section = if expr.is_none() {
|
||||||
|
@ -47,7 +48,7 @@ pub fn codegen(
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#section
|
#section
|
||||||
static mut #name: #ty = #expr;
|
static mut #mangled_name: #ty = #expr;
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +77,12 @@ pub fn codegen(
|
||||||
let ptr = if expr.is_none() {
|
let ptr = if expr.is_none() {
|
||||||
quote!(
|
quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#name.as_mut_ptr()
|
#mangled_name.as_mut_ptr()
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
quote!(
|
quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
&mut #name
|
&mut #mangled_name
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub fn codegen(
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
|
let mangled_name = util::mangle_ident(&name);
|
||||||
|
|
||||||
if ctxt.is_init() {
|
if ctxt.is_init() {
|
||||||
if !analysis.ownerships.contains_key(name) {
|
if !analysis.ownerships.contains_key(name) {
|
||||||
|
@ -47,7 +48,7 @@ pub fn codegen(
|
||||||
|
|
||||||
values.push(quote!(
|
values.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#name: &#mut_ #name
|
#name: &#mut_ #mangled_name
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
// Owned by someone else
|
// Owned by someone else
|
||||||
|
@ -60,7 +61,7 @@ pub fn codegen(
|
||||||
|
|
||||||
values.push(quote!(
|
values.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#name: &mut #name
|
#name: &mut #mangled_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -115,9 +116,9 @@ pub fn codegen(
|
||||||
let is_late = expr.is_none();
|
let is_late = expr.is_none();
|
||||||
if is_late {
|
if is_late {
|
||||||
let expr = if mut_.is_some() {
|
let expr = if mut_.is_some() {
|
||||||
quote!(&mut *#name.as_mut_ptr())
|
quote!(&mut *#mangled_name.as_mut_ptr())
|
||||||
} else {
|
} else {
|
||||||
quote!(&*#name.as_ptr())
|
quote!(&*#mangled_name.as_ptr())
|
||||||
};
|
};
|
||||||
|
|
||||||
values.push(quote!(
|
values.push(quote!(
|
||||||
|
@ -127,7 +128,7 @@ pub fn codegen(
|
||||||
} else {
|
} else {
|
||||||
values.push(quote!(
|
values.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#name: &#mut_ #name
|
#name: &#mut_ #mangled_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{format_ident, quote};
|
use quote::quote;
|
||||||
use rtic_syntax::{ast::App, Context};
|
use rtic_syntax::{ast::App, Context};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -22,13 +22,10 @@ pub fn codegen(
|
||||||
Vec<TokenStream2>,
|
Vec<TokenStream2>,
|
||||||
// user_software_tasks -- the `#[task]` functions written by the user
|
// user_software_tasks -- the `#[task]` functions written by the user
|
||||||
Vec<TokenStream2>,
|
Vec<TokenStream2>,
|
||||||
// user_software_tasks_imports -- the imports for `#[task]` functions written by the user
|
|
||||||
Vec<TokenStream2>,
|
|
||||||
) {
|
) {
|
||||||
let mut mod_app = vec![];
|
let mut mod_app = vec![];
|
||||||
let mut root = vec![];
|
let mut root = vec![];
|
||||||
let mut user_tasks = vec![];
|
let mut user_tasks = vec![];
|
||||||
let mut software_tasks_imports = vec![];
|
|
||||||
|
|
||||||
for (name, task) in &app.software_tasks {
|
for (name, task) in &app.software_tasks {
|
||||||
let inputs = &task.inputs;
|
let inputs = &task.inputs;
|
||||||
|
@ -93,13 +90,6 @@ pub fn codegen(
|
||||||
analysis,
|
analysis,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add resources to imports
|
|
||||||
let name_res = format_ident!("{}Resources", name);
|
|
||||||
software_tasks_imports.push(quote!(
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name_res;
|
|
||||||
));
|
|
||||||
|
|
||||||
root.push(item);
|
root.push(item);
|
||||||
|
|
||||||
mod_app.push(constructor);
|
mod_app.push(constructor);
|
||||||
|
@ -129,11 +119,6 @@ pub fn codegen(
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
software_tasks_imports.push(quote!(
|
|
||||||
#(#cfgs)*
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
use super::#name;
|
|
||||||
));
|
|
||||||
|
|
||||||
root.push(module::codegen(
|
root.push(module::codegen(
|
||||||
Context::SoftwareTask(name),
|
Context::SoftwareTask(name),
|
||||||
|
@ -144,5 +129,5 @@ pub fn codegen(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
(mod_app, root, user_tasks, software_tasks_imports)
|
(mod_app, root, user_tasks)
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,14 @@ pub fn late_resources_ident(init: &Ident) -> Ident {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Mangle an ident
|
||||||
|
pub fn mangle_ident(ident: &Ident) -> Ident {
|
||||||
|
Ident::new(
|
||||||
|
&format!("__rtic_internal_{}", ident.to_string()),
|
||||||
|
Span::call_site(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn link_section_index() -> usize {
|
fn link_section_index() -> usize {
|
||||||
static INDEX: AtomicUsize = AtomicUsize::new(0);
|
static INDEX: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue