-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d83e9f
commit 0b322f8
Showing
5 changed files
with
175 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"preLaunchTask": "${defaultBuildTask}", | ||
"type": "probe-rs-debug", | ||
"request": "launch", | ||
"name": "Run bsp_demo", | ||
"flashingConfig": { | ||
"flashingEnabled": true, | ||
}, | ||
"chip": "nrf52840_xxaa", | ||
"coreConfigs": [ | ||
{ | ||
"programBinary": "./target/thumbv7em-none-eabihf/debug/bsp_demo" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"preLaunchTask": "${defaultBuildTask}", | ||
"type": "probe-rs-debug", | ||
"request": "launch", | ||
"name": "Run bsp_demo", | ||
"flashingConfig": { | ||
"flashingEnabled": true | ||
}, | ||
"chip": "nrf52840_xxaa", | ||
"coreConfigs": [ | ||
{ | ||
"coreIndex": 0, | ||
"rttEnabled": true, | ||
"programBinary": "./target/thumbv7em-none-eabihf/debug/bsp_demo" | ||
} | ||
], | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,50 @@ | ||
//! A simple LED blinking demo for nRF52840-DK | ||
//! | ||
//! Demonstrates using a Board Support Package, defmt, and the probe-rs extension for VS Code | ||
|
||
#![no_std] | ||
#![no_main] | ||
|
||
use core::fmt::Write; | ||
use cortex_m_rt::entry; | ||
use nrf52840_dk_bsp::{hal, Board}; | ||
|
||
extern crate defmt_rtt; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let mut nrf52 = Board::take().unwrap(); | ||
let mut timer = hal::Timer::new(nrf52.TIMER0); | ||
// We do some hardware set-up first | ||
defmt::info!("Starting up..."); | ||
let mut board = Board::take().unwrap(); | ||
let mut timer = hal::Timer::new(board.TIMER0); | ||
|
||
// Now go into an infinite loop | ||
loop { | ||
writeln!(nrf52.cdc, "On!").unwrap(); | ||
nrf52.leds.led_2.enable(); | ||
// We're logging over both defmt, and the J-Link's UART to USB Serial | ||
// Port interface. | ||
defmt::debug!("On!"); | ||
writeln!(board.cdc, "On!").unwrap(); | ||
|
||
// Control the LED | ||
board.leds.led_2.enable(); | ||
|
||
// Wait for 1 second (this is a 1 MHz timer) | ||
timer.delay(1_000_000); | ||
writeln!(nrf52.cdc, "Off!").unwrap(); | ||
nrf52.leds.led_2.disable(); | ||
|
||
// More logging | ||
defmt::debug!("Off!"); | ||
writeln!(board.cdc, "Off!").unwrap(); | ||
|
||
// Control the LED | ||
board.leds.led_2.disable(); | ||
|
||
// Wait for 1 second again | ||
timer.delay(1_000_000); | ||
} | ||
} | ||
|
||
#[panic_handler] | ||
fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
loop { | ||
cortex_m::asm::udf(); | ||
} | ||
fn panic(info: &core::panic::PanicInfo) -> ! { | ||
defmt::error!("Panic! {:?}", defmt::Debug2Format(&info)); | ||
cortex_m::asm::udf(); | ||
} |