diff --git a/.cargo/config b/.cargo/config index 36061ee450eaf722a309f65e270a6b1afd7a0afc..1ab52827c2bfa858bc120a5e4f7a33137de3649c 100644 --- a/.cargo/config +++ b/.cargo/config @@ -29,3 +29,6 @@ rustflags = [ "-C", "linker=arm-none-eabi-ld", "-Z", "linker-flavor=ld", ] + +[build] +target = "thumbv7em-none-eabihf" \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000000000000000000000000000000000..f74e5c17e20f7853909494a33a6ecc946a4688d8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,110 @@ +{ + // 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 diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000000000000000000000000000000000..846c88a066025b9e3c9e44f8ec2a9c396e05c4dd --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,91 @@ +{ + // 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 diff --git a/Cargo.toml b/Cargo.toml index 3c772ff5bbf10f43a8d22915451db4012796d3ca..b71aaa61ca04e6125d0fa68d6fba59fb16302ada 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,9 +25,10 @@ compiletest_rs = "0.2.8" features = ["abort-on-panic"] version = "0.3.3" -[dev-dependencies.stm32f103xx] +[dev-dependencies.stm32f40x] +git = "https://gitlab.henriktjader.com/pln/STM32F40x" features = ["rt"] -version = "0.7.5" +version = "0.1.0" [profile.release] lto = true diff --git a/examples/full-syntax.rs b/examples/full-syntax.rs index 9b6b394e5e7442d6149a155a9e6ba0e7e12435cb..ecf4149c2d1c9e9bdd64000fc12e8f4d92874803 100644 --- a/examples/full-syntax.rs +++ b/examples/full-syntax.rs @@ -4,12 +4,12 @@ #![no_std] extern crate cortex_m_rtfm as rtfm; -extern crate stm32f103xx; +extern crate stm32f40x; use rtfm::{app, Threshold}; app! { - device: stm32f103xx, + device: stm32f40x, resources: { static CO_OWNED: u32 = 0; diff --git a/examples/generics.rs b/examples/generics.rs index 57c9b8ebc600e12d4c74abcede583272f884da55..394c84892ff1958a4f8fd21bccfcabc6c80d6ef9 100644 --- a/examples/generics.rs +++ b/examples/generics.rs @@ -4,13 +4,13 @@ #![no_std] extern crate cortex_m_rtfm as rtfm; -extern crate stm32f103xx; +extern crate stm32f40x; use rtfm::{app, Resource, Threshold}; -use stm32f103xx::{SPI1, GPIOA}; +use stm32f40x::{SPI1, GPIOA}; app! { - device: stm32f103xx, + device: stm32f40x, tasks: { EXTI0: { diff --git a/examples/late-resources.rs b/examples/late-resources.rs index bc386584d9b1b8204b89fb4935cb33227f542b6e..3bb851f976449ea38d03c59aef0053fc684e9db1 100644 --- a/examples/late-resources.rs +++ b/examples/late-resources.rs @@ -5,12 +5,12 @@ #![no_std] extern crate cortex_m_rtfm as rtfm; -extern crate stm32f103xx; +extern crate stm32f40x; use rtfm::{app, Threshold}; app! { - device: stm32f103xx, + device: stm32f40x, resources: { // Usually, resources are initialized with a constant initializer: diff --git a/examples/nested.rs b/examples/nested.rs index 1c164f86b029d221f2bd2ce0a2302bc9143ebcf2..86034961b2e281e602111cd053863eacf29bdf9e 100644 --- a/examples/nested.rs +++ b/examples/nested.rs @@ -7,13 +7,13 @@ #![no_std] extern crate cortex_m_rtfm as rtfm; -extern crate stm32f103xx; +extern crate stm32f40x; -use stm32f103xx::Interrupt; +use stm32f40x::Interrupt; use rtfm::{app, Resource, Threshold}; app! { - device: stm32f103xx, + device: stm32f40x, resources: { static LOW: u64 = 0; @@ -107,6 +107,10 @@ fn exti0( // Upon leaving the critical section the preemption threshold drops back // to 2 and `exti2` immediately preempts this task // ~> 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 diff --git a/examples/one-task.rs b/examples/one-task.rs index e58d9fcd90c543508c8b917fe50382d9d6a02c8f..59a90c8e66dc4b9f0c1fcf4655aa4879eb763d50 100644 --- a/examples/one-task.rs +++ b/examples/one-task.rs @@ -3,15 +3,16 @@ #![feature(proc_macro)] #![no_std] +#[macro_use(iprint, iprintln)] extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; -extern crate stm32f103xx; +extern crate stm32f40x; use cortex_m::peripheral::SystClkSource; use rtfm::{app, Threshold}; app! { - device: stm32f103xx, + device: stm32f40x, // Here data resources are declared // @@ -35,29 +36,16 @@ app! { // These are the resources this task has access to. // - // A resource can be a peripheral like `GPIOC` or a static variable - // like `ON` - resources: [GPIOC, ON], + // A resource can be a peripheral like `ITM` + resources: [ITM, ON], }, } } -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()); - +fn init(p: init::Peripherals, _r: init::Resources) { // configure the system timer to generate one interrupt every second 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_counter(); } @@ -74,15 +62,6 @@ fn idle() -> ! { // // `r` is the set of resources this task has access to. `SYS_TICK::Resources` // has one field per resource declared in `app!`. -fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) { - // toggle state - **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()); - } +fn sys_tick(_t: &mut Threshold, p: SYS_TICK::Resources) { + iprintln!(&p.ITM.stim[0], "Hello"); } diff --git a/examples/preemption.rs b/examples/preemption.rs index 5fda37d57e1902ae7164014d4de876589256d0a8..77ab8fc512cd1241f9bfe59f194c368e6a91f955 100644 --- a/examples/preemption.rs +++ b/examples/preemption.rs @@ -4,12 +4,12 @@ #![no_std] extern crate cortex_m_rtfm as rtfm; -extern crate stm32f103xx; +extern crate stm32f40x; use rtfm::{app, Resource, Threshold}; app! { - device: stm32f103xx, + device: stm32f40x, resources: { static COUNTER: u64 = 0; diff --git a/examples/two-tasks.rs b/examples/two-tasks.rs index 2200e5baa0b7b2cd46f541a76d689ec00d34beec..26d37f28999216f27d338b60a82759b67e04630f 100644 --- a/examples/two-tasks.rs +++ b/examples/two-tasks.rs @@ -4,12 +4,12 @@ #![no_std] extern crate cortex_m_rtfm as rtfm; -extern crate stm32f103xx; +extern crate stm32f40x; use rtfm::{app, Threshold}; app! { - device: stm32f103xx, + device: stm32f40x, resources: { static COUNTER: u64 = 0; diff --git a/examples/zero-tasks.rs b/examples/zero-tasks.rs index 9176103d434d8159bcc6bffaa10740e6cfbcfd59..91ff10334ebf92aea3da04e23b5f414bfdfbdf14 100644 --- a/examples/zero-tasks.rs +++ b/examples/zero-tasks.rs @@ -4,8 +4,9 @@ #![feature(proc_macro)] #![no_std] -extern crate cortex_m_rtfm as rtfm; // IMPORTANT always do this rename -extern crate stm32f103xx; // the device crate +extern crate cortex_m_rtfm as rtfm; +// IMPORTANT always do this rename +extern crate stm32f40x; // the device crate // import the procedural macro use rtfm::app; @@ -16,7 +17,7 @@ use rtfm::app; // `main` yourself. app! { // this is the path to the device crate - device: stm32f103xx, + device: stm32f40x, } // The initialization phase.