Skip to content
Snippets Groups Projects
Commit 235e63a9 authored by Jorge Aparicio's avatar Jorge Aparicio
Browse files

adapt to changes in cortex-m-rtfm

parent 0c0d52ac
No related branches found
No related tags found
No related merge requests found
Showing with 52 additions and 30 deletions
//! Blinky using `await!` //! Blinky using `await!`
#![allow(unreachable_code)] // for the `await!` macro #![allow(unreachable_code)] // for the `await!` macro
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(used)] #![feature(used)]
......
//! Blocking version of blinky //! Blocking version of blinky
#![allow(unreachable_code)] // for the `block!` macro #![allow(unreachable_code)] // for the `block!` macro
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(used)] #![feature(used)]
......
//! Blinky using futures //! Blinky using futures
#![allow(unreachable_code)] // for the `try_nb!` macro #![allow(unreachable_code)] // for the `try_nb!` macro
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(used)] #![feature(used)]
......
//! Blinks the user LED //! Blinks the user LED
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -42,14 +44,14 @@ fn idle() -> ! { ...@@ -42,14 +44,14 @@ fn idle() -> ! {
} }
// TASKS // TASKS
task!(SYS_TICK, blink, Local { task!(SYS_TICK, blink, Locals {
state: bool = false; static STATE: bool = false;
}); });
fn blink(_t: Threshold, l: &mut Local, _r: SYS_TICK::Resources) { fn blink(_t: &mut Threshold, l: &mut Locals, _r: SYS_TICK::Resources) {
l.state = !l.state; *l.STATE = !*l.STATE;
if l.state { if *l.STATE {
Green.on(); Green.on();
} else { } else {
Green.off(); Green.off();
......
//! Input capture using TIM1 //! Input capture using TIM1
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -36,7 +37,7 @@ fn idle(r: idle::Resources) -> ! { ...@@ -36,7 +37,7 @@ fn idle(r: idle::Resources) -> ! {
const CHANNELS: [Channel; 4] = const CHANNELS: [Channel; 4] =
[Channel::_1, Channel::_2, Channel::_3, Channel::_4]; [Channel::_1, Channel::_2, Channel::_3, Channel::_4];
let capture = Capture(r.TIM1); let capture = Capture(&**r.TIM1);
for c in &CHANNELS { for c in &CHANNELS {
capture.enable(*c); capture.enable(*c);
......
//! Input capture using TIM2 //! Input capture using TIM2
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -36,7 +37,7 @@ fn idle(r: idle::Resources) -> ! { ...@@ -36,7 +37,7 @@ fn idle(r: idle::Resources) -> ! {
const CHANNELS: [Channel; 4] = const CHANNELS: [Channel; 4] =
[Channel::_1, Channel::_2, Channel::_3, Channel::_4]; [Channel::_1, Channel::_2, Channel::_3, Channel::_4];
let capture = Capture(r.TIM2); let capture = Capture(&**r.TIM2);
for c in &CHANNELS { for c in &CHANNELS {
capture.enable(*c); capture.enable(*c);
......
//! Input capture using TIM3 //! Input capture using TIM3
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -35,7 +36,7 @@ fn init(p: init::Peripherals) { ...@@ -35,7 +36,7 @@ fn init(p: init::Peripherals) {
fn idle(r: idle::Resources) -> ! { fn idle(r: idle::Resources) -> ! {
const CHANNELS: [Channel; 2] = [Channel::_1, Channel::_2]; const CHANNELS: [Channel; 2] = [Channel::_1, Channel::_2];
let capture = Capture(r.TIM3); let capture = Capture(&**r.TIM3);
for c in &CHANNELS { for c in &CHANNELS {
capture.enable(*c); capture.enable(*c);
......
//! Input capture using TIM4 //! Input capture using TIM4
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -36,7 +37,7 @@ fn idle(r: idle::Resources) -> ! { ...@@ -36,7 +37,7 @@ fn idle(r: idle::Resources) -> ! {
const CHANNELS: [Channel; 4] = const CHANNELS: [Channel; 4] =
[Channel::_1, Channel::_2, Channel::_3, Channel::_4]; [Channel::_1, Channel::_2, Channel::_3, Channel::_4];
let capture = Capture(r.TIM4); let capture = Capture(&**r.TIM4);
for c in &CHANNELS { for c in &CHANNELS {
capture.enable(*c); capture.enable(*c);
......
//! Two concurrent tasks using `await!` //! Two concurrent tasks using `await!`
#![allow(unreachable_code)] // for the `await!` macro #![allow(unreachable_code)] // for the `await!` macro
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(used)] #![feature(used)]
......
//! Two concurrent tasks using futures //! Two concurrent tasks using futures
#![allow(unreachable_code)] // for the `try_nb!` macro #![allow(unreachable_code)] // for the `try_nb!` macro
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(used)] #![feature(used)]
......
//! Serial loopback //! Serial loopback
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -14,7 +16,7 @@ use blue_pill::prelude::*; ...@@ -14,7 +16,7 @@ use blue_pill::prelude::*;
use blue_pill::serial::Event; use blue_pill::serial::Event;
use blue_pill::time::Hertz; use blue_pill::time::Hertz;
use blue_pill::{Serial, Timer, stm32f103xx}; use blue_pill::{Serial, Timer, stm32f103xx};
use rtfm::{Threshold, app}; use rtfm::{app, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f103xx,
...@@ -62,17 +64,17 @@ fn idle() -> ! { ...@@ -62,17 +64,17 @@ fn idle() -> ! {
// TASKS // TASKS
task!(TIM2, blinky, Local { task!(TIM2, blinky, Local {
state: bool = false; static STATE: bool = false;
}); });
fn blinky(_t: Threshold, l: &mut Local, r: TIM2::Resources) { fn blinky(_t: &mut Threshold, l: &mut Local, r: TIM2::Resources) {
let timer = Timer(r.TIM2); let timer = Timer(&**r.TIM2);
timer.wait().unwrap(); timer.wait().unwrap();
l.state = !l.state; *l.STATE = !*l.STATE;
if l.state { if *l.STATE {
Green.on(); Green.on();
} else { } else {
Green.off(); Green.off();
...@@ -81,8 +83,8 @@ fn blinky(_t: Threshold, l: &mut Local, r: TIM2::Resources) { ...@@ -81,8 +83,8 @@ fn blinky(_t: Threshold, l: &mut Local, r: TIM2::Resources) {
task!(USART1, loopback); task!(USART1, loopback);
fn loopback(_t: Threshold, r: USART1::Resources) { fn loopback(_t: &mut Threshold, r: USART1::Resources) {
let serial = Serial(r.USART1); let serial = Serial(&**r.USART1);
let byte = serial.read().unwrap(); let byte = serial.read().unwrap();
serial.write(byte).unwrap(); serial.write(byte).unwrap();
......
//! CPU usage monitor //! CPU usage monitor
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(proc_macro)] #![feature(proc_macro)]
...@@ -17,13 +18,13 @@ use blue_pill::Timer; ...@@ -17,13 +18,13 @@ use blue_pill::Timer;
use blue_pill::stm32f103xx; use blue_pill::stm32f103xx;
use blue_pill::time::Hertz; use blue_pill::time::Hertz;
use blue_pill::prelude::*; use blue_pill::prelude::*;
use rtfm::{Threshold, app}; use rtfm::{app, Resource, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f103xx,
resources: { resources: {
SLEEP_TIME: u32 = 0; static SLEEP_TIME: u32 = 0;
}, },
idle: { idle: {
...@@ -53,7 +54,7 @@ fn init(p: init::Peripherals, _r: init::Resources) { ...@@ -53,7 +54,7 @@ fn init(p: init::Peripherals, _r: init::Resources) {
} }
// IDLE LOOP // IDLE LOOP
fn idle(_t: Threshold, mut r: idle::Resources) -> ! { fn idle(_t: &mut Threshold, mut r: idle::Resources) -> ! {
loop { loop {
// For the span of this critical section the processor will not service // For the span of this critical section the processor will not service
// interrupts (tasks) // interrupts (tasks)
...@@ -77,8 +78,8 @@ fn idle(_t: Threshold, mut r: idle::Resources) -> ! { ...@@ -77,8 +78,8 @@ fn idle(_t: Threshold, mut r: idle::Resources) -> ! {
task!(TIM2, periodic); task!(TIM2, periodic);
fn periodic(_t: Threshold, r: TIM2::Resources) { fn periodic(_t: &mut Threshold, r: TIM2::Resources) {
let timer = Timer(r.TIM2); let timer = Timer(&**r.TIM2);
timer.wait().unwrap(); timer.wait().unwrap();
......
//! Sets PB12 high //! Sets PB12 high
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
......
//! Prints "Hello" and then "World" on the OpenOCD console //! Prints "Hello" and then "World" on the OpenOCD console
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(proc_macro)] #![feature(proc_macro)]
...@@ -19,7 +20,7 @@ app! { ...@@ -19,7 +20,7 @@ app! {
device: blue_pill::stm32f103xx, device: blue_pill::stm32f103xx,
resources: { resources: {
HSTDOUT: Option<HStdout> = None; static HSTDOUT: Option<HStdout> = None;
}, },
idle: { idle: {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
//! World //! World
//! ``` //! ```
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
......
//! Turns the user LED on //! Turns the user LED on
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
......
//! Serial loopback via USART1 //! Serial loopback via USART1
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -12,7 +13,7 @@ use blue_pill::Serial; ...@@ -12,7 +13,7 @@ use blue_pill::Serial;
use blue_pill::prelude::*; use blue_pill::prelude::*;
use blue_pill::serial::Event; use blue_pill::serial::Event;
use blue_pill::time::Hertz; use blue_pill::time::Hertz;
use rtfm::{Threshold, app}; use rtfm::{app, Threshold};
// CONFIGURATION // CONFIGURATION
pub const BAUD_RATE: Hertz = Hertz(115_200); pub const BAUD_RATE: Hertz = Hertz(115_200);
...@@ -44,8 +45,8 @@ fn idle() -> ! { ...@@ -44,8 +45,8 @@ fn idle() -> ! {
task!(USART1, loopback); task!(USART1, loopback);
fn loopback(_t: Threshold, r: USART1::Resources) { fn loopback(_t: &mut Threshold, r: USART1::Resources) {
let serial = Serial(r.USART1); let serial = Serial(&**r.USART1);
let byte = serial.read().unwrap(); let byte = serial.read().unwrap();
serial.write(byte).unwrap(); serial.write(byte).unwrap();
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
//! - '-' decrease duty by 1 //! - '-' decrease duty by 1
//! - '/' decrease duty by a factor of 2 //! - '/' decrease duty by a factor of 2
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -18,7 +19,7 @@ use core::u16; ...@@ -18,7 +19,7 @@ use core::u16;
use blue_pill::prelude::*; use blue_pill::prelude::*;
use blue_pill::time::Hertz; use blue_pill::time::Hertz;
use blue_pill::{Channel, Pwm, Serial}; use blue_pill::{Channel, Pwm, Serial};
use rtfm::{Threshold, app}; use rtfm::{app, Threshold};
const BAUD_RATE: Hertz = Hertz(115_200); const BAUD_RATE: Hertz = Hertz(115_200);
const FREQUENCY: Hertz = Hertz(1_000); const FREQUENCY: Hertz = Hertz(1_000);
...@@ -55,9 +56,9 @@ fn idle() -> ! { ...@@ -55,9 +56,9 @@ fn idle() -> ! {
task!(USART1, rx); task!(USART1, rx);
fn rx(_t: Threshold, r: USART1::Resources) { fn rx(_t: &mut Threshold, r: USART1::Resources) {
let pwm = Pwm(r.TIM2); let pwm = Pwm(&**r.TIM2);
let serial = Serial(r.USART1); let serial = Serial(&**r.USART1);
let byte = serial.read().unwrap(); let byte = serial.read().unwrap();
// Echo back to signal we are alive // Echo back to signal we are alive
......
//! Output a PWM with a duty cycle of ~6% on all the channels of TIM1 //! Output a PWM with a duty cycle of ~6% on all the channels of TIM1
// FIXME doesn't seem to work :-( // FIXME doesn't seem to work :-(
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
......
//! Output a PWM with a duty cycle of ~6% on all the channels of TIM2 //! Output a PWM with a duty cycle of ~6% on all the channels of TIM2
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment