Skip to content

Commit

Permalink
fix: arduino multi-bytes
Browse files Browse the repository at this point in the history
Fixed support for reading multiple bytes at once through the I2C bridge.
  • Loading branch information
mookums committed Jan 22, 2024
1 parent c91ff9b commit faea778
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arduino/feather-evm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ uint16_t read_from_msp(unsigned int reg, int size) {
Wire.beginTransmission(msp_address);
Wire.write(reg);
Wire.endTransmission(false);
Wire.requestFrom(msp_address, size , true);
Wire.requestFrom(msp_address, 1);

unsigned int returnInt = 0;
for(int i = 0; i < size; i++) {
unsigned int returnInt = Wire.read();
for(int i = 0; i < size-1; i++) {
returnInt = (returnInt << 8) | Wire.read();
}

Expand All @@ -35,16 +35,16 @@ uint16_t read_from_bq(unsigned int reg, int size) {
Wire.endTransmission(false);
Wire.requestFrom((bq_address), size);

unsigned int returnInt = 0;
for(int i = 0; i < size; i++) {
unsigned int returnInt = Wire.read();
for(int i = 0; i < size-1; i++) {
returnInt = (returnInt << 8) | Wire.read();
}

return returnInt;
}

void write_to_bq(unsigned int reg, uint8_t data) {
// Write to BQ76925
// Read from BQ76925
// From: https://www.ti.com/lit/ds/symlink/bq76925.pdf?ts=1705535736818
// I2C is not really standardized so things happen however chip manus want it to.
// This chip encodes both the I2C address AND the register into one address.
Expand Down

0 comments on commit faea778

Please sign in to comment.