I am working on the BHI160B shuttle board connected to an STM32F411.I am working on this example(BHI160B_ReferenceCode) I have integrated the library into my STM project, and I have determined that the I2C address of my BHI160B shuttle board 3.0 is 0x29. The next step was to modify the read/write operations in the bhy_support.c driver file as follows: int8_t sensor_i2c_write(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size){
HAL_I2C_Mem_Write(&hi2c1, (uint16_t) addr, (uint16_t) reg, I2C_MEMADD_SIZE_8BIT, p_buf, size,HAL_MAX_DELAY);
}
int8_t sensor_i2c_read(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size){
HAL_I2C_Mem_Read(&hi2c1, (uint16_t) addr, (uint16_t) reg,I2C_MEMADD_SIZE_8BIT,p_buf, size, HAL_MAX_DELAY);
} I connected the Shuttle Board to my NUCLEO board like this: ___J1___|___NUCLEO___
1/2 | 3.3V
3 | GND
2 | PB7 -> I2C1_SCL
4 | PB6 -> I2C1_SDA The problem occurs during initialization, specifically within the "bhy_init" function, when attempting to read (BHY_BUS_READ_FUNC) the BHY_I2C_REG_PRODUCT_ID_ADDR register (0x90). It gets stuck in the HAL function (HAL_StatusTypeDef I2C_WaitOnMasterAddressFlagUntilTimeout). BHY_RETURN_FUNCTION_TYPE bhy_init(struct bhy_t *bhy)
{
/* variable used for return the status of communication result*/
BHY_RETURN_FUNCTION_TYPE com_rslt = BHY_COMM_RES;
u8 v_data_u8 = BHY_INIT_VALUE;
/* assign bhy ptr */
p_bhy = bhy;
com_rslt =
p_bhy->BHY_BUS_READ_FUNC(p_bhy->device_addr,
BHY_I2C_REG_PRODUCT_ID_ADDR,
&v_data_u8, BHY_GEN_READ_WRITE_LENGTH);
/* read product Id */
p_bhy->product_id = v_data_u8;
return com_rslt;
}
... View more