Commit addd0e4d authored by schneider's avatar schneider
Browse files

fix(bhy): Return correct error codes from platform support

parent 9de1261b
......@@ -79,17 +79,18 @@ static int8_t sensor_i2c_write(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16
buf[0] = reg;
memcpy(buf + 1, p_buf, size);
return I2C_MasterWrite(I2C_DEVICE, addr << 1, buf, size + 1, 0);
int l = I2C_MasterWrite(I2C_DEVICE, addr << 1, buf, size + 1, 0);
return l == size + 1 ? BHY_SUCCESS : BHY_ERROR;
}
static int8_t sensor_i2c_read(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size)
{
//printf("sensor_i2c_read 0x%02x %d\n", reg, size);
if(I2C_MasterWrite(I2C_DEVICE, addr << 1, &reg, 1, 1) == 1) {
return I2C_MasterRead(I2C_DEVICE, addr << 1, p_buf, size, 0);
int l = I2C_MasterRead(I2C_DEVICE, addr << 1, p_buf, size, 0);
return l == size ? BHY_SUCCESS : BHY_ERROR;
}
// TODO: return error code
return 0;
return BHY_ERROR;
}
/********************************************************************************/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment