summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 071966a..84bc3c0 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,7 +11,7 @@ use core::mem;
use core::panic::PanicInfo;
use cortex_m::asm::wfi;
use cortex_m_rt::{entry, exception, ExceptionFrame};
-use embedded_hal::digital::v2::OutputPin;
+use embedded_hal::{blocking::i2c::Write, digital::v2::OutputPin};
use log::{info, LevelFilter};
use smart_leds::colors;
use smart_leds_trait::SmartLedsWrite;
@@ -31,6 +31,8 @@ static mut LED: usize = 0;
static HANDLERS: HandlerArray = HandlerArray::new();
+const NRF_WIREADDR: u8 = 10;
+
#[entry]
fn main() -> ! {
let mut cp = CorePeripherals::take().expect("taking core peripherals");
@@ -56,6 +58,16 @@ fn main() -> ! {
&mut pins.port,
);
+ let mut i2c_master = hal::i2c_master(
+ &mut clocks,
+ 400_000.hz(),
+ dp.SERCOM2,
+ &mut dp.PM,
+ pins.d0,
+ pins.d2,
+ &mut pins.port,
+ );
+
let mut red_led = pins.d13.into_open_drain_output(&mut pins.port);
red_led.set_low().expect("turning off red LED");
unsafe { LED = mem::transmute(&red_led) }
@@ -98,7 +110,13 @@ fn main() -> ! {
info!("Bootstrap complete.");
+ let mut last_tick = 0;
loop {
+ let tick = rtc::millis();
+ if tick > last_tick + 1024 {
+ last_tick = tick;
+ i2c_master.write(NRF_WIREADDR, b"!").expect("writing i2c");
+ }
wfi()
}
});