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

nucleo 64 port

parent c184f91e
No related branches found
No related tags found
No related merge requests found
...@@ -29,3 +29,6 @@ rustflags = [ ...@@ -29,3 +29,6 @@ rustflags = [
"-C", "linker=arm-none-eabi-ld", "-C", "linker=arm-none-eabi-ld",
"-Z", "linker-flavor=ld", "-Z", "linker-flavor=ld",
] ]
[build]
target = "thumbv7em-none-eabihf"
\ No newline at end of file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Debug one-task",
"gdbpath": "/usr/bin/arm-none-eabi-gdb",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/one-task",
"target": ":3333",
"remote": true,
"autorun": [
"monitor reset init",
"monitor arm semihosting enable",
"monitor tpiu config internal /tmp/itm.log uart off 16000000",
"monitor itm port 0 on",
"load"
],
"cwd": "${workspaceRoot}"
},
{
"type": "gdb",
"request": "attach",
"name": "Debug nested",
"gdbpath": "/usr/bin/arm-none-eabi-gdb",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/nested",
"target": ":3333",
"remote": true,
"autorun": [
"monitor reset init",
"monitor arm semihosting enable",
"monitor tpiu config internal /tmp/itm.log uart off 16000000",
"monitor itm port 0 on",
"load"
],
"cwd": "${workspaceRoot}"
},
{
"type": "gdb",
"request": "attach",
"name": "Debug full-syntax",
"gdbpath": "/usr/bin/arm-none-eabi-gdb",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/full-syntax",
"target": ":3333",
"remote": true,
"autorun": [
"monitor reset init",
"monitor arm semihosting enable",
"monitor tpiu config internal /tmp/itm.log uart off 16000000",
"monitor itm port 0 on",
"load"
],
"cwd": "${workspaceRoot}"
},
{
"type": "gdb",
"request": "attach",
"name": "Debug late-resource",
"gdbpath": "/usr/bin/arm-none-eabi-gdb",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/late-resource",
"target": ":3333",
"remote": true,
"autorun": [
"monitor reset init",
"monitor arm semihosting enable",
"monitor tpiu config internal /tmp/itm.log uart off 16000000",
"monitor itm port 0 on",
"load"
],
"cwd": "${workspaceRoot}"
},
{
"type": "gdb",
"request": "attach",
"name": "Debug preemption",
"gdbpath": "/usr/bin/arm-none-eabi-gdb",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/preemption",
"target": ":3333",
"remote": true,
"autorun": [
"monitor reset init",
"monitor arm semihosting enable",
"monitor tpiu config internal /tmp/itm.log uart off 16000000",
"monitor itm port 0 on",
"load"
],
"cwd": "${workspaceRoot}"
},
{
"type": "gdb",
"request": "attach",
"name": "Debug zero-tasks",
"gdbpath": "/usr/bin/arm-none-eabi-gdb",
"executable": "./target/thumbv7em-none-eabihf/debug/examples/zero-tasks",
"target": ":3333",
"remote": true,
"autorun": [
"monitor reset init",
"monitor arm semihosting enable",
"monitor tpiu config internal /tmp/itm.log uart off 16000000",
"monitor itm port 0 on",
"load"
],
"cwd": "${workspaceRoot}"
}
]
}
\ No newline at end of file
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "xargo build --example one-task",
"type": "shell",
"command": "xargo build --example one-task",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "xargo build --example nested",
"type": "shell",
"command": "xargo build --example nested",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "xargo build --example preemption",
"type": "shell",
"command": "xargo build --example preemption",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "xargo build --example late-resources",
"type": "shell",
"command": "xargo build --example late-resources",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "xargo build --example generics",
"type": "shell",
"command": "xargo build --example generics",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "xargo build --example full-syntax",
"type": "shell",
"command": "xargo build --example full-syntax",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "xargo build --example zero-tasks",
"type": "shell",
"command": "xargo build --example zero-tasks",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
}
]
}
\ No newline at end of file
...@@ -25,9 +25,10 @@ compiletest_rs = "0.2.8" ...@@ -25,9 +25,10 @@ compiletest_rs = "0.2.8"
features = ["abort-on-panic"] features = ["abort-on-panic"]
version = "0.3.3" version = "0.3.3"
[dev-dependencies.stm32f103xx] [dev-dependencies.stm32f40x]
git = "https://gitlab.henriktjader.com/pln/STM32F40x"
features = ["rt"] features = ["rt"]
version = "0.7.5" version = "0.1.0"
[profile.release] [profile.release]
lto = true lto = true
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; extern crate stm32f40x;
use rtfm::{app, Threshold}; use rtfm::{app, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f40x,
resources: { resources: {
static CO_OWNED: u32 = 0; static CO_OWNED: u32 = 0;
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; extern crate stm32f40x;
use rtfm::{app, Resource, Threshold}; use rtfm::{app, Resource, Threshold};
use stm32f103xx::{SPI1, GPIOA}; use stm32f40x::{SPI1, GPIOA};
app! { app! {
device: stm32f103xx, device: stm32f40x,
tasks: { tasks: {
EXTI0: { EXTI0: {
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; extern crate stm32f40x;
use rtfm::{app, Threshold}; use rtfm::{app, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f40x,
resources: { resources: {
// Usually, resources are initialized with a constant initializer: // Usually, resources are initialized with a constant initializer:
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; extern crate stm32f40x;
use stm32f103xx::Interrupt; use stm32f40x::Interrupt;
use rtfm::{app, Resource, Threshold}; use rtfm::{app, Resource, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f40x,
resources: { resources: {
static LOW: u64 = 0; static LOW: u64 = 0;
...@@ -107,6 +107,10 @@ fn exti0( ...@@ -107,6 +107,10 @@ fn exti0(
// Upon leaving the critical section the preemption threshold drops back // Upon leaving the critical section the preemption threshold drops back
// to 2 and `exti2` immediately preempts this task // to 2 and `exti2` immediately preempts this task
// ~> exti2 // ~> exti2
// I
// After excecution of exti2 we now return to the exti0 task
rtfm::bkpt();
}); });
// Once again the preemption threshold drops but this time to 1. Now the // Once again the preemption threshold drops but this time to 1. Now the
......
...@@ -3,15 +3,16 @@ ...@@ -3,15 +3,16 @@
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
#[macro_use(iprint, iprintln)]
extern crate cortex_m; extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; extern crate stm32f40x;
use cortex_m::peripheral::SystClkSource; use cortex_m::peripheral::SystClkSource;
use rtfm::{app, Threshold}; use rtfm::{app, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f40x,
// Here data resources are declared // Here data resources are declared
// //
...@@ -35,29 +36,16 @@ app! { ...@@ -35,29 +36,16 @@ app! {
// These are the resources this task has access to. // These are the resources this task has access to.
// //
// A resource can be a peripheral like `GPIOC` or a static variable // A resource can be a peripheral like `ITM`
// like `ON` resources: [ITM, ON],
resources: [GPIOC, ON],
}, },
} }
} }
fn init(p: init::Peripherals, r: init::Resources) { fn init(p: init::Peripherals, _r: init::Resources) {
// `init` can modify all the `resources` declared in `app!`
r.ON;
// power on GPIOC
p.RCC.apb2enr.modify(|_, w| w.iopcen().enabled());
// configure PC13 as output
p.GPIOC.bsrr.write(|w| w.bs13().set());
p.GPIOC
.crh
.modify(|_, w| w.mode13().output().cnf13().push());
// configure the system timer to generate one interrupt every second // configure the system timer to generate one interrupt every second
p.SYST.set_clock_source(SystClkSource::Core); p.SYST.set_clock_source(SystClkSource::Core);
p.SYST.set_reload(8_000_000); // 1s p.SYST.set_reload(16_000_000); // 1s
p.SYST.enable_interrupt(); p.SYST.enable_interrupt();
p.SYST.enable_counter(); p.SYST.enable_counter();
} }
...@@ -74,15 +62,6 @@ fn idle() -> ! { ...@@ -74,15 +62,6 @@ fn idle() -> ! {
// //
// `r` is the set of resources this task has access to. `SYS_TICK::Resources` // `r` is the set of resources this task has access to. `SYS_TICK::Resources`
// has one field per resource declared in `app!`. // has one field per resource declared in `app!`.
fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) { fn sys_tick(_t: &mut Threshold, p: SYS_TICK::Resources) {
// toggle state iprintln!(&p.ITM.stim[0], "Hello");
**r.ON = !**r.ON;
if **r.ON {
// set the pin PC13 high
r.GPIOC.bsrr.write(|w| w.bs13().set());
} else {
// set the pin PC13 low
r.GPIOC.bsrr.write(|w| w.br13().reset());
}
} }
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; extern crate stm32f40x;
use rtfm::{app, Resource, Threshold}; use rtfm::{app, Resource, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f40x,
resources: { resources: {
static COUNTER: u64 = 0; static COUNTER: u64 = 0;
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; extern crate stm32f40x;
use rtfm::{app, Threshold}; use rtfm::{app, Threshold};
app! { app! {
device: stm32f103xx, device: stm32f40x,
resources: { resources: {
static COUNTER: u64 = 0; static COUNTER: u64 = 0;
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; // IMPORTANT always do this rename extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx; // the device crate // IMPORTANT always do this rename
extern crate stm32f40x; // the device crate
// import the procedural macro // import the procedural macro
use rtfm::app; use rtfm::app;
...@@ -16,7 +17,7 @@ use rtfm::app; ...@@ -16,7 +17,7 @@ use rtfm::app;
// `main` yourself. // `main` yourself.
app! { app! {
// this is the path to the device crate // this is the path to the device crate
device: stm32f103xx, device: stm32f40x,
} }
// The initialization phase. // The initialization phase.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment