This commit is contained in:
Alexey Zholtikov 2025-06-06 19:06:17 +03:00
parent 46019d0141
commit fff4013b40
3 changed files with 9 additions and 3 deletions

View File

@ -73,6 +73,7 @@ extern "C"
{ {
uint8_t i2c_address; // The i2c address of PCF8574 expander that caused the interrupt. uint8_t i2c_address; // The i2c address of PCF8574 expander that caused the interrupt.
uint8_t gpio_number; // The GPIO that caused the interrupt. uint8_t gpio_number; // The GPIO that caused the interrupt.
bool gpio_level; // The GPIO level that caused the interrupt.
} zh_pcf8574_event_on_isr_t; } zh_pcf8574_event_on_isr_t;
/** /**

View File

@ -1 +1 @@
1.2.0 1.3.0

View File

@ -223,6 +223,7 @@ static void IRAM_ATTR _zh_pcf8574_isr_processing_task(void *pvParameter)
zh_pcf8574_event_on_isr_t event = {0}; zh_pcf8574_event_on_isr_t event = {0};
event.i2c_address = handle->i2c_address; event.i2c_address = handle->i2c_address;
event.gpio_number = 0xFF; event.gpio_number = 0xFF;
uint8_t old_reg = handle->gpio_status;
uint8_t reg_temp = 0; uint8_t reg_temp = 0;
esp_err_t err = _zh_pcf8574_read_register(handle, &reg_temp); esp_err_t err = _zh_pcf8574_read_register(handle, &reg_temp);
if (err != ESP_OK) if (err != ESP_OK)
@ -232,9 +233,13 @@ static void IRAM_ATTR _zh_pcf8574_isr_processing_task(void *pvParameter)
} }
for (uint8_t j = 0; j <= 7; ++j) for (uint8_t j = 0; j <= 7; ++j)
{ {
if (((handle->gpio_work_mode & _gpio_matrix[j]) != 0) && ((reg_temp & _gpio_matrix[j]) == 0)) if ((handle->gpio_work_mode & _gpio_matrix[j]) != 0)
{
if ((old_reg & _gpio_matrix[j]) != (reg_temp & _gpio_matrix[j]))
{ {
event.gpio_number = j; event.gpio_number = j;
event.gpio_level = reg_temp & _gpio_matrix[j];
}
break; break;
} }
} }