Every time i try to write or read from I2C with the os_hal_i2c library, the read/write functions return "I2C_EINVAL". After debugging i found out that in the i2c struct, mode is first set to I2C_MASTER_MODE. But after passing the struct to "mtk_mhal_i2c_trigger_transfer" the mode is set to unknown, and an error is returned. My code is the following:
int initRet = mtk_os_hal_i2c_ctrl_init(OS_HAL_I2C_ISU2); int speedRet = mtk_os_hal_i2c_speed_init(OS_HAL_I2C_ISU2, I2C_SCL_100kHz); int ret = mtk_os_hal_i2c_write_read(OS_HAL_I2C_ISU2, SHT31_ADR, i2cTxBuf, &i2cRxBuf, sizeof(i2cTxBuf), sizeof(i2cRxBuf));
Hi,
Every time i try to write or read from I2C with the os_hal_i2c library, the read/write functions return "I2C_EINVAL". After debugging i found out that in the i2c struct, mode is first set to I2C_MASTER_MODE. But after passing the struct to "mtk_mhal_i2c_trigger_transfer" the mode is set to unknown, and an error is returned. My code is the following:
int initRet = mtk_os_hal_i2c_ctrl_init(OS_HAL_I2C_ISU2);
int speedRet = mtk_os_hal_i2c_speed_init(OS_HAL_I2C_ISU2, I2C_SCL_100kHz);
int ret = mtk_os_hal_i2c_write_read(OS_HAL_I2C_ISU2, SHT31_ADR, i2cTxBuf, &i2cRxBuf, sizeof(i2cTxBuf), sizeof(i2cRxBuf));