stm32f7xx-hal icon indicating copy to clipboard operation
stm32f7xx-hal copied to clipboard

LTDC DisplayController::draw_rectangle is racy

Open fhars opened this issue 2 years ago • 1 comments

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 {

fhars avatar Sep 19 '23 12:09 fhars

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

eldruin avatar Sep 20 '23 07:09 eldruin