Compare commits
3 Commits
da153abac6
...
7a4bb73a43
Author | SHA1 | Date | |
---|---|---|---|
|
7a4bb73a43 | ||
|
b5bfc0081f | ||
|
abaf98de01 |
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -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",
|
||||
"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",
|
||||
"request": "launch",
|
||||
@ -28,15 +9,12 @@
|
||||
"cwd": "${workspaceRoot}",
|
||||
"preLaunchTask": "Cargo Build (debug)",
|
||||
"runToMain": true,
|
||||
"executable": "./target/thumbv7em-none-eabihf/debug/app",
|
||||
/* Run `cargo build --example itm` and uncomment this line to run itm example */
|
||||
// "executable": "./target/thumbv7em-none-eabihf/debug/examples/itm",
|
||||
"executable": "./target/thumbv7em-none-eabihf/debug/nrf52-dk-app",
|
||||
"device": "NRF52832",
|
||||
"configFiles": [
|
||||
"/usr/local/share/openocd/scripts/interface/jlink.cfg",
|
||||
"/usr/local/share/openocd/scripts/board/nordic_nrf52_dk.cfg"
|
||||
],
|
||||
// "svdFile": "${workspaceRoot}/.vscode/STM32F303.svd",
|
||||
"swoConfig": {
|
||||
"enabled": true,
|
||||
"cpuFrequency": 8000000,
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "app"
|
||||
name = "nrf52-dk-app"
|
||||
version = "0.1.0"
|
||||
authors = ["Andres O. Vela"]
|
||||
edition = "2018"
|
||||
@ -13,8 +13,7 @@ cortex-m-semihosting = "0.3.7"
|
||||
|
||||
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]
|
||||
version = "0.2.3"
|
||||
|
27
src/main.rs
27
src/main.rs
@ -1,12 +1,10 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
use cortex_m::peripheral::{syst, Peripherals};
|
||||
use cortex_m::peripheral::Peripherals;
|
||||
use cortex_m_rt::{entry, exception};
|
||||
use cortex_m_semihosting::hprintln;
|
||||
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use nrf52832_hal as hal;
|
||||
use nrf52832_hal::gpio::Level;
|
||||
use nrf52_pac;
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
@ -20,16 +18,23 @@ fn main() -> ! {
|
||||
|
||||
let peripherals = Peripherals::take().unwrap();
|
||||
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.clear_current();
|
||||
systick.enable_interrupt();
|
||||
systick.enable_counter();
|
||||
|
||||
let p = hal::pac::Peripherals::take().unwrap();
|
||||
let port0 = hal::gpio::p0::Parts::new(p.P0);
|
||||
let mut led = port0.p0_17.into_push_pull_output(Level::Low);
|
||||
led.set_low().unwrap();
|
||||
let nrf_peripherals = nrf52_pac::Peripherals::take().unwrap();
|
||||
let p0 = nrf_peripherals.P0;
|
||||
|
||||
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;
|
||||
loop {
|
||||
@ -38,11 +43,11 @@ fn main() -> ! {
|
||||
FIRE_1S = false;
|
||||
if state {
|
||||
hprintln!("off").unwrap();
|
||||
led.set_low().unwrap();
|
||||
p0.outclr.write(|w| w.bits(1 << 17));
|
||||
state = false;
|
||||
} else {
|
||||
hprintln!("on").unwrap();
|
||||
led.set_high().unwrap();
|
||||
p0.outset.write(|w| w.bits(1 << 17));
|
||||
state = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user