GPIO descriptor fixes (#578)
This commit is contained in:
committed by
GitHub
parent
a3fda9ad8f
commit
8b92aa8e5a
@@ -71,16 +71,16 @@ static int pin_or_unused(const struct GpioPinSpec& pin) {
|
||||
// start()), which makes it fall back to sending a SWRESET command instead - itself a valid and
|
||||
// commonly-recommended reset path, so this pulse plus that fallback is redundant-safe, not harmful.
|
||||
// Timing (10ms low, 10ms recovery) matches esp_lcd_ili9341's own hardware-reset path exactly.
|
||||
static error_t pulse_reset(GpioDescriptor* descriptor, bool active_high) {
|
||||
static error_t pulse_reset(GpioDescriptor* descriptor) {
|
||||
if (descriptor == nullptr) {
|
||||
return ERROR_NONE;
|
||||
}
|
||||
error_t error = gpio_descriptor_set_level(descriptor, active_high);
|
||||
error_t error = gpio_descriptor_set_level(descriptor, true);
|
||||
if (error != ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
error = gpio_descriptor_set_level(descriptor, !active_high);
|
||||
error = gpio_descriptor_set_level(descriptor, false);
|
||||
if (error != ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
@@ -117,20 +117,13 @@ static error_t start(Device* device) {
|
||||
internal->reset_descriptor = nullptr;
|
||||
internal->reset_active_high = config->reset_active_high;
|
||||
if (config->pin_reset.gpio_controller != nullptr) {
|
||||
internal->reset_descriptor = gpio_descriptor_acquire(config->pin_reset.gpio_controller, config->pin_reset.pin, GPIO_OWNER_GPIO);
|
||||
internal->reset_descriptor = gpio_descriptor_acquire(config->pin_reset.gpio_controller, config->pin_reset.pin, GPIO_FLAG_DIRECTION_OUTPUT | GPIO_FLAG_ACTIVE_LOW, GPIO_OWNER_GPIO);
|
||||
if (internal->reset_descriptor == nullptr) {
|
||||
LOG_E(TAG, "Failed to acquire reset GPIO descriptor");
|
||||
vSemaphoreDelete(internal->draw_done_semaphore);
|
||||
free(internal);
|
||||
return ERROR_RESOURCE;
|
||||
}
|
||||
if (gpio_descriptor_set_flags(internal->reset_descriptor, config->pin_reset.flags | GPIO_FLAG_DIRECTION_OUTPUT) != ERROR_NONE) {
|
||||
LOG_E(TAG, "Failed to configure reset pin as output");
|
||||
gpio_descriptor_release(internal->reset_descriptor);
|
||||
vSemaphoreDelete(internal->draw_done_semaphore);
|
||||
free(internal);
|
||||
return ERROR_RESOURCE;
|
||||
}
|
||||
}
|
||||
|
||||
esp_lcd_panel_io_spi_config_t io_config = {
|
||||
@@ -195,7 +188,7 @@ static error_t start(Device* device) {
|
||||
// Every failure path below must clean up fully: unlike stop_device, this is never retried by the kernel
|
||||
// if start_device fails (see device_start() in TactilityKernel), so a partial failure here would leak.
|
||||
bool ok =
|
||||
pulse_reset(internal->reset_descriptor, internal->reset_active_high) == ERROR_NONE &&
|
||||
pulse_reset(internal->reset_descriptor) == ERROR_NONE &&
|
||||
esp_lcd_panel_reset(internal->panel_handle) == ESP_OK &&
|
||||
esp_lcd_panel_init(internal->panel_handle) == ESP_OK &&
|
||||
(!config->invert_color || esp_lcd_panel_invert_color(internal->panel_handle, true) == ESP_OK);
|
||||
@@ -263,7 +256,7 @@ static error_t stop(Device* device) {
|
||||
|
||||
static error_t ili9341_reset(Device* device) {
|
||||
auto* internal = static_cast<Ili9341Internal*>(device_get_driver_data(device));
|
||||
error_t error = pulse_reset(internal->reset_descriptor, internal->reset_active_high);
|
||||
error_t error = pulse_reset(internal->reset_descriptor);
|
||||
if (error != ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user