diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h index a3018c43..b6bfb588 100644 --- a/code/espurna/config/prototypes.h +++ b/code/espurna/config/prototypes.h @@ -51,7 +51,9 @@ template String getSetting(const String& key, unsigned int index, T // ----------------------------------------------------------------------------- // I2C // ----------------------------------------------------------------------------- -unsigned char i2cFindFirst(size_t size, unsigned char * addresses); +unsigned char i2cFindAndLock(size_t size, unsigned char * addresses); +bool i2cGetLock(unsigned char address); +bool i2cReleaseLock(unsigned char address); // ----------------------------------------------------------------------------- // Debug diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index fa0e6a35..e25d0302 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -93,7 +93,7 @@ //-------------------------------------------------------------------------------- #ifndef BMX280_SUPPORT -#define BMX280_SUPPORT 0 +#define BMX280_SUPPORT 1 #endif #ifndef BMX280_ADDRESS @@ -283,7 +283,7 @@ //-------------------------------------------------------------------------------- #ifndef SI7021_SUPPORT -#define SI7021_SUPPORT 0 +#define SI7021_SUPPORT 1 #endif #ifndef SI7021_ADDRESS diff --git a/code/espurna/i2c.ino b/code/espurna/i2c.ino index e914b35d..77a83e63 100644 --- a/code/espurna/i2c.ino +++ b/code/espurna/i2c.ino @@ -8,6 +8,9 @@ Copyright (C) 2017 by Xose PĂ©rez #if I2C_SUPPORT +#include +std::vector _i2c_locked; + #if I2C_USE_BRZO #include "brzo_i2c.h" unsigned long _i2c_scl_frequency = 0; @@ -123,13 +126,50 @@ bool i2cCheck(unsigned char address) { #endif } -unsigned char i2cFindFirst(size_t size, unsigned char * addresses) { - for (unsigned char i=0; i