diff --git a/boards/pygamer/Cargo.toml b/boards/pygamer/Cargo.toml index b0e30b4efea..1675af9ed46 100644 --- a/boards/pygamer/Cargo.toml +++ b/boards/pygamer/Cargo.toml @@ -47,6 +47,8 @@ usbd-serial = "0.2" [features] # ask the HAL to enable atsamd51j support default = ["rt", "atsamd-hal/samd51j"] +dma = ["atsamd-hal/dma"] +max-channels = ["dma", "atsamd-hal/max-channels"] panic_led = [] rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"] usb = ["atsamd-hal/usb", "usb-device"] diff --git a/boards/pygamer/examples/clock_out.rs b/boards/pygamer/examples/clock_out.rs index a6cac263988..9f744a92d9c 100644 --- a/boards/pygamer/examples/clock_out.rs +++ b/boards/pygamer/examples/clock_out.rs @@ -30,5 +30,7 @@ fn main() -> ! { .configure_gclk_divider_and_source(Gclk2, 40, Dpll0, false) .unwrap(); let _clock_out_pin: GclkOut = pins.d5.into(); - loop {} + loop { + cortex_m::asm::wfi(); + } } diff --git a/boards/pygamer/examples/ferris_img.rs b/boards/pygamer/examples/ferris_img.rs index 8852532f73c..2cf9068d492 100644 --- a/boards/pygamer/examples/ferris_img.rs +++ b/boards/pygamer/examples/ferris_img.rs @@ -59,5 +59,7 @@ fn main() -> ! { let ferris = Image::new(&raw_image, Point::new(32, 32)); ferris.draw(&mut display).unwrap(); - loop {} + loop { + cortex_m::asm::wfi(); + } } diff --git a/boards/pygamer/examples/qspi.rs b/boards/pygamer/examples/qspi.rs index 4ac03d9c0d8..212aed377f9 100644 --- a/boards/pygamer/examples/qspi.rs +++ b/boards/pygamer/examples/qspi.rs @@ -99,7 +99,9 @@ fn main() -> ! { flash.read_memory(0, &mut read_buf); assert_eq!(read_buf, write_buf); - loop {} + loop { + cortex_m::asm::wfi(); + } } /// Wait for the write-in-progress and suspended write/erase. diff --git a/boards/pygamer/src/pins.rs b/boards/pygamer/src/pins.rs index 4cee2655b9c..d6fa0363b87 100644 --- a/boards/pygamer/src/pins.rs +++ b/boards/pygamer/src/pins.rs @@ -582,13 +582,22 @@ pub struct Display { pub tft_backlight: TftBacklightReset, } -/// This empty error occurs if there is an issue setting up the on-board -/// display. +/// Error that can occur when initializing the display. #[derive(Debug)] -pub struct DisplayError; +pub enum DisplayError { + /// Could not configure the SERCOM4 clock. + SercomClock, + /// Could not configure the SPI port to drive the display. + Spi, + /// Could not setup the ST7735 display driver. + Driver, + /// Could not configure the TC2/TC3 clock for PWM control of the backlight. + Tc2Tc3Clock, +} impl From<()> for DisplayError { + #[inline] fn from(_value: ()) -> Self { - DisplayError + Self::Driver } } @@ -615,7 +624,9 @@ impl Display { delay: &mut hal::delay::Delay, ) -> Result<(DisplayDriver, Pwm2), DisplayError> { let gclk0 = clocks.gclk0(); - let clock = &clocks.sercom4_core(&gclk0).ok_or(DisplayError)?; + let clock = &clocks + .sercom4_core(&gclk0) + .ok_or(DisplayError::SercomClock)?; let pads = spi::Pads::default() .sclk(self.tft_sclk) .data_out(self.tft_mosi); @@ -629,7 +640,7 @@ impl Display { .into_panic_on_read(), tft_cs, ) - .map_err(|_| DisplayError)?; + .map_err(|_| DisplayError::Spi)?; let mut display = st7735_lcd::ST7735::new( tft_spi, self.tft_dc.into(),