Skip to main content
SDall
Associate III
June 28, 2019
Solved

Hall i2c

  • June 28, 2019
  • 2 replies
  • 733 views

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

This topic has been closed for replies.
Best answer by Tesla DeLorean

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);

2 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
June 28, 2019

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);

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
SDall
SDallAuthor
Associate III
June 28, 2019

Thanks so much!​