Skip to content

Commit

Permalink
Fix compilation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
hayschan committed Jan 3, 2024
1 parent 3ec331d commit 52e9858
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
14 changes: 2 additions & 12 deletions include/xgzf4000.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 16 additions & 16 deletions xgzf4000.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 52e9858

Please sign in to comment.