From 235e63a94a4e55f991b7605b8b6898f0ed1cc877 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio <jorge@japaric.io> Date: Fri, 21 Jul 2017 00:01:03 -0500 Subject: [PATCH] adapt to changes in cortex-m-rtfm --- examples/blinky-await.rs | 1 + examples/blinky-blocking.rs | 1 + examples/blinky-futures.rs | 1 + examples/blinky.rs | 12 +++++++----- examples/capture1.rs | 3 ++- examples/capture2.rs | 3 ++- examples/capture3.rs | 3 ++- examples/capture4.rs | 3 ++- examples/concurrent-await.rs | 1 + examples/concurrent-futures.rs | 1 + examples/concurrent.rs | 18 ++++++++++-------- examples/cpu.rs | 11 ++++++----- examples/gpio.rs | 1 + examples/hello.rs | 3 ++- examples/itm.rs | 1 + examples/led.rs | 1 + examples/loopback.rs | 7 ++++--- examples/pwm-control.rs | 9 +++++---- examples/pwm1.rs | 1 + examples/pwm2.rs | 1 + examples/pwm3.rs | 1 + examples/pwm4.rs | 1 + examples/qei1.rs | 19 ++++++++++--------- examples/qei2.rs | 16 +++++++++------- examples/qei3.rs | 16 +++++++++------- examples/qei4.rs | 16 +++++++++------- examples/spi1.rs | 3 ++- examples/spi2.rs | 3 ++- examples/usart1-rx-dma.rs | 7 ++++--- examples/usart1-tx-dma.rs | 7 ++++--- examples/usart1.rs | 1 + examples/usart2.rs | 1 + examples/usart3.rs | 1 + examples/wait1.rs | 3 ++- examples/wait2.rs | 3 ++- examples/wait3.rs | 3 ++- examples/wait4.rs | 3 ++- examples/ws2812.rs | 5 +++-- 38 files changed, 117 insertions(+), 74 deletions(-) diff --git a/examples/blinky-await.rs b/examples/blinky-await.rs index 84b200c..5ce6fbf 100644 --- a/examples/blinky-await.rs +++ b/examples/blinky-await.rs @@ -1,6 +1,7 @@ //! Blinky using `await!` #![allow(unreachable_code)] // for the `await!` macro +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(used)] diff --git a/examples/blinky-blocking.rs b/examples/blinky-blocking.rs index 048caa4..8f58160 100644 --- a/examples/blinky-blocking.rs +++ b/examples/blinky-blocking.rs @@ -1,6 +1,7 @@ //! Blocking version of blinky #![allow(unreachable_code)] // for the `block!` macro +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(used)] diff --git a/examples/blinky-futures.rs b/examples/blinky-futures.rs index ada6e4e..3d9e235 100644 --- a/examples/blinky-futures.rs +++ b/examples/blinky-futures.rs @@ -1,6 +1,7 @@ //! Blinky using futures #![allow(unreachable_code)] // for the `try_nb!` macro +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(used)] diff --git a/examples/blinky.rs b/examples/blinky.rs index baaa52c..ad3e749 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -1,6 +1,8 @@ //! 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(); diff --git a/examples/capture1.rs b/examples/capture1.rs index be63206..00ec6e7 100644 --- a/examples/capture1.rs +++ b/examples/capture1.rs @@ -1,5 +1,6 @@ //! 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); diff --git a/examples/capture2.rs b/examples/capture2.rs index e81137f..f3936e5 100644 --- a/examples/capture2.rs +++ b/examples/capture2.rs @@ -1,5 +1,6 @@ //! 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); diff --git a/examples/capture3.rs b/examples/capture3.rs index e806202..835d0af 100644 --- a/examples/capture3.rs +++ b/examples/capture3.rs @@ -1,5 +1,6 @@ //! 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); diff --git a/examples/capture4.rs b/examples/capture4.rs index 2074c96..b156b6c 100644 --- a/examples/capture4.rs +++ b/examples/capture4.rs @@ -1,5 +1,6 @@ //! 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); diff --git a/examples/concurrent-await.rs b/examples/concurrent-await.rs index 991c76c..1bed021 100644 --- a/examples/concurrent-await.rs +++ b/examples/concurrent-await.rs @@ -1,6 +1,7 @@ //! Two concurrent tasks using `await!` #![allow(unreachable_code)] // for the `await!` macro +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(used)] diff --git a/examples/concurrent-futures.rs b/examples/concurrent-futures.rs index fad6df9..f959608 100644 --- a/examples/concurrent-futures.rs +++ b/examples/concurrent-futures.rs @@ -1,6 +1,7 @@ //! Two concurrent tasks using futures #![allow(unreachable_code)] // for the `try_nb!` macro +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(used)] diff --git a/examples/concurrent.rs b/examples/concurrent.rs index 004a219..28dffae 100644 --- a/examples/concurrent.rs +++ b/examples/concurrent.rs @@ -1,6 +1,8 @@ //! 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(); diff --git a/examples/cpu.rs b/examples/cpu.rs index d7804c3..b81ef4e 100644 --- a/examples/cpu.rs +++ b/examples/cpu.rs @@ -1,5 +1,6 @@ //! 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(); diff --git a/examples/gpio.rs b/examples/gpio.rs index c9d4348..0b5a5b3 100644 --- a/examples/gpio.rs +++ b/examples/gpio.rs @@ -1,5 +1,6 @@ //! Sets PB12 high +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/hello.rs b/examples/hello.rs index 27d3e35..f2c0938 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,5 +1,6 @@ //! 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: { diff --git a/examples/itm.rs b/examples/itm.rs index 76dc7b9..9c31f71 100644 --- a/examples/itm.rs +++ b/examples/itm.rs @@ -19,6 +19,7 @@ //! World //! ``` +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/led.rs b/examples/led.rs index 1e8b552..64143f4 100644 --- a/examples/led.rs +++ b/examples/led.rs @@ -1,5 +1,6 @@ //! Turns the user LED on +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/loopback.rs b/examples/loopback.rs index a2981d9..6e19cf2 100644 --- a/examples/loopback.rs +++ b/examples/loopback.rs @@ -1,5 +1,6 @@ //! 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(); diff --git a/examples/pwm-control.rs b/examples/pwm-control.rs index 4b92475..70ba754 100644 --- a/examples/pwm-control.rs +++ b/examples/pwm-control.rs @@ -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 diff --git a/examples/pwm1.rs b/examples/pwm1.rs index 27f89e2..60d520c 100644 --- a/examples/pwm1.rs +++ b/examples/pwm1.rs @@ -1,6 +1,7 @@ //! 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] diff --git a/examples/pwm2.rs b/examples/pwm2.rs index b90b7c6..5b6773f 100644 --- a/examples/pwm2.rs +++ b/examples/pwm2.rs @@ -1,5 +1,6 @@ //! 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] diff --git a/examples/pwm3.rs b/examples/pwm3.rs index 514945b..a5ddfed 100644 --- a/examples/pwm3.rs +++ b/examples/pwm3.rs @@ -1,5 +1,6 @@ //! Output a PWM with a duty cycle of ~6% on all the channels of TIM3 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/pwm4.rs b/examples/pwm4.rs index c32ecb2..c5d6b7f 100644 --- a/examples/pwm4.rs +++ b/examples/pwm4.rs @@ -1,5 +1,6 @@ //! Output a PWM with a duty cycle of ~6% on all the channels of TIM4 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/qei1.rs b/examples/qei1.rs index 203c681..ba49f09 100644 --- a/examples/qei1.rs +++ b/examples/qei1.rs @@ -2,7 +2,9 @@ //! //! Periodically reports the readings of the QEI +#![deny(unsafe_code)] #![deny(warnings)] +#![feature(const_fn)] #![feature(proc_macro)] #![no_std] @@ -15,7 +17,7 @@ extern crate cortex_m_rtfm as rtfm; use blue_pill::prelude::*; use blue_pill::time::Hertz; use blue_pill::{Qei, Timer}; -use rtfm::{Threshold, app}; +use rtfm::{app, Threshold}; // CONFIGURATION const FREQUENCY: Hertz = Hertz(1); @@ -49,24 +51,23 @@ fn idle() -> ! { } task!(TIM4, periodic, Locals { - previous: Option<u16> = None; + static PREVIOUS: Option<u16> = None; }); -fn periodic(_t: Threshold, l: &mut Locals, r: TIM4::Resources) { - let qei = Qei(r.TIM1); - let timer = Timer(r.TIM4); +fn periodic(_t: &mut Threshold, l: &mut Locals, r: TIM4::Resources) { + let qei = Qei(&**r.TIM1); + let timer = Timer(&**r.TIM4); - // NOTE(unwrap) timeout should have already occurred - timer.wait().unwrap_or_else(|_| unreachable!()); + timer.wait().unwrap(); let curr = qei.count(); let dir = qei.direction(); - if let Some(prev) = l.previous.take() { + if let Some(prev) = l.PREVIOUS.take() { let speed = (curr as i16).wrapping_sub(prev as i16); iprintln!(&r.ITM.stim[0], "{} - {} - {:?}", curr, speed, dir); } - l.previous = Some(curr); + *l.PREVIOUS = Some(curr); } diff --git a/examples/qei2.rs b/examples/qei2.rs index 701f8fa..edba974 100644 --- a/examples/qei2.rs +++ b/examples/qei2.rs @@ -2,7 +2,9 @@ //! //! Periodically reports the readings of the QEI +#![deny(unsafe_code)] #![deny(warnings)] +#![feature(const_fn)] #![feature(proc_macro)] #![no_std] @@ -15,7 +17,7 @@ extern crate cortex_m_rtfm as rtfm; use blue_pill::prelude::*; use blue_pill::time::Hertz; use blue_pill::{Qei, Timer}; -use rtfm::{Threshold, app}; +use rtfm::{app, Threshold}; const FREQUENCY: Hertz = Hertz(1); @@ -48,12 +50,12 @@ fn idle() -> ! { } task!(TIM4, periodic, Locals { - previous: Option<u16> = None; + static PREVIOUS: Option<u16> = None; }); -fn periodic(_t: Threshold, l: &mut Locals, r: TIM4::Resources) { - let qei = Qei(r.TIM2); - let timer = Timer(r.TIM4); +fn periodic(_t: &mut Threshold, l: &mut Locals, r: TIM4::Resources) { + let qei = Qei(&**r.TIM2); + let timer = Timer(&**r.TIM4); // NOTE(unwrap) timeout should have already occurred timer.wait().unwrap(); @@ -61,11 +63,11 @@ fn periodic(_t: Threshold, l: &mut Locals, r: TIM4::Resources) { let curr = qei.count(); let dir = qei.direction(); - if let Some(prev) = l.previous.take() { + if let Some(prev) = l.PREVIOUS.take() { let speed = (curr as i16).wrapping_sub(prev as i16); iprintln!(&r.ITM.stim[0], "{} - {} - {:?}", curr, speed, dir); } - l.previous = Some(curr); + *l.PREVIOUS = Some(curr); } diff --git a/examples/qei3.rs b/examples/qei3.rs index 5a28a92..e0ed7de 100644 --- a/examples/qei3.rs +++ b/examples/qei3.rs @@ -2,7 +2,9 @@ //! //! Periodically reports the readings of the QEI +#![deny(unsafe_code)] #![deny(warnings)] +#![feature(const_fn)] #![feature(proc_macro)] #![no_std] @@ -15,7 +17,7 @@ extern crate cortex_m_rtfm as rtfm; use blue_pill::time::Hertz; use blue_pill::{Qei, Timer}; use blue_pill::prelude::*; -use rtfm::{Threshold, app}; +use rtfm::{app, Threshold}; const FREQUENCY: Hertz = Hertz(1); @@ -48,23 +50,23 @@ fn idle() -> ! { } task!(TIM4, periodic, Locals { - previous: Option<u16> = None; + static PREVIOUS: Option<u16> = None; }); -fn periodic(_t: Threshold, l: &mut Locals, r: TIM4::Resources) { - let qei = Qei(r.TIM3); - let timer = Timer(r.TIM4); +fn periodic(_t: &mut Threshold, l: &mut Locals, r: TIM4::Resources) { + let qei = Qei(&**r.TIM3); + let timer = Timer(&**r.TIM4); timer.wait().unwrap(); let curr = qei.count(); let dir = qei.direction(); - if let Some(prev) = l.previous.take() { + if let Some(prev) = l.PREVIOUS.take() { let speed = (curr as i16).wrapping_sub(prev as i16); iprintln!(&r.ITM.stim[0], "{} - {} - {:?}", curr, speed, dir); } - l.previous = Some(curr); + *l.PREVIOUS = Some(curr); } diff --git a/examples/qei4.rs b/examples/qei4.rs index e5ccb73..b04c7ea 100644 --- a/examples/qei4.rs +++ b/examples/qei4.rs @@ -2,7 +2,9 @@ //! //! Periodically reports the readings of the QEI +#![deny(unsafe_code)] #![deny(warnings)] +#![feature(const_fn)] #![feature(proc_macro)] #![no_std] @@ -15,7 +17,7 @@ extern crate cortex_m_rtfm as rtfm; use blue_pill::time::Hertz; use blue_pill::{Qei, Timer}; use blue_pill::prelude::*; -use rtfm::{Threshold, app}; +use rtfm::{app, Threshold}; const FREQUENCY: Hertz = Hertz(1); @@ -48,23 +50,23 @@ fn idle() -> ! { } task!(TIM1_UP_TIM10, periodic, Locals { - previous: Option<u16> = None; + static PREVIOUS: Option<u16> = None; }); -fn periodic(_t: Threshold, l: &mut Locals, r: TIM1_UP_TIM10::Resources) { - let qei = Qei(r.TIM4); - let timer = Timer(r.TIM1); +fn periodic(_t: &mut Threshold, l: &mut Locals, r: TIM1_UP_TIM10::Resources) { + let qei = Qei(&**r.TIM4); + let timer = Timer(&**r.TIM1); timer.wait().unwrap(); let curr = qei.count(); let dir = qei.direction(); - if let Some(prev) = l.previous.take() { + if let Some(prev) = l.PREVIOUS.take() { let speed = (curr as i16).wrapping_sub(prev as i16); iprintln!(&r.ITM.stim[0], "{} - {} - {:?}", curr, speed, dir); } - l.previous = Some(curr); + *l.PREVIOUS = Some(curr); } diff --git a/examples/spi1.rs b/examples/spi1.rs index e573a41..0b8b2c6 100644 --- a/examples/spi1.rs +++ b/examples/spi1.rs @@ -1,5 +1,6 @@ //! Interfacing the MPU9250 using SPI1 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] @@ -40,7 +41,7 @@ fn idle(r: idle::Resources) -> ! { // Read mode pub const R: u8 = 1 << 7; - let spi = Spi(r.SPI1); + let spi = Spi(&**r.SPI1); rtfm::bkpt(); diff --git a/examples/spi2.rs b/examples/spi2.rs index 47ea42c..2f352f0 100644 --- a/examples/spi2.rs +++ b/examples/spi2.rs @@ -1,5 +1,6 @@ //! Interfacing the MPU9250 using SPI2 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] @@ -40,7 +41,7 @@ fn idle(r: idle::Resources) -> ! { // Read mode pub const R: u8 = 1 << 7; - let spi = Spi(r.SPI2); + let spi = Spi(&**r.SPI2); rtfm::bkpt(); diff --git a/examples/usart1-rx-dma.rs b/examples/usart1-rx-dma.rs index 041a234..7f3c0b3 100644 --- a/examples/usart1-rx-dma.rs +++ b/examples/usart1-rx-dma.rs @@ -1,5 +1,6 @@ //! Test receiving serial data using the DMA +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(proc_macro)] @@ -13,7 +14,7 @@ extern crate nb; use blue_pill::Serial; use blue_pill::dma::{Buffer, Dma1Channel5}; use blue_pill::time::Hertz; -use rtfm::{Threshold, app}; +use rtfm::{app, Threshold}; pub const BAUD_RATE: Hertz = Hertz(115_200); @@ -21,7 +22,7 @@ app! { device: blue_pill::stm32f103xx, resources: { - BUFFER: Buffer<[u8; 8], Dma1Channel5> = Buffer::new([0; 8]); + static BUFFER: Buffer<[u8; 8], Dma1Channel5> = Buffer::new([0; 8]); }, tasks: { @@ -49,7 +50,7 @@ fn idle() -> ! { task!(DMA1_CHANNEL5, transfer_done); -fn transfer_done(_t: Threshold, r: DMA1_CHANNEL5::Resources) { +fn transfer_done(_t: &mut Threshold, r: DMA1_CHANNEL5::Resources) { r.BUFFER.release(r.DMA1).unwrap(); rtfm::bkpt(); diff --git a/examples/usart1-tx-dma.rs b/examples/usart1-tx-dma.rs index c5ccc3a..06f209e 100644 --- a/examples/usart1-tx-dma.rs +++ b/examples/usart1-tx-dma.rs @@ -1,5 +1,6 @@ //! Test sending serial data using the DMA +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(proc_macro)] @@ -13,7 +14,7 @@ extern crate nb; use blue_pill::Serial; use blue_pill::dma::{Buffer, Dma1Channel4}; use blue_pill::time::Hertz; -use rtfm::{Threshold, app}; +use rtfm::{app, Threshold}; pub const BAUD_RATE: Hertz = Hertz(115_200); @@ -21,7 +22,7 @@ app! { device: blue_pill::stm32f103xx, resources: { - BUFFER: Buffer<[u8; 14], Dma1Channel4> = Buffer::new([0; 14]); + static BUFFER: Buffer<[u8; 14], Dma1Channel4> = Buffer::new([0; 14]); }, tasks: { @@ -50,7 +51,7 @@ fn idle() -> ! { task!(DMA1_CHANNEL4, transfer_done); -fn transfer_done(_t: Threshold, r: DMA1_CHANNEL4::Resources) { +fn transfer_done(_t: &mut Threshold, r: DMA1_CHANNEL4::Resources) { r.BUFFER.release(r.DMA1).unwrap(); rtfm::bkpt(); diff --git a/examples/usart1.rs b/examples/usart1.rs index b496219..9abd07d 100644 --- a/examples/usart1.rs +++ b/examples/usart1.rs @@ -2,6 +2,7 @@ //! //! Connect the TX and RX pins to run this test +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/usart2.rs b/examples/usart2.rs index 55ae04e..2af3b2e 100644 --- a/examples/usart2.rs +++ b/examples/usart2.rs @@ -2,6 +2,7 @@ //! //! Connect the TX and RX pins to run this test +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/usart3.rs b/examples/usart3.rs index 7559972..5d5815f 100644 --- a/examples/usart3.rs +++ b/examples/usart3.rs @@ -2,6 +2,7 @@ //! //! Connect the TX and RX pins to run this test +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] diff --git a/examples/wait1.rs b/examples/wait1.rs index 9310769..4b3a811 100644 --- a/examples/wait1.rs +++ b/examples/wait1.rs @@ -1,5 +1,6 @@ //! Periodic timeouts with TIM1 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] @@ -33,7 +34,7 @@ fn init(p: init::Peripherals) { } fn idle(r: idle::Resources) -> ! { - let timer = Timer(r.TIM1); + let timer = Timer(&**r.TIM1); let mut state = false; loop { diff --git a/examples/wait2.rs b/examples/wait2.rs index 36af50d..61e0403 100644 --- a/examples/wait2.rs +++ b/examples/wait2.rs @@ -1,5 +1,6 @@ //! Periodic timeouts with TIM2 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] @@ -32,7 +33,7 @@ fn init(p: init::Peripherals) { } fn idle(r: idle::Resources) -> ! { - let timer = Timer(r.TIM2); + let timer = Timer(&**r.TIM2); let mut state = false; loop { diff --git a/examples/wait3.rs b/examples/wait3.rs index 1dc2d8f..8b05861 100644 --- a/examples/wait3.rs +++ b/examples/wait3.rs @@ -1,5 +1,6 @@ //! Periodic timeouts with TIM3 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] @@ -33,7 +34,7 @@ fn init(p: init::Peripherals) { } fn idle(r: idle::Resources) -> ! { - let timer = Timer(r.TIM3); + let timer = Timer(&**r.TIM3); let mut state = false; loop { diff --git a/examples/wait4.rs b/examples/wait4.rs index 98beb7b..cc6b2df 100644 --- a/examples/wait4.rs +++ b/examples/wait4.rs @@ -1,5 +1,6 @@ //! Periodic timeouts with TIM4 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] @@ -33,7 +34,7 @@ fn init(p: init::Peripherals) { } fn idle(r: idle::Resources) -> ! { - let timer = Timer(r.TIM4); + let timer = Timer(&**r.TIM4); let mut state = false; loop { diff --git a/examples/ws2812.rs b/examples/ws2812.rs index 449ef09..59dc20b 100644 --- a/examples/ws2812.rs +++ b/examples/ws2812.rs @@ -2,6 +2,7 @@ //! //! To test this demo connect the data-in pin of the LED ring to pin PA0 +#![deny(unsafe_code)] #![deny(warnings)] #![feature(const_fn)] #![feature(proc_macro)] @@ -27,7 +28,7 @@ app! { device: blue_pill::stm32f103xx, resources: { - BUFFER: Buffer<[u8; 577], Dma1Channel2> = Buffer::new([_0; 577]); + static BUFFER: Buffer<[u8; 577], Dma1Channel2> = Buffer::new([_0; 577]); }, idle: { @@ -51,7 +52,7 @@ fn init(p: init::Peripherals, r: init::Resources) { } fn idle(r: idle::Resources) -> ! { - let pwm = Pwm(r.TIM2); + let pwm = Pwm(&**r.TIM2); pwm.set_duties(r.DMA1, Channel::_1, r.BUFFER).unwrap(); -- GitLab