Skip to content

Arduino-esp32 SDK Wire library error. #6855

@Arya11111

Description

@Arya11111

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions