diff --git a/boards/grand_central_m4/Cargo.toml b/boards/grand_central_m4/Cargo.toml index 639e2efd1c0..f0cb37bf38a 100644 --- a/boards/grand_central_m4/Cargo.toml +++ b/boards/grand_central_m4/Cargo.toml @@ -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] @@ -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" diff --git a/boards/grand_central_m4/examples/blinky_basic.rs b/boards/grand_central_m4/examples/blinky_basic.rs index f10f25e9e62..e54bdf4fba7 100644 --- a/boards/grand_central_m4/examples/blinky_basic.rs +++ b/boards/grand_central_m4/examples/blinky_basic.rs @@ -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 { diff --git a/boards/grand_central_m4/examples/eic.rs b/boards/grand_central_m4/examples/eic.rs index cec3c24fba2..3749760d340 100644 --- a/boards/grand_central_m4/examples/eic.rs +++ b/boards/grand_central_m4/examples/eic.rs @@ -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) @@ -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(); @@ -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(); } diff --git a/boards/grand_central_m4/examples/neopixel_rainbow.rs b/boards/grand_central_m4/examples/neopixel_rainbow.rs index fac68bb1078..83136824643 100644 --- a/boards/grand_central_m4/examples/neopixel_rainbow.rs +++ b/boards/grand_central_m4/examples/neopixel_rainbow.rs @@ -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); diff --git a/boards/grand_central_m4/examples/usb_serial.rs b/boards/grand_central_m4/examples/usb_serial.rs index 5f2ca6bbe7d..bb46d4be12e 100644 --- a/boards/grand_central_m4/examples/usb_serial.rs +++ b/boards/grand_central_m4/examples/usb_serial.rs @@ -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, )); diff --git a/boards/grand_central_m4/src/lib.rs b/boards/grand_central_m4/src/lib.rs index a39e55ac867..6e2db4a9e1d 100644 --- a/boards/grand_central_m4/src/lib.rs +++ b/boards/grand_central_m4/src/lib.rs @@ -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!( @@ -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, mosi: impl Into, miso: impl Into, @@ -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, cs: impl Into, data0: impl Into, @@ -555,7 +555,7 @@ pub fn i2c_master( clocks: &mut GenericClockController, baud: impl Into, sercom: I2cSercom, - mclk: &mut pac::MCLK, + mclk: &mut pac::Mclk, sda: impl Into, scl: impl Into, ) -> I2c { @@ -581,7 +581,7 @@ pub fn uart( clocks: &mut GenericClockController, baud: impl Into, sercom: UartSercom, - mclk: &mut pac::MCLK, + mclk: &mut pac::Mclk, uart_rx: impl Into, uart_tx: impl Into, ) -> Uart { @@ -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, dp: impl Into, ) -> UsbBusAllocator { - 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))