mirror of https://github.com/arendst/Tasmota.git
Patch library I2Cdevlib-Core for 2.4.0-rc2
This commit is contained in:
parent
8366ee116a
commit
503a0d9f00
|
@ -45,6 +45,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "I2Cdev.h"
|
#include "I2Cdev.h"
|
||||||
|
|
||||||
|
// Tasmota fixes for esp8266-core v2.4.0-rc2
|
||||||
|
#define i2min(a,b) ((a)<(b)?(a):(b))
|
||||||
|
|
||||||
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
||||||
|
|
||||||
#ifdef I2CDEV_IMPLEMENTATION_WARNINGS
|
#ifdef I2CDEV_IMPLEMENTATION_WARNINGS
|
||||||
|
@ -225,12 +228,12 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
||||||
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
||||||
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
||||||
// smaller chunks instead of all at once
|
// smaller chunks instead of all at once
|
||||||
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
|
for (uint8_t k = 0; k < length; k += i2min(length, BUFFER_LENGTH)) {
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.send(regAddr);
|
Wire.send(regAddr);
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));
|
Wire.requestFrom(devAddr, (uint8_t)i2min(length - k, BUFFER_LENGTH));
|
||||||
|
|
||||||
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
||||||
data[count] = Wire.receive();
|
data[count] = Wire.receive();
|
||||||
|
@ -249,12 +252,12 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
||||||
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
||||||
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
||||||
// smaller chunks instead of all at once
|
// smaller chunks instead of all at once
|
||||||
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
|
for (uint8_t k = 0; k < length; k += i2min(length, BUFFER_LENGTH)) {
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.write(regAddr);
|
Wire.write(regAddr);
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));
|
Wire.requestFrom(devAddr, (uint8_t)i2min(length - k, BUFFER_LENGTH));
|
||||||
|
|
||||||
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
||||||
data[count] = Wire.read();
|
data[count] = Wire.read();
|
||||||
|
@ -273,12 +276,12 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
|
||||||
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
||||||
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
||||||
// smaller chunks instead of all at once
|
// smaller chunks instead of all at once
|
||||||
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
|
for (uint8_t k = 0; k < length; k += i2min(length, BUFFER_LENGTH)) {
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.write(regAddr);
|
Wire.write(regAddr);
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));
|
Wire.requestFrom(devAddr, (uint8_t)i2min(length - k, BUFFER_LENGTH));
|
||||||
|
|
||||||
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
|
||||||
data[count] = Wire.read();
|
data[count] = Wire.read();
|
||||||
|
@ -345,7 +348,7 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
||||||
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
||||||
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
||||||
// smaller chunks instead of all at once
|
// smaller chunks instead of all at once
|
||||||
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
|
for (uint8_t k = 0; k < length * 2; k += i2min(length * 2, BUFFER_LENGTH)) {
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.send(regAddr);
|
Wire.send(regAddr);
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
|
@ -378,7 +381,7 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
||||||
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
||||||
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
||||||
// smaller chunks instead of all at once
|
// smaller chunks instead of all at once
|
||||||
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
|
for (uint8_t k = 0; k < length * 2; k += i2min(length * 2, BUFFER_LENGTH)) {
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.write(regAddr);
|
Wire.write(regAddr);
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
|
@ -411,7 +414,7 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
|
||||||
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
|
||||||
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
|
||||||
// smaller chunks instead of all at once
|
// smaller chunks instead of all at once
|
||||||
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
|
for (uint8_t k = 0; k < length * 2; k += i2min(length * 2, BUFFER_LENGTH)) {
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.write(regAddr);
|
Wire.write(regAddr);
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
|
|
Loading…
Reference in New Issue