Skip to content

Commit

Permalink
deps(grand_central_m4)!: Update HAL dependency to v0.18 (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
supersimple33 authored Nov 17, 2024
1 parent e717771 commit 201dbd3
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 53 deletions.
8 changes: 4 additions & 4 deletions boards/grand_central_m4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ version = "0.7"
optional = true

[dependencies.atsamd-hal]
version = "0.17.0"
version = "0.18"
default-features = false

[dependencies.usb-device]
version = "0.3"
version = "0.3.2"
optional = true

[dependencies.cortex-m]
Expand Down Expand Up @@ -47,10 +47,10 @@ chip = "ATSAMD51P20A"
name = "blinky_basic"

[[example]]
name = "neopixel_rainbow"
name = "eic"

[[example]]
name = "eic"
name = "neopixel_rainbow"

[[example]]
name = "usb_serial"
Expand Down
12 changes: 6 additions & 6 deletions boards/grand_central_m4/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_external_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let pins = bsp::Pins::new(peripherals.PORT);
let pins = bsp::Pins::new(peripherals.port);
let mut red_led: bsp::RedLed = pin_alias!(pins.red_led).into();
let mut delay = Delay::new(core.SYST, &mut clocks);
loop {
Expand Down
20 changes: 10 additions & 10 deletions boards/grand_central_m4/examples/eic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let mut core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let pins = bsp::Pins::new(peripherals.PORT);
let pins = bsp::Pins::new(peripherals.port);
free(|cs| {
RED_LED
.borrow(cs)
Expand All @@ -65,11 +65,11 @@ fn main() -> ! {

let gclk0 = clocks.gclk0();
let eic_clock = clocks.eic(&gclk0).unwrap();
let mut eic = eic::init_with_ulp32k(&mut peripherals.MCLK, eic_clock, peripherals.EIC);
let mut eic = eic::init_with_ulp32k(&mut peripherals.mclk, eic_clock, peripherals.eic);
let button: Pin<_, PullUpInterrupt> = pins.d46.into();
eic.button_debounce_pins(&[button.id()]);
let mut extint_button = ExtInt6::new(button);
extint_button.sense(&mut eic, Sense::BOTH);
extint_button.sense(&mut eic, Sense::Both);
extint_button.enable_interrupt(&mut eic);
eic.finalize();

Expand All @@ -95,9 +95,9 @@ fn EIC_EXTINT_6() {
// clear the interrupt and toggle the led
let eic = unsafe {
// Accessing registers from interrupts context is safe
&*pac::EIC::ptr()
&*pac::Eic::ptr()
};
eic.intflag
eic.intflag()
.modify(|r, w| unsafe { w.bits(r.bits() | 1 << 6) });
toggle_led();
}
14 changes: 7 additions & 7 deletions boards/grand_central_m4/examples/neopixel_rainbow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_external_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let gclk0 = clocks.gclk0();
let tc2_3 = clocks.tc2_tc3(&gclk0).unwrap();
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.TC3, &mut peripherals.MCLK);
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.tc3, &mut peripherals.mclk);
timer.start(Hertz::MHz(3).into_duration());

let pins = bsp::Pins::new(peripherals.PORT);
let pins = bsp::Pins::new(peripherals.port);
let neopixel_pin = pins.neopixel.into_push_pull_output();
let mut neopixel = ws2812::Ws2812::new(timer, neopixel_pin);
let mut delay = Delay::new(core.SYST, &mut clocks);
Expand Down
18 changes: 9 additions & 9 deletions boards/grand_central_m4/examples/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let mut core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let gclk0 = clocks.gclk0();
let tc2_3 = clocks.tc2_tc3(&gclk0).unwrap();
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.TC3, &mut peripherals.MCLK);
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.tc3, &mut peripherals.mclk);
InterruptDrivenTimer::start(&mut timer, Hertz::MHz(3).into_duration());

let pins = bsp::Pins::new(peripherals.PORT);
let pins = bsp::Pins::new(peripherals.port);
let neopixel_pin = pins.neopixel.into_push_pull_output();
let mut neopixel = ws2812::Ws2812::new(timer, neopixel_pin);
let _ = neopixel.write((0..5).map(|_| RGB8::default()));

let bus_allocator = unsafe {
USB_ALLOCATOR = Some(bsp::usb_allocator(
peripherals.USB,
peripherals.usb,
&mut clocks,
&mut peripherals.MCLK,
&mut peripherals.mclk,
pins.usb_dm,
pins.usb_dp,
));
Expand Down
34 changes: 17 additions & 17 deletions boards/grand_central_m4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ use hal::{
time::Hertz,
};

use pac::MCLK;
use pac::Mclk;

#[cfg(feature = "usb")]
use hal::usb::{usb_device::bus::UsbBusAllocator, UsbBus};

hal::bsp_peripherals!(
SERCOM0 { UartSercom }
SERCOM1 { UartSercom2 }
SERCOM5 { UartSercom3 }
SERCOM3 { I2cSercom }
SERCOM6 { I2cSercom2 }
SERCOM7 { SpiSercom }
Sercom0 { UartSercom }
Sercom1 { UartSercom2 }
Sercom5 { UartSercom3 }
Sercom3 { I2cSercom }
Sercom6 { I2cSercom2 }
Sercom7 { SpiSercom }
);

hal::bsp_pins!(
Expand Down Expand Up @@ -495,7 +495,7 @@ pub fn spi_master(
clocks: &mut GenericClockController,
baud: Hertz,
sercom7: SpiSercom,
mclk: &mut pac::MCLK,
mclk: &mut pac::Mclk,
sclk: impl Into<Sclk>,
mosi: impl Into<Mosi>,
miso: impl Into<Miso>,
Expand All @@ -516,8 +516,8 @@ pub fn spi_master(
/// assuming 120MHz system clock, for 4MHz QSPI mode 0 operation.
#[allow(clippy::too_many_arguments)]
pub fn qspi_master(
mclk: &mut MCLK,
qspi: pac::QSPI,
mclk: &mut Mclk,
qspi: pac::Qspi,
sclk: impl Into<FlashSclk>,
cs: impl Into<FlashCs>,
data0: impl Into<FlashD0>,
Expand Down Expand Up @@ -555,7 +555,7 @@ pub fn i2c_master(
clocks: &mut GenericClockController,
baud: impl Into<Hertz>,
sercom: I2cSercom,
mclk: &mut pac::MCLK,
mclk: &mut pac::Mclk,
sda: impl Into<Sda>,
scl: impl Into<Scl>,
) -> I2c {
Expand All @@ -581,7 +581,7 @@ pub fn uart(
clocks: &mut GenericClockController,
baud: impl Into<Hertz>,
sercom: UartSercom,
mclk: &mut pac::MCLK,
mclk: &mut pac::Mclk,
uart_rx: impl Into<UartRx>,
uart_tx: impl Into<UartTx>,
) -> Uart {
Expand All @@ -597,16 +597,16 @@ pub fn uart(
#[cfg(feature = "usb")]
/// Convenience function for setting up USB
pub fn usb_allocator(
usb: pac::USB,
usb: pac::Usb,
clocks: &mut GenericClockController,
mclk: &mut pac::MCLK,
mclk: &mut pac::Mclk,
dm: impl Into<UsbDm>,
dp: impl Into<UsbDp>,
) -> UsbBusAllocator<UsbBus> {
use pac::gclk::{genctrl::SRCSELECT_A, pchctrl::GENSELECT_A};
use pac::gclk::{genctrl::Srcselect, pchctrl::Genselect};

clocks.configure_gclk_divider_and_source(GENSELECT_A::GCLK2, 1, SRCSELECT_A::DFLL, false);
let usb_gclk = clocks.get_gclk(GENSELECT_A::GCLK2).unwrap();
clocks.configure_gclk_divider_and_source(Genselect::Gclk2, 1, Srcselect::Dfll, false);
let usb_gclk = clocks.get_gclk(Genselect::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

0 comments on commit 201dbd3

Please sign in to comment.