-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Related area
I2C Wire library.
Hardware specification
no, only soft error.
Is your feature request related to a problem?
no
Describe the solution you'd like
Please modify function [uint8_t endTransmission(bool sendStop) ]'s accomplish.
When sendStop = false, I2c master can't send data to i2c slave, this is a wrong way.
In other SDK's Wire library, sendStop = false means I2C master will send data to slave, but not send stop bit.
Describe alternatives you've considered
//#define I2C_BUFFER_LENGTH 128
When sending more than 128 bytes of data at a time, it will cause data loss.
/**
*@param endflag
*@n true send data and send stop condition.
*@n false send data and don't send stop condition.
/
bool sendData(uint8_t addr, void pData, uint16_t size, bool endflag){
if(pData == NULL){
return false;
}
uint8_t *pBuf = (uint8_t *)pData;
uint16_t remain = size ;
uint8_t ret = 0;
while(remain){
size = (remain > I2C_BUFFER_LENGTH ? I2C_BUFFER_LENGTH : remain;
remain -= size;
Wire.beginTransmission(addr);
Wire.write(pBuf, size);
if(remain){
ret = Wire.endTransmission(/*sendStop =*/false); //in this step, use Arduino-esp32 SDK , I2C master can’t send data to //I2C slave.This phenomenon is not in line with the design of the Wire library
pBuf += size;
}else{
ret = Wire.endTransmission(endflag);
}
if(ret != 0) return false;
yield();
}
return true;
}
Additional context
/**
*@param sendStop
*@n true send data and send stop condition.
*@n false send data and don't send stop condition, but in Arduino-esp32 SDK ,sendStop=false,I2C master can't send data to slave,which will cause data lost.
*/
uint8_t endTransmission(bool sendStop);
I have checked existing list of Feature requests and the Contribution Guide
- I confirm I have checked existing list of Feature requests and Contribution Guide.