From 7ffeea4009357cbeed616d4236d57fd4dde12ba8 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 25 Sep 2023 15:22:37 +1000 Subject: [PATCH] Don't acquire the spi bus in the display driver Interrupt-based transactions don't need it, and it causes issues. --- src/drivers/display.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp index b4889b4b..48310074 100644 --- a/src/drivers/display.cpp +++ b/src/drivers/display.cpp @@ -202,10 +202,6 @@ auto Display::SetDutyCycle(uint_fast8_t new_duty, bool fade) -> void { } void Display::SendInitialisationSequence(const uint8_t* data) { - // Hold onto the bus for the entire sequence so that we're not interrupted - // part way through. - spi_device_acquire_bus(handle_, portMAX_DELAY); - // First byte of the data is the number of commands. for (int i = *(data++); i > 0; i--) { uint8_t command = *(data++); @@ -222,14 +218,9 @@ void Display::SendInitialisationSequence(const uint8_t* data) { sleep_duration_ms = 500; } - // Avoid hanging on to the bus whilst delaying. - spi_device_release_bus(handle_); vTaskDelay(pdMS_TO_TICKS(sleep_duration_ms)); - spi_device_acquire_bus(handle_, portMAX_DELAY); } } - - spi_device_release_bus(handle_); } void Display::SendCommandWithData(uint8_t command, @@ -284,10 +275,6 @@ void Display::SendTransaction(TransactionType type, void Display::OnLvglFlush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_map) { - // Ideally we want to complete a single flush as quickly as possible, so - // grab the bus for this entire transaction sequence. - spi_device_acquire_bus(handle_, portMAX_DELAY); - // First we need to specify the rectangle of the display we're writing into. uint16_t data[2] = {0, 0}; @@ -306,8 +293,6 @@ void Display::OnLvglFlush(lv_disp_drv_t* disp_drv, SendCommandWithData(displays::ST77XX_RAMWR, reinterpret_cast(color_map), size * 2); - spi_device_release_bus(handle_); - lv_disp_flush_ready(&driver_); }