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

adapt to changes in cortex-m-rtfm

parent 3366617b
Branches
No related tags found
No related merge requests found
//! Turns the user LED on
//! Blinks the user LED
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m;
#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
use blue_pill::Timer;
use blue_pill::led::{self, Green};
use blue_pill::prelude::*;
use blue_pill::time::Hertz;
use rtfm::Threshold;
use cortex_m::peripheral::SystClkSource;
use rtfm::{app, Threshold};
rtfm! {
app! {
device: blue_pill::stm32f103xx,
resources: {},
init: {
path: init,
},
idle: {
path: idle,
},
tasks: {
TIM2: {
SYS_TICK: {
priority: 1,
enabled: true,
resources: [TIM2],
},
},
}
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1);
// INITIALIZATION PHASE
fn init(p: init::Peripherals) {
let timer = Timer(p.TIM2);
led::init(p.GPIOC, p.RCC);
timer.init(FREQUENCY.invert(), p.RCC);
timer.resume();
p.SYST.set_clock_source(SystClkSource::Core);
p.SYST.set_reload(8_000_000); // 1s
p.SYST.enable_interrupt();
p.SYST.enable_counter();
}
// IDLE LOOP
......@@ -59,15 +42,11 @@ fn idle() -> ! {
}
// TASKS
task!(TIM2, blink, Local {
task!(SYS_TICK, blink, Local {
state: bool = false;
});
fn blink(_t: Threshold, l: &mut Local, r: TIM2::Resources) {
let timer = Timer(r.TIM2);
timer.wait().unwrap();
fn blink(_t: Threshold, l: &mut Local, _r: SYS_TICK::Resources) {
l.state = !l.state;
if l.state {
......
......
//! Input capture using TIM1
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(iprint, iprintln)]
......@@ -14,19 +13,15 @@ extern crate nb;
use blue_pill::prelude::*;
use blue_pill::time::Milliseconds;
use blue_pill::{Capture, Channel};
use rtfm::app;
// CONFIGURATION
const RESOLUTION: Milliseconds = Milliseconds(1);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
resources: [ITM, TIM1],
},
}
......
......
//! Input capture using TIM2
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(iprint, iprintln)]
......@@ -14,19 +13,15 @@ extern crate nb;
use blue_pill::time::Milliseconds;
use blue_pill::{Capture, Channel};
use blue_pill::prelude::*;
use rtfm::app;
// CONFIGURATION
const RESOLUTION: Milliseconds = Milliseconds(1);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
resources: [ITM, TIM2],
},
}
......
......
//! Input capture using TIM3
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(iprint, iprintln)]
......@@ -14,19 +13,15 @@ extern crate nb;
use blue_pill::prelude::*;
use blue_pill::time::Milliseconds;
use blue_pill::{Capture, Channel};
use rtfm::app;
// CONFIGURATION
const RESOLUTION: Milliseconds = Milliseconds(1);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
resources: [ITM, TIM3],
},
}
......
......
//! Input capture using TIM4
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use]
......@@ -14,19 +13,15 @@ extern crate nb;
use blue_pill::time::Milliseconds;
use blue_pill::{Capture, Channel};
use blue_pill::prelude::*;
use rtfm::app;
// CONFIGURATION
const RESOLUTION: Milliseconds = Milliseconds(1);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
resources: [ITM, TIM4],
},
}
......
......
//! Serial loopback
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
......@@ -15,25 +14,18 @@ use blue_pill::prelude::*;
use blue_pill::serial::Event;
use blue_pill::time::Hertz;
use blue_pill::{Serial, Timer, stm32f103xx};
use rtfm::Threshold;
use rtfm::{Threshold, app};
rtfm! {
app! {
device: stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
tasks: {
TIM2: {
priority: 1,
enabled: true,
resources: [TIM2],
},
USART1: {
priority: 1,
enabled: true,
......
......
......@@ -2,9 +2,8 @@
#![deny(warnings)]
#![feature(const_fn)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
......@@ -18,21 +17,16 @@ use blue_pill::Timer;
use blue_pill::stm32f103xx;
use blue_pill::time::Hertz;
use blue_pill::prelude::*;
use rtfm::Threshold;
use rtfm::{Threshold, app};
rtfm! {
app! {
device: stm32f103xx,
resources: {
SLEEP_TIME: u32 = 0;
},
init: {
path: init,
},
idle: {
path: idle,
resources: [DWT, SLEEP_TIME],
},
......
......
//! Set PB12 high
//! Sets PB12 high
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m_rtfm as rtfm;
use blue_pill::gpio::{self, PB12};
use rtfm::app;
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
}
fn init(p: init::Peripherals) {
......
......
......@@ -2,9 +2,8 @@
#![deny(warnings)]
#![feature(const_fn)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m;
......@@ -14,20 +13,16 @@ extern crate cortex_m_semihosting;
use core::fmt::Write;
use cortex_m_semihosting::hio::{self, HStdout};
use rtfm::app;
rtfm! {
app! {
device: blue_pill::stm32f103xx,
resources: {
HSTDOUT: Option<HStdout> = None;
},
init: {
path: init,
},
idle: {
path: idle,
resources: [HSTDOUT],
},
}
......
......
......@@ -19,24 +19,21 @@
//! World
//! ```
#![feature(plugin)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(iprint, iprintln)]
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
rtfm! {
device: blue_pill::stm32f103xx,
use rtfm::app;
init: {
path: init,
},
app! {
device: blue_pill::stm32f103xx,
idle: {
path: idle,
resources: [ITM],
},
}
......
......
//! Turns the user LED on
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m_rtfm as rtfm;
use blue_pill::led::{self, Green};
use rtfm::app;
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
}
fn init(p: init::Peripherals) {
......
......
//! Serial loopback via USART1
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(task)]
......@@ -13,22 +12,14 @@ use blue_pill::Serial;
use blue_pill::prelude::*;
use blue_pill::serial::Event;
use blue_pill::time::Hertz;
use rtfm::Threshold;
use rtfm::{Threshold, app};
// CONFIGURATION
pub const BAUD_RATE: Hertz = Hertz(115_200);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
tasks: {
USART1: {
enabled: true,
......
......
......@@ -6,9 +6,8 @@
//! - '/' decrease duty by a factor of 2
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(task)]
......@@ -19,23 +18,14 @@ use core::u16;
use blue_pill::prelude::*;
use blue_pill::time::Hertz;
use blue_pill::{Channel, Pwm, Serial};
use rtfm::Threshold;
use rtfm::{Threshold, app};
// CONFIGURATION
const BAUD_RATE: Hertz = Hertz(115_200);
const FREQUENCY: Hertz = Hertz(1_000);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
tasks: {
USART1: {
enabled: true,
......
......
......@@ -2,9 +2,8 @@
// FIXME doesn't seem to work :-(
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m_rtfm as rtfm;
......@@ -12,20 +11,12 @@ extern crate cortex_m_rtfm as rtfm;
use blue_pill::prelude::*;
use blue_pill::time::Hertz;
use blue_pill::{Channel, Pwm};
use rtfm::app;
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1_000);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
}
fn init(p: init::Peripherals) {
......
......
//! Output a PWM with a duty cycle of ~6% on all the channels of TIM2
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m_rtfm as rtfm;
......@@ -11,20 +10,12 @@ extern crate cortex_m_rtfm as rtfm;
use blue_pill::prelude::*;
use blue_pill::time::Hertz;
use blue_pill::{Channel, Pwm};
use rtfm::app;
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1_000); // Hz
const FREQUENCY: Hertz = Hertz(1_000);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
}
fn init(p: init::Peripherals) {
......
......
//! Output a PWM with a duty cycle of ~6% on all the channels of TIM3
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m_rtfm as rtfm;
......@@ -11,20 +10,12 @@ extern crate cortex_m_rtfm as rtfm;
use blue_pill::{Channel, Pwm};
use blue_pill::time::Hertz;
use blue_pill::prelude::*;
use rtfm::app;
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1_000);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
}
fn init(p: init::Peripherals) {
......
......
//! Output a PWM with a duty cycle of ~6% on all the channels of TIM4
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
extern crate cortex_m_rtfm as rtfm;
......@@ -11,20 +10,12 @@ extern crate cortex_m_rtfm as rtfm;
use blue_pill::prelude::*;
use blue_pill::time::Hertz;
use blue_pill::{Channel, Pwm};
use rtfm::app;
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1_000);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
}
fn init(p: init::Peripherals) {
......
......
......@@ -3,9 +3,8 @@
//! Periodically reports the readings of the QEI
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(iprint, iprintln)]
......@@ -16,22 +15,14 @@ extern crate cortex_m_rtfm as rtfm;
use blue_pill::prelude::*;
use blue_pill::time::Hertz;
use blue_pill::{Qei, Timer};
use rtfm::Threshold;
use rtfm::{Threshold, app};
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
tasks: {
TIM4: {
enabled: true,
......
......
......@@ -3,9 +3,8 @@
//! Periodically reports the readings of the QEI
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(iprint, iprintln)]
......@@ -16,22 +15,13 @@ extern crate cortex_m_rtfm as rtfm;
use blue_pill::prelude::*;
use blue_pill::time::Hertz;
use blue_pill::{Qei, Timer};
use rtfm::Threshold;
use rtfm::{Threshold, app};
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
tasks: {
TIM4: {
enabled: true,
......
......
......@@ -3,9 +3,8 @@
//! Periodically reports the readings of the QEI
#![deny(warnings)]
#![feature(plugin)]
#![feature(proc_macro)]
#![no_std]
#![plugin(cortex_m_rtfm_macros)]
extern crate blue_pill;
#[macro_use(iprint, iprintln)]
......@@ -16,22 +15,13 @@ extern crate cortex_m_rtfm as rtfm;
use blue_pill::time::Hertz;
use blue_pill::{Qei, Timer};
use blue_pill::prelude::*;
use rtfm::Threshold;
use rtfm::{Threshold, app};
// CONFIGURATION
const FREQUENCY: Hertz = Hertz(1);
rtfm! {
app! {
device: blue_pill::stm32f103xx,
init: {
path: init,
},
idle: {
path: idle,
},
tasks: {
TIM4: {
enabled: true,
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment