Skip to content

Commit

Permalink
Fix alternative i2c implementation
Browse files Browse the repository at this point in the history
The alternative I2C implementation takes a non-const data pointer for its write,
thus we need to cast away constness to fix the compiler's warning which is treated
as error with the default arduino settings.
  • Loading branch information
abrauchli committed Apr 24, 2020
1 parent df6346a commit cf56687
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sensirion_hw_i2c_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ void sensirion_i2c_release(void)
{
}

int8_t sensirion_i2c_read(uint8_t address, u8* data, uint16_t count)
int8_t sensirion_i2c_read(uint8_t address, uint8_t *data, uint16_t count)
{
return I2c.read(address, count, data);
}

int8_t sensirion_i2c_write(uint8_t address, const u8* data, uint16_t count)
int8_t sensirion_i2c_write(uint8_t address, const uint8_t *data, uint16_t count)
{
// the API doesn't forsee calls without register, so we'll use the first
// byte as "register", and pass the rest as data argument
if (count == 0) {
return 0;
}
return I2c.write(address, data[0], data + 1, count - 1);
return I2c.write(address, data[0], (uint8_t *)(data + 1), count - 1);
}

#else /* SPS30_USE_ALT_I2C */
Expand Down

0 comments on commit cf56687

Please sign in to comment.