Skip to content
Snippets Groups Projects
Commit 1595f50f authored by Per's avatar Per
Browse files

rtfm_blinky wip

parent 23ddecd9
No related branches found
No related tags found
No related merge requests found
[]
\ No newline at end of file
[{"node":"UART9","expanded":true,"format":0},{"node":"USART2.SR","expanded":true,"format":0}]
\ No newline at end of file
......@@ -184,6 +184,34 @@
"svdFile": "STM32F413.svd",
"cwd": "${workspaceRoot}"
},
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"name": "rtfm_blinky (debug)",
"preLaunchTask": "cargo build --example rtfm_blinky",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/rtfm_blinky",
// uses local config files
"configFiles": [
"./stlink.cfg",
"./stm32f4x.cfg"
],
"swoConfig": {
"enabled": true,
"cpuFrequency": 16000000,
"swoFrequency": 2000000,
"source": "probe",
"decoders": [
{
"type": "console",
"label": "ITM",
"port": 0
}
]
},
"svdFile": "STM32F413.svd",
"cwd": "${workspaceRoot}"
},
{
"type": "cortex-debug",
"request": "launch",
......@@ -609,5 +637,69 @@
"svdFile": "STM32F413.svd",
"cwd": "${workspaceRoot}"
},
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"name": "bare10 (reselase)",
"preLaunchTask": "cargo build --example bare10 --release",
"executable": "./target/thumbv7em-none-eabihf/release/examples/bare10",
"configFiles": [
"interface/stlink.cfg",
"target/stm32f4x.cfg"
],
"swoConfig": {
"enabled": true,
"cpuFrequency": 16000000,
"swoFrequency": 2000000,
"source": "probe",
"decoders": [
{
"type": "console",
"label": "ITM0",
"port": 0
},
{
"type": "console",
"label": "ITM1",
"port": 1
}
]
},
"svdFile": "STM32F413.svd",
"cwd": "${workspaceRoot}"
},
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"name": "bare10 (debug)",
"preLaunchTask": "cargo build --example bare10",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/bare10",
"configFiles": [
"interface/stlink.cfg",
"target/stm32f4x.cfg"
],
"swoConfig": {
"enabled": true,
"cpuFrequency": 16000000,
"swoFrequency": 2000000,
"source": "probe",
"decoders": [
{
"type": "console",
"label": "ITM0",
"port": 0
},
// {
// "type": "console",
// "label": "ITM1",
// "port": 1
// }
]
},
"svdFile": "STM32F413.svd",
"cwd": "${workspaceRoot}"
},
]
}
\ No newline at end of file
......@@ -87,6 +87,18 @@
"isDefault": true
}
},
{
"type": "shell",
"label": "cargo build --example rtfm_blinky",
"command": "cargo build --example rtfm_blinky --features \"hal rtfm\"",
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "cargo build --example rtfm_interrupt --features \"pac rtfm\"",
......@@ -267,5 +279,29 @@
"isDefault": true
}
},
{
"type": "shell",
"label": "cargo build --example bare10",
"command": "cargo build --example bare10 --features \"hal rtfm\"",
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "cargo build --example bare10 --release",
"command": "cargo build --example bare10 --release --features \"hal rtfm\"",
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
]
}
\ No newline at end of file
......@@ -14,11 +14,11 @@ use hal::stm32::ITM;
use heapless::consts::*;
use heapless::spsc::{Consumer, Producer, Queue};
use nb::block;
use rtfm::app;
#[app(device = hal::stm32)]
const APP: () = {
// Late resources
static mut TX: Tx<hal::stm32::USART2> = ();
......@@ -38,7 +38,7 @@ const APP: () = {
let (producer, consumer) = RB.as_mut().unwrap().split();
let stim = &mut core.ITM.stim[0];
iprintln!(stim, "start");
iprintln!(stim, "bare9");
let rcc = device.RCC.constrain();
......@@ -49,6 +49,7 @@ const APP: () = {
let tx = gpioa.pa2.into_alternate_af7();
let rx = gpioa.pa3.into_alternate_af7(); // try comment out
// let rx = gpioa.pa3.into_alternate_af6(); // try uncomment
let mut serial = Serial::usart2(
device.USART2,
......@@ -101,7 +102,7 @@ const APP: () = {
match rx.read() {
Ok(byte) => {
let _ = tx.write(byte);
block!(tx.write(byte)).unwrap();
match resources.PRODUCER.enqueue(byte) {
Ok(_) => {}
Err(_) => asm::bkpt(),
......
#![no_main]
#![no_std]
extern crate panic_halt;
use cortex_m::peripheral::syst::SystClkSource;
use stm32f4::stm32f413::GPIOA;
use rtfm::app;
#[app(device = stm32f4::stm32f413)]
const APP: () = {
// late resorce binding
static mut GPIOA: GPIOA = ();
// init runs in an interrupt free section
#[init]
fn init() {
// configures the system timer to trigger a SysTick exception every second
core.SYST.set_clock_source(SystClkSource::Core);
core.SYST.set_reload(16_000_000); // period = 1s
core.SYST.enable_counter();
core.SYST.enable_interrupt();
// power on GPIOA, RM0368 6.3.11
device.RCC.ahb1enr.modify(|_, w| w.gpioaen().set_bit());
// configure PA5 as output, RM0368 8.4.1
device.GPIOA.moder.modify(|_, w| w.moder5().bits(1));
// pass on late resources
GPIOA = device.GPIOA;
}
#[exception (resources = [GPIOA])]
fn SysTick() {
static mut TOGGLE: bool = false;
if *TOGGLE {
GPIOA.bsrr().write(|w| w.bs5().set_bit());
} else {
GPIOA.bsrr.write(|w| w.br5().set_bit());
}
*TOGGLE = !TOGGLE;
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment