diff options
| -rw-r--r-- | embassy-stm32/src/ltdc.rs | 21 | ||||
| -rw-r--r-- | examples/stm32h735/src/bin/ltdc.rs | 42 |
2 files changed, 29 insertions, 34 deletions
diff --git a/embassy-stm32/src/ltdc.rs b/embassy-stm32/src/ltdc.rs index 564236d6f..4c5239971 100644 --- a/embassy-stm32/src/ltdc.rs +++ b/embassy-stm32/src/ltdc.rs | |||
| @@ -2,18 +2,19 @@ | |||
| 2 | //! See ST application note AN4861: Introduction to LCD-TFT display controller (LTDC) on STM32 MCUs for high level details | 2 | //! See ST application note AN4861: Introduction to LCD-TFT display controller (LTDC) on STM32 MCUs for high level details |
| 3 | //! This module was tested against the stm32h735g-dk using the RM0468 ST reference manual for detailed register information | 3 | //! This module was tested against the stm32h735g-dk using the RM0468 ST reference manual for detailed register information |
| 4 | 4 | ||
| 5 | use crate::{ | 5 | use core::future::poll_fn; |
| 6 | gpio::{AfType, OutputType, Speed}, | 6 | use core::marker::PhantomData; |
| 7 | interrupt::{self, typelevel::Interrupt}, | 7 | use core::task::Poll; |
| 8 | peripherals, rcc, Peripheral, | 8 | |
| 9 | }; | ||
| 10 | use core::{future::poll_fn, marker::PhantomData, task::Poll}; | ||
| 11 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 9 | use embassy_hal_internal::{into_ref, PeripheralRef}; |
| 12 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 13 | use stm32_metapac::ltdc::{ | 11 | use stm32_metapac::ltdc::regs::Dccr; |
| 14 | regs::Dccr, | 12 | use stm32_metapac::ltdc::vals::{Bf1, Bf2, Cfuif, Clif, Crrif, Cterrif, Pf, Vbr}; |
| 15 | vals::{Bf1, Bf2, Cfuif, Clif, Crrif, Cterrif, Pf, Vbr}, | 13 | |
| 16 | }; | 14 | use crate::gpio::{AfType, OutputType, Speed}; |
| 15 | use crate::interrupt::typelevel::Interrupt; | ||
| 16 | use crate::interrupt::{self}; | ||
| 17 | use crate::{peripherals, rcc, Peripheral}; | ||
| 17 | 18 | ||
| 18 | static LTDC_WAKER: AtomicWaker = AtomicWaker::new(); | 19 | static LTDC_WAKER: AtomicWaker = AtomicWaker::new(); |
| 19 | 20 | ||
diff --git a/examples/stm32h735/src/bin/ltdc.rs b/examples/stm32h735/src/bin/ltdc.rs index 5c75a7db1..a36fdef2c 100644 --- a/examples/stm32h735/src/bin/ltdc.rs +++ b/examples/stm32h735/src/bin/ltdc.rs | |||
| @@ -11,22 +11,18 @@ | |||
| 11 | use bouncy_box::BouncyBox; | 11 | use bouncy_box::BouncyBox; |
| 12 | use defmt::{info, unwrap}; | 12 | use defmt::{info, unwrap}; |
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_stm32::{ | 14 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 15 | bind_interrupts, | 15 | use embassy_stm32::ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge}; |
| 16 | gpio::{Level, Output, Speed}, | 16 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 17 | ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge}, | ||
| 18 | peripherals, | ||
| 19 | }; | ||
| 20 | use embassy_time::{Duration, Timer}; | 17 | use embassy_time::{Duration, Timer}; |
| 21 | use embedded_graphics::{ | 18 | use embedded_graphics::draw_target::DrawTarget; |
| 22 | draw_target::DrawTarget, | 19 | use embedded_graphics::geometry::{OriginDimensions, Point, Size}; |
| 23 | geometry::{OriginDimensions, Point, Size}, | 20 | use embedded_graphics::image::Image; |
| 24 | image::Image, | 21 | use embedded_graphics::pixelcolor::raw::RawU24; |
| 25 | pixelcolor::{raw::RawU24, Rgb888}, | 22 | use embedded_graphics::pixelcolor::Rgb888; |
| 26 | prelude::*, | 23 | use embedded_graphics::prelude::*; |
| 27 | primitives::Rectangle, | 24 | use embedded_graphics::primitives::Rectangle; |
| 28 | Pixel, | 25 | use embedded_graphics::Pixel; |
| 29 | }; | ||
| 30 | use heapless::{Entry, FnvIndexMap}; | 26 | use heapless::{Entry, FnvIndexMap}; |
| 31 | use tinybmp::Bmp; | 27 | use tinybmp::Bmp; |
| 32 | use {defmt_rtt as _, panic_probe as _}; | 28 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -100,7 +96,7 @@ async fn main(spawner: Spawner) { | |||
| 100 | 96 | ||
| 101 | // enable the bottom layer with a 256 color lookup table | 97 | // enable the bottom layer with a 256 color lookup table |
| 102 | ltdc.init_layer(&layer_config, Some(&clut)); | 98 | ltdc.init_layer(&layer_config, Some(&clut)); |
| 103 | 99 | ||
| 104 | // Safety: the DoubleBuffer controls access to the statically allocated frame buffers | 100 | // Safety: the DoubleBuffer controls access to the statically allocated frame buffers |
| 105 | // and it is the only thing that mutates their content | 101 | // and it is the only thing that mutates their content |
| 106 | let mut double_buffer = DoubleBuffer::new( | 102 | let mut double_buffer = DoubleBuffer::new( |
| @@ -283,12 +279,9 @@ impl OriginDimensions for DoubleBuffer { | |||
| 283 | 279 | ||
| 284 | mod rcc_setup { | 280 | mod rcc_setup { |
| 285 | 281 | ||
| 286 | use embassy_stm32::{rcc::*, Peripherals}; | 282 | use embassy_stm32::rcc::{Hse, HseMode, *}; |
| 287 | use embassy_stm32::{ | 283 | use embassy_stm32::time::Hertz; |
| 288 | rcc::{Hse, HseMode}, | 284 | use embassy_stm32::{Config, Peripherals}; |
| 289 | time::Hertz, | ||
| 290 | Config, | ||
| 291 | }; | ||
| 292 | 285 | ||
| 293 | /// Sets up clocks for the stm32h735g mcu | 286 | /// Sets up clocks for the stm32h735g mcu |
| 294 | /// change this if you plan to use a different microcontroller | 287 | /// change this if you plan to use a different microcontroller |
| @@ -359,12 +352,13 @@ mod rcc_setup { | |||
| 359 | config.rcc.apb2_pre = APBPrescaler::DIV2; | 352 | config.rcc.apb2_pre = APBPrescaler::DIV2; |
| 360 | config.rcc.apb3_pre = APBPrescaler::DIV2; | 353 | config.rcc.apb3_pre = APBPrescaler::DIV2; |
| 361 | config.rcc.apb4_pre = APBPrescaler::DIV2; | 354 | config.rcc.apb4_pre = APBPrescaler::DIV2; |
| 362 | embassy_stm32::init(config) | 355 | embassy_stm32::init(config) |
| 363 | } | 356 | } |
| 364 | } | 357 | } |
| 365 | 358 | ||
| 366 | mod bouncy_box { | 359 | mod bouncy_box { |
| 367 | use embedded_graphics::{geometry::Point, primitives::Rectangle}; | 360 | use embedded_graphics::geometry::Point; |
| 361 | use embedded_graphics::primitives::Rectangle; | ||
| 368 | 362 | ||
| 369 | enum Direction { | 363 | enum Direction { |
| 370 | DownLeft, | 364 | DownLeft, |
