Add workaround for unstable writes to RP2040

This commit is contained in:
Renze Nicolai 2022-03-11 04:41:34 +01:00
parent 08c4a07184
commit c5a4be6479
2 changed files with 10 additions and 2 deletions

View file

@ -73,7 +73,15 @@ esp_err_t rp2040_get_lcd_mode(RP2040* device, lcd_mode_t* mode) {
} }
esp_err_t rp2040_set_lcd_mode(RP2040* device, lcd_mode_t mode) { esp_err_t rp2040_set_lcd_mode(RP2040* device, lcd_mode_t mode) {
return i2c_write_reg_n(device->i2c_bus, device->i2c_address, RP2040_REG_LCD_MODE, (uint8_t*) &mode, 1); esp_err_t res;
lcd_mode_t verification;
do {
res = i2c_write_reg_n(device->i2c_bus, device->i2c_address, RP2040_REG_LCD_MODE, (uint8_t*) &mode, 1);
if (res != ESP_OK) return res;
res = rp2040_get_lcd_mode(device, &verification);
if (res != ESP_OK) return res;
} while (verification != mode);
return res;
} }
esp_err_t rp2040_get_lcd_backlight(RP2040* device, uint8_t* brightness) { esp_err_t rp2040_get_lcd_backlight(RP2040* device, uint8_t* brightness) {

View file

@ -492,7 +492,7 @@ void fpga_test(void) {
reload_fpga = false; reload_fpga = false;
ili9341_deinit(ili9341); ili9341_deinit(ili9341);
ili9341_select(ili9341, false); ili9341_select(ili9341, false);
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(200 / portTICK_PERIOD_MS);
ili9341_select(ili9341, true); ili9341_select(ili9341, true);
ESP_LOGI(TAG, "Loading app bitstream into FPGA..."); ESP_LOGI(TAG, "Loading app bitstream into FPGA...");