lvgl_esp32_drivers icon indicating copy to clipboard operation
lvgl_esp32_drivers copied to clipboard

GT911 show error the first time

Open herexiong opened this issue 1 week ago • 0 comments

When I use GT911, I have to reboot it manually after burning, otherwise it won’t work properly. The i2c_master_cmd_begin function reports an error ESP_FAIL Sending command error, slave hasn’t ACK the transfer. I found a comment in the code (// Only show error the first time) and I want to know why. Can this be fixed? image

I tried to use the GT911_RST() function to fix it, but it didn't work.

void GT911_RST()
{
    //init I2C before GT911 reset
    lvgl_i2c_init(I2C_NUM_0);

    // 设置4号RTS和17号INT引脚为输出模式
    gpio_set_direction(GT911_PIN_RST, GPIO_MODE_OUTPUT);
    gpio_set_direction(GT911_PIN_INT, GPIO_MODE_OUTPUT);

    // 低电平复位
    gpio_set_level(GT911_PIN_RST, 0);
    gpio_set_level(GT911_PIN_INT, 0);

    vTaskDelay(pdMS_TO_TICKS(10));

    if (GT911_I2C_SLAVE_ADDR == 0x5D)
    {
        vTaskDelay(pdMS_TO_TICKS(15));
        gpio_set_level(GT911_PIN_RST, 1); // RTS拉高
        vTaskDelay(pdMS_TO_TICKS(50));
        gpio_set_direction(GT911_PIN_INT, (GPIO_MODE_INPUT) | (GPIO_MODE_DEF_OD)); // 将INT转为悬浮输入态
    }
    else if (GT911_I2C_SLAVE_ADDR == 0x14)
    {
        vTaskDelay(pdMS_TO_TICKS(5));
        gpio_set_level(GT911_PIN_INT, 1);
        vTaskDelay(pdMS_TO_TICKS(10));
        gpio_set_level(GT911_PIN_RST, 1);// RTS拉高
        vTaskDelay(pdMS_TO_TICKS(50));
        gpio_set_direction(GT911_PIN_INT, (GPIO_MODE_INPUT) | (GPIO_MODE_DEF_OD)); // 将INT转为悬浮输入态
    }
}

Thank you for reading.

herexiong avatar Jun 26 '24 17:06 herexiong