Skip to content

Commit

Permalink
fix Arduino Wire common-mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
lanselambor committed Apr 9, 2018
1 parent e3a3e7c commit cbeca41
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions bmm150.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ void BMM150::i2c_read(short address, uint8_t *buffer, short length)
Wire.beginTransmission(BMM150_I2C_Address);
Wire.write(address);
Wire.endTransmission();

Wire.beginTransmission(BMM150_I2C_Address);
Wire.requestFrom(BMM150_I2C_Address, length);

if(Wire.available() == length)
Expand All @@ -339,8 +337,6 @@ void BMM150::i2c_read(short address, uint8_t *buffer, short length)
buffer[i] = Wire.read();
}
}

Wire.endTransmission();
}


Expand All @@ -349,8 +345,6 @@ void BMM150::i2c_read(short address, int8_t *buffer, short length)
Wire.beginTransmission(BMM150_I2C_Address);
Wire.write(address);
Wire.endTransmission();

Wire.beginTransmission(BMM150_I2C_Address);
Wire.requestFrom(BMM150_I2C_Address, length);

if(Wire.available() == length)
Expand All @@ -360,8 +354,6 @@ void BMM150::i2c_read(short address, int8_t *buffer, short length)
buffer[i] = Wire.read();
}
}

Wire.endTransmission();
}

uint8_t BMM150::i2c_read(short address)
Expand All @@ -371,12 +363,8 @@ uint8_t BMM150::i2c_read(short address)
Wire.beginTransmission(BMM150_I2C_Address);
Wire.write(address);
Wire.endTransmission();

Wire.beginTransmission(BMM150_I2C_Address);
Wire.requestFrom(BMM150_I2C_Address, 1);
byte = Wire.read();

Wire.endTransmission();
return byte;
}

Expand Down

0 comments on commit cbeca41

Please sign in to comment.