From 52e98589362f3bbf69e74e4e14a827a1952f8f38 Mon Sep 17 00:00:00 2001 From: Hays Chan <25737801+hayschan@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:42:00 +0800 Subject: [PATCH] Fix compilation bugs --- include/xgzf4000.h | 14 ++------------ xgzf4000.c | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/include/xgzf4000.h b/include/xgzf4000.h index a25b840..9c37b23 100644 --- a/include/xgzf4000.h +++ b/include/xgzf4000.h @@ -36,18 +36,8 @@ typedef struct { uint8_t i2c_addr; /*!< I2C address of XGZF4000 device, can be 0x38 or 0x39 according to A0 pin */ } xgzf4000_i2c_config_t; -/** - * @brief Create new XGZF4000 device handle. - * - * @param[in] i2c_conf Config for I2C used by XGZF4000 - * @param[out] handle_out New XGZF4000 device handle - * @return - * - ESP_OK Device handle creation success. - * - ESP_ERR_INVALID_ARG Invalid device handle or argument. - * - ESP_ERR_NO_MEM Memory allocation failed. - * - */ -esp_err_t xgzf4000_new_sensor(const xgzf4000_i2c_config_t *i2c_conf, xgzf4000_dev_handle_t *handle_out); + +esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin) /** * @brief Delete XGZF4000 device handle. diff --git a/xgzf4000.c b/xgzf4000.c index f6dc97d..f247c0c 100644 --- a/xgzf4000.c +++ b/xgzf4000.c @@ -80,7 +80,7 @@ esp_err_t xgzf4000_read_air_flow(xgzf4000_dev_handle_t handle, uint32_t *flow_ra return ESP_OK; } -esp_err_t adafruit_stemma_soil_sensor_init(i2c_port_t i2c_num, int sda_pin, int scl_pin) +esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin) { i2c_config_t conf; conf.mode = I2C_MODE_MASTER; @@ -94,26 +94,26 @@ esp_err_t adafruit_stemma_soil_sensor_init(i2c_port_t i2c_num, int sda_pin, int return i2c_driver_install(i2c_num, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0); } -esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin) -{ - ESP_LOGI(TAG, "Initializing XGZF4000 Air Flow Sensor"); - ESP_LOGI(TAG, "%-15s: %1.1f - %1.1fV", "SUPPLY_VOLTAGE", SUPPLY_VOLTAGE_MIN, SUPPLY_VOLTAGE_MAX); - ESP_LOGI(TAG, "%-15s: %.2f - %.2f℃", "TEMPERATURE", TEMPERATURE_MIN, TEMPERATURE_MAX); - ESP_LOGI(TAG, "%-15s: %.2fMPa", "PRESSURE", PRESSURE_MAX); +// esp_err_t xgzf4000_new_sensor(i2c_port_t i2c_num, int sda_pin, int scl_pin) +// { +// ESP_LOGI(TAG, "Initializing XGZF4000 Air Flow Sensor"); +// ESP_LOGI(TAG, "%-15s: %1.1f - %1.1fV", "SUPPLY_VOLTAGE", SUPPLY_VOLTAGE_MIN, SUPPLY_VOLTAGE_MAX); +// ESP_LOGI(TAG, "%-15s: %.2f - %.2f℃", "TEMPERATURE", TEMPERATURE_MIN, TEMPERATURE_MAX); +// ESP_LOGI(TAG, "%-15s: %.2fMPa", "PRESSURE", PRESSURE_MAX); - ESP_RETURN_ON_FALSE(i2c_conf, ESP_ERR_INVALID_ARG, TAG, "invalid device config pointer"); - ESP_RETURN_ON_FALSE(handle_out, ESP_ERR_INVALID_ARG, TAG, "invalid device handle pointer"); +// ESP_RETURN_ON_FALSE(i2c_conf, ESP_ERR_INVALID_ARG, TAG, "invalid device config pointer"); +// ESP_RETURN_ON_FALSE(handle_out, ESP_ERR_INVALID_ARG, TAG, "invalid device handle pointer"); - xgzf4000_dev_t *handle = calloc(1, sizeof(xgzf4000_dev_t)); - ESP_RETURN_ON_FALSE(handle, ESP_ERR_NO_MEM, TAG, "memory allocation for device handler failed"); +// xgzf4000_dev_t *handle = calloc(1, sizeof(xgzf4000_dev_t)); +// ESP_RETURN_ON_FALSE(handle, ESP_ERR_NO_MEM, TAG, "memory allocation for device handler failed"); - handle->i2c_port = i2c_conf->i2c_port; - handle->i2c_addr = i2c_conf->i2c_addr; // Default I2C address for XGZF4000 is 0x50 +// handle->i2c_port = i2c_conf->i2c_port; +// handle->i2c_addr = i2c_conf->i2c_addr; // Default I2C address for XGZF4000 is 0x50 - *handle_out = handle; - return ESP_OK; -} +// *handle_out = handle; +// return ESP_OK; +// } esp_err_t xgzf4000_del_sensor(xgzf4000_dev_handle_t handle)