summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock12
-rw-r--r--Cargo.toml3
-rwxr-xr-xsrc/main.rs20
3 files changed, 24 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 432a5ce..975c1e8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -34,9 +34,8 @@ dependencies = [
[[package]]
name = "atsamd-hal"
version = "0.6.0"
-source = "git+https://github.com/atsamd-rs/atsamd?rev=97d55c19#97d55c19f0e5234cf9766311477bc696357271fd"
dependencies = [
- "atsamd21e18a 0.5.0 (git+https://github.com/atsamd-rs/atsamd?rev=97d55c19)",
+ "atsamd21e18a 0.5.0",
"bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -49,7 +48,6 @@ dependencies = [
[[package]]
name = "atsamd21e18a"
version = "0.5.0"
-source = "git+https://github.com/atsamd-rs/atsamd?rev=97d55c19#97d55c19f0e5234cf9766311477bc696357271fd"
dependencies = [
"bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -84,7 +82,7 @@ dependencies = [
"smart-leds 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smart-leds-trait 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"starb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "trinket_m0 0.4.0 (git+https://github.com/atsamd-rs/atsamd?rev=97d55c19)",
+ "trinket_m0 0.4.0",
]
[[package]]
@@ -308,9 +306,8 @@ dependencies = [
[[package]]
name = "trinket_m0"
version = "0.4.0"
-source = "git+https://github.com/atsamd-rs/atsamd?rev=97d55c19#97d55c19f0e5234cf9766311477bc696357271fd"
dependencies = [
- "atsamd-hal 0.6.0 (git+https://github.com/atsamd-rs/atsamd?rev=97d55c19)",
+ "atsamd-hal 0.6.0",
"cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"cortex-m-rt 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -350,8 +347,6 @@ dependencies = [
"checksum aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a316c7ea8e1e9ece54862c992def5a7ac14de9f5832b69d71760680efeeefa"
"checksum apa102-spi 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "244c305e53cabeadfce23409fe24bfcedaa20166aa3f16f6c4ab256302158fd5"
"checksum as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "293dac66b274fab06f95e7efb05ec439a6b70136081ea522d270bc351ae5bb27"
-"checksum atsamd-hal 0.6.0 (git+https://github.com/atsamd-rs/atsamd?rev=97d55c19)" = "<none>"
-"checksum atsamd21e18a 0.5.0 (git+https://github.com/atsamd-rs/atsamd?rev=97d55c19)" = "<none>"
"checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a"
"checksum bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
@@ -382,7 +377,6 @@ dependencies = [
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
"checksum starb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36de9f301031f2a692afe144c8a757950d2b60b7fbf447055b8e19a9c232fb2c"
"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e"
-"checksum trinket_m0 0.4.0 (git+https://github.com/atsamd-rs/atsamd?rev=97d55c19)" = "<none>"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45c297f0afb6928cd08ab1ff9d95e99392595ea25ae1b5ecf822ff8764e57a0d"
diff --git a/Cargo.toml b/Cargo.toml
index 003cfcb..69cd14f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,4 +22,5 @@ apa102-spi = "0.2"
[patch.crates-io]
#atsamd-hal = { git = "https://github.com/atsamd-rs/atsamd", rev = "97d55c19" }
-trinket_m0 = { git = "https://github.com/atsamd-rs/atsamd", rev = "97d55c19" }
+#trinket_m0 = { git = "https://github.com/atsamd-rs/atsamd", rev = "97d55c19" }
+trinket_m0 = { path = "../usbh/atsamd/boards/trinket_m0" }
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()
}
});