I2C bus upgrade (#432)

This commit is contained in:
Zaltora 2017-09-01 06:29:32 -03:00 committed by Ruslan V. Uss
parent d100f42b1f
commit b83c2629b9
56 changed files with 909 additions and 804 deletions

View file

@ -11,17 +11,20 @@
#define SCL_PIN 5
#define SDA_PIN 4
#define I2C_BUS 0
static void measure(void *pvParameters)
{
bh1750_configure(BH1750_ADDR_LO,
BH1750_CONTINUOUS_MODE | BH1750_HIGH_RES_MODE);
i2c_dev_t dev = {
.addr = BH1750_ADDR_LO,
.bus = I2C_BUS,
};
bh1750_configure(&dev, BH1750_CONTINUOUS_MODE | BH1750_HIGH_RES_MODE);
while (1) {
while(1) {
vTaskDelay(200 / portTICK_PERIOD_MS);
printf("Lux: %d\n", bh1750_read(BH1750_ADDR_LO));
printf("Lux: %d\n", bh1750_read(&dev));
}
}
}
@ -35,7 +38,7 @@ void user_init(void)
printf("SDK version : %s\n", sdk_system_get_sdk_version());
printf("GIT version : %s\n", GITSHORTREV);
i2c_init(SCL_PIN, SDA_PIN);
i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);
xTaskCreate(measure, "measure_task", 256, NULL, 2, NULL);
}