summaryrefslogtreecommitdiffstats
path: root/ble/src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-11 22:12:51 -0400
committerBrian Cully <bjc@kublai.com>2019-08-13 15:33:14 -0400
commit9cf9bb05f460a830384c211fa3ed94580de755df (patch)
treead05246b6955007975ab0d7c6c633c46a300e472 /ble/src
parent48b18d01e3fa887b884fe6aac26b39e321eab56b (diff)
downloadbleusb-9cf9bb05f460a830384c211fa3ed94580de755df.tar.gz
bleusb-9cf9bb05f460a830384c211fa3ed94580de755df.zip
WIP: sample code and runner for mdk board.
Diffstat (limited to 'ble/src')
-rw-r--r--ble/src/main.rs40
1 files changed, 38 insertions, 2 deletions
diff --git a/ble/src/main.rs b/ble/src/main.rs
index e7a11a9..8b8c513 100644
--- a/ble/src/main.rs
+++ b/ble/src/main.rs
@@ -1,3 +1,39 @@
-fn main() {
- println!("Hello, world!");
+//! BLE interface.
+#![no_std]
+#![no_main]
+
+use core::fmt::Write;
+use cortex_m_rt::entry;
+use nb::block;
+
+#[allow(unused_imports)]
+extern crate panic_semihosting;
+
+use nrf52840_mdk_bsp::{
+ hal::{
+ prelude::*,
+ timer::{self, Timer},
+ },
+ Board,
+};
+
+#[entry]
+fn main() -> ! {
+ let mut nrf52 = Board::take().unwrap();
+
+ let mut timer = Timer::new(nrf52.TIMER0);
+
+ write!(nrf52.cdc, "Bootstrap complete.").ok();
+ loop {
+ write!(nrf52.cdc, ".").ok();
+ delay(&mut timer, 1_000_000); // 1s
+ }
+}
+
+fn delay<T>(timer: &mut Timer<T>, cycles: u32)
+where
+ T: timer::Instance,
+{
+ timer.start(cycles);
+ let _ = block!(timer.wait());
}