Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grand_central_m4: Bump usb-device version #753

Merged
merged 10 commits into from
Aug 31, 2024
1 change: 1 addition & 0 deletions boards/grand_central_m4/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- update path of Cargo config
- bumped usb-device version to 0.3
jbeaurivage marked this conversation as resolved.
Show resolved Hide resolved

# v0.6.0

Expand Down
23 changes: 11 additions & 12 deletions boards/grand_central_m4/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[package]
name = "grand_central_m4"
version = "0.6.0"
authors = [
"Dustin Little <dlittle@toyatech.net>"
]
authors = ["Dustin Little <dlittle@toyatech.net>"]
description = "Board Support crate for the Adafruit Grand Central M4 Express"
keywords = ["no-std", "arm", "cortex-m", "embedded-hal"]
categories = ["embedded", "hardware-support", "no-std"]
Expand All @@ -12,32 +10,34 @@ edition = "2021"
repository = "https://github.com/atsamd-rs/atsamd"
readme = "README.md"

[dependencies]
ws2812-timer-delay = "0.3"

[dependencies.cortex-m-rt]
version = "0.7"
optional = true

[dependencies.atsamd-hal]
version = "0.15"
path = "../../hal"
version = "0.17.0"
supersimple33 marked this conversation as resolved.
Show resolved Hide resolved
default-features = false

[dependencies.usb-device]
version = "0.2"
version = "0.3.1"
optional = true

[dependencies.cortex-m]
version = "0.7"
features = ["critical-section-single-core"]

[dev-dependencies]
cortex-m = "0.7"
usbd-serial = "0.1"
usbd-serial = "0.2"
panic-halt = "0.2"
panic-semihosting = "0.5"
smart-leds = "0.3"
ws2812-timer-delay = "0.3"

[features]
default = ["rt", "atsamd-hal/samd51p", "atsamd-hal/unproven"]
default = ["rt", "atsamd-hal/samd51p"]
rt = ["cortex-m-rt", "atsamd-hal/samd51p-rt"]
unproven = ["atsamd-hal/unproven"]
usb = ["atsamd-hal/usb", "usb-device"]

[profile.dev]
Expand All @@ -63,4 +63,3 @@ name = "neopixel_rainbow"
[[example]]
name = "usb_serial"
required-features = ["usb"]

6 changes: 2 additions & 4 deletions boards/grand_central_m4/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use grand_central_m4 as bsp;

use bsp::ehal;
use bsp::hal;
use bsp::pac;

Expand All @@ -17,7 +16,6 @@ use hal::clock::GenericClockController;
use hal::prelude::*;
use pac::{CorePeripherals, Peripherals};

use ehal::blocking::delay::DelayMs;
use hal::delay::Delay;

#[entry]
Expand All @@ -35,9 +33,9 @@ fn main() -> ! {
let mut red_led: bsp::RedLed = pin_alias!(pins.red_led).into();
let mut delay = Delay::new(core.SYST, &mut clocks);
loop {
delay.delay_ms(200u16);
delay.delay_ms(200u8);
red_led.set_high().unwrap();
delay.delay_ms(200u16);
delay.delay_ms(200u8);
red_led.set_low().unwrap();
}
}
8 changes: 5 additions & 3 deletions boards/grand_central_m4/examples/neopixel_rainbow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ use panic_semihosting as _;
use bsp::entry;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::prelude::*;
use hal::ehal::delay::DelayNs;
use hal::time::Hertz;
use hal::timer::TimerCounter;
use hal::timer_traits::InterruptDrivenTimer;
use pac::{CorePeripherals, Peripherals};

