About I2C read

arespno
Posts: 9
Joined: Sat Feb 20, 2016 12:19 pm

About I2C read

Postby arespno » Sat Dec 10, 2016 2:39 am

Code: Select all

<esp32-hal-i2c.c>

On "i2c_err_t i2cRead(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * data, uint8_t len, bool sendStop)"

    while(len) {
        cmdIdx = (index)?0:2;
        willRead = (len > 32)?32:(len-1);
        if(cmdIdx){
            i2cResetFiFo(i2c);
        }

+		if (willRead) {
			i2cSetCmd(i2c, cmdIdx++, I2C_CMD_READ, willRead, false, false, false);
+		}
       if((len - willRead) > 1) {
           i2cSetCmd(i2c, cmdIdx++, I2C_CMD_END, 0, false, false, false);
       } else {
           willRead++;
           i2cSetCmd(i2c, cmdIdx++, I2C_CMD_READ, 1, true, false, false);
           if(sendStop) {
               i2cSetCmd(i2c, cmdIdx++, I2C_CMD_STOP, 0, false, false, false);
           }
       }
Some IC2 devices can read.
Last edited by arespno on Sat Dec 10, 2016 3:58 am, edited 1 time in total.

ESP_Sprite
Posts: 9772
Joined: Thu Nov 26, 2015 4:08 am

Re: About I2C read

Postby ESP_Sprite » Sat Dec 10, 2016 3:21 am

Yes, what is your issue with this code?

Who is online

Users browsing this forum: No registered users and 51 guests