Skip to content

Commit

Permalink
Merge branch 'bugfix/test_case_i2c_config_issue' into 'develop/v2.0'
Browse files Browse the repository at this point in the history
bugfix: fix test case i2c config issue

See merge request rd/esp-iot-solution!477
  • Loading branch information
leeebo committed Jan 15, 2021
2 parents ffd4980 + 575b562 commit 8af2182
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 132 deletions.
24 changes: 15 additions & 9 deletions components/sensors/gesture/apds9960/test/apds9960_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,24 @@ static void apds9960_gpio_vl_init(void)
static void apds9960_test_init()
{
int i2c_master_port = APDS9960_I2C_MASTER_NUM;
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = APDS9960_I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = APDS9960_I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = APDS9960_I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = APDS9960_I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = APDS9960_I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = APDS9960_I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(i2c_master_port, &conf);
apds9960 = apds9960_create(i2c_bus, APDS9960_I2C_ADDRESS);
}

static void apds9960_test_deinit()
{
apds9960_delete(&apds9960);
i2c_bus_delete(&i2c_bus);
}

static void apds9960_test_gesture()
{
int cnt = 0;
Expand Down Expand Up @@ -85,7 +92,6 @@ TEST_CASE("Sensor apds9960 test", "[apds9960][iot][sensor]")
apds9960_gesture_init(apds9960);
vTaskDelay(1000 / portTICK_RATE_MS);
apds9960_test_func();
apds9960_delete(&apds9960);
i2c_bus_delete(&i2c_bus);
apds9960_test_deinit();
}

15 changes: 8 additions & 7 deletions components/sensors/humiture/hdc2010/test/hdc2010_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ static const char *TAG = "hdc2010";

void hdc2010_init_test()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = HDC2010_I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = HDC2010_I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = HDC2010_I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = HDC2010_I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = HDC2010_I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = HDC2010_I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(HDC2010_I2C_MASTER_NUM, &conf);
hdc2010 = hdc2010_create(i2c_bus, HDC2010_ADDR_PIN_SELECT_GND);
}
Expand Down
15 changes: 8 additions & 7 deletions components/sensors/humiture/hts221/test/hts221_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ static hts221_handle_t hts221 = NULL;

void hts221_init_test()
{
i2c_config_t conf;
uint8_t hts221_deviceid;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf);
hts221 = hts221_create(i2c_bus, HTS221_I2C_ADDRESS);
hts221_get_deviceid(hts221, &hts221_deviceid);
Expand Down
15 changes: 8 additions & 7 deletions components/sensors/humiture/mvh3004d/test/mvh3004d_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ static mvh3004d_handle_t mvh3004d = NULL;

void mvh3004d_init_test()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf);
mvh3004d = mvh3004d_create(i2c_bus, MVH3004D_SLAVE_ADDR);
}
Expand Down
15 changes: 8 additions & 7 deletions components/sensors/humiture/sht3x/test/sht3x_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ static sht3x_handle_t sht3x = NULL;
*/
static void sht3x_init_test()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf);
sht3x = sht3x_create(i2c_bus, SHT3x_ADDR_PIN_SELECT_VSS);
sht3x_set_measure_mode(sht3x, SHT3x_PER_2_MEDIUM); /*!< here read data in periodic mode*/
Expand Down
24 changes: 15 additions & 9 deletions components/sensors/imu/lis2dh12/test/lis2dh12_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ static lis2dh12_handle_t lis2dh12 = NULL;
*/
static void lis2dh12_test_init()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf);
lis2dh12 = lis2dh12_create(i2c_bus, LIS2DH12_I2C_ADDRESS);
}

static void lis2dh12_test_deinit()
{
lis2dh12_delete(&lis2dh12);
i2c_bus_delete(&i2c_bus);
}

static void lis2dh12_test_get_data(void)
{
uint8_t deviceid;
Expand Down Expand Up @@ -104,6 +111,5 @@ TEST_CASE("Sensor lis2dh12 test get data [1000ms]", "[lis2dh12][iot][sensor]")
lis2dh12_test_init();
vTaskDelay(1000 / portTICK_RATE_MS);
lis2dh12_test_get_data();
lis2dh12_delete(&lis2dh12);
i2c_bus_delete(&i2c_bus);
lis2dh12_test_deinit();
}
24 changes: 15 additions & 9 deletions components/sensors/imu/mpu6050/test/mpu6050_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ static mpu6050_handle_t mpu6050 = NULL;
*/
static void mpu6050_test_init()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf);
mpu6050 = mpu6050_create(i2c_bus, MPU6050_I2C_ADDRESS);
}

