[관련 HAL 함수 소개]
[진행 과정]
[코드]
uint8_t snd_soc_TCC_read(uint16_t i2cAddress, uint8_t *tccData, int addressSize)
{
HAL_StatusTypeDef ret = HAL_I2C_Master_Sequential_Transmit_IT(&hi2c2, i2cAddress, tccData, addressSize, I2C_FIRST_FRAME);
HAL_Delay(100);
while (HAL_I2C_GetState(&hi2c2) != HAL_I2C_STATE_READY)
{
}
uint8_t i2cReadBuffer[16] = {0,};
HAL_StatusTypeDef rets = HAL_I2C_Master_Sequential_Receive_IT(&hi2c2, i2cAddress+1, i2cReadBuffer, 1, I2C_LAST_FRAME);
HAL_Delay(100);
while (HAL_I2C_GetState(&hi2c2) != HAL_I2C_STATE_READY)
{
}
if (rets == HAL_OK)
{
printf("TCC7604 HAL_OK !! receive --> %X\n", i2cReadBuffer[0]);
}else {
if (rets == HAL_BUSY) printf(" TCC7604 BUSY !!! \n");
if (rets == HAL_ERROR) printf(" TCC7604 ERROR !!! \n");
if (rets == HAL_TIMEOUT) printf(" TCC7604 TIMEOUT !!! \n");
}
}