Check if target device is ready for communication.
1424 __IO uint32_t SMBUS_Trials = 0UL;
1429 if (hsmbus->
State == HAL_SMBUS_STATE_READY)
1431 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_BUSY) != RESET)
1439 hsmbus->
State = HAL_SMBUS_STATE_BUSY;
1440 hsmbus->
ErrorCode = HAL_SMBUS_ERROR_NONE;
1451 tmp1 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_STOPF);
1452 tmp2 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF);
1454 while ((tmp1 == RESET) && (tmp2 == RESET))
1456 if (Timeout != HAL_MAX_DELAY)
1458 if (((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0UL))
1461 hsmbus->
State = HAL_SMBUS_STATE_READY;
1464 hsmbus->
ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT;
1472 tmp1 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_STOPF);
1473 tmp2 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF);
1477 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF) == RESET)
1486 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF);
1489 hsmbus->
State = HAL_SMBUS_STATE_READY;
1505 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF);
1508 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF);
1512 if (SMBUS_Trials == Trials)
1515 hsmbus->
Instance->CR2 |= I2C_CR2_STOP;
1524 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF);
1530 while (SMBUS_Trials < Trials);
1532 hsmbus->
State = HAL_SMBUS_STATE_READY;
1535 hsmbus->
ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT;
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
static HAL_StatusTypeDef SMBUS_WaitOnFlagUntilTimeout(struct __SMBUS_HandleTypeDef *hsmbus, uint32_t Flag, FlagStatus Status, uint32_t Timeout)
Handle SMBUS Communication Timeout.