static void mpu6050_test_deinit()
{
mpu6050_delete(&mpu6050);
i2c_bus_delete(&i2c_bus);
}

static void mpu6050_test_get_data()
{
uint8_t mpu6050_deviceid;
Expand Down Expand Up @@ -70,6 +77,5 @@ TEST_CASE("Sensor mpu6050 test get data [1000ms]", "[mpu6050][iot][sensor]")
mpu6050_test_init();
vTaskDelay(1000 / portTICK_RATE_MS);
mpu6050_test_get_data();
mpu6050_delete(&mpu6050);
i2c_bus_delete(&i2c_bus);
mpu6050_test_deinit();
}
24 changes: 15 additions & 9 deletions components/sensors/light_sensor/bh1750/test/bh1750_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@ static bh1750_handle_t bh1750 = NULL;

static void bh1750_test_init()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf);
bh1750 = bh1750_create(i2c_bus, BH1750_I2C_ADDRESS_DEFAULT);
}

static void bh1750_test_deinit()
{
bh1750_delete(&bh1750);
i2c_bus_delete(&i2c_bus);
}

static void bh1750_test_get_data()
{
int ret;
Expand Down Expand Up @@ -78,6 +85,5 @@ TEST_CASE("Sensor BH1750 test", "[bh1750][iot][sensor]")
{
bh1750_test_init();
bh1750_test_get_data();
bh1750_delete(&bh1750);
i2c_bus_delete(&i2c_bus);
bh1750_test_deinit();
}
26 changes: 16 additions & 10 deletions components/sensors/light_sensor/veml6040/test/veml6040_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,24 @@ static veml6040_handle_t veml6040 = NULL;

static void veml6040_test_init()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = VEML6040_I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = VEML6040_I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = VEML6040_I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = VEML6040_I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = VEML6040_I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = VEML6040_I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(VEML6040_I2C_MASTER_NUM, &conf);
veml6040 = veml6040_create(i2c_bus, VEML6040_I2C_ADDRESS);
}

static void veml6040_test_deinit()
{
veml6040_delete(&veml6040);
i2c_bus_delete(&i2c_bus);
}

static void veml6040_test_set_mode()
{
veml6040_config_t veml6040_info;
Expand Down Expand Up @@ -78,9 +85,8 @@ static void veml6040_test_get_date()
TEST_CASE("Sensor veml6040 test", "[veml6040][iot][sensor]")
{
veml6040_test_init();
veml6040_test_set_mode()
veml6040_test_set_mode();
veml6040_test_get_date();
veml6040_delete(&veml6040);
i2c_bus_delete(&i2c_bus);
veml6040_test_deinit();
}

32 changes: 16 additions & 16 deletions components/sensors/light_sensor/veml6075/test/veml6075_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,24 @@ static veml6075_handle_t veml6075 = NULL;

static void veml6075_test_init()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = VEML6075_I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = VEML6075_I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = VEML6075_I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = VEML6075_I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = VEML6075_I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = VEML6075_I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(VEML6075_I2C_MASTER_NUM, &conf);
veml6075 = veml6075_create(i2c_bus, VEML6075_I2C_ADDRESS);
}

static void veml6075_test_deinit()
{
veml6075_delete(&veml6075);
i2c_bus_delete(&i2c_bus);
}

static void veml6075_test_set_mode()
{
veml6075_config_t veml6075_info;
Expand Down Expand Up @@ -74,17 +81,10 @@ static void veml6075_test_get_date()
}
}

static void veml6075_test()
TEST_CASE("Sensor veml6075 test", "[veml6075][iot][sensor]")
{
veml6075_test_init();
veml6075_test_set_mode();
veml6075_test_get_date();
veml6075_delete(&veml6075);
i2c_bus_delete(&i2c_bus);
}

TEST_CASE("Sensor veml6075 test", "[veml6075][iot][sensor]")
{
veml6075_test();
veml6075_test_deinit();
}

15 changes: 8 additions & 7 deletions components/sensors/pressure/bme280/test/bme280_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ static bme280_handle_t bme280 = NULL;

void bme280_test_init()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_bus = i2c_bus_create(I2C_MASTER_NUM, &conf);
bme280 = bme280_create(i2c_bus, BME280_I2C_ADDRESS_DEFAULT);
ESP_LOGI("BME280:", "bme280_default_init:%d", bme280_default_init(bme280));
Expand Down
Loading

0 comments on commit 8af2182

Please sign in to comment.