I am using and ADP5587 in my design. It is interfaced with a custom keypad of 12 keys. I am using extra rows as standard GPIO.
In normal operation the keypad comes up and is works fine.
However if one of the keys is held down while booting my device, I don't get interrupts for any key presses
and key presses do not seem to register until I power cycle the chip. This also occurs if I set the GPIO pin to act as
a key source to interrupt when the GPIO changes.
Any ideas on what might be causing this?
Configuration:
/***
* @brief Keypad initialization
*/
esp_err_t keypad_init(esp_err_t (*queue_event_func)(keyPress_t *))
{
TOV_LOGI("Initializing Keypad");
uint8_t devID = 0;
esp_err_t rc = ESP_OK;
rc = i2c_read_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_DEV_ID, &devID);
if (rc != ESP_OK) {
TOV_LOGW("Could not find Keyscan Chip ERR:%s", esp_err_to_name(rc));
}
rc = i2c_write_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_KP_GPIO1, 0x0F); // Row0-Row3 in use
if (rc != ESP_OK) {
TOV_LOGW("Keyscan Init Failed1 ERR:%s", esp_err_to_name(rc));
}
rc = i2c_write_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_KP_GPIO2, 0xFF); // Col0-Col7 in use
if (rc != ESP_OK) {
TOV_LOGW("Keyscan Init Failed2 ERR:%s", esp_err_to_name(rc));
}
rc = i2c_write_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_KP_GPIO3, 0x03); // Col8-Col9 in use
if (rc != ESP_OK) {
TOV_LOGW("Keyscan Init Failed3 ERR:%s", esp_err_to_name(rc));
}
//Set door switch to act like a button in the matrix
//rc = i2c_write_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_GPI_EM_REG1, BIT(DOOR_SWITCH));
rc = check_model_resistor();
if (rc != ESP_OK) {
TOV_LOGW("Model Resistor Check Failed ERR:%x", rc);
}
// NOT IN USE Interrupt config: 0001 0000 - deassert for 275us for each new keypress
// Overflow FIFO: 0010 0000
// Enable key event interrupts: 0000 0001
rc = i2c_write_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_CFG, 0b00100001);
if (rc != ESP_OK) {
TOV_LOGW("Keyscan Init Failed4 ERR:%x", rc);
}
memset(keyArray, 0, sizeof(keyArray));
queue_event = queue_event_func;
uint8_t gpioRegister = 0;
rc = i2c_read_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_GPIO_DAT_STAT1, &gpioRegister);
rc = i2c_read_register_byte(I2C_ADDR_KEYSCAN, TCA8418_REG_GPIO_DAT_STAT1, &gpioRegister);
clear_keystrokes();
keypad_fetchkeystrokes();
TOV_LOGI("Keypad Initialized!!!!!!");
return rc;
}