From 7f54fa3d8aa6a2f52774271b2685741f8f5a07e1 Mon Sep 17 00:00:00 2001 From: Alexey Zholtikov Date: Sun, 11 May 2025 13:45:54 +0300 Subject: [PATCH] refactor: changed variable type --- include/zh_pcf8574.h | 26 +++++++++++++------------- zh_pcf8574.c | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/zh_pcf8574.h b/include/zh_pcf8574.h index 3b7c33b..8340735 100644 --- a/include/zh_pcf8574.h +++ b/include/zh_pcf8574.h @@ -35,19 +35,19 @@ extern "C" typedef struct // Structure for initial initialization of PCF8574 expander. { - uint8_t task_priority; // Task priority for the PCF8574 expander isr processing. @note It is not recommended to set a value less than 10. - uint16_t stack_size; // Stack size for task for the PCF8574 expander isr processing processing. @note The minimum size is 2048 bytes. - uint8_t i2c_address; // Expander I2C address. - bool p0_gpio_work_mode; // Expander GPIO PO work mode. True for input, false for output. - bool p1_gpio_work_mode; // Expander GPIO P1 work mode. True for input, false for output. - bool p2_gpio_work_mode; // Expander GPIO P2 work mode. True for input, false for output. - bool p3_gpio_work_mode; // Expander GPIO P3 work mode. True for input, false for output. - bool p4_gpio_work_mode; // Expander GPIO P4 work mode. True for input, false for output. - bool p5_gpio_work_mode; // Expander GPIO P5 work mode. True for input, false for output. - bool p6_gpio_work_mode; // Expander GPIO P6 work mode. True for input, false for output. - bool p7_gpio_work_mode; // Expander GPIO P7 work mode. True for input, false for output. - gpio_num_t interrupt_gpio; // Interrupt GPIO. @attention Must be same for all PCF8574 expanders. - bool i2c_port; // I2C port. @attention Must be same for all PCF8574 expanders. + uint8_t task_priority; // Task priority for the PCF8574 expander isr processing. @note It is not recommended to set a value less than 10. + uint16_t stack_size; // Stack size for task for the PCF8574 expander isr processing processing. @note The minimum size is 2048 bytes. + uint8_t i2c_address; // Expander I2C address. + bool p0_gpio_work_mode; // Expander GPIO PO work mode. True for input, false for output. + bool p1_gpio_work_mode; // Expander GPIO P1 work mode. True for input, false for output. + bool p2_gpio_work_mode; // Expander GPIO P2 work mode. True for input, false for output. + bool p3_gpio_work_mode; // Expander GPIO P3 work mode. True for input, false for output. + bool p4_gpio_work_mode; // Expander GPIO P4 work mode. True for input, false for output. + bool p5_gpio_work_mode; // Expander GPIO P5 work mode. True for input, false for output. + bool p6_gpio_work_mode; // Expander GPIO P6 work mode. True for input, false for output. + bool p7_gpio_work_mode; // Expander GPIO P7 work mode. True for input, false for output. + uint8_t interrupt_gpio; // Interrupt GPIO. @attention Must be same for all PCF8574 expanders. + bool i2c_port; // I2C port. @attention Must be same for all PCF8574 expanders. #ifndef CONFIG_IDF_TARGET_ESP8266 i2c_master_bus_handle_t i2c_handle; // Unique I2C bus handle. @attention Must be same for all PCF8574 expanders. #endif diff --git a/zh_pcf8574.c b/zh_pcf8574.c index 4c244b3..69254cf 100644 --- a/zh_pcf8574.c +++ b/zh_pcf8574.c @@ -14,7 +14,7 @@ static const char *TAG = "zh_pcf8574"; return err; \ } -static gpio_num_t _interrupt_gpio = GPIO_NUM_MAX; +static uint8_t _interrupt_gpio = GPIO_NUM_MAX; static SemaphoreHandle_t _interrupt_semaphore = NULL; static uint8_t _gpio_matrix[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; @@ -49,7 +49,7 @@ esp_err_t zh_pcf8574_init(const zh_pcf8574_init_config_t *config, zh_pcf8574_han return err; } ZH_PCF8574_LOGI("GPIO setup completed successfully."); - if (config->interrupt_gpio < GPIO_NUM_MAX && config->interrupt_gpio >= GPIO_NUM_0 && handle->gpio_work_mode != 0) + if (config->interrupt_gpio < GPIO_NUM_MAX && handle->gpio_work_mode != 0) { err = _zh_pcf8574_configure_interrupts(config, *handle); if (err != ESP_OK)