stm32-rs / stm32f7xx-hal

A Rust embedded-hal HAL for all MCUs in the STM32 F7 family
Apache License 2.0
114 stars 65 forks source link

LTDC DisplayController::draw_rectangle is racy #201

Open fhars opened 9 months ago

fhars commented 9 months ago

The first (few?) draw requests after a large rectangle will be garbled. Until the "safer DMA transfers" have landed, it may be better to block the call if a transfer is already in flight:

@@ -369,6 +369,9 @@ impl<T: 'static + SupportedWord> DisplayController<T> {
         bottom_right: (usize, usize),
         color: u32,
     ) {
+       // Block until the previous transfer is finished
+       while self._dma2d.cr.read().start().bit_is_set() {}
+
         // Output color format
         self._dma2d.opfccr.write(|w| {
             w.cm().bits(match &self.pixel_format {
eldruin commented 9 months ago

Thanks for finding this! Could you submit it as a PR?