From 0c0d52acaf34d2cc0dbe661d01e37c3fe6aa7165 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio <jorge@japaric.io> Date: Fri, 14 Jul 2017 21:03:12 -0500 Subject: [PATCH] adapt to changes in cortex-m-rtfm --- examples/blinky.rs | 49 +++++++++++---------------------------- examples/capture1.rs | 11 +++------ examples/capture2.rs | 11 +++------ examples/capture3.rs | 11 +++------ examples/capture4.rs | 11 +++------ examples/concurrent.rs | 16 ++++--------- examples/cpu.rs | 12 +++------- examples/gpio.rs | 16 ++++--------- examples/hello.rs | 11 +++------ examples/itm.rs | 13 ++++------- examples/led.rs | 14 +++-------- examples/loopback.rs | 15 +++--------- examples/pwm-control.rs | 16 +++---------- examples/pwm1.rs | 15 +++--------- examples/pwm2.rs | 17 ++++---------- examples/pwm3.rs | 15 +++--------- examples/pwm4.rs | 15 +++--------- examples/qei1.rs | 15 +++--------- examples/qei2.rs | 16 +++---------- examples/qei3.rs | 16 +++---------- examples/qei4.rs | 16 +++---------- examples/spi1.rs | 12 +++------- examples/spi2.rs | 11 +++------ examples/usart1-rx-dma.rs | 16 +++---------- examples/usart1-tx-dma.rs | 16 +++---------- examples/usart1.rs | 14 +++-------- examples/usart2.rs | 14 +++-------- examples/usart3.rs | 16 ++++--------- examples/wait1.rs | 12 +++------- examples/wait2.rs | 12 +++------- examples/wait3.rs | 12 +++------- examples/wait4.rs | 12 +++------- examples/ws2812.rs | 11 +++------ 33 files changed, 116 insertions(+), 373 deletions(-) diff --git a/examples/blinky.rs b/examples/blinky.rs index b911a9a..baaa52c 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -1,53 +1,36 @@ -//! 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 { diff --git a/examples/capture1.rs b/examples/capture1.rs index 5f9cc8b..be63206 100644 --- a/examples/capture1.rs +++ b/examples/capture1.rs @@ -1,9 +1,8 @@ //! 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], }, } diff --git a/examples/capture2.rs b/examples/capture2.rs index 8005c9b..e81137f 100644 --- a/examples/capture2.rs +++ b/examples/capture2.rs @@ -1,9 +1,8 @@ //! 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], }, } diff --git a/examples/capture3.rs b/examples/capture3.rs index 5d35e11..e806202 100644 --- a/examples/capture3.rs +++ b/examples/capture3.rs @@ -1,9 +1,8 @@ //! 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], }, } diff --git a/examples/capture4.rs b/examples/capture4.rs index b08142a..2074c96 100644 --- a/examples/capture4.rs +++ b/examples/capture4.rs @@ -1,9 +1,8 @@ //! 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], }, } diff --git a/examples/concurrent.rs b/examples/concurrent.rs index 26a1d9f..004a219 100644 --- a/examples/concurrent.rs +++ b/examples/concurrent.rs @@ -1,9 +1,8 @@ //! 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, diff --git a/examples/cpu.rs b/examples/cpu.rs index a86bde9..d7804c3 100644 --- a/examples/cpu.rs +++ b/examples/cpu.rs @@ -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], }, diff --git a/examples/gpio.rs b/examples/gpio.rs index a246d94..c9d4348 100644 --- a/examples/gpio.rs +++ b/examples/gpio.rs @@ -1,25 +1,17 @@ -//! 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) { diff --git a/examples/hello.rs b/examples/hello.rs index 3bf5933..27d3e35 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -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], }, } diff --git a/examples/itm.rs b/examples/itm.rs index 106193c..76dc7b9 100644 --- a/examples/itm.rs +++ b/examples/itm.rs @@ -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], }, } diff --git a/examples/led.rs b/examples/led.rs index b890356..1e8b552 100644 --- a/examples/led.rs +++ b/examples/led.rs @@ -1,25 +1,17 @@ //! 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) { diff --git a/examples/loopback.rs b/examples/loopback.rs index 00e675b..a2981d9 100644 --- a/examples/loopback.rs +++ b/examples/loopback.rs @@ -1,9 +1,8 @@ //! 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, diff --git a/examples/pwm-control.rs b/examples/pwm-control.rs index 142aab6..4b92475 100644 --- a/examples/pwm-control.rs +++ b/examples/pwm-control.rs @@ -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, diff --git a/examples/pwm1.rs b/examples/pwm1.rs index 0bda209..27f89e2 100644 --- a/examples/pwm1.rs +++ b/examples/pwm1.rs @@ -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) { diff --git a/examples/pwm2.rs b/examples/pwm2.rs index 5d9afed..b90b7c6 100644 --- a/examples/pwm2.rs +++ b/examples/pwm2.rs @@ -1,9 +1,8 @@ //! 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) { diff --git a/examples/pwm3.rs b/examples/pwm3.rs index 4d0413e..514945b 100644 --- a/examples/pwm3.rs +++ b/examples/pwm3.rs @@ -1,9 +1,8 @@ //! 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) { diff --git a/examples/pwm4.rs b/examples/pwm4.rs index bdf4aa6..c32ecb2 100644 --- a/examples/pwm4.rs +++ b/examples/pwm4.rs @@ -1,9 +1,8 @@ //! 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) { diff --git a/examples/qei1.rs b/examples/qei1.rs index 97320b6..203c681 100644 --- a/examples/qei1.rs +++ b/examples/qei1.rs @@ -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, diff --git a/examples/qei2.rs b/examples/qei2.rs index f1f63a3..701f8fa 100644 --- a/examples/qei2.rs +++ b/examples/qei2.rs @@ -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, diff --git a/examples/qei3.rs b/examples/qei3.rs index d1afc67..5a28a92 100644 --- a/examples/qei3.rs +++ b/examples/qei3.rs @@ -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, diff --git a/examples/qei4.rs b/examples/qei4.rs index 728e067..e5ccb73 100644 --- a/examples/qei4.rs +++ b/examples/qei4.rs @@ -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: { TIM1_UP_TIM10: { enabled: true, diff --git a/examples/spi1.rs b/examples/spi1.rs index 2ef9b0d..e573a41 100644 --- a/examples/spi1.rs +++ b/examples/spi1.rs @@ -1,9 +1,8 @@ //! Interfacing the MPU9250 using SPI1 #![deny(warnings)] -#![feature(plugin)] +#![feature(proc_macro)] #![no_std] -#![plugin(cortex_m_rtfm_macros)] extern crate blue_pill; #[macro_use(iprint, iprintln)] @@ -12,16 +11,12 @@ extern crate cortex_m_rtfm as rtfm; use blue_pill::Spi; use blue_pill::prelude::*; +use rtfm::app; -rtfm! { +app! { device: blue_pill::stm32f103xx, - init: { - path: init, - }, - idle: { - path: idle, resources: [ITM, SPI1], }, } @@ -51,7 +46,6 @@ fn idle(r: idle::Resources) -> ! { spi.enable(); - // The SPI is buffered. We can send a few bytes while spi.send(WHO_AM_I | R).is_err() {} let _junk = loop { diff --git a/examples/spi2.rs b/examples/spi2.rs index 59e5fa8..47ea42c 100644 --- a/examples/spi2.rs +++ b/examples/spi2.rs @@ -1,9 +1,8 @@ //! Interfacing the MPU9250 using SPI2 #![deny(warnings)] -#![feature(plugin)] +#![feature(proc_macro)] #![no_std] -#![plugin(cortex_m_rtfm_macros)] extern crate blue_pill; #[macro_use(iprint, iprintln)] @@ -12,16 +11,12 @@ extern crate cortex_m_rtfm as rtfm; use blue_pill::Spi; use blue_pill::prelude::*; +use rtfm::app; -rtfm! { +app! { device: blue_pill::stm32f103xx, - init: { - path: init, - }, - idle: { - path: idle, resources: [ITM, SPI2], }, } diff --git a/examples/usart1-rx-dma.rs b/examples/usart1-rx-dma.rs index cbecbb3..041a234 100644 --- a/examples/usart1-rx-dma.rs +++ b/examples/usart1-rx-dma.rs @@ -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; #[macro_use(task)] @@ -14,26 +13,17 @@ extern crate nb; use blue_pill::Serial; use blue_pill::dma::{Buffer, Dma1Channel5}; 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, resources: { BUFFER: Buffer<[u8; 8], Dma1Channel5> = Buffer::new([0; 8]); }, - init: { - path: init, - }, - - idle: { - path: idle, - }, - tasks: { DMA1_CHANNEL5: { enabled: true, diff --git a/examples/usart1-tx-dma.rs b/examples/usart1-tx-dma.rs index 0b8ec18..c5ccc3a 100644 --- a/examples/usart1-tx-dma.rs +++ b/examples/usart1-tx-dma.rs @@ -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; #[macro_use(task)] @@ -14,26 +13,17 @@ extern crate nb; use blue_pill::Serial; use blue_pill::dma::{Buffer, Dma1Channel4}; 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, resources: { BUFFER: Buffer<[u8; 14], Dma1Channel4> = Buffer::new([0; 14]); }, - init: { - path: init, - }, - - idle: { - path: idle, - }, - tasks: { DMA1_CHANNEL4: { enabled: true, diff --git a/examples/usart1.rs b/examples/usart1.rs index 5dba7dd..b496219 100644 --- a/examples/usart1.rs +++ b/examples/usart1.rs @@ -3,9 +3,8 @@ //! Connect the TX and RX pins to run this test #![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; @@ -14,20 +13,13 @@ extern crate nb; use blue_pill::Serial; use blue_pill::prelude::*; use blue_pill::time::Hertz; +use rtfm::app; // CONFIGURATION pub const BAUD_RATE: Hertz = Hertz(115_200); -rtfm! { +app! { device: blue_pill::stm32f103xx, - - init: { - path: init, - }, - - idle: { - path: idle, - }, } fn init(p: init::Peripherals) { diff --git a/examples/usart2.rs b/examples/usart2.rs index a8482a8..55ae04e 100644 --- a/examples/usart2.rs +++ b/examples/usart2.rs @@ -3,8 +3,7 @@ //! Connect the TX and RX pins to run this test #![deny(warnings)] -#![feature(plugin)] -#![plugin(cortex_m_rtfm_macros)] +#![feature(proc_macro)] #![no_std] extern crate blue_pill; @@ -15,20 +14,13 @@ use blue_pill::Serial; use blue_pill::time::Hertz; use blue_pill::prelude::*; use nb::Error; +use rtfm::app; // CONFIGURATION pub const BAUD_RATE: Hertz = Hertz(115_200); -rtfm! { +app! { device: blue_pill::stm32f103xx, - - init: { - path: init, - }, - - idle: { - path: idle, - }, } fn init(p: init::Peripherals) { diff --git a/examples/usart3.rs b/examples/usart3.rs index afb3e7b..7559972 100644 --- a/examples/usart3.rs +++ b/examples/usart3.rs @@ -3,32 +3,24 @@ //! Connect the TX and RX pins to run this test #![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; extern crate nb; use blue_pill::Serial; -use blue_pill::time::Hertz; use blue_pill::prelude::*; +use blue_pill::time::Hertz; use nb::Error; +use rtfm::app; // CONFIGURATION pub const BAUD_RATE: Hertz = Hertz(115_200); -rtfm! { +app! { device: blue_pill::stm32f103xx, - - init: { - path: init, - }, - - idle: { - path: idle, - }, } fn init(p: init::Peripherals) { diff --git a/examples/wait1.rs b/examples/wait1.rs index 854f466..9310769 100644 --- a/examples/wait1.rs +++ b/examples/wait1.rs @@ -1,9 +1,8 @@ //! Periodic timeouts with TIM1 #![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,19 +11,14 @@ use blue_pill::Timer; use blue_pill::led::{self, Green}; use blue_pill::prelude::*; use blue_pill::time::Hertz; +use rtfm::app; -// CONFIGURATION const FREQUENCY: Hertz = Hertz(1); -rtfm! { +app! { device: blue_pill::stm32f103xx, - init: { - path: init, - }, - idle: { - path: idle, resources: [TIM1], }, } diff --git a/examples/wait2.rs b/examples/wait2.rs index 7bbf582..36af50d 100644 --- a/examples/wait2.rs +++ b/examples/wait2.rs @@ -1,9 +1,8 @@ //! Periodic timeouts with 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; @@ -12,19 +11,14 @@ use blue_pill::Timer; use blue_pill::led::{self, Green}; use blue_pill::prelude::*; use blue_pill::time::Hertz; +use rtfm::app; -// CONFIGURATION const FREQUENCY: Hertz = Hertz(1); -rtfm! { +app! { device: blue_pill::stm32f103xx, - init: { - path: init, - }, - idle: { - path: idle, resources: [TIM2], }, } diff --git a/examples/wait3.rs b/examples/wait3.rs index d2643a3..1dc2d8f 100644 --- a/examples/wait3.rs +++ b/examples/wait3.rs @@ -1,9 +1,8 @@ //! Periodic timeouts with 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; @@ -12,19 +11,14 @@ use blue_pill::Timer; use blue_pill::led::{self, Green}; use blue_pill::prelude::*; use blue_pill::time::Hertz; +use rtfm::app; -// CONFIGURATION const FREQUENCY: Hertz = Hertz(1); -rtfm! { +app! { device: blue_pill::stm32f103xx, - init: { - path: init, - }, - idle: { - path: idle, resources: [TIM3], }, } diff --git a/examples/wait4.rs b/examples/wait4.rs index df55f68..98beb7b 100644 --- a/examples/wait4.rs +++ b/examples/wait4.rs @@ -1,9 +1,8 @@ //! Periodic timeouts with 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; @@ -12,19 +11,14 @@ use blue_pill::Timer; use blue_pill::led::{self, Green}; use blue_pill::prelude::*; use blue_pill::time::Hertz; +use rtfm::app; -// CONFIGURATION const FREQUENCY: Hertz = Hertz(1); -rtfm! { +app! { device: blue_pill::stm32f103xx, - init: { - path: init, - }, - idle: { - path: idle, resources: [TIM4], }, } diff --git a/examples/ws2812.rs b/examples/ws2812.rs index 0d3ec89..449ef09 100644 --- a/examples/ws2812.rs +++ b/examples/ws2812.rs @@ -4,9 +4,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_rtfm as rtfm; @@ -17,25 +16,21 @@ use blue_pill::dma::{Buffer, Dma1Channel2}; use blue_pill::prelude::*; use blue_pill::time::Hertz; use blue_pill::{Channel, Pwm}; +use rtfm::app; // CONFIGURATION const FREQUENCY: Hertz = Hertz(200_000); const _0: u8 = 3; const _1: u8 = 5; -rtfm! { +app! { device: blue_pill::stm32f103xx, resources: { BUFFER: Buffer<[u8; 577], Dma1Channel2> = Buffer::new([_0; 577]); }, - init: { - path: init, - }, - idle: { - path: idle, resources: [BUFFER, DMA1, TIM2], }, } -- GitLab