diff options
Diffstat (limited to 'usb/src/main.rs')
-rw-r--r-- | usb/src/main.rs | 54 |
1 files changed, 33 insertions, 21 deletions
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 |