Skip to content
Snippets Groups Projects
Commit f7111f9e authored by Johannes Sjölund's avatar Johannes Sjölund
Browse files

Fork for STM32f411RE

parent 29526c2b
No related branches found
No related tags found
No related merge requests found
Showing with 226 additions and 326 deletions
target remote :3333
# monitor arm semihosting enable
monitor arm semihosting enable
# # send captured ITM to the file itm.fifo
# # (the microcontroller SWO pin must be connected to the programmer SWO pin)
......
......@@ -5,9 +5,9 @@ description = "Board Support Crate for the STM32F3DISCOVERY"
documentation = "https://docs.rs/f3"
keywords = ["arm", "cortex-m", "stm32"]
license = "MIT OR Apache-2.0"
name = "f3"
name = "f4"
repository = "https://github.com/japaric/f3"
version = "0.5.0"
version = "0.1.0"
[dependencies]
static-ref = "0.2.0"
......@@ -23,9 +23,10 @@ rev = "7d904f515d15fd5fe7ea34e18820ea83e2651fa2"
[dependencies.nb]
git = "https://github.com/japaric/nb"
[dependencies.stm32f30x]
[dependencies.stm32f40x]
features = ["rt"]
version = "0.5.0"
#version = "0.5.0"
git = "https://gitlab.henriktjader.com/pln/STM32F40x"
[dev-dependencies]
cortex-m = "0.3.0"
......
[![Build status](https://travis-ci.org/japaric/f3.svg?branch=master)](https://travis-ci.org/japaric/f3)
[![crates.io](https://img.shields.io/crates/d/f3.svg)](https://crates.io/crates/f3)
[![crates.io](https://img.shields.io/crates/v/f3.svg)](https://crates.io/crates/f3)
# `f4`
# `f3`
> Board Support Crate for the NUCLEO-F411RE
> Board Support Crate for the STM32F3DISCOVERY
[STM32F3DISCOVERY]: http://www.st.com/en/evaluation-tools/stm32f3discovery.html
[NUCLEO-F411RE]: http://www.st.com/en/evaluation-tools/nucleo-f411re.html
## [Documentation](https://docs.rs/f3)
......
......@@ -4,12 +4,12 @@
#![feature(proc_macro)]
#![no_std]
extern crate f3;
extern crate f4;
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
use cortex_m::peripheral::SystClkSource;
use f3::led::{self, LEDS};
use f4::led::{self, LEDS};
use rtfm::{app, Threshold};
// CONFIGURATION
......@@ -17,7 +17,7 @@ const FREQUENCY: u32 = 4; // Hz
// TASKS & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
resources: {
static ON: bool = false;
......@@ -33,10 +33,10 @@ app! {
// INITIALIZATION PHASE
fn init(p: init::Peripherals, _r: init::Resources) {
led::init(p.GPIOE, p.RCC);
led::init(p.GPIOA, p.RCC);
p.SYST.set_clock_source(SystClkSource::Core);
p.SYST.set_reload(8_000_000 / FREQUENCY);
p.SYST.set_reload(16_000_000 / FREQUENCY);
p.SYST.enable_interrupt();
p.SYST.enable_counter();
}
......
......@@ -7,13 +7,13 @@
extern crate cast;
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
extern crate f3;
extern crate f4;
use f3::Serial;
use f3::led::{self, LEDS};
use f3::prelude::*;
use f3::serial::Event;
use f3::time::Hertz;
use f4::Serial;
use f4::led::{self, LEDS};
use f4::prelude::*;
use f4::serial::Event;
use f4::time::Hertz;
use cortex_m::peripheral::SystClkSource;
use cast::{usize, u8};
use rtfm::{app, Threshold};
......@@ -25,7 +25,7 @@ const DIVISOR: u32 = 4;
// TASKS & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
resources: {
static STATE: u8 = 0;
......@@ -37,23 +37,23 @@ app! {
resources: [STATE],
},
USART1_EXTI25: {
USART2: {
path: loopback,
resources: [USART1],
resources: [USART2],
},
}
}
// INITIALIZATION PHASE
fn init(p: init::Peripherals, _r: init::Resources) {
led::init(p.GPIOE, p.RCC);
led::init(p.GPIOA, p.RCC);
let serial = Serial(p.USART1);
let serial = Serial(p.USART2);
serial.init(BAUD_RATE.invert(), Some(p.DMA1), p.GPIOA, p.RCC);
serial.listen(Event::Rxne);
p.SYST.set_clock_source(SystClkSource::Core);
p.SYST.set_reload(8_000_000 / DIVISOR);
p.SYST.set_reload(16_000_000 / DIVISOR);
p.SYST.enable_interrupt();
p.SYST.enable_counter();
}
......@@ -67,8 +67,8 @@ fn idle() -> ! {
}
// TASKS
fn loopback(_t: &mut Threshold, r: USART1_EXTI25::Resources) {
let serial = Serial(&**r.USART1);
fn loopback(_t: &mut Threshold, r: USART2::Resources) {
let serial = Serial(&**r.USART2);
if let Ok(byte) = serial.read() {
if serial.write(byte).is_err() {
......
......@@ -6,7 +6,7 @@
extern crate cortex_m_rtfm as rtfm;
extern crate cortex_m_semihosting as semihosting;
extern crate f3;
extern crate f4;
use core::fmt::Write;
......@@ -15,7 +15,7 @@ use semihosting::hio;
// TASKS & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
}
// INITIALIZATION PHASE
......
......@@ -12,13 +12,13 @@
#[macro_use]
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
extern crate f3;
extern crate f4;
use rtfm::{app, Threshold};
// TASK & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
idle: {
resources: [ITM],
......
......@@ -5,19 +5,19 @@
#![no_std]
extern crate cortex_m_rtfm as rtfm;
extern crate f3;
extern crate f4;
use f3::led::{self, LEDS};
use f4::led::{self, LEDS};
use rtfm::app;
// TASKS & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
}
// INITIALIZATION PHASE
fn init(p: init::Peripherals) {
led::init(&p.GPIOE, &p.RCC);
led::init(&p.GPIOA, &p.RCC);
}
// IDLE LOOP
......
......@@ -5,12 +5,12 @@
#![no_std]
extern crate cortex_m_rtfm as rtfm;
extern crate f3;
extern crate f4;
use f3::prelude::*;
use f3::Serial;
use f3::serial::Event;
use f3::time::Hertz;
use f4::prelude::*;
use f4::Serial;
use f4::serial::Event;
use f4::time::Hertz;
use rtfm::{app, Threshold};
// CONFIGURATION
......@@ -18,19 +18,19 @@ const BAUD_RATE: Hertz = Hertz(115_200);
// TASKS & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
tasks: {
USART1_EXTI25: {
USART2: {
path: loopback,
resources: [USART1],
resources: [USART2],
},
}
}
// INITIALIZATION PHASE
fn init(p: init::Peripherals) {
let serial = Serial(p.USART1);
let serial = Serial(p.USART2);
serial.init(BAUD_RATE.invert(), Some(p.DMA1), p.GPIOA, p.RCC);
serial.listen(Event::Rxne);
......@@ -46,8 +46,8 @@ fn idle() -> ! {
// TASKS
// Send back the received byte
fn loopback(_t: &mut Threshold, r: USART1_EXTI25::Resources) {
let serial = Serial(&**r.USART1);
fn loopback(_t: &mut Threshold, r: USART2::Resources) {
let serial = Serial(&**r.USART2);
let byte = serial.read().unwrap();
serial.write(byte).unwrap();
......
......@@ -15,18 +15,18 @@
extern crate cast;
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
extern crate f3;
extern crate f4;
extern crate heapless;
use cast::{usize, u8};
use cortex_m::peripheral::SystClkSource;
use f3::Serial;
use f3::led::{self, LEDS};
use f3::prelude::*;
use f3::serial::Event;
use f4::Serial;
use f4::led::{self, LEDS};
use f4::prelude::*;
use f4::serial::Event;
use heapless::Vec;
use rtfm::{app, Resource, Threshold};
use f3::time::Hertz;
use f4::time::Hertz;
// CONFIGURATION
const BAUD_RATE: Hertz = Hertz(115_200);
......@@ -34,7 +34,7 @@ const DIVISOR: u32 = 4;
// TASK & RESOURCES
app!{
device: f3::stm32f30x,
device: f4::stm32f40x,
resources: {
static BUFFER: Vec<u8, [u8; 16]> = Vec::new([0; 16]);
......@@ -43,10 +43,10 @@ app!{
},
tasks: {
USART1_EXTI25: {
USART2: {
path: receive,
priority: 1,
resources: [BUFFER, SHARED, USART1],
resources: [BUFFER, SHARED, USART2],
},
SYS_TICK: {
......@@ -59,9 +59,9 @@ app!{
// INITIALIZATION PHASE
fn init(p: init::Peripherals, _r: init::Resources) {
led::init(&p.GPIOE, &p.RCC);
led::init(&p.GPIOA, &p.RCC);
let serial = Serial(p.USART1);
let serial = Serial(p.USART2);
serial.init(BAUD_RATE.invert(), Some(p.DMA1), p.GPIOA, p.RCC);
serial.listen(Event::Rxne);
......@@ -80,8 +80,8 @@ fn idle() -> ! {
}
// TASKS
fn receive(t: &mut Threshold, mut r: USART1_EXTI25::Resources) {
let serial = Serial(&**r.USART1);
fn receive(t: &mut Threshold, mut r: USART2::Resources) {
let serial = Serial(&**r.USART2);
let byte = serial.read().unwrap();
if serial.write(byte).is_err() {
......
......@@ -18,16 +18,16 @@
extern crate cast;
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
extern crate f3;
extern crate f4;
extern crate heapless;
use cast::{usize, u8};
use cortex_m::peripheral::SystClkSource;
use f3::Serial;
use f3::led::{self, LEDS};
use f3::prelude::*;
use f3::serial::Event;
use f3::time::Hertz;
use f4::Serial;
use f4::led::{self, LEDS};
use f4::prelude::*;
use f4::serial::Event;
use f4::time::Hertz;
use heapless::Vec;
use rtfm::{app, Threshold};
......@@ -37,7 +37,7 @@ const DIVISOR: u32 = 4;
// TASKS & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
resources: {
// 16 byte buffer
......@@ -47,9 +47,9 @@ app! {
},
tasks: {
USART1_EXTI25: {
USART2: {
path: receive,
resources: [BUFFER, SHARED, USART1],
resources: [BUFFER, SHARED, USART2],
},
SYS_TICK: {
......@@ -61,15 +61,15 @@ app! {
// INITIALIZATION PHASE
fn init(p: init::Peripherals, _r: init::Resources) {
led::init(&p.GPIOE, &p.RCC);
led::init(&p.GPIOA, &p.RCC);
let serial = Serial(p.USART1);
let serial = Serial(p.USART2);
serial.init(BAUD_RATE.invert(), Some(p.DMA1), p.GPIOA, p.RCC);
serial.listen(Event::Rxne);
p.SYST.set_clock_source(SystClkSource::Core);
p.SYST.set_reload(8_000_000 / DIVISOR);
p.SYST.set_reload(16_000_000 / DIVISOR);
p.SYST.enable_interrupt();
p.SYST.enable_counter();
}
......@@ -83,8 +83,8 @@ fn idle() -> ! {
}
// TASKS
fn receive(_t: &mut Threshold, r: USART1_EXTI25::Resources) {
let serial = Serial(&**r.USART1);
fn receive(_t: &mut Threshold, r: USART2::Resources) {
let serial = Serial(&**r.USART2);
let byte = serial.read().unwrap();
......
......@@ -5,13 +5,13 @@
#![no_std]
extern crate cast;
extern crate f3;
extern crate f4;
extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
use cast::{usize, u8};
use cortex_m::peripheral::SystClkSource;
use f3::led::{self, LEDS};
use f4::led::{self, LEDS};
use rtfm::{app, Threshold};
// CONFIGURATION
......@@ -19,7 +19,7 @@ const DIVISOR: u32 = 4;
// TASKS & RESOURCES
app! {
device: f3::stm32f30x,
device: f4::stm32f40x,
resources: {
static STATE: u8 = 0;
......@@ -35,10 +35,10 @@ app! {
// INITIALIZATION PHASE
fn init(p: init::Peripherals, _r: init::Resources) {
led::init(p.GPIOE, p.RCC);
led::init(p.GPIOA, p.RCC);
p.SYST.set_clock_source(SystClkSource::Core);
p.SYST.set_reload(8_000_000 / DIVISOR);
p.SYST.set_reload(16_000_000 / DIVISOR);
p.SYST.enable_interrupt();
p.SYST.enable_counter();
}
......
File mode changed from 100644 to 100755
MEMORY
{
CCRAM : ORIGIN = 0x10000000, LENGTH = 8K
FLASH : ORIGIN = 0x08000000, LENGTH = 256K
RAM : ORIGIN = 0x20000000, LENGTH = 40K
/* NOTE K = KiBi = 1024 bytes */
/* TODO Adjust these memory regions to match your device memory layout */
FLASH : ORIGIN = 0x08000000, LENGTH = 512K
RAM : ORIGIN = 0x20000000, LENGTH = 96K
}
_stack_start = ORIGIN(CCRAM) + LENGTH(CCRAM);
/* This is where the call stack will be allocated. */
/* The stack is of the full descending type. */
/* You may want to use this variable to locate the call stack and static
variables in different memory regions. Below is shown the default value */
/* _stack_start = ORIGIN(RAM) + LENGTH(RAM); */
/* You can use this symbol to customize the location of the .text section */
/* If omitted the .text section will be placed right after the .vector_table
section */
/* This is required only on microcontrollers that store some configuration right
after the vector table */
/* _stext = ORIGIN(FLASH) + 0x400; */
......@@ -5,7 +5,7 @@ use core::marker::PhantomData;
use core::ops;
use nb;
use stm32f30x::DMA1;
use stm32f40x::DMA1;
/// DMA error
#[derive(Debug)]
......@@ -24,8 +24,8 @@ pub struct Dma1Channel2 {
_0: (),
}
/// Channel 4 of DMA1
pub struct Dma1Channel4 {
/// Channel 6 of DMA1
pub struct Dma1Channel6 {
_0: (),
}
......@@ -201,12 +201,12 @@ impl<T> Buffer<T, Dma1Channel2> {
return Ok(());
}
if dma1.isr.read().teif2().bit_is_set() {
if dma1.lisr.read().teif2().bit_is_set() {
Err(nb::Error::Other(Error::Transfer))
} else if dma1.isr.read().tcif2().bit_is_set() {
} else if dma1.lisr.read().tcif2().bit_is_set() {
unsafe { self.unlock(state) }
dma1.ifcr.write(|w| w.ctcif2().set_bit());
dma1.ccr2.modify(|_, w| w.en().clear_bit());
dma1.lifcr.write(|w| w.ctcif2().set_bit());
dma1.s2cr.modify(|_, w| w.en().clear_bit());
Ok(())
} else {
Err(nb::Error::WouldBlock)
......@@ -214,7 +214,7 @@ impl<T> Buffer<T, Dma1Channel2> {
}
}
impl<T> Buffer<T, Dma1Channel4> {
impl<T> Buffer<T, Dma1Channel6> {
/// Waits until the DMA releases this buffer
pub fn release(&self, dma1: &DMA1) -> nb::Result<(), Error> {
let state = self.state.get();
......@@ -223,12 +223,12 @@ impl<T> Buffer<T, Dma1Channel4> {
return Ok(());
}
if dma1.isr.read().teif4().bit_is_set() {
if dma1.hisr.read().teif6().bit_is_set() {
Err(nb::Error::Other(Error::Transfer))
} else if dma1.isr.read().tcif4().bit_is_set() {
} else if dma1.hisr.read().tcif6().bit_is_set() {
unsafe { self.unlock(state) }
dma1.ifcr.write(|w| w.ctcif4().set_bit());
dma1.ccr4.modify(|_, w| w.en().clear_bit());
dma1.hifcr.write(|w| w.ctcif6().set_bit());
dma1.s6cr.modify(|_, w| w.en().clear_bit());
Ok(())
} else {
Err(nb::Error::WouldBlock)
......@@ -245,12 +245,12 @@ impl<T> Buffer<T, Dma1Channel5> {
return Ok(());
}
if dma1.isr.read().teif5().bit_is_set() {
if dma1.hisr.read().teif5().bit_is_set() {
Err(nb::Error::Other(Error::Transfer))
} else if dma1.isr.read().tcif5().bit_is_set() {
} else if dma1.hisr.read().tcif5().bit_is_set() {
unsafe { self.unlock(state) }
dma1.ifcr.write(|w| w.ctcif5().set_bit());
dma1.ccr5.modify(|_, w| w.en().clear_bit());
dma1.hifcr.write(|w| w.ctcif5().set_bit());
dma1.s5cr.modify(|_, w| w.en().clear_bit());
Ok(())
} else {
Err(nb::Error::WouldBlock)
......
//! Prints "Hello" and then "World" on the OpenOCD console
//! Prints "Hello, world" on the OpenOCD console
//!
//! ```
//!
//! #![feature(used)]
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! // version = "0.2.6"
//! #[macro_use]
//! extern crate cortex_m;
//!
//! // version = "0.2.0"
//! extern crate cortex_m_rt;
//!
//! // version = "0.1.0"
//! #[macro_use]
//! extern crate cortex_m_rtfm as rtfm;
//! extern crate cortex_m_semihosting as semihosting;
//! extern crate f4;
//!
//! extern crate f3;
//! use core::fmt::Write;
//!
//! use f3::stm32f30x;
//! use rtfm::{P0, T0, TMax};
//! use rtfm::app;
//! use semihosting::hio;
//!
//! // TASKS
//! tasks!(stm32f30x, {});
//! // TASKS & RESOURCES
//! app! {
//! device: f4::stm32f40x,
//! }
//!
//! // INITIALIZATION PHASE
//! fn init(_priority: P0, _threshold: &TMax) {
//! hprintln!("Hello");
//! }
//! fn init(_p: init::Peripherals) {}
//!
//! // IDLE LOOP
//! fn idle(_priority: P0, _threshold: T0) -> ! {
//! hprintln!("World");
//! fn idle() -> ! {
//! writeln!(hio::hstdout().unwrap(), "Hello, world!").unwrap();
//!
//! // Sleep
//! loop {
//! rtfm::wfi();
//! }
......
......@@ -6,55 +6,40 @@
//! [`itm`]: https://docs.rs/itm/0.1.1/itm/
//!
//! ```
//!
//! #![feature(const_fn)]
//! #![feature(used)]
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! // version = "0.2.6"
//! #[macro_use]
//! extern crate cortex_m;
//!
//! // version = "0.2.0"
//! extern crate cortex_m_rt;
//!
//! // version = "0.1.0"
//! #[macro_use]
//! extern crate cortex_m_rtfm as rtfm;
//! extern crate f4;
//!
//! extern crate f3;
//! use rtfm::{app, Threshold};
//!
//! use f3::stm32f30x;
//! use rtfm::{P0, T0, TMax};
//! // TASK & RESOURCES
//! app! {
//! device: f4::stm32f40x,
//!
//! // RESOURCES
//! peripherals!(stm32f30x, {
//! ITM: Peripheral {
//! register_block: Itm,
//! ceiling: C0,
//! idle: {
//! resources: [ITM],
//! },
//! });
//! }
//!
//! // INITIALIZATION PHASE
//! fn init(ref priority: P0, threshold: &TMax) {
//! let itm = ITM.access(priority, threshold);
//!
//! iprintln!(&itm.stim[0], "Hello");
//! fn init(p: init::Peripherals) {
//! iprintln!(&p.ITM.stim[0], "Hello");
//! }
//!
//! // IDLE LOOP
//! fn idle(ref priority: P0, ref threshold: T0) -> ! {
//! let itm = ITM.access(priority, threshold);
//!
//! iprintln!(&itm.stim[0], "World");
//! fn idle(_t: &mut Threshold, r: idle::Resources) -> ! {
//! iprintln!(&r.ITM.stim[0], "World");
//!
//! // Sleep
//! loop {
//! rtfm::wfi();
//! }
//! }
//!
//! // TASKS
//! tasks!(stm32f30x, {});
//! ```
// Auto-generated. Do not modify.
//! Turns all the user LEDs on
//!
//! ```
//!
//! #![feature(const_fn)]
//! #![feature(used)]
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! // version = "0.2.0"
//! extern crate cortex_m_rt;
//!
//! // version = "0.1.0"
//! #[macro_use]
//! extern crate cortex_m_rtfm as rtfm;
//! extern crate f4;
//!
//! extern crate f3;
//!
//! use f3::led::{self, LEDS};
//! use f3::stm32f30x;
//! use rtfm::{P0, T0, TMax};
//! use f4::led::{self, LEDS};
//! use rtfm::app;
//!
//! // RESOURCES
//! peripherals!(stm32f30x, {
//! GPIOE: Peripheral {
//! register_block: Gpioe,
//! ceiling: C0,
//! },
//! RCC: Peripheral {
//! register_block: Rcc,
//! ceiling: C0,
//! },
//! });
//! // TASKS & RESOURCES
//! app! {
//! device: f4::stm32f40x,
//! }
//!
//! // INITIALIZATION PHASE
//! fn init(ref priority: P0, threshold: &TMax) {
//! let gpioe = GPIOE.access(priority, threshold);
//! let rcc = RCC.access(priority, threshold);
//!
//! led::init(&gpioe, &rcc);
//! fn init(p: init::Peripherals) {
//! led::init(&p.GPIOA, &p.RCC);
//! }
//!
//! // IDLE LOOP
//! fn idle(_priority: P0, _threshold: T0) -> ! {
//! fn idle() -> ! {
//! for led in &LEDS {
//! led.on();
//! }
......@@ -50,8 +33,5 @@
//! rtfm::wfi();
//! }
//! }
//!
//! // TASKS
//! tasks!(stm32f30x, {});
//! ```
// Auto-generated. Do not modify.
//! Blinks an LED
//!
//! ```
//!
//! #![feature(const_fn)]
//! #![feature(used)]
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! // version = "0.2.0"
//! extern crate cortex_m_rt;
//!
//! // version = "0.1.0"
//! #[macro_use]
//! extern crate f4;
//! extern crate cortex_m;
//! extern crate cortex_m_rtfm as rtfm;
//!
//! extern crate f3;
//!
//! use f3::led::{self, LEDS};
//! use f3::stm32f30x::interrupt::Tim7;
//! use f3::stm32f30x;
//! use f3::timer::Timer;
//! use rtfm::{Local, P0, P1, T0, T1, TMax};
//! use cortex_m::peripheral::SystClkSource;
//! use f4::led::{self, LEDS};
//! use rtfm::{app, Threshold};
//!
//! // CONFIGURATION
//! const FREQUENCY: u32 = 1; // Hz
//! const FREQUENCY: u32 = 4; // Hz
//!
//! // TASKS & RESOURCES
//! app! {
//! device: f4::stm32f40x,
//!
//! // RESOURCES
//! peripherals!(stm32f30x, {
//! GPIOE: Peripheral {
//! register_block: Gpioe,
//! ceiling: C0,
//! resources: {
//! static ON: bool = false;
//! },
//! RCC: Peripheral {
//! register_block: Rcc,
//! ceiling: C0,
//!
//! tasks: {
//! SYS_TICK: {
//! path: toggle,
//! resources: [ON],
//! },
//! TIM7: Peripheral {
//! register_block: Tim7,
//! ceiling: C1,
//! },
//! });
//! }
//!
//! // INITIALIZATION PHASE
//! fn init(ref priority: P0, threshold: &TMax) {
//! let gpioe = GPIOE.access(priority, threshold);
//! let rcc = RCC.access(priority, threshold);
//! let tim7 = TIM7.access(priority, threshold);
//! let timer = Timer(&tim7);
//!
//! // Configure the PEx pins as output pins
//! led::init(&gpioe, &rcc);
//!
//! // Configure TIM7 for periodic update events
//! timer.init(&rcc, FREQUENCY);
//! fn init(p: init::Peripherals, _r: init::Resources) {
//! led::init(p.GPIOA, p.RCC);
//!
//! // Start the timer
//! timer.resume();
//! p.SYST.set_clock_source(SystClkSource::Core);
//! p.SYST.set_reload(16_000_000 / FREQUENCY);
//! p.SYST.enable_interrupt();
//! p.SYST.enable_counter();
//! }
//!
//! // IDLE LOOP
//! fn idle(_priority: P0, _threshold: T0) -> ! {
//! fn idle() -> ! {
//! // Sleep
//! loop {
//! rtfm::wfi();
......@@ -66,36 +52,15 @@
//! }
//!
//! // TASKS
//! tasks!(stm32f30x, {
//! periodic: Task {
//! interrupt: Tim7,
//! priority: P1,
//! enabled: true,
//! },
//! });
//!
//! fn periodic(mut task: Tim7, ref priority: P1, ref threshold: T1) {
//! // Task local data
//! static STATE: Local<bool, Tim7> = Local::new(false);
//!
//! let tim7 = TIM7.access(priority, threshold);
//! let timer = Timer(&tim7);
//!
//! if timer.clear_update_flag().is_ok() {
//! let state = STATE.borrow_mut(&mut task);
//! // Toggle the state of the LED
//! fn toggle(_t: &mut Threshold, r: SYS_TICK::Resources) {
//! **r.ON = !**r.ON;
//!
//! *state = !*state;
//!
//! if *state {
//! if **r.ON {
//! LEDS[0].on();
//! } else {
//! LEDS[0].off();
//! }
//! } else {
//! // Only reachable through `rtfm::request(periodic)`
//! #[cfg(debug_assertion)]
//! unreachable!()
//! }
//! }
//! ```
// Auto-generated. Do not modify.
//! A LED roulette!
//!
//! ```
//!
//! #![feature(const_fn)]
//! #![feature(used)]
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! // version = "0.2.2", default-features = false
//! extern crate cast;
//!
//! // version = "0.2.0"
//! extern crate cortex_m_rt;
//!
//! // version = "0.1.0"
//! #[macro_use]
//! extern crate f4;
//! extern crate cortex_m;
//! extern crate cortex_m_rtfm as rtfm;
//!
//! extern crate f3;
//!
//! use cast::{u8, usize};
//! use f3::led::{self, LEDS};
//! use f3::stm32f30x::interrupt::Tim7;
//! use f3::stm32f30x;
//! use f3::timer::Timer;
//! use rtfm::{Local, P0, P1, T0, T1, TMax};
//! use cast::{usize, u8};
//! use cortex_m::peripheral::SystClkSource;
//! use f4::led::{self, LEDS};
//! use rtfm::{app, Threshold};
//!
//! // CONFIGURATION
//! const FREQUENCY: u32 = 4; // Hz
//! const DIVISOR: u32 = 4;
//!
//! // RESOURCES
//! peripherals!(stm32f30x, {
//! GPIOE: Peripheral {
//! register_block: Gpioe,
//! ceiling: C0,
//! // TASKS & RESOURCES
//! app! {
//! device: f4::stm32f40x,
//!
//! resources: {
//! static STATE: u8 = 0;
//! },
//! RCC: Peripheral {
//! register_block: Rcc,
//! ceiling: C0,
//!
//! tasks: {
//! SYS_TICK: {
//! path: roulette,
//! resources: [STATE],
//! },
//! TIM7: Peripheral {
//! register_block: Tim7,
//! ceiling: C1,
//! },
//! });
//! }
//!
//! // INITIALIZATION PHASE
//! fn init(ref priority: P0, threshold: &TMax) {
//! let gpioe = GPIOE.access(priority, threshold);
//! let rcc = RCC.access(priority, threshold);
//! let tim7 = TIM7.access(priority, threshold);
//! let timer = Timer(&tim7);
//! fn init(p: init::Peripherals, _r: init::Resources) {
//! led::init(p.GPIOA, p.RCC);
//!
//! led::init(&gpioe, &rcc);
//! timer.init(&rcc, FREQUENCY);
//! timer.resume();
//! p.SYST.set_clock_source(SystClkSource::Core);
//! p.SYST.set_reload(16_000_000 / DIVISOR);
//! p.SYST.enable_interrupt();
//! p.SYST.enable_counter();
//! }
//!
//! // IDLE LOOP
//! fn idle(_priority: P0, _threshold: T0) -> ! {
//! fn idle() -> ! {
//! // Sleep
//! loop {
//! rtfm::wfi();
......@@ -65,35 +54,14 @@
//! }
//!
//! // TASKS
//! tasks!(stm32f30x, {
//! roulette: Task {
//! interrupt: Tim7,
//! priority: P1,
//! enabled: true,
//! },
//! });
//!
//! fn roulette(mut task: Tim7, ref priority: P1, ref threshold: T1) {
//! static STATE: Local<u8, Tim7> = Local::new(0);
//!
//! let tim7 = TIM7.access(priority, threshold);
//! let timer = Timer(&tim7);
//!
//! if timer.clear_update_flag().is_ok() {
//! let state = STATE.borrow_mut(&mut task);
//!
//! let curr = *state;
//! fn roulette(_t: &mut Threshold, r: SYS_TICK::Resources) {
//! let curr = **r.STATE;
//! let next = (curr + 1) % u8(LEDS.len()).unwrap();
//!
//! LEDS[usize(curr)].off();
//! LEDS[usize(next)].on();
//!
//! *state = next;
//! } else {
//! // Only reachable through `rtfm::request(roulette)`
//! #[cfg(debug_assertion)]
//! unreachable!()
//! }
//! **r.STATE = next;
//! }
//! ```
// Auto-generated. Do not modify.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment