cancel
Showing results for 
Search instead for 
Did you mean: 

Hall i2c

SDall
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

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 Venmo
Up vote any posts that you find helpful, it shows what's working..
SDall
Associate II

Thanks so much!​