Code: Select all
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, i2c_addr << 1 | READ_BIT, ACK_CHECK_EN);
i2c_master_read_byte(cmd, &bytes[0], ACK_VAL);
i2c_master_read_byte(cmd, &bytes[1], NACK_VAL);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
bytes[0] = bytes[0] & mask;
if(low_first) data[0] = bytes[1] << 8 | bytes[0];
else data[0] = bytes[0] << 8 | bytes[1];
Code: Select all
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, i2c_addr << 1 | READ_BIT, ACK_CHECK_EN);
i2c_master_read_byte(cmd, &bytes[0], ACK_VAL);
i2c_master_read_byte(cmd, &bytes[1], NACK_VAL);
bytes[0] = bytes[0] & mask;
if(low_first) data[0] = bytes[1] << 8 | bytes[0];
else data[0] = bytes[0] << 8 | bytes[1];
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);