34#include "freertos/FreeRTOS.h"
40static const char *TAG =
"XL9555";
44static bool init_done =
false;
46esp_err_t xl9555_init()
48 ESP_LOGI(TAG,
"----DRIVER XL9555 ----");
51#if CONFIG_I2C_COMMUNICATION_METHOD_CALLBACK_RW
53 uint8_t address = XL9555_SLAVE_ADDRESS0;
56 i2c_drv_device_init(address);
58 ESP_LOGI(TAG,
"Implemented using read and write callback methods");
60 ESP_LOGI(TAG,
"Initializing XL9555 successfully!");
62 ESP_LOGE(TAG,
"Failed to initialize XL9555 failed!");
68#if CONFIG_I2C_COMMUNICATION_METHOD_BUILTIN_RW
69#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0)) && defined(CONFIG_SENSORLIB_ESP_IDF_NEW_API)
71 ESP_LOGI(TAG,
"Implemented using built-in read and write methods (Use higher version >= 5.0 API)");
75 extern i2c_master_bus_handle_t bus_handle;
77 if (io.
begin(bus_handle)) {
78 ESP_LOGI(TAG,
"Initializing XL9555 successfully!");
80 ESP_LOGE(TAG,
"Failed to initialize XL9555 failed!");
86 ESP_LOGI(TAG,
"Implemented using built-in read and write methods (Use lower version < 5.0 API)");
87 if (io.
begin((i2c_port_t)CONFIG_I2C_MASTER_PORT_NUM, CONFIG_SENSOR_SDA, CONFIG_SENSOR_SCL)) {
88 ESP_LOGI(TAG,
"Initializing XL9555 successfully!");
90 ESP_LOGE(TAG,
"Failed to initialize XL9555 failed!");
bool begin(SensorCommCustom::CustomCallback callback, uint8_t addr)
Initialize the sensor using custom callback interface.
Concrete driver for the XL9555 16‑bit I2C GPIO expander.
bool i2c_wr_function(uint8_t addr, uint8_t reg, uint8_t *buf, size_t len, bool writeReg, bool isWrite)