summaryrefslogtreecommitdiffstats
path: root/ble/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ble/src/main.rs')
-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());
}