summaryrefslogtreecommitdiffstats
path: root/usb/src
diff options
context:
space:
mode:
Diffstat (limited to 'usb/src')
-rw-r--r--usb/src/dotstar.rs2
-rw-r--r--usb/src/logger.rs10
-rw-r--r--usb/src/main.rs54
-rw-r--r--usb/src/rtc.rs3
4 files changed, 41 insertions, 28 deletions
diff --git a/usb/src/dotstar.rs b/usb/src/dotstar.rs
index 8e930d0..c7eed7d 100644
--- a/usb/src/dotstar.rs
+++ b/usb/src/dotstar.rs
@@ -1,9 +1,9 @@
use trinket_m0::{
clock::GenericClockController,
gpio::{self, Floating, Input},
+ pac::{PM, SERCOM1},
prelude::*,
sercom::{self, PadPin, SPIMaster1},
- PM, SERCOM1,
};
use apa102_spi::Apa102;
diff --git a/usb/src/logger.rs b/usb/src/logger.rs
index 9fbba77..7357c22 100644
--- a/usb/src/logger.rs
+++ b/usb/src/logger.rs
@@ -1,14 +1,14 @@
+use crate::hal::{
+ gpio::{Pa6, Pa7, PfD},
+ sercom::{Sercom0Pad2, Sercom0Pad3, UART0},
+};
use crate::rtc;
-use starb::{Reader, RingBuffer, Writer};
use core::cell::UnsafeCell;
use core::fmt::{self, Write};
use embedded_hal::{digital::v2::OutputPin, serial};
use log::{Metadata, Record};
-use trinket_m0::{
- gpio::{Pa6, Pa7, PfD},
- sercom::{Sercom0Pad2, Sercom0Pad3, UART0},
-};
+use starb::{Reader, RingBuffer, Writer};
static mut UART0: usize = 0;
diff --git a/usb/src/main.rs b/usb/src/main.rs
index 523d275..42cdf55 100644
--- a/usb/src/main.rs
+++ b/usb/src/main.rs
@@ -3,6 +3,12 @@
#![no_std]
#![no_main]
+#[cfg(feature = "feather-m0")]
+use feather_m0 as hal;
+#[cfg(feature = "trinket-m0")]
+use trinket_m0 as hal;
+
+#[cfg(feature = "trinket-m0")]
mod dotstar;
mod logger;
mod macros;
@@ -13,21 +19,24 @@ use bootkbd::BootKeyboard;
use clint::HandlerArray;
use core::mem;
use core::panic::PanicInfo;
-use cortex_m::{asm::wfi, peripheral::NVIC};
+use cortex_m::{
+ asm::wfi,
+ peripheral::{Peripherals as CorePeripherals, NVIC},
+};
use cortex_m_rt::{entry, exception, ExceptionFrame};
use embedded_hal::{blocking::i2c::Write, digital::v2::OutputPin};
-use log::{info, LevelFilter};
-use smart_leds::colors;
-use smart_leds_trait::SmartLedsWrite;
-use trinket_m0::{
- self as hal,
+use hal::{
clock::GenericClockController,
gpio::{OpenDrain, Output, Pa10, Pa6, Pa7, PfD},
+ pac::{interrupt, Interrupt, Peripherals},
sercom,
- target_device::{interrupt, Interrupt},
time::*,
- CorePeripherals, Peripherals,
};
+use log::{info, LevelFilter};
+#[cfg(feature = "trinket-m0")]
+use smart_leds::colors;
+#[cfg(feature = "trinket-m0")]
+use smart_leds_trait::SmartLedsWrite;
use usb_host::Driver;
// A very unsafe copy of an LED to turn on when things go really, really wrong.
@@ -77,19 +86,22 @@ fn main() -> ! {
red_led.set_low().expect("turning off red LED");
unsafe { LED = mem::transmute(&red_led) }
- let mut dotstar = dotstar::new(
- dp.SERCOM1,
- pins.swdio,
- pins.dotstar_di,
- pins.dotstar_ci,
- &mut pins.port,
- &mut dp.PM,
- &mut clocks,
- );
- let black = [colors::BLACK];
- dotstar
- .write(black.iter().cloned())
- .expect("turning off dotstar");
+ #[cfg(feature = "trinket-m0")]
+ {
+ let mut dotstar = dotstar::new(
+ dp.SERCOM1,
+ pins.swdio,
+ pins.dotstar_di,
+ pins.dotstar_ci,
+ &mut pins.port,
+ &mut dp.PM,
+ &mut clocks,
+ );
+ let black = [colors::BLACK];
+ dotstar
+ .write(black.iter().cloned())
+ .expect("turning off dotstar");
+ }
// We do the transmute because, while all the underlying data is
// static, we're unable to get a referecence to the UART or LED
diff --git a/usb/src/rtc.rs b/usb/src/rtc.rs
index fa7b347..dc4259f 100644
--- a/usb/src/rtc.rs
+++ b/usb/src/rtc.rs
@@ -1,6 +1,7 @@
+use crate::hal::{clock::GenericClockController, pac::RTC};
+
use core::sync::atomic::{AtomicUsize, Ordering};
use log;
-use trinket_m0::{clock::GenericClockController, RTC};
struct Clock(AtomicUsize);
impl Clock {