Unfortunately, access to the I2C bus generates panic (see below) when I touch the panel, the esp32 generates the interrupt and calls the ISR handler.
Does anyone know a solution for this problem?
Thanks in advance,
Michael
Code: Select all
esp_err_t IRAM_ATTR i2c_read(uint8_t addr, uint8_t reg, uint8_t *data, size_t len)
{
esp_err_t ret;
i2c_cmd_handle_t cmd;
if (len == 0)
return(ESP_OK);
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_ENABLE);
i2c_master_write_byte(cmd, reg, I2C_ACK_CHECK_ENABLE);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(I2C_USED_INTERFACE, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (ret != ESP_OK)
return(ret);
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr << 1) | I2C_MASTER_READ, I2C_ACK_CHECK_ENABLE);
if (len > 1)
i2c_master_read(cmd, data, len - 1, I2C_ACK_VALUE);
i2c_master_read_byte(cmd, data + len - 1, I2C_NACK_VALUE);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(I2C_USED_INTERFACE, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
return(ret);
}
static void IRAM_ATTR ft6236_isr_handler(void *args)
{
uint8_t i2c_buf[14];
touch_panel_event_t tp_event;
if (i2c_read(FT6236_I2C_IO_ADDR, FT6236_REG_GEST_ID, i2c_buf, 14) == ESP_OK)
{
if (0 < i2c_buf[1] && i2c_buf[1] < 3)
{
ft6236_decode_gesture(i2c_buf, &tp_event);
xQueueSendFromISR(msg_queue, &tp_event, NULL);
}
}
}
esp_err_t ft6236_initialize(void)
{
int i;
esp_err_t ret;
gpio_set_direction(PIN_GPIO_FT6236_INT, GPIO_MODE_INPUT);
gpio_set_pull_mode(PIN_GPIO_FT6236_INT, GPIO_PULLUP_ONLY);
if ((ret = gpio_set_intr_type(PIN_GPIO_FT6236_INT, GPIO_INTR_NEGEDGE)) != ESP_OK)
return(ret);
if ((ret = gpio_install_isr_service(0)) != ESP_OK)
return(ret);
if ((ret = gpio_isr_handler_add(PIN_GPIO_FT6236_INT, ft6236_isr_handler, NULL)) != ESP_OK)
{
gpio_uninstall_isr_service();
return(ret);
}
if ((ret = gpio_intr_enable(PIN_GPIO_FT6236_INT)) != ESP_OK)
{
gpio_isr_handler_remove(PIN_GPIO_FT6236_INT);
gpio_uninstall_isr_service();
return(ret);
}
return(ESP_OK);
}
Code: Select all
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC : 0x40088510 PS : 0x00060c34 A0 : 0x80086ec6 A1 : 0x3ffb04c0
0x40088510: vListInsert at /opt/esp32/esp-idf/components/freertos/list.c:188 (discriminator 1)
A2 : 0x3ffc47e0 A3 : 0x3ffb91cc A4 : 0x00060c22 A5 : 0x00000001
A6 : 0x00060c22 A7 : 0x00000000 A8 : 0x3ffb91cc A9 : 0x3ffb91cc
A10 : 0x00000019 A11 : 0x00000019 A12 : 0x00000014 A13 : 0x00000001
A14 : 0x00060c23 A15 : 0x00000001 SAR : 0x0000001b EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Core 0 was running in ISR context:
EPC1 : 0x400e5ac0 EPC2 : 0x400e9e86 EPC3 : 0x00000000 EPC4 : 0x40088510
0x400e5ac0: i2c_master_stop at /opt/esp32/esp-idf/components/driver/i2c.c:971
0x400e9e86: esp_vApplicationWaitiHook at /opt/esp32/esp-idf/components/esp32/freertos_hooks.c:66
0x40088510: vListInsert at /opt/esp32/esp-idf/components/freertos/list.c:188 (discriminator 1)
Backtrace: 0x40088510:0x3ffb04c0 0x40086ec3:0x3ffb04e0 0x40085bec:0x3ffb0500 0x400e5f1a:0x3ffb0540 0x400d29da:0x3ffb0580 0x40082bf1:0x3ffb05a0 0x400852ae:0x3ffb05f0 0x400825c1:0x3ffb0610 0x400e9e83:0x00000000
0x40088510: vListInsert at /opt/esp32/esp-idf/components/freertos/list.c:188 (discriminator 1)
0x40086ec3: vTaskPlaceOnEventList at /opt/esp32/esp-idf/components/freertos/tasks.c:4609
0x40085bec: xQueueGenericReceive at /opt/esp32/esp-idf/components/freertos/queue.c:2037
0x400e5f1a: i2c_master_cmd_begin at /opt/esp32/esp-idf/components/driver/i2c.c:1271
0x400d29da: i2c_read at /home/mick/Projects/ESP32/ILI9488_FT6236/main/interfaces.c:161
0x40082bf1: ft6236_isr_handler at /home/mick/Projects/ESP32/ILI9488_FT6236/main/ft6236.c:230
0x400852ae: gpio_intr_service at /opt/esp32/esp-idf/components/driver/gpio.c:549
0x400825c1: _xt_medint2 at /opt/esp32/esp-idf/components/freertos/xtensa_vectors.S:1185
0x400e9e83: esp_vApplicationWaitiHook at /opt/esp32/esp-idf/components/esp32/freertos_hooks.c:66
Core 1 register dump:
PC : 0x40085e69 PS : 0x00060034 A0 : 0x800862be A1 : 0x3ffb9580
0x40085e69: uxPortCompareSet at /opt/esp32/esp-idf/components/freertos/port.c:374
(inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /opt/esp32/esp-idf/components/freertos/portmux_impl.inc.h:86
(inlined by) vPortCPUAcquireMutexIntsDisabled at /opt/esp32/esp-idf/components/freertos/portmux_impl.h:98
(inlined by) vPortCPUAcquireMutex at /opt/esp32/esp-idf/components/freertos/port.c:365
A2 : 0x3ffb106c A3 : 0x00000000 A4 : 0x80085e06 A5 : 0x3ffb0bd0
A6 : 0x3ffb0c18 A7 : 0x00000001 A8 : 0x0000abab A9 : 0x0000abab
A10 : 0x00060023 A11 : 0xb33fffff A12 : 0x0000cdcd A13 : 0x3ffb0ba0
A14 : 0x00000008 A15 : 0x00000001 SAR : 0x00000020 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x40085e69:0x3ffb9580 0x400862bb:0x3ffb95a0 0x400878ac:0x3ffb95c0 0x40087862:0x00000000
0x40085e69: uxPortCompareSet at /opt/esp32/esp-idf/components/freertos/port.c:374
(inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /opt/esp32/esp-idf/components/freertos/portmux_impl.inc.h:86
(inlined by) vPortCPUAcquireMutexIntsDisabled at /opt/esp32/esp-idf/components/freertos/portmux_impl.h:98
(inlined by) vPortCPUAcquireMutex at /opt/esp32/esp-idf/components/freertos/port.c:365
0x400862bb: vTaskSwitchContext at /opt/esp32/esp-idf/components/freertos/tasks.c:4609
0x400878ac: _frxt_dispatch at /opt/esp32/esp-idf/components/freertos/portasm.S:406
0x40087862: _frxt_int_exit at /opt/esp32/esp-idf/components/freertos/portasm.S:206