Compare commits

...

3 Commits

Author SHA1 Message Date
Thomas Klaehn
7a4bb73a43 wip 2021-07-31 13:31:13 +02:00
Thomas Klaehn
b5bfc0081f Rename application 2021-06-05 08:07:04 +02:00
Thomas Klaehn
abaf98de01 Exchange hal with own svd2rust generated hal 2021-06-04 12:45:09 +02:00
3 changed files with 19 additions and 37 deletions

24
.vscode/launch.json vendored
View File

@ -1,25 +1,6 @@
{ {
/*
* Requires the Rust Language Server (RLS) and Cortex-Debug extensions
* https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
* https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug
*/
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"type": "cortex-debug",
"request": "launch",
"name": "Debug (QEMU)",
"servertype": "qemu",
"cwd": "${workspaceRoot}",
"preLaunchTask": "Cargo Build (debug)",
"runToMain": true,
"executable": "./target/thumbv7m-none-eabi/debug/app",
/* Run `cargo build --example hello` and uncomment this line to run semi-hosting example */
//"executable": "./target/thumbv7m-none-eabi/debug/examples/hello",
"cpu": "cortex-m3",
"machine": "lm3s6965evb",
},
{ {
"type": "cortex-debug", "type": "cortex-debug",
"request": "launch", "request": "launch",
@ -28,15 +9,12 @@
"cwd": "${workspaceRoot}", "cwd": "${workspaceRoot}",
"preLaunchTask": "Cargo Build (debug)", "preLaunchTask": "Cargo Build (debug)",
"runToMain": true, "runToMain": true,
"executable": "./target/thumbv7em-none-eabihf/debug/app", "executable": "./target/thumbv7em-none-eabihf/debug/nrf52-dk-app",
/* Run `cargo build --example itm` and uncomment this line to run itm example */
// "executable": "./target/thumbv7em-none-eabihf/debug/examples/itm",
"device": "NRF52832", "device": "NRF52832",
"configFiles": [ "configFiles": [
"/usr/local/share/openocd/scripts/interface/jlink.cfg", "/usr/local/share/openocd/scripts/interface/jlink.cfg",
"/usr/local/share/openocd/scripts/board/nordic_nrf52_dk.cfg" "/usr/local/share/openocd/scripts/board/nordic_nrf52_dk.cfg"
], ],
// "svdFile": "${workspaceRoot}/.vscode/STM32F303.svd",
"swoConfig": { "swoConfig": {
"enabled": true, "enabled": true,
"cpuFrequency": 8000000, "cpuFrequency": 8000000,

View File

@ -1,5 +1,5 @@
[package] [package]
name = "app" name = "nrf52-dk-app"
version = "0.1.0" version = "0.1.0"
authors = ["Andres O. Vela"] authors = ["Andres O. Vela"]
edition = "2018" edition = "2018"
@ -13,8 +13,7 @@ cortex-m-semihosting = "0.3.7"
panic-semihosting = "0.5.6" panic-semihosting = "0.5.6"
nrf52832-hal = { features = ["rt"], path = "/home/tkl/nrf-hal/nrf52832-hal" } nrf52-pac = { git = "https://git.blackfinn.de/rust/nrf52-pac.git" }
[dependencies.embedded-hal] [dependencies.embedded-hal]
version = "0.2.3" version = "0.2.3"

View File

@ -1,12 +1,10 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use cortex_m::peripheral::{syst, Peripherals}; use cortex_m::peripheral::Peripherals;
use cortex_m_rt::{entry, exception}; use cortex_m_rt::{entry, exception};
use cortex_m_semihosting::hprintln; use cortex_m_semihosting::hprintln;
use embedded_hal::digital::v2::OutputPin; use nrf52_pac;
use nrf52832_hal as hal;
use nrf52832_hal::gpio::Level;
use panic_semihosting as _; use panic_semihosting as _;
@ -20,16 +18,23 @@ fn main() -> ! {
let peripherals = Peripherals::take().unwrap(); let peripherals = Peripherals::take().unwrap();
let mut systick = peripherals.SYST; let mut systick = peripherals.SYST;
systick.set_clock_source(syst::SystClkSource::Core); systick.set_clock_source(cortex_m::peripheral::syst::SystClkSource::Core);
systick.set_reload(F_CPU / 1000 - 1); systick.set_reload(F_CPU / 1000 - 1);
systick.clear_current(); systick.clear_current();
systick.enable_interrupt(); systick.enable_interrupt();
systick.enable_counter(); systick.enable_counter();
let p = hal::pac::Peripherals::take().unwrap(); let nrf_peripherals = nrf52_pac::Peripherals::take().unwrap();
let port0 = hal::gpio::p0::Parts::new(p.P0); let p0 = nrf_peripherals.P0;
let mut led = port0.p0_17.into_push_pull_output(Level::Low);
led.set_low().unwrap(); unsafe {
p0.outset.write(|w| w.bits(1 << 17));
p0.pin_cnf[17].write(|w| {
w.input().disconnect();
w.dir().output();
w
});
}
let mut state:bool = false; let mut state:bool = false;
loop { loop {
@ -38,11 +43,11 @@ fn main() -> ! {
FIRE_1S = false; FIRE_1S = false;
if state { if state {
hprintln!("off").unwrap(); hprintln!("off").unwrap();
led.set_low().unwrap(); p0.outclr.write(|w| w.bits(1 << 17));
state = false; state = false;
} else { } else {
hprintln!("on").unwrap(); hprintln!("on").unwrap();
led.set_high().unwrap(); p0.outset.write(|w| w.bits(1 << 17));
state = true; state = true;
} }
} }