2019-06-28 01:07 PM
hi I'm trying to write some code to read on i2c an as 4058b encoder with the HALL library with stm32, with arduino it works perfectly:
Wire.beginTransmission (_slaveAdress);
Wire.write (internal_register
);
Wire.endTransmission ();
Wire.requestFrom (_slaveAddress, nbByte2Read);
for (bytes i = 0; i <nbByte2Read; i ++) {
readArray [i] = Wire.read ();
}
readValue = (((uint16_t) readArray [0]) << 6);
readValue + = (readArray [1] & 0x3F);
Could you have an equal reproduction of code with HALL i2c?
thank you
Solved! Go to Solution.
2019-06-28 01:24 PM
HAL_StatusTypeDef status = HAL_I2C_Mem_Read(&I2CHandle, (_slaveAddress << 1), &internal_register, 1, readArray, nbByte2Read, 100);
if (status != HAL_OK)
printf("I2C Read Failed %d %08X\n", status, I2CHandle.ErrorCode);
2019-06-28 01:24 PM
HAL_StatusTypeDef status = HAL_I2C_Mem_Read(&I2CHandle, (_slaveAddress << 1), &internal_register, 1, readArray, nbByte2Read, 100);
if (status != HAL_OK)
printf("I2C Read Failed %d %08X\n", status, I2CHandle.ErrorCode);
2019-06-28 02:23 PM
Thanks so much!