Skip to content
Snippets Groups Projects
Commit a06a5e0b authored by Per Lindgren's avatar Per Lindgren
Browse files

bare8, 9

parent b7b96ccd
No related branches found
No related tags found
No related merge requests found
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
}, },
{ {
"type": "shell", "type": "shell",
"label": "cargo build --example device --features stm32f4", "label": "cargo build --example device --features pac",
"command": "cargo build --example device --features stm32f4", "command": "cargo build --example device --features pac",
"problemMatcher": [ "problemMatcher": [
"$rustc" "$rustc"
], ],
...@@ -77,8 +77,8 @@ ...@@ -77,8 +77,8 @@
}, },
{ {
"type": "shell", "type": "shell",
"label": "cargo build --example rtfm_interrupt --features stm32f4", "label": "cargo build --example rtfm_interrupt --features \"pac rtfm\"",
"command": "cargo build --example rtfm_interrupt --features stm32f4", "command": "cargo build --example rtfm_interrupt --features \"pac rtfm\"",
"problemMatcher": [ "problemMatcher": [
"$rustc" "$rustc"
], ],
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
{ {
"type": "shell", "type": "shell",
"label": "cargo build --example bare7 --features stm32f4", "label": "cargo build --example bare7 --features stm32f4",
"command": "cargo build --example bare7 --features stm32f4", "command": "cargo build --example bare7 --features \"hal pac\"",
"problemMatcher": [ "problemMatcher": [
"$rustc" "$rustc"
], ],
...@@ -234,19 +234,7 @@ ...@@ -234,19 +234,7 @@
{ {
"type": "shell", "type": "shell",
"label": "cargo build --example bare8 --features stm32f4", "label": "cargo build --example bare8 --features stm32f4",
"command": "cargo build --example bare8 --features stm32f4", "command": "cargo build --example bare8 --features \"hal rtfm\"",
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "cargo build --example bare8 --features stm32f4",
"command": "cargo build --example bare8 --features stm32f4",
"problemMatcher": [ "problemMatcher": [
"$rustc" "$rustc"
], ],
...@@ -258,7 +246,7 @@ ...@@ -258,7 +246,7 @@
{ {
"type": "shell", "type": "shell",
"label": "cargo build --example bare9 --features stm32f4", "label": "cargo build --example bare9 --features stm32f4",
"command": "cargo build --example bare9 --features stm32f4", "command": "cargo build --example bare9 --features \"hal rtfm\"",
"problemMatcher": [ "problemMatcher": [
"$rustc" "$rustc"
], ],
......
...@@ -19,7 +19,10 @@ panic-semihosting = "0.5.1" ...@@ -19,7 +19,10 @@ panic-semihosting = "0.5.1"
panic-itm = "0.4.0" panic-itm = "0.4.0"
bare-metal = "0.2.4" bare-metal = "0.2.4"
nb = "0.1.1" nb = "0.1.1"
cortex-m-rtfm = "0.4.0"
[dependencies.cortex-m-rtfm]
version = "0.4.0"
optional = true
[dependencies.cortex-m] [dependencies.cortex-m]
version = "0.5.8" version = "0.5.8"
...@@ -31,12 +34,18 @@ features = ["inline-asm"] # <- currently requires nightly compiler ...@@ -31,12 +34,18 @@ features = ["inline-asm"] # <- currently requires nightly compiler
[dependencies.stm32f4] [dependencies.stm32f4]
version = "0.5.0" version = "0.5.0"
features = ["stm32f413", "rt"] features = ["stm32f413", "rt"]
# optional = true optional = true
[dependencies.stm32f4xx-hal] [dependencies.stm32f4xx-hal]
git = "https://github.com/stm32-rs/stm32f4xx-hal.git" git = "https://github.com/stm32-rs/stm32f4xx-hal.git"
version = "0.2.8" version = "0.2.8"
features = ["stm32f413", "rt"] features = ["stm32f413", "rt"]
optional = true
[features]
hal = ["stm32f4", "stm32f4xx-hal"]
rtfm = ["cortex-m-rtfm"]
pac = ["stm32f4"]
# this lets you use `cargo fix`! # this lets you use `cargo fix`!
[[bin]] [[bin]]
......
...@@ -27,17 +27,15 @@ ...@@ -27,17 +27,15 @@
extern crate panic_halt; extern crate panic_halt;
use cortex_m::{iprintln, peripheral::itm::Stim}; use cortex_m::{iprintln, peripheral::itm::Stim};
use cortex_m_rt::{entry}; use cortex_m_rt::entry;
use stm32f4::stm32f411; use stm32f4::stm32f413;
use stm32f411::{ use stm32f413::{DWT, GPIOA, GPIOC, RCC};
DWT, GPIOA, GPIOC, RCC,
};
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
let p = stm32f411::Peripherals::take().unwrap(); let p = stm32f413::Peripherals::take().unwrap();
let mut c = stm32f411::CorePeripherals::take().unwrap(); let mut c = stm32f413::CorePeripherals::take().unwrap();
let stim = &mut c.ITM.stim[0]; let stim = &mut c.ITM.stim[0];
iprintln!(stim, "Hello, bare6!"); iprintln!(stim, "Hello, bare6!");
......
...@@ -5,25 +5,25 @@ ...@@ -5,25 +5,25 @@
extern crate panic_halt; extern crate panic_halt;
use cortex_m::iprintln; use cortex_m::{asm, iprintln};
use nb::block; use nb::block;
extern crate stm32f4xx_hal as hal; extern crate stm32f4xx_hal as hal;
use crate::hal::prelude::*; use crate::hal::prelude::*;
use crate::hal::serial::{config::Config, Rx, Serial, Tx}; use crate::hal::serial::{config::Config, Event, Rx, Serial, Tx};
use hal::stm32::{ITM, USART2}; use hal::stm32::ITM;
// use crate::hal::stm32::Interrupt::EXTI0; // use crate::hal::stm32::Interrupt::EXTI0;
use rtfm::app; use rtfm::app;
// use hal::stm32::Interrupt::EXTI0; // use hal::stm32::Interrupt::EXTI0;
#[app(device = hal::stm32)]
// #[app(device = stm32f4xx_hal::stm32)] // #[app(device = stm32f4xx_hal::stm32)]
#[app(device = hal::stm32)]
const APP: () = { const APP: () = {
// Late resources // Late resources
static mut TX: Tx<USART2> = (); static mut TX: Tx<hal::stm32::USART2> = ();
static mut RX: Rx<USART2> = (); static mut RX: Rx<hal::stm32::USART2> = ();
static mut ITM: ITM = (); static mut ITM: ITM = ();
// init runs in an interrupt free section // init runs in an interrupt free section
...@@ -42,7 +42,7 @@ const APP: () = { ...@@ -42,7 +42,7 @@ const APP: () = {
let tx = gpioa.pa2.into_alternate_af7(); let tx = gpioa.pa2.into_alternate_af7();
let rx = gpioa.pa3.into_alternate_af7(); // try comment out let rx = gpioa.pa3.into_alternate_af7(); // try comment out
let serial = Serial::usart2( let mut serial = Serial::usart2(
device.USART2, device.USART2,
(tx, rx), (tx, rx),
Config::default().baudrate(115_200.bps()), Config::default().baudrate(115_200.bps()),
...@@ -50,6 +50,8 @@ const APP: () = { ...@@ -50,6 +50,8 @@ const APP: () = {
) )
.unwrap(); .unwrap();
// generate interrupt on Rxne
serial.listen(Event::Rxne);
// Separate out the sender and receiver of the serial port // Separate out the sender and receiver of the serial port
let (tx, rx) = serial.split(); let (tx, rx) = serial.split();
...@@ -60,13 +62,28 @@ const APP: () = { ...@@ -60,13 +62,28 @@ const APP: () = {
} }
// idle may be interrupted by other interrupt/tasks in the system // idle may be interrupted by other interrupt/tasks in the system
#[idle(resources = [RX, TX, ITM])] // #[idle(resources = [RX, TX, ITM])]
#[idle(resources = [ITM])]
fn idle() -> ! { fn idle() -> ! {
loop {
resources.ITM.lock(|itm| {
let stim = &mut itm.stim[0];
iprintln!(stim, "goto sleep");
});
asm::wfi();
resources.ITM.lock(|itm| {
let stim = &mut itm.stim[0];
iprintln!(stim, "woken..");
});
}
}
#[interrupt(resources = [RX, TX, ITM])]
fn USART2() {
let rx = resources.RX; let rx = resources.RX;
let tx = resources.TX; let tx = resources.TX;
let stim = &mut resources.ITM.stim[0]; let stim = &mut resources.ITM.stim[0];
loop {
match block!(rx.read()) { match block!(rx.read()) {
Ok(byte) => { Ok(byte) => {
iprintln!(stim, "Ok {:?}", byte); iprintln!(stim, "Ok {:?}", byte);
...@@ -77,9 +94,6 @@ const APP: () = { ...@@ -77,9 +94,6 @@ const APP: () = {
} }
} }
} }
}
// #[interrupt]
// fn EXTI0() {}
}; };
// extern crate cortex_m_rtfm as rtfm; // extern crate cortex_m_rtfm as rtfm;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment