From d9056b48c2b60be0f929917e3c09c40d78ed6649 Mon Sep 17 00:00:00 2001 From: Per Lindgren <per.lindgren@ltu.se> Date: Sat, 13 Jan 2018 16:51:03 +0100 Subject: [PATCH] Initial commit --- Cargo.toml | 4 ++-- examples/blinky-blocking.rs | 2 +- examples/blinky.rs | 2 +- examples/capture4.rs | 2 +- examples/concurrency.rs | 2 +- examples/hello-world.rs | 2 +- examples/hello.rs | 2 +- examples/imu.rs | 4 ++-- examples/itm.rs | 2 +- examples/led.rs | 2 +- examples/loopback.rs | 2 +- examples/mco.rs | 4 ++-- examples/preemption.rs | 2 +- examples/pwm-control.rs | 2 +- examples/pwm1.rs | 2 +- examples/resource.rs | 2 +- examples/roulette.rs | 2 +- examples/spi1.rs | 8 ++++---- examples/usart2-dma.rs | 2 +- examples/usart2-rx-dma.rs | 2 +- examples/usart2-tx-dma.rs | 2 +- examples/ws2812.rs | 2 +- src/capture.rs | 2 +- src/clock.rs | 2 +- src/dma.rs | 2 +- src/examples/_0_hello.rs | 2 +- src/examples/_1_itm.rs | 2 +- src/examples/_2_led.rs | 2 +- src/examples/_3_blinky.rs | 2 +- src/examples/_4_roulette.rs | 2 +- src/examples/_5_loopback.rs | 2 +- src/examples/_6_concurrency.rs | 2 +- src/examples/_7_resource.rs | 2 +- src/examples/_8_preemption.rs | 2 +- src/led.rs | 2 +- src/leds.rs | 2 +- src/lib.rs | 2 +- src/lsm9ds1.rs | 4 ++-- src/pwm.rs | 2 +- src/serial.rs | 32 ++++++++------------------------ src/spi.rs | 2 +- src/timer.rs | 2 +- 42 files changed, 56 insertions(+), 72 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fc1f404..88691e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,10 +26,10 @@ rev = "7d904f515d15fd5fe7ea34e18820ea83e2651fa2" [dependencies.nb] git = "https://github.com/japaric/nb" -[dependencies.stm32f413] +[dependencies.stm32f429x] features = ["rt"] #version = "0.5.0" -git = "https://gitlab.henriktjader.com/pln/stm32f413" +git = "https://gitlab.henriktjader.com/pln/stm32f429x" [dev-dependencies] cortex-m = "0.3.0" diff --git a/examples/blinky-blocking.rs b/examples/blinky-blocking.rs index e008567..c43b5db 100644 --- a/examples/blinky-blocking.rs +++ b/examples/blinky-blocking.rs @@ -23,7 +23,7 @@ use rtfm::{app, Threshold}; const FREQUENCY: Hertz = Hertz(1); app! { - device: f4::stm32f413, + device: f4::stm32f429x, idle: { resources: [TIM11], diff --git a/examples/blinky.rs b/examples/blinky.rs index b21fbd8..8fccf9d 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -17,7 +17,7 @@ const FREQUENCY: u32 = 1; // Hz // TASKS & RESOURCES app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static ON: bool = false; diff --git a/examples/capture4.rs b/examples/capture4.rs index 48fe944..25c62ec 100644 --- a/examples/capture4.rs +++ b/examples/capture4.rs @@ -19,7 +19,7 @@ const RESOLUTION: Milliseconds = Milliseconds(1); const CHANNELS: [Channel; 2] = [Channel::_1, Channel::_2]; app! { - device: f4::stm32f413, + device: f4::stm32f429x, idle: { resources: [ITM, TIM2], diff --git a/examples/concurrency.rs b/examples/concurrency.rs index a7db377..be94cab 100644 --- a/examples/concurrency.rs +++ b/examples/concurrency.rs @@ -24,7 +24,7 @@ const DIVISOR: u32 = 4; // TASKS & RESOURCES app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static ON: bool = false; diff --git a/examples/hello-world.rs b/examples/hello-world.rs index 3d46988..47f4c34 100644 --- a/examples/hello-world.rs +++ b/examples/hello-world.rs @@ -14,7 +14,7 @@ use rtfm::{app, Threshold}; use semihosting::hio::{self, HStdout}; app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static HSTDOUT: Option<HStdout> = None; diff --git a/examples/hello.rs b/examples/hello.rs index f4c8be5..46cb01b 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -11,7 +11,7 @@ extern crate f4; use rtfm::app; app! { - device: f4::stm32f413, + device: f4::stm32f429x, } fn init(_p: init::Peripherals) {} diff --git a/examples/imu.rs b/examples/imu.rs index 46cc0fb..647c3f6 100644 --- a/examples/imu.rs +++ b/examples/imu.rs @@ -19,7 +19,7 @@ extern crate cortex_m_rtfm as rtfm; #[macro_use] extern crate f4; extern crate heapless; -extern crate stm32f413; +extern crate stm32f429x; use cortex_m::peripheral::SystClkSource; use core::ops::Deref; @@ -36,7 +36,7 @@ const FREQUENCY: u32 = 10; const MAX_TX_LEN: usize = 256; app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static IMU_SETTINGS: ImuSettings = ImuSettings::new(); diff --git a/examples/itm.rs b/examples/itm.rs index 8c0a217..e0531e8 100644 --- a/examples/itm.rs +++ b/examples/itm.rs @@ -31,7 +31,7 @@ extern crate f4; use rtfm::{app, Threshold}; app! { - device: f4::stm32f413, + device: f4::stm32f429x, idle: { resources: [ITM], diff --git a/examples/led.rs b/examples/led.rs index 59f81fa..747611a 100644 --- a/examples/led.rs +++ b/examples/led.rs @@ -12,7 +12,7 @@ use rtfm::app; // TASKS & RESOURCES app! { - device: f4::stm32f413, + device: f4::stm32f429x, } // INITIALIZATION PHASE diff --git a/examples/loopback.rs b/examples/loopback.rs index 2f6e36e..c2f49b3 100644 --- a/examples/loopback.rs +++ b/examples/loopback.rs @@ -18,7 +18,7 @@ const BAUD_RATE: Hertz = Hertz(115_200); // TASKS & RESOURCES app! { - device: f4::stm32f413, + device: f4::stm32f429x, tasks: { USART2: { diff --git a/examples/mco.rs b/examples/mco.rs index 779ce0e..de59ad2 100644 --- a/examples/mco.rs +++ b/examples/mco.rs @@ -1,4 +1,4 @@ -//! Set the clock frequency on the Nucleo-64 stm32f413 +//! Set the clock frequency on the Nucleo-64 stm32f429x #![deny(warnings)] #![feature(proc_macro)] #![no_std] @@ -16,7 +16,7 @@ const FREQUENCY: u32 = 10; // Hz // TASKS & RESOURCES app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static ON: bool = false; diff --git a/examples/preemption.rs b/examples/preemption.rs index dcce6c0..7a8a020 100644 --- a/examples/preemption.rs +++ b/examples/preemption.rs @@ -34,7 +34,7 @@ const DIVISOR: u32 = 4; // TASK & RESOURCES app!{ - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static BUFFER: Vec<u8, [u8; 16]> = Vec::new([0; 16]); diff --git a/examples/pwm-control.rs b/examples/pwm-control.rs index bb38d0b..6c34192 100644 --- a/examples/pwm-control.rs +++ b/examples/pwm-control.rs @@ -24,7 +24,7 @@ const BAUD_RATE: Hertz = Hertz(115_200); const FREQUENCY: Hertz = Hertz(1_000); app! { - device: f4::stm32f413, + device: f4::stm32f429x, tasks: { USART2: { diff --git a/examples/pwm1.rs b/examples/pwm1.rs index 2c3fa91..8f8d0e5 100644 --- a/examples/pwm1.rs +++ b/examples/pwm1.rs @@ -14,7 +14,7 @@ use rtfm::app; const FREQUENCY: Hertz = Hertz(10_000); app! { - device: f4::stm32f413, + device: f4::stm32f429x, } fn init(p: init::Peripherals) { diff --git a/examples/resource.rs b/examples/resource.rs index 660f540..ce3180b 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -37,7 +37,7 @@ const DIVISOR: u32 = 4; // TASKS & RESOURCES app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { // 16 byte buffer diff --git a/examples/roulette.rs b/examples/roulette.rs index 83da6f9..e232040 100644 --- a/examples/roulette.rs +++ b/examples/roulette.rs @@ -19,7 +19,7 @@ const DIVISOR: u32 = 4; // TASKS & RESOURCES app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static STATE: u8 = 0; diff --git a/examples/spi1.rs b/examples/spi1.rs index fc8be0c..bba0f31 100644 --- a/examples/spi1.rs +++ b/examples/spi1.rs @@ -15,15 +15,15 @@ extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; extern crate f4; -extern crate stm32f413; +extern crate stm32f429x; use f4::Spi; use f4::prelude::*; use rtfm::{app, Threshold}; -use stm32f413::GPIOA; +use stm32f429x::GPIOA; app! { - device: f4::stm32f413, + device: f4::stm32f429x, idle: { resources: [SPI3, GPIOA], @@ -79,7 +79,7 @@ fn disable_ag(gpioa: &mut GPIOA) { gpioa.odr.modify(|_, w| w.odr8().bit(true)); } -fn send_receive(spi: &f4::Spi<f4::stm32f413::SPI3>, addr: u8) -> u8 { +fn send_receive(spi: &f4::Spi<f4::stm32f429x::SPI3>, addr: u8) -> u8 { // Send and receive using the hal crate while spi.send(addr).is_err() {} while spi.read().is_err() {} diff --git a/examples/usart2-dma.rs b/examples/usart2-dma.rs index 8c9a81e..cee7048 100644 --- a/examples/usart2-dma.rs +++ b/examples/usart2-dma.rs @@ -38,7 +38,7 @@ enum CmdType { } app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static CMD_BUFFER: Vec<u8, [u8; MAX_CMD_LEN]> = Vec::new([0; MAX_CMD_LEN]); diff --git a/examples/usart2-rx-dma.rs b/examples/usart2-rx-dma.rs index b741d51..3cfe7b8 100644 --- a/examples/usart2-rx-dma.rs +++ b/examples/usart2-rx-dma.rs @@ -16,7 +16,7 @@ use rtfm::{app, Threshold}; const BAUD_RATE: Hertz = Hertz(115_200); app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static BUFFER: Buffer<[u8; 8], Dma1Channel5> = Buffer::new([0; 8]); diff --git a/examples/usart2-tx-dma.rs b/examples/usart2-tx-dma.rs index 2d553cd..294d4ac 100644 --- a/examples/usart2-tx-dma.rs +++ b/examples/usart2-tx-dma.rs @@ -16,7 +16,7 @@ use rtfm::{app, Threshold}; const BAUD_RATE: Hertz = Hertz(115_200); app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static BUFFER: Buffer<[u8; 15], Dma1Channel6> = Buffer::new([0; 15]); diff --git a/examples/ws2812.rs b/examples/ws2812.rs index 7e1f89d..1aec62b 100644 --- a/examples/ws2812.rs +++ b/examples/ws2812.rs @@ -24,7 +24,7 @@ const _0: u8 = 3; const _1: u8 = 5; app! { - device: f4::stm32f413, + device: f4::stm32f429x, resources: { static BUFFER: Buffer<[u8; 577], Dma1Channel2> = Buffer::new([_0; 577]); diff --git a/src/capture.rs b/src/capture.rs index 291a4a8..8e3a3c4 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -39,7 +39,7 @@ use core::u32; use cast::u32; use hal; use nb; -use stm32f413::{TIM1, TIM2, TIM3, TIM4, GPIOA, GPIOB, GPIOC, RCC}; +use stm32f429x::{TIM1, TIM2, TIM3, TIM4, GPIOA, GPIOB, GPIOC, RCC}; use timer::Channel; diff --git a/src/clock.rs b/src/clock.rs index 907643a..9b0d5fe 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -1,6 +1,6 @@ //! System clocking -use stm32f413::{FLASH, RCC}; +use stm32f429x::{FLASH, RCC}; const HSI_FREQ: u32 = 16_000_000; diff --git a/src/dma.rs b/src/dma.rs index 71a2788..c696fae 100644 --- a/src/dma.rs +++ b/src/dma.rs @@ -5,7 +5,7 @@ use core::marker::PhantomData; use core::ops; use nb; -use stm32f413::DMA1; +use stm32f429x::DMA1; /// DMA error #[derive(Debug)] diff --git a/src/examples/_0_hello.rs b/src/examples/_0_hello.rs index 9784efe..c4c2a80 100644 --- a/src/examples/_0_hello.rs +++ b/src/examples/_0_hello.rs @@ -17,7 +17,7 @@ //! //! // TASKS & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! } //! //! // INITIALIZATION PHASE diff --git a/src/examples/_1_itm.rs b/src/examples/_1_itm.rs index e99db44..b1f2850 100644 --- a/src/examples/_1_itm.rs +++ b/src/examples/_1_itm.rs @@ -20,7 +20,7 @@ //! //! // TASK & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! //! idle: { //! resources: [ITM], diff --git a/src/examples/_2_led.rs b/src/examples/_2_led.rs index 8bc3371..b494768 100644 --- a/src/examples/_2_led.rs +++ b/src/examples/_2_led.rs @@ -14,7 +14,7 @@ //! //! // TASKS & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! } //! //! // INITIALIZATION PHASE diff --git a/src/examples/_3_blinky.rs b/src/examples/_3_blinky.rs index 0507c8d..c970c4f 100644 --- a/src/examples/_3_blinky.rs +++ b/src/examples/_3_blinky.rs @@ -19,7 +19,7 @@ //! //! // TASKS & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! //! resources: { //! static ON: bool = false; diff --git a/src/examples/_4_roulette.rs b/src/examples/_4_roulette.rs index ffde32a..48998af 100644 --- a/src/examples/_4_roulette.rs +++ b/src/examples/_4_roulette.rs @@ -21,7 +21,7 @@ //! //! // TASKS & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! //! resources: { //! static STATE: u8 = 0; diff --git a/src/examples/_5_loopback.rs b/src/examples/_5_loopback.rs index b30b205..7a8fdb6 100644 --- a/src/examples/_5_loopback.rs +++ b/src/examples/_5_loopback.rs @@ -20,7 +20,7 @@ //! //! // TASKS & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! //! tasks: { //! USART2: { diff --git a/src/examples/_6_concurrency.rs b/src/examples/_6_concurrency.rs index b989569..0f4835d 100644 --- a/src/examples/_6_concurrency.rs +++ b/src/examples/_6_concurrency.rs @@ -27,7 +27,7 @@ //! //! // TASKS & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! //! resources: { //! static STATE: u8 = 0; diff --git a/src/examples/_7_resource.rs b/src/examples/_7_resource.rs index 2afb0df..5ff5165 100644 --- a/src/examples/_7_resource.rs +++ b/src/examples/_7_resource.rs @@ -39,7 +39,7 @@ //! //! // TASKS & RESOURCES //! app! { -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! //! resources: { //! // 16 byte buffer diff --git a/src/examples/_8_preemption.rs b/src/examples/_8_preemption.rs index 9064cb7..e08c3dd 100644 --- a/src/examples/_8_preemption.rs +++ b/src/examples/_8_preemption.rs @@ -36,7 +36,7 @@ //! //! // TASK & RESOURCES //! app!{ -//! device: f4::stm32f413, +//! device: f4::stm32f429x, //! //! resources: { //! static BUFFER: Vec<u8, [u8; 16]> = Vec::new([0; 16]); diff --git a/src/led.rs b/src/led.rs index 6b039d1..57fc971 100644 --- a/src/led.rs +++ b/src/led.rs @@ -1,6 +1,6 @@ //! User LED PA5 -use stm32f413::{GPIOA, RCC}; +use stm32f429x::{GPIOA, RCC}; /// LED connected to pin PA5 pub const LED: PA5 = PA5; diff --git a/src/leds.rs b/src/leds.rs index 65e3f29..1e79efb 100644 --- a/src/leds.rs +++ b/src/leds.rs @@ -1,6 +1,6 @@ //! Eight LEDs connected to PORTB -use stm32f413::{GPIOB, RCC}; +use stm32f429x::{GPIOB, RCC}; /// All the LEDs pub static LEDS: [Led; 8] = [ diff --git a/src/lib.rs b/src/lib.rs index 72d1e8b..e1e3b81 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ extern crate embedded_hal as hal; extern crate nb; extern crate static_ref; -pub extern crate stm32f413; +pub extern crate stm32f429x; // For documentation only pub mod examples; diff --git a/src/lsm9ds1.rs b/src/lsm9ds1.rs index 6440ea1..56c3c75 100644 --- a/src/lsm9ds1.rs +++ b/src/lsm9ds1.rs @@ -1,8 +1,8 @@ //! Interfacing the LSM9DS1 3D accelerometer, gyroscope, and magnetometer //! using SPI. -extern crate stm32f413; -use stm32f413::{SPI1, SPI2, SPI3, GPIOA}; +extern crate stm32f429x; +use stm32f429x::{SPI1, SPI2, SPI3, GPIOA}; use spi::Spi; use prelude::*; diff --git a/src/pwm.rs b/src/pwm.rs index 11dd9aa..176d043 100644 --- a/src/pwm.rs +++ b/src/pwm.rs @@ -36,7 +36,7 @@ use core::marker::Unsize; use cast::{u16, u32}; use hal; use static_ref::Static; -use stm32f413::{DMA1, TIM1, TIM2, TIM3, TIM4, GPIOA, GPIOB, GPIOC, RCC}; +use stm32f429x::{DMA1, TIM1, TIM2, TIM3, TIM4, GPIOA, GPIOB, GPIOC, RCC}; use dma::{self, Buffer, Dma1Channel2}; use timer::Channel; diff --git a/src/serial.rs b/src/serial.rs index 61f3140..eb42873 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -17,7 +17,7 @@ use cast::u16; use hal; use nb; use static_ref::Static; -use stm32f413::{gpioa, DMA1, USART2, usart1, GPIOA, RCC}; +use stm32f429x::{gpioa, DMA1, USART2, usart6 as usart1, GPIOA, RCC}; use dma::{self, Buffer, Dma1Channel5, Dma1Channel6}; @@ -94,25 +94,14 @@ where /// /// The serial interface will be configured to use 8 bits of data, 1 stop /// bit, no hardware control and to omit parity checking - pub fn init<B>( - &self, - baud_rate: B, - dma1: Option<&DMA1>, - gpio: &U::GPIO, - rcc: &RCC, - ) where + pub fn init<B>(&self, baud_rate: B, dma1: Option<&DMA1>, gpio: &U::GPIO, rcc: &RCC) + where B: Into<U::Ticks>, { self._init(baud_rate.into(), dma1, gpio, rcc) } - fn _init( - &self, - baud_rate: U::Ticks, - dma1: Option<&DMA1>, - gpio: &U::GPIO, - rcc: &RCC, - ) { + fn _init(&self, baud_rate: U::Ticks, dma1: Option<&DMA1>, gpio: &U::GPIO, rcc: &RCC) { let usart = self.0; // power up peripherals @@ -138,9 +127,8 @@ where gpio.afrl .modify(|_, w| unsafe { w.afrl2().bits(7).afrl3().bits(7) }); // Highest output speed - gpio.ospeedr.modify(|_, w| unsafe { - w.ospeedr2().bits(0b11).ospeedr3().bits(0b11) - }); + gpio.ospeedr + .modify(|_, w| unsafe { w.ospeedr2().bits(0b11).ospeedr3().bits(0b11) }); // RM0368 8.3 Table 23 gpio.moder .modify(|_, w| unsafe { w.moder2().bits(2).moder3().bits(2) }); @@ -308,9 +296,7 @@ where } else if sr.rxne().bit_is_set() { // NOTE(read_volatile) the register is 9 bits big but we'll only // work with the first 8 bits - Ok(unsafe { - ptr::read_volatile(&usart2.dr as *const _ as *const u8) - }) + Ok(unsafe { ptr::read_volatile(&usart2.dr as *const _ as *const u8) }) } else { Err(nb::Error::WouldBlock) } @@ -335,9 +321,7 @@ where Err(nb::Error::Other(Error::Framing)) } else if sr.txe().bit_is_set() { // NOTE(write_volatile) see NOTE in the `read` method - unsafe { - ptr::write_volatile(&usart2.dr as *const _ as *mut u8, byte) - } + unsafe { ptr::write_volatile(&usart2.dr as *const _ as *mut u8, byte) } Ok(()) } else { Err(nb::Error::WouldBlock) diff --git a/src/spi.rs b/src/spi.rs index af74a3f..5001b73 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -28,7 +28,7 @@ use core::ptr; use hal; use nb; -use stm32f413::{SPI1, SPI2, SPI3, GPIOA, GPIOB, RCC}; +use stm32f429x::{SPI1, SPI2, SPI3, GPIOA, GPIOB, RCC}; /// SPI result pub type Result<T> = ::core::result::Result<T, nb::Error<Error>>; diff --git a/src/timer.rs b/src/timer.rs index 2856152..48c5cdb 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -5,7 +5,7 @@ use core::any::{Any, TypeId}; use cast::{u16, u32}; use hal; use nb::{self, Error}; -use stm32f413::{TIM1, TIM10, TIM11, TIM2, TIM3, TIM4, TIM5, TIM9, RCC}; +use stm32f429x::{TIM1, TIM10, TIM11, TIM2, TIM3, TIM4, TIM5, TIM9, RCC}; /// Channel associated to a timer #[derive(Clone, Copy, Debug)] -- GitLab