aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/ltdc.rs21
-rw-r--r--examples/stm32h735/src/bin/ltdc.rs42
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
5use crate::{ 5use core::future::poll_fn;
6 gpio::{AfType, OutputType, Speed}, 6use core::marker::PhantomData;
7 interrupt::{self, typelevel::Interrupt}, 7use core::task::Poll;
8 peripherals, rcc, Peripheral, 8
9};
10use core::{future::poll_fn, marker::PhantomData, task::Poll};
11use embassy_hal_internal::{into_ref, PeripheralRef}; 9use embassy_hal_internal::{into_ref, PeripheralRef};
12use embassy_sync::waitqueue::AtomicWaker; 10use embassy_sync::waitqueue::AtomicWaker;
13use stm32_metapac::ltdc::{ 11use stm32_metapac::ltdc::regs::Dccr;
14 regs::Dccr, 12use stm32_metapac::ltdc::vals::{Bf1, Bf2, Cfuif, Clif, Crrif, Cterrif, Pf, Vbr};
15 vals::{Bf1, Bf2, Cfuif, Clif, Crrif, Cterrif, Pf, Vbr}, 13
16}; 14use crate::gpio::{AfType, OutputType, Speed};
15use crate::interrupt::typelevel::Interrupt;
16use crate::interrupt::{self};
17use crate::{peripherals, rcc, Peripheral};
17 18
18static LTDC_WAKER: AtomicWaker = AtomicWaker::new(); 19static 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 @@
11use bouncy_box::BouncyBox; 11use bouncy_box::BouncyBox;
12use defmt::{info, unwrap}; 12use defmt::{info, unwrap};
13use embassy_executor::Spawner; 13use embassy_executor::Spawner;
14use embassy_stm32::{ 14use embassy_stm32::gpio::{Level, Output, Speed};
15 bind_interrupts, 15use embassy_stm32::ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge};
16 gpio::{Level, Output, Speed}, 16use embassy_stm32::{bind_interrupts, peripherals};
17 ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge},
18 peripherals,
19};
20use embassy_time::{Duration, Timer}; 17use embassy_time::{Duration, Timer};
21use embedded_graphics::{ 18use embedded_graphics::draw_target::DrawTarget;
22 draw_target::DrawTarget, 19use embedded_graphics::geometry::{OriginDimensions, Point, Size};
23 geometry::{OriginDimensions, Point, Size}, 20use embedded_graphics::image::Image;
24 image::Image, 21use embedded_graphics::pixelcolor::raw::RawU24;
25 pixelcolor::{raw::RawU24, Rgb888}, 22use embedded_graphics::pixelcolor::Rgb888;
26 prelude::*, 23use embedded_graphics::prelude::*;
27 primitives::Rectangle, 24use embedded_graphics::primitives::Rectangle;
28 Pixel, 25use embedded_graphics::Pixel;
29};
30use heapless::{Entry, FnvIndexMap}; 26use heapless::{Entry, FnvIndexMap};
31use tinybmp::Bmp; 27use tinybmp::Bmp;
32use {defmt_rtt as _, panic_probe as _}; 28use {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
284mod rcc_setup { 280mod 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
366mod bouncy_box { 359mod 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,