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