afarhan / sbitx

168 stars 58 forks source link

i2cbb.c function i2cbb_read_i2c_block_data possible missing curly brackets. #37

Closed g8kig closed 1 year ago

g8kig commented 1 year ago

The function i2cbb_read_i2c_block_data in file i2cbb.c is possibly missing curly brackets judging by the indentation.

  uint8_t i = 0;
  for (i = 0; i < length - 1; i++) 
    values[i] = i2c_read_byte(0,0);
    values[i] = i2c_read_byte(1,1);

    i2c_stop_cond();

should this actually be

  uint8_t i = 0;
  for (i = 0; i < length - 1; i++){
    values[i] = i2c_read_byte(0,0);
    values[i] = i2c_read_byte(1,1);

    i2c_stop_cond();
  }
afarhan commented 1 year ago

The last byte has to send a stop bit. If you see the code of i2c_read_byte, the second parameter signals sending a stop bit that ends the block read. The indentation is badly done, but the code is alright.