@@ -38,6 +38,7 @@ void MatrixPanel_FPGA_SPI::do_swapFrame_() {
3838 }
3939 SpiLockGuard spi_lock (this );
4040 if (!spi_lock.locked ())
41+ if (!wait_for_fpga_resetstatus_ ())
4142 return ;
4243 uint8_t buf[1 ];
4344 uint16_t buf_len = 0 ;
@@ -78,6 +79,7 @@ void MatrixPanel_FPGA_SPI::do_fulfillWatchdog_() {
7879 }
7980 SpiLockGuard spi_lock (this );
8081 if (!spi_lock.locked ())
82+ if (!wait_for_fpga_resetstatus_ ())
8183 return ;
8284 uint8_t buf[9 ] = {' W' , 0xDE , 0xAD , 0xBE , 0xEF ,
8385 0xFE , 0xEB , 0xDA , 0xED }; // 'W' is
@@ -143,6 +145,22 @@ void MatrixPanel_FPGA_SPI::init_fpga_resetstatus_gpio_() {
143145 }
144146}
145147
148+ bool MatrixPanel_FPGA_SPI::wait_for_fpga_resetstatus_ () {
149+ if (!fpga_resetstatus_configured_)
150+ return true ;
151+ const TickType_t start = xTaskGetTickCount ();
152+ const TickType_t timeout =
153+ pdMS_TO_TICKS (m_cfg.fpga_resetstatus_timeout_ms );
154+ while (gpio_get_level ((gpio_num_t )m_cfg.gpio .fpga_resetstatus ) == 0 ) {
155+ if ((xTaskGetTickCount () - start) > timeout) {
156+ ESP_LOGW (" fpga_resetstatus" , " Timeout waiting for FPGA resetstatus" );
157+ return false ;
158+ }
159+ vTaskDelay (1 );
160+ }
161+ return true ;
162+ }
163+
146164bool MatrixPanel_FPGA_SPI::consume_fpga_reset () {
147165 if (!fpga_resetstatus_configured_)
148166 return false ;
@@ -203,6 +221,7 @@ void MatrixPanel_FPGA_SPI::do_drawFrameRGB888_(const uint8_t *data,
203221 }
204222 SpiLockGuard spi_lock (this );
205223 if (!spi_lock.locked ())
224+ if (!wait_for_fpga_resetstatus_ ())
206225 return ;
207226
208227 const size_t chunk_bytes =
@@ -283,6 +302,7 @@ void MatrixPanel_FPGA_SPI::do_drawRowRGB888_(const uint8_t y,
283302 }
284303 SpiLockGuard spi_lock (this );
285304 if (!spi_lock.locked ())
305+ if (!wait_for_fpga_resetstatus_ ())
286306 return ;
287307
288308 uint8_t buf[expected_row_bytes];
@@ -333,6 +353,7 @@ void MatrixPanel_FPGA_SPI::do_drawPixelRGB888_(int16_t x, int16_t y, uint8_t r,
333353 }
334354 SpiLockGuard spi_lock (this );
335355 if (!spi_lock.locked ())
356+ if (!wait_for_fpga_resetstatus_ ())
336357 return ;
337358 uint8_t buf[7 ];
338359 uint8_t buf_len = 0 ;
@@ -393,6 +414,7 @@ void MatrixPanel_FPGA_SPI::do_fillScreenRGB888_(uint8_t r, uint8_t g,
393414 }
394415 SpiLockGuard spi_lock (this );
395416 if (!spi_lock.locked ())
417+ if (!wait_for_fpga_resetstatus_ ())
396418 return ;
397419 uint8_t buf[4 ];
398420 uint8_t buf_len = 0 ;
@@ -438,6 +460,7 @@ void MatrixPanel_FPGA_SPI::do_clearScreen_() {
438460 }
439461 SpiLockGuard spi_lock (this );
440462 if (!spi_lock.locked ())
463+ if (!wait_for_fpga_resetstatus_ ())
441464 return ;
442465 uint8_t buf[1 ];
443466 uint8_t buf_len = 0 ;
@@ -478,6 +501,7 @@ void MatrixPanel_FPGA_SPI::do_setBrightness8_(const uint8_t b) {
478501 }
479502 SpiLockGuard spi_lock (this );
480503 if (!spi_lock.locked ())
504+ if (!wait_for_fpga_resetstatus_ ())
481505 return ;
482506 uint8_t buf[2 ];
483507 uint8_t buf_len = 0 ;
@@ -523,6 +547,7 @@ void MatrixPanel_FPGA_SPI::do_fillRect_(int16_t x, int16_t y, int16_t w,
523547 }
524548 SpiLockGuard spi_lock (this );
525549 if (!spi_lock.locked ())
550+ if (!wait_for_fpga_resetstatus_ ())
526551 return ;
527552 uint8_t buf[10 ];
528553 uint8_t buf_len = 0 ;
0 commit comments