Remove trinket_m0 bsp crate
This commit is contained in:
parent
0d9b3c8bcc
commit
10b98e1ad1
|
@ -8,7 +8,12 @@ build = "src/build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apa102-spi = "0.3.2"
|
apa102-spi = "0.3.2"
|
||||||
atsamd-hal = "0.14"
|
atsamd-hal = { version = "0.14", default-features = false, features = [
|
||||||
|
"samd21e",
|
||||||
|
"samd21e-rt",
|
||||||
|
"unproven",
|
||||||
|
"usb",
|
||||||
|
] }
|
||||||
bitbang-hal = "0.3.2"
|
bitbang-hal = "0.3.2"
|
||||||
cortex-m = "0.7.4"
|
cortex-m = "0.7.4"
|
||||||
cortex-m-rt = "0.7.1"
|
cortex-m-rt = "0.7.1"
|
||||||
|
@ -17,7 +22,6 @@ embedded-hal = "0.2"
|
||||||
once_cell = { version = "1.7.2", default-features = false }
|
once_cell = { version = "1.7.2", default-features = false }
|
||||||
panic-halt = "0.2.0"
|
panic-halt = "0.2.0"
|
||||||
smart-leds = "0.3"
|
smart-leds = "0.3"
|
||||||
trinket_m0 = { version = "0.11.0", features = ["unproven", "usb"] }
|
|
||||||
usb-device = "0.2"
|
usb-device = "0.2"
|
||||||
usbd-serial = "0.1"
|
usbd-serial = "0.1"
|
||||||
streamdeck-common = { version = "0.1.0", path = "./streamdeck-common" }
|
streamdeck-common = { version = "0.1.0", path = "./streamdeck-common" }
|
||||||
|
|
32
src/bsp.rs
32
src/bsp.rs
|
@ -1,8 +1,15 @@
|
||||||
use atsamd_hal::gpio::v2::{
|
pub use atsamd_hal as hal;
|
||||||
Disabled, Floating, Input, Output, Pin, PullUp, PushPull, PA00, PA01, PA14,
|
pub use cortex_m_rt::entry;
|
||||||
};
|
|
||||||
use atsamd_hal::prelude::_embedded_hal_timer_CountDown as CountDown;
|
|
||||||
use embedded_hal::timer::Periodic;
|
use embedded_hal::timer::Periodic;
|
||||||
|
use hal::{
|
||||||
|
gpio::v2::{
|
||||||
|
Disabled, Floating, Input, Output, Pin, PullUp, PushPull, PA00, PA01, PA14, PA24, PA25,
|
||||||
|
},
|
||||||
|
prelude::_embedded_hal_timer_CountDown as CountDown,
|
||||||
|
usb::UsbBus,
|
||||||
|
};
|
||||||
|
use usb_device::class_prelude::UsbBusAllocator;
|
||||||
|
|
||||||
pub struct Dotstar {
|
pub struct Dotstar {
|
||||||
pub ci: Pin<PA01, Disabled<Floating>>,
|
pub ci: Pin<PA01, Disabled<Floating>>,
|
||||||
|
@ -10,6 +17,21 @@ pub struct Dotstar {
|
||||||
pub nc: Pin<PA14, Disabled<Floating>>,
|
pub nc: Pin<PA14, Disabled<Floating>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn usb_allocator(
|
||||||
|
usb: hal::pac::USB,
|
||||||
|
clocks: &mut hal::clock::GenericClockController,
|
||||||
|
pm: &mut hal::pac::PM,
|
||||||
|
dm: Pin<PA24, Disabled<Floating>>,
|
||||||
|
dp: Pin<PA25, Disabled<Floating>>,
|
||||||
|
) -> Option<UsbBusAllocator<UsbBus>> {
|
||||||
|
let gckl0 = clocks.gclk0();
|
||||||
|
let usb_clock = &clocks.usb(&gckl0)?;
|
||||||
|
|
||||||
|
Some(UsbBusAllocator::new(UsbBus::new(
|
||||||
|
usb_clock, pm, dm, dp, usb,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
pub type Spi<C> = bitbang_hal::spi::SPI<
|
pub type Spi<C> = bitbang_hal::spi::SPI<
|
||||||
Pin<PA14, Input<PullUp>>,
|
Pin<PA14, Input<PullUp>>,
|
||||||
Pin<PA00, Output<PushPull>>,
|
Pin<PA00, Output<PushPull>>,
|
||||||
|
@ -31,7 +53,7 @@ impl Dotstar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
atsamd_hal::bsp_pins! (
|
hal::bsp_pins! (
|
||||||
PA08 {
|
PA08 {
|
||||||
name: d0
|
name: d0
|
||||||
aliases: {
|
aliases: {
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -8,21 +8,19 @@ use atsamd_hal::{
|
||||||
time::MegaHertz,
|
time::MegaHertz,
|
||||||
};
|
};
|
||||||
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
|
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
|
||||||
use trinket_m0 as hal;
|
|
||||||
|
|
||||||
|
use atsamd_hal::{
|
||||||
|
clock::GenericClockController,
|
||||||
|
pac::{interrupt, CorePeripherals, Peripherals},
|
||||||
|
prelude::_atsamd_hal_embedded_hal_digital_v2_OutputPin,
|
||||||
|
usb::UsbBus,
|
||||||
|
};
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use cortex_m::{
|
use cortex_m::{
|
||||||
asm::delay as cycle_delay,
|
asm::delay as cycle_delay,
|
||||||
interrupt::Mutex,
|
interrupt::Mutex,
|
||||||
peripheral::{NVIC, SCB},
|
peripheral::{NVIC, SCB},
|
||||||
};
|
};
|
||||||
use hal::{
|
|
||||||
clock::GenericClockController,
|
|
||||||
entry,
|
|
||||||
pac::{interrupt, CorePeripherals, Peripherals},
|
|
||||||
prelude::_atsamd_hal_embedded_hal_digital_v2_OutputPin,
|
|
||||||
usb::UsbBus,
|
|
||||||
};
|
|
||||||
use once_cell::unsync::OnceCell;
|
use once_cell::unsync::OnceCell;
|
||||||
use smart_leds::{SmartLedsWrite, RGB8};
|
use smart_leds::{SmartLedsWrite, RGB8};
|
||||||
use streamdeck_common::{handle_input, Handshake, UnsafeSync};
|
use streamdeck_common::{handle_input, Handshake, UnsafeSync};
|
||||||
|
@ -32,7 +30,7 @@ use usbd_serial::{SerialPort, USB_CLASS_CDC};
|
||||||
mod bsp;
|
mod bsp;
|
||||||
mod trinket_buttons;
|
mod trinket_buttons;
|
||||||
|
|
||||||
use bsp::{Dotstar, Pins};
|
use bsp::{entry, Dotstar, Pins};
|
||||||
use trinket_buttons::Buttons;
|
use trinket_buttons::Buttons;
|
||||||
|
|
||||||
static USB_ALLOCATOR: UnsafeSync<OnceCell<UsbBusAllocator<UsbBus>>> =
|
static USB_ALLOCATOR: UnsafeSync<OnceCell<UsbBusAllocator<UsbBus>>> =
|
||||||
|
@ -74,13 +72,14 @@ fn main() -> ! {
|
||||||
let mut red_led = pins.d13.into_push_pull_output();
|
let mut red_led = pins.d13.into_push_pull_output();
|
||||||
red_led.set_low().unwrap();
|
red_led.set_low().unwrap();
|
||||||
|
|
||||||
let usb_allocator = hal::usb_allocator(
|
let usb_allocator = bsp::usb_allocator(
|
||||||
peripherals.USB,
|
peripherals.USB,
|
||||||
&mut clocks,
|
&mut clocks,
|
||||||
&mut peripherals.PM,
|
&mut peripherals.PM,
|
||||||
pins.usb_dm,
|
pins.usb_dm,
|
||||||
pins.usb_dp,
|
pins.usb_dp,
|
||||||
);
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// SAFETY: No interrupt will access USB_ALLOCATOR before this point, since it is only
|
// SAFETY: No interrupt will access USB_ALLOCATOR before this point, since it is only
|
||||||
// referenced from inside the USB_SERIAL mutex and the USB_BUS mutex, which have not been set
|
// referenced from inside the USB_SERIAL mutex and the USB_BUS mutex, which have not been set
|
||||||
|
|
Loading…
Reference in a new issue