use smart_leds::{
Expand All @@ -38,7 +40,7 @@ fn main() -> ! {
let gclk0 = clocks.gclk0();
let tc2_3 = clocks.tc2_tc3(&gclk0).unwrap();
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.TC3, &mut peripherals.MCLK);
timer.start(3.mhz());
timer.start(Hertz::MHz(3).into_duration());

let pins = bsp::Pins::new(peripherals.PORT);
let neopixel_pin = pins.neopixel.into_push_pull_output();
Expand All @@ -53,7 +55,7 @@ fn main() -> ! {
val: 32,
})];
neopixel.write(colors.iter().cloned()).unwrap();
delay.delay_ms(5u8);
delay.delay_ms(5);
}
}
}
12 changes: 8 additions & 4 deletions boards/grand_central_m4/examples/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ use cortex_m::peripheral::NVIC;
use hal::clock::GenericClockController;
use hal::pac::{interrupt, CorePeripherals, Peripherals};
use hal::prelude::*;
use hal::time::Hertz;
use hal::timer::TimerCounter;
use hal::timer_traits::InterruptDrivenTimer;
use hal::usb::UsbBus;
use smart_leds::{colors, hsv::RGB8, SmartLedsWrite};
use usb_device::bus::UsbBusAllocator;
Expand All @@ -50,7 +52,7 @@ fn main() -> ! {
let gclk0 = clocks.gclk0();
let tc2_3 = clocks.tc2_tc3(&gclk0).unwrap();
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.TC3, &mut peripherals.MCLK);
timer.start(3.mhz());
InterruptDrivenTimer::start(&mut timer, Hertz::MHz(3).into_duration());

let pins = bsp::Pins::new(peripherals.PORT);
let neopixel_pin = pins.neopixel.into_push_pull_output();
Expand All @@ -72,9 +74,11 @@ fn main() -> ! {
USB_SERIAL = Some(SerialPort::new(&bus_allocator));
USB_BUS = Some(
UsbDeviceBuilder::new(&bus_allocator, UsbVidPid(0x16c0, 0x27dd))
.manufacturer("Fake company")
.product("Serial port")
.serial_number("TEST")
.strings(&[StringDescriptors::new(LangID::EN_US)
.manufacturer("Fake company")
.product("Serial port")
.serial_number("TEST")])
.expect("Failed to set strings")
.device_class(USB_CLASS_CDC)
.build(),
);
Expand Down
8 changes: 4 additions & 4 deletions boards/grand_central_m4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ pub type Spi = spi::Spi<spi::Config<SpiPads>, spi::Duplex>;
/// SPI Master in SPI Mode 0.
pub fn spi_master(
clocks: &mut GenericClockController,
baud: impl Into<Hertz>,
baud: Hertz,
sercom7: SpiSercom,
mclk: &mut pac::MCLK,
sclk: impl Into<Sclk>,
Expand Down Expand Up @@ -603,10 +603,10 @@ pub fn usb_allocator(
dm: impl Into<UsbDm>,
dp: impl Into<UsbDp>,
) -> UsbBusAllocator<UsbBus> {
use pac::gclk::{genctrl::SRC_A, pchctrl::GEN_A};
use pac::gclk::{genctrl::SRCSELECT_A, pchctrl::GENSELECT_A};

clocks.configure_gclk_divider_and_source(GEN_A::GCLK2, 1, SRC_A::DFLL, false);
let usb_gclk = clocks.get_gclk(GEN_A::GCLK2).unwrap();
clocks.configure_gclk_divider_and_source(GENSELECT_A::GCLK2, 1, SRCSELECT_A::DFLL, false);
let usb_gclk = clocks.get_gclk(GENSELECT_A::GCLK2).unwrap();
let usb_clock = &clocks.usb(&usb_gclk).unwrap();
let (dm, dp) = (dm.into(), dp.into());
UsbBusAllocator::new(UsbBus::new(usb_clock, mclk, dm, dp, usb))
Expand Down
2 changes: 1 addition & 1 deletion pac/atsamd51p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
edition = "2021"

[dependencies]
cortex-m = "0.7"
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
supersimple33 marked this conversation as resolved.
Show resolved Hide resolved
vcell = "0.1"
critical-section = "1.1"

Expand Down