Updated examples

More work
This commit is contained in:
Emil Fresk 2020-10-15 18:50:17 +02:00
parent 355cb82d06
commit f96b25fdf2
45 changed files with 176 additions and 214 deletions

View file

@ -5,13 +5,14 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
// NOTE: does NOT properly work on QEMU
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[init]
fn init(cx: init::Context) -> init::LateResources {
// omitted: initialization of `CYCCNT`

View file

@ -5,13 +5,14 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
// `examples/interrupt.rs` rewritten to use `binds`
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[init]
fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::UART0);

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[init]
fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::UART0);

View file

@ -5,13 +5,14 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
#[cfg(debug_assertions)]
use cortex_m_semihosting::hprintln;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::debug;
#[cfg(debug_assertions)]
use cortex_m_semihosting::hprintln;
#[resources]
struct Resources {
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::hprintln;
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::hprintln;
use lm3s6965::Interrupt;
#[resources]
struct Resources {
// Some resources to work with

View file

@ -6,10 +6,10 @@
#![no_std]
use panic_semihosting as _;
use rtic::cyccnt::U32Ext;
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
use rtic::cyccnt::U32Ext;
#[resources]
struct Resources {

View file

@ -5,13 +5,16 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use cortex_m_semihosting::hprintln;
use panic_semihosting as _;
use rtic::{Exclusive, Mutex};
use rtic::Mutex;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use rtic::Exclusive;
#[resources]
struct Resources {
#[init(0)]

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[init]
fn init(_: init::Context) -> init::LateResources {
// Pends the UART0 interrupt but its handler won't run until *after*

View file

@ -5,11 +5,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
#[init]
fn init(_: init::Context) -> init::LateResources {
hprintln!("init").unwrap();

View file

@ -5,11 +5,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965, peripherals = true)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
#[init]
fn init(cx: init::Context) -> init::LateResources {
static mut X: u32 = 0;

View file

@ -5,21 +5,18 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use heapless::{
consts::*,
i,
spsc::{Consumer, Producer, Queue},
};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use heapless::{
consts::*,
spsc::{Consumer, Producer},
i,
spsc::{Consumer, Producer, Queue},
};
use lm3s6965::Interrupt;
// Late resources
#[resources]
struct Resources {

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[resources]
struct Resources {
#[init(0)]

View file

@ -5,11 +5,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
#[init]
fn init(_: init::Context) -> init::LateResources {
foo::spawn(/* no message */).unwrap();

View file

@ -6,8 +6,6 @@
#![no_std]
use core::marker::PhantomData;
use cortex_m_semihosting::debug;
use panic_halt as _;
pub struct NotSync {
@ -18,6 +16,7 @@ pub struct NotSync {
mod app {
use super::NotSync;
use core::marker::PhantomData;
use cortex_m_semihosting::debug;
#[resources]
struct Resources {

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[resources]
struct Resources {
key: u32,

View file

@ -5,15 +5,15 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::hprintln;
use panic_semihosting as _;
use rtic::cyccnt::{Instant, U32Ext};
const PERIOD: u32 = 8_000_000;
// NOTE: does NOT work on QEMU!
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
use cortex_m_semihosting::hprintln;
use rtic::cyccnt::{Instant, U32Ext};
const PERIOD: u32 = 8_000_000;
#[init]
fn init(cx: init::Context) -> init::LateResources {

View file

@ -3,11 +3,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::debug;
#[init]
fn init(_: init::Context) -> init::LateResources {
assert!(cortex_m::Peripherals::take().is_none());

View file

@ -5,12 +5,10 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use heapless::{
pool,
pool::singleton::{Box, Pool},
};
use lm3s6965::Interrupt;
use panic_semihosting as _;
use rtic::app;
@ -19,7 +17,9 @@ pool!(P: [u8; 128]);
#[app(device = lm3s6965)]
mod app {
use crate::Box;
use crate::{Box, Pool};
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
// Import the memory pool into scope
use super::P;

View file

@ -3,13 +3,14 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
use rtic::app;
#[app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[init]
fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::GPIOA);

View file

@ -5,11 +5,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
#[init]
fn init(_: init::Context) -> init::LateResources {
foo::spawn().unwrap();

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[resources]
struct Resources {
// A resource

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
#[resources]
struct Resources {
// A resource

View file

@ -5,14 +5,15 @@
#![no_main]
#![no_std]
use cortex_m::peripheral::DWT;
use cortex_m_semihosting::hprintln;
use panic_halt as _;
use rtic::cyccnt::{Instant, U32Ext as _};
// NOTE: does NOT work on QEMU!
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
use cortex_m::peripheral::DWT;
use cortex_m_semihosting::hprintln;
use rtic::cyccnt::{Instant, U32Ext as _};
#[init()]
fn init(mut cx: init::Context) -> init::LateResources {
// Initialize (enable) the monotonic timer (CYCCNT)

View file

@ -5,8 +5,6 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use lm3s6965::Interrupt;
use panic_halt as _;
use rtic::app;
@ -14,6 +12,8 @@ pub struct MustBeSend;
#[app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::debug;
use lm3s6965::Interrupt;
use super::MustBeSend;
#[resources]

View file

@ -5,11 +5,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
#[init]
fn init(_c: init::Context) -> init::LateResources {
foo::spawn(1, 2).unwrap();

View file

@ -5,11 +5,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
#[init]
fn init(_c: init::Context) -> init::LateResources {
foo::spawn(1, 2).unwrap();

View file

@ -5,20 +5,18 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use heapless::{
consts::*,
i,
spsc::{Consumer, Producer, Queue},
};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use crate::U4;
use crate::{Consumer, Producer};
use cortex_m_semihosting::{debug, hprintln};
use heapless::{
consts::*,
i,
spsc::{Consumer, Producer, Queue},
};
use lm3s6965::Interrupt;
// Late resources
#[resources]

View file

@ -17,18 +17,18 @@ mod app {
// Cortex-M exception
#[task(binds = SVCall)]
fn foo(c: foo::Context) {
foo_trampoline(c)
crate::foo_trampoline(c)
}
// LM3S6965 interrupt
#[task(binds = UART0)]
fn bar(c: bar::Context) {
bar_trampoline(c)
crate::bar_trampoline(c)
}
}
#[allow(dead_code)]
fn foo_trampoline(_: foo::Context) {}
fn foo_trampoline(_: app::foo::Context) {}
#[allow(dead_code)]
fn bar_trampoline(_: bar::Context) {}
fn bar_trampoline(_: app::bar::Context) {}

View file

@ -3,11 +3,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::debug;
#[init]
fn init(_: init::Context) -> init::LateResources {
rtic::pend(lm3s6965::Interrupt::UART0);

View file

@ -3,11 +3,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::debug;
#[init]
fn init(_: init::Context) -> init::LateResources {
init::LateResources {}

View file

@ -3,11 +3,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::debug;
#[init]
fn init(_: init::Context) -> init::LateResources {
debug::exit(debug::EXIT_SUCCESS);

View file

@ -14,6 +14,7 @@ pub struct NotSend {
#[rtic::app(device = lm3s6965)]
mod app {
use super::NotSend;
use core::marker::PhantomData;
#[resources]
struct Resources {

View file

@ -6,10 +6,11 @@
#![no_std]
use panic_halt as _;
use rtic::cyccnt::{Instant, U32Ext as _};
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
use rtic::cyccnt::{Instant, U32Ext as _};
#[init]
fn init(c: init::Context) -> init::LateResources {
let _: Result<(), ()> = foo::schedule(c.start + 10.cycles());

View file

@ -3,11 +3,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::debug;
#[init]
fn init(_: init::Context) -> init::LateResources {
taskmain::spawn().ok();

View file

@ -5,11 +5,12 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
use cortex_m_semihosting::{debug, hprintln};
#[init]
fn init(_: init::Context) -> init::LateResources {
foo::spawn().unwrap();

View file

@ -5,12 +5,13 @@
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use panic_semihosting as _;
use rtic::cyccnt;
#[rtic::app(device = lm3s6965, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
use cortex_m_semihosting::debug;
use rtic::cyccnt;
#[resources]
struct Resources {
#[init(0)]