From 9cf9bb05f460a830384c211fa3ed94580de755df Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sun, 11 Aug 2019 22:12:51 -0400 Subject: WIP: sample code and runner for mdk board. --- ble/src/main.rs | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'ble/src') 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(timer: &mut Timer, cycles: u32) +where + T: timer::Instance, +{ + timer.start(cycles); + let _ = block!(timer.wait()); } -- cgit v1.2.3