this sounds so simple but I did spend too many hours trying to just read data out from my HMC5883L 3-axis Magnetometer. I admitt I just switched from 8bit to the 32bit world, so bare with me... The "new" HAL drivers lack a bit of description and exsamples on the web so I ask you for help. Here the code; Cube MX generated on a 32F303 discovery board.
/* I2C2 init function */
hi2c2.Instance = I2C2;
hi2c2.Init.Timing = 0x00201D2D;
hi2c2.Init.OwnAddress1 = 0;
hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
hi2c2.Init.OwnAddress2 = 0;
hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
/**Configure Analogue filter
#define HMC5883L_MASTER_ADDR 0x13
X_axis = make_word(readHMC5883LBuffer,readHMC5883LBuffer);
Z_axis = make_word(readHMC5883LBuffer,readHMC5883LBuffer);
Y_axis = make_word(readHMC5883LBuffer,readHMC5883LBuffer);
The SCL pin goes low a few cycles and then time out gets called...
Thanks for some suggestions!