Lines Matching refs:hsmbus
212 static HAL_StatusTypeDef SMBUS_WaitOnFlagUntilTimeout(SMBUS_HandleTypeDef *hsmbus, uint32_t Flag,
216 static HAL_StatusTypeDef SMBUS_Master_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t StatusFlags);
217 static HAL_StatusTypeDef SMBUS_Slave_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t StatusFlags);
218 static void SMBUS_ITErrorHandler(SMBUS_HandleTypeDef *hsmbus);
221 static void SMBUS_Enable_IRQ(SMBUS_HandleTypeDef *hsmbus, uint32_t InterruptRequest);
222 static void SMBUS_Disable_IRQ(SMBUS_HandleTypeDef *hsmbus, uint32_t InterruptRequest);
225 static void SMBUS_Flush_TXDR(SMBUS_HandleTypeDef *hsmbus);
228 static void SMBUS_TransferConfig(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t Size,
232 static void SMBUS_ConvertOtherXferOptions(SMBUS_HandleTypeDef *hsmbus);
289 HAL_StatusTypeDef HAL_SMBUS_Init(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_Init() argument
292 if (hsmbus == NULL) in HAL_SMBUS_Init()
298 assert_param(IS_SMBUS_INSTANCE(hsmbus->Instance)); in HAL_SMBUS_Init()
299 assert_param(IS_SMBUS_ANALOG_FILTER(hsmbus->Init.AnalogFilter)); in HAL_SMBUS_Init()
300 assert_param(IS_SMBUS_OWN_ADDRESS1(hsmbus->Init.OwnAddress1)); in HAL_SMBUS_Init()
301 assert_param(IS_SMBUS_ADDRESSING_MODE(hsmbus->Init.AddressingMode)); in HAL_SMBUS_Init()
302 assert_param(IS_SMBUS_DUAL_ADDRESS(hsmbus->Init.DualAddressMode)); in HAL_SMBUS_Init()
303 assert_param(IS_SMBUS_OWN_ADDRESS2(hsmbus->Init.OwnAddress2)); in HAL_SMBUS_Init()
304 assert_param(IS_SMBUS_OWN_ADDRESS2_MASK(hsmbus->Init.OwnAddress2Masks)); in HAL_SMBUS_Init()
305 assert_param(IS_SMBUS_GENERAL_CALL(hsmbus->Init.GeneralCallMode)); in HAL_SMBUS_Init()
306 assert_param(IS_SMBUS_NO_STRETCH(hsmbus->Init.NoStretchMode)); in HAL_SMBUS_Init()
307 assert_param(IS_SMBUS_PEC(hsmbus->Init.PacketErrorCheckMode)); in HAL_SMBUS_Init()
308 assert_param(IS_SMBUS_PERIPHERAL_MODE(hsmbus->Init.PeripheralMode)); in HAL_SMBUS_Init()
310 if (hsmbus->State == HAL_SMBUS_STATE_RESET) in HAL_SMBUS_Init()
313 hsmbus->Lock = HAL_UNLOCKED; in HAL_SMBUS_Init()
316 …hsmbus->MasterTxCpltCallback = HAL_SMBUS_MasterTxCpltCallback; /* Legacy weak MasterTxCpltCallback… in HAL_SMBUS_Init()
317 …hsmbus->MasterRxCpltCallback = HAL_SMBUS_MasterRxCpltCallback; /* Legacy weak MasterRxCpltCallback… in HAL_SMBUS_Init()
318 …hsmbus->SlaveTxCpltCallback = HAL_SMBUS_SlaveTxCpltCallback; /* Legacy weak SlaveTxCpltCallback … in HAL_SMBUS_Init()
319 …hsmbus->SlaveRxCpltCallback = HAL_SMBUS_SlaveRxCpltCallback; /* Legacy weak SlaveRxCpltCallback … in HAL_SMBUS_Init()
320 …hsmbus->ListenCpltCallback = HAL_SMBUS_ListenCpltCallback; /* Legacy weak ListenCpltCallback … in HAL_SMBUS_Init()
321 …hsmbus->ErrorCallback = HAL_SMBUS_ErrorCallback; /* Legacy weak ErrorCallback … in HAL_SMBUS_Init()
322 …hsmbus->AddrCallback = HAL_SMBUS_AddrCallback; /* Legacy weak AddrCallback … in HAL_SMBUS_Init()
324 if (hsmbus->MspInitCallback == NULL) in HAL_SMBUS_Init()
326 hsmbus->MspInitCallback = HAL_SMBUS_MspInit; /* Legacy weak MspInit */ in HAL_SMBUS_Init()
330 hsmbus->MspInitCallback(hsmbus); in HAL_SMBUS_Init()
333 HAL_SMBUS_MspInit(hsmbus); in HAL_SMBUS_Init()
337 hsmbus->State = HAL_SMBUS_STATE_BUSY; in HAL_SMBUS_Init()
340 __HAL_SMBUS_DISABLE(hsmbus); in HAL_SMBUS_Init()
344 hsmbus->Instance->TIMINGR = hsmbus->Init.Timing & TIMING_CLEAR_MASK; in HAL_SMBUS_Init()
348 hsmbus->Instance->TIMEOUTR &= ~I2C_TIMEOUTR_TIMOUTEN; in HAL_SMBUS_Init()
349 hsmbus->Instance->TIMEOUTR &= ~I2C_TIMEOUTR_TEXTEN; in HAL_SMBUS_Init()
350 hsmbus->Instance->TIMEOUTR = hsmbus->Init.SMBusTimeout; in HAL_SMBUS_Init()
354 hsmbus->Instance->OAR1 &= ~I2C_OAR1_OA1EN; in HAL_SMBUS_Init()
356 if (hsmbus->Init.OwnAddress1 != 0UL) in HAL_SMBUS_Init()
358 if (hsmbus->Init.AddressingMode == SMBUS_ADDRESSINGMODE_7BIT) in HAL_SMBUS_Init()
360 hsmbus->Instance->OAR1 = (I2C_OAR1_OA1EN | hsmbus->Init.OwnAddress1); in HAL_SMBUS_Init()
364 hsmbus->Instance->OAR1 = (I2C_OAR1_OA1EN | I2C_OAR1_OA1MODE | hsmbus->Init.OwnAddress1); in HAL_SMBUS_Init()
370 if (hsmbus->Init.AddressingMode == SMBUS_ADDRESSINGMODE_10BIT) in HAL_SMBUS_Init()
372 hsmbus->Instance->CR2 = (I2C_CR2_ADD10); in HAL_SMBUS_Init()
376 hsmbus->Instance->CR2 |= (I2C_CR2_AUTOEND | I2C_CR2_NACK); in HAL_SMBUS_Init()
380 hsmbus->Instance->OAR2 = (hsmbus->Init.DualAddressMode | hsmbus->Init.OwnAddress2 | \ in HAL_SMBUS_Init()
381 (hsmbus->Init.OwnAddress2Masks << 8U)); in HAL_SMBUS_Init()
385 hsmbus->Instance->CR1 = (hsmbus->Init.GeneralCallMode | hsmbus->Init.NoStretchMode | \ in HAL_SMBUS_Init()
386 hsmbus->Init.PacketErrorCheckMode | hsmbus->Init.PeripheralMode | \ in HAL_SMBUS_Init()
387 hsmbus->Init.AnalogFilter); in HAL_SMBUS_Init()
391 if ((hsmbus->Init.PacketErrorCheckMode == SMBUS_PEC_ENABLE) && \ in HAL_SMBUS_Init()
392 ((hsmbus->Init.PeripheralMode == SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE) || \ in HAL_SMBUS_Init()
393 (hsmbus->Init.PeripheralMode == SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE_ARP))) in HAL_SMBUS_Init()
395 hsmbus->Instance->CR1 |= I2C_CR1_SBC; in HAL_SMBUS_Init()
399 __HAL_SMBUS_ENABLE(hsmbus); in HAL_SMBUS_Init()
401 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Init()
402 hsmbus->PreviousState = HAL_SMBUS_STATE_READY; in HAL_SMBUS_Init()
403 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_Init()
414 HAL_StatusTypeDef HAL_SMBUS_DeInit(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_DeInit() argument
417 if (hsmbus == NULL) in HAL_SMBUS_DeInit()
423 assert_param(IS_SMBUS_INSTANCE(hsmbus->Instance)); in HAL_SMBUS_DeInit()
425 hsmbus->State = HAL_SMBUS_STATE_BUSY; in HAL_SMBUS_DeInit()
428 __HAL_SMBUS_DISABLE(hsmbus); in HAL_SMBUS_DeInit()
431 if (hsmbus->MspDeInitCallback == NULL) in HAL_SMBUS_DeInit()
433 hsmbus->MspDeInitCallback = HAL_SMBUS_MspDeInit; /* Legacy weak MspDeInit */ in HAL_SMBUS_DeInit()
437 hsmbus->MspDeInitCallback(hsmbus); in HAL_SMBUS_DeInit()
440 HAL_SMBUS_MspDeInit(hsmbus); in HAL_SMBUS_DeInit()
443 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_DeInit()
444 hsmbus->PreviousState = HAL_SMBUS_STATE_RESET; in HAL_SMBUS_DeInit()
445 hsmbus->State = HAL_SMBUS_STATE_RESET; in HAL_SMBUS_DeInit()
448 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_DeInit()
459 __weak void HAL_SMBUS_MspInit(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_MspInit() argument
462 UNUSED(hsmbus); in HAL_SMBUS_MspInit()
475 __weak void HAL_SMBUS_MspDeInit(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_MspDeInit() argument
478 UNUSED(hsmbus); in HAL_SMBUS_MspDeInit()
494 HAL_StatusTypeDef HAL_SMBUS_ConfigAnalogFilter(SMBUS_HandleTypeDef *hsmbus, uint32_t AnalogFilter) in HAL_SMBUS_ConfigAnalogFilter() argument
497 assert_param(IS_SMBUS_INSTANCE(hsmbus->Instance)); in HAL_SMBUS_ConfigAnalogFilter()
500 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_ConfigAnalogFilter()
503 __HAL_LOCK(hsmbus); in HAL_SMBUS_ConfigAnalogFilter()
505 hsmbus->State = HAL_SMBUS_STATE_BUSY; in HAL_SMBUS_ConfigAnalogFilter()
508 __HAL_SMBUS_DISABLE(hsmbus); in HAL_SMBUS_ConfigAnalogFilter()
511 hsmbus->Instance->CR1 &= ~(I2C_CR1_ANFOFF); in HAL_SMBUS_ConfigAnalogFilter()
514 hsmbus->Instance->CR1 |= AnalogFilter; in HAL_SMBUS_ConfigAnalogFilter()
516 __HAL_SMBUS_ENABLE(hsmbus); in HAL_SMBUS_ConfigAnalogFilter()
518 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_ConfigAnalogFilter()
521 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_ConfigAnalogFilter()
538 HAL_StatusTypeDef HAL_SMBUS_ConfigDigitalFilter(SMBUS_HandleTypeDef *hsmbus, uint32_t DigitalFilter) in HAL_SMBUS_ConfigDigitalFilter() argument
543 assert_param(IS_SMBUS_INSTANCE(hsmbus->Instance)); in HAL_SMBUS_ConfigDigitalFilter()
546 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_ConfigDigitalFilter()
549 __HAL_LOCK(hsmbus); in HAL_SMBUS_ConfigDigitalFilter()
551 hsmbus->State = HAL_SMBUS_STATE_BUSY; in HAL_SMBUS_ConfigDigitalFilter()
554 __HAL_SMBUS_DISABLE(hsmbus); in HAL_SMBUS_ConfigDigitalFilter()
557 tmpreg = hsmbus->Instance->CR1; in HAL_SMBUS_ConfigDigitalFilter()
566 hsmbus->Instance->CR1 = tmpreg; in HAL_SMBUS_ConfigDigitalFilter()
568 __HAL_SMBUS_ENABLE(hsmbus); in HAL_SMBUS_ConfigDigitalFilter()
570 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_ConfigDigitalFilter()
573 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_ConfigDigitalFilter()
605 HAL_StatusTypeDef HAL_SMBUS_RegisterCallback(SMBUS_HandleTypeDef *hsmbus, in HAL_SMBUS_RegisterCallback() argument
614 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterCallback()
619 if (HAL_SMBUS_STATE_READY == hsmbus->State) in HAL_SMBUS_RegisterCallback()
624 hsmbus->MasterTxCpltCallback = pCallback; in HAL_SMBUS_RegisterCallback()
628 hsmbus->MasterRxCpltCallback = pCallback; in HAL_SMBUS_RegisterCallback()
632 hsmbus->SlaveTxCpltCallback = pCallback; in HAL_SMBUS_RegisterCallback()
636 hsmbus->SlaveRxCpltCallback = pCallback; in HAL_SMBUS_RegisterCallback()
640 hsmbus->ListenCpltCallback = pCallback; in HAL_SMBUS_RegisterCallback()
644 hsmbus->ErrorCallback = pCallback; in HAL_SMBUS_RegisterCallback()
648 hsmbus->MspInitCallback = pCallback; in HAL_SMBUS_RegisterCallback()
652 hsmbus->MspDeInitCallback = pCallback; in HAL_SMBUS_RegisterCallback()
657 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterCallback()
664 else if (HAL_SMBUS_STATE_RESET == hsmbus->State) in HAL_SMBUS_RegisterCallback()
669 hsmbus->MspInitCallback = pCallback; in HAL_SMBUS_RegisterCallback()
673 hsmbus->MspDeInitCallback = pCallback; in HAL_SMBUS_RegisterCallback()
678 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterCallback()
688 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterCallback()
718 HAL_StatusTypeDef HAL_SMBUS_UnRegisterCallback(SMBUS_HandleTypeDef *hsmbus, in HAL_SMBUS_UnRegisterCallback() argument
723 if (HAL_SMBUS_STATE_READY == hsmbus->State) in HAL_SMBUS_UnRegisterCallback()
728 …hsmbus->MasterTxCpltCallback = HAL_SMBUS_MasterTxCpltCallback; /* Legacy weak MasterTxCpltCallback… in HAL_SMBUS_UnRegisterCallback()
732 …hsmbus->MasterRxCpltCallback = HAL_SMBUS_MasterRxCpltCallback; /* Legacy weak MasterRxCpltCallback… in HAL_SMBUS_UnRegisterCallback()
736 …hsmbus->SlaveTxCpltCallback = HAL_SMBUS_SlaveTxCpltCallback; /* Legacy weak SlaveTxCpltCallback … in HAL_SMBUS_UnRegisterCallback()
740 …hsmbus->SlaveRxCpltCallback = HAL_SMBUS_SlaveRxCpltCallback; /* Legacy weak SlaveRxCpltCallback … in HAL_SMBUS_UnRegisterCallback()
744 …hsmbus->ListenCpltCallback = HAL_SMBUS_ListenCpltCallback; /* Legacy weak ListenCpltCallback … in HAL_SMBUS_UnRegisterCallback()
748 …hsmbus->ErrorCallback = HAL_SMBUS_ErrorCallback; /* Legacy weak ErrorCallback … in HAL_SMBUS_UnRegisterCallback()
752 …hsmbus->MspInitCallback = HAL_SMBUS_MspInit; /* Legacy weak MspInit … in HAL_SMBUS_UnRegisterCallback()
756 …hsmbus->MspDeInitCallback = HAL_SMBUS_MspDeInit; /* Legacy weak MspDeInit … in HAL_SMBUS_UnRegisterCallback()
761 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterCallback()
768 else if (HAL_SMBUS_STATE_RESET == hsmbus->State) in HAL_SMBUS_UnRegisterCallback()
773 …hsmbus->MspInitCallback = HAL_SMBUS_MspInit; /* Legacy weak MspInit … in HAL_SMBUS_UnRegisterCallback()
777 …hsmbus->MspDeInitCallback = HAL_SMBUS_MspDeInit; /* Legacy weak MspDeInit … in HAL_SMBUS_UnRegisterCallback()
782 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterCallback()
792 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterCallback()
809 HAL_StatusTypeDef HAL_SMBUS_RegisterAddrCallback(SMBUS_HandleTypeDef *hsmbus, in HAL_SMBUS_RegisterAddrCallback() argument
817 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterAddrCallback()
822 if (HAL_SMBUS_STATE_READY == hsmbus->State) in HAL_SMBUS_RegisterAddrCallback()
824 hsmbus->AddrCallback = pCallback; in HAL_SMBUS_RegisterAddrCallback()
829 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterAddrCallback()
845 HAL_StatusTypeDef HAL_SMBUS_UnRegisterAddrCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_UnRegisterAddrCallback() argument
849 if (HAL_SMBUS_STATE_READY == hsmbus->State) in HAL_SMBUS_UnRegisterAddrCallback()
851 hsmbus->AddrCallback = HAL_SMBUS_AddrCallback; /* Legacy weak AddrCallback */ in HAL_SMBUS_UnRegisterAddrCallback()
856 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterAddrCallback()
925 HAL_StatusTypeDef HAL_SMBUS_Master_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, in HAL_SMBUS_Master_Transmit_IT() argument
933 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_Master_Transmit_IT()
936 __HAL_LOCK(hsmbus); in HAL_SMBUS_Master_Transmit_IT()
938 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_TX; in HAL_SMBUS_Master_Transmit_IT()
939 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Master_Transmit_IT()
941 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Master_Transmit_IT()
942 hsmbus->XferCount = Size; in HAL_SMBUS_Master_Transmit_IT()
943 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Master_Transmit_IT()
947 if (hsmbus->pBuffPtr == NULL) in HAL_SMBUS_Master_Transmit_IT()
949 hsmbus->XferOptions &= ~SMBUS_AUTOEND_MODE; in HAL_SMBUS_Master_Transmit_IT()
954 hsmbus->XferSize = MAX_NBYTE_SIZE; in HAL_SMBUS_Master_Transmit_IT()
958 hsmbus->XferSize = Size; in HAL_SMBUS_Master_Transmit_IT()
963 if ((hsmbus->XferSize < hsmbus->XferCount) && (hsmbus->XferSize == MAX_NBYTE_SIZE)) in HAL_SMBUS_Master_Transmit_IT()
965 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Transmit_IT()
966 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in HAL_SMBUS_Master_Transmit_IT()
975 tmp = hsmbus->XferOptions; in HAL_SMBUS_Master_Transmit_IT()
977 if ((hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_TX) && \ in HAL_SMBUS_Master_Transmit_IT()
980 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Master_Transmit_IT()
987 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Master_Transmit_IT()
990 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Transmit_IT()
991 hsmbus->XferOptions, in HAL_SMBUS_Master_Transmit_IT()
997 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in HAL_SMBUS_Master_Transmit_IT()
999 hsmbus->XferSize--; in HAL_SMBUS_Master_Transmit_IT()
1000 hsmbus->XferCount--; in HAL_SMBUS_Master_Transmit_IT()
1005 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Master_Transmit_IT()
1010 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_TX); in HAL_SMBUS_Master_Transmit_IT()
1031 HAL_StatusTypeDef HAL_SMBUS_Master_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uin… in HAL_SMBUS_Master_Receive_IT() argument
1039 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_Master_Receive_IT()
1042 __HAL_LOCK(hsmbus); in HAL_SMBUS_Master_Receive_IT()
1044 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_RX; in HAL_SMBUS_Master_Receive_IT()
1045 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Master_Receive_IT()
1048 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Master_Receive_IT()
1049 hsmbus->XferCount = Size; in HAL_SMBUS_Master_Receive_IT()
1050 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Master_Receive_IT()
1054 if (hsmbus->pBuffPtr == NULL) in HAL_SMBUS_Master_Receive_IT()
1056 hsmbus->XferOptions &= ~SMBUS_AUTOEND_MODE; in HAL_SMBUS_Master_Receive_IT()
1061 hsmbus->XferSize = MAX_NBYTE_SIZE; in HAL_SMBUS_Master_Receive_IT()
1065 hsmbus->XferSize = Size; in HAL_SMBUS_Master_Receive_IT()
1070 if ((hsmbus->XferSize < hsmbus->XferCount) && (hsmbus->XferSize == MAX_NBYTE_SIZE)) in HAL_SMBUS_Master_Receive_IT()
1072 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Receive_IT()
1073 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in HAL_SMBUS_Master_Receive_IT()
1082 tmp = hsmbus->XferOptions; in HAL_SMBUS_Master_Receive_IT()
1084 if ((hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_RX) && \ in HAL_SMBUS_Master_Receive_IT()
1087 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Master_Receive_IT()
1094 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Master_Receive_IT()
1097 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Receive_IT()
1098 hsmbus->XferOptions, in HAL_SMBUS_Master_Receive_IT()
1104 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Master_Receive_IT()
1109 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_RX); in HAL_SMBUS_Master_Receive_IT()
1128 HAL_StatusTypeDef HAL_SMBUS_Master_Abort_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress) in HAL_SMBUS_Master_Abort_IT() argument
1130 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_Master_Abort_IT()
1133 __HAL_LOCK(hsmbus); in HAL_SMBUS_Master_Abort_IT()
1137 if (hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_TX) in HAL_SMBUS_Master_Abort_IT()
1139 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_TX; in HAL_SMBUS_Master_Abort_IT()
1141 else if (hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_RX) in HAL_SMBUS_Master_Abort_IT()
1143 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_RX; in HAL_SMBUS_Master_Abort_IT()
1151 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Master_Abort_IT()
1155 SMBUS_TransferConfig(hsmbus, DevAddress, 1, SMBUS_AUTOEND_MODE, SMBUS_NO_STARTSTOP); in HAL_SMBUS_Master_Abort_IT()
1158 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Master_Abort_IT()
1163 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in HAL_SMBUS_Master_Abort_IT()
1165 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_TX); in HAL_SMBUS_Master_Abort_IT()
1167 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in HAL_SMBUS_Master_Abort_IT()
1169 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_RX); in HAL_SMBUS_Master_Abort_IT()
1193 HAL_StatusTypeDef HAL_SMBUS_Slave_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t… in HAL_SMBUS_Slave_Transmit_IT() argument
1199 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_Slave_Transmit_IT()
1203 hsmbus->ErrorCode = HAL_SMBUS_ERROR_INVALID_PARAM; in HAL_SMBUS_Slave_Transmit_IT()
1208 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR | SMBUS_IT_TX); in HAL_SMBUS_Slave_Transmit_IT()
1211 __HAL_LOCK(hsmbus); in HAL_SMBUS_Slave_Transmit_IT()
1213 hsmbus->State = (HAL_SMBUS_STATE_SLAVE_BUSY_TX | HAL_SMBUS_STATE_LISTEN); in HAL_SMBUS_Slave_Transmit_IT()
1214 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Slave_Transmit_IT()
1217 hsmbus->Instance->CR1 |= I2C_CR1_SBC; in HAL_SMBUS_Slave_Transmit_IT()
1220 hsmbus->Instance->CR2 &= ~I2C_CR2_NACK; in HAL_SMBUS_Slave_Transmit_IT()
1223 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Slave_Transmit_IT()
1224 hsmbus->XferCount = Size; in HAL_SMBUS_Slave_Transmit_IT()
1225 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Slave_Transmit_IT()
1228 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Slave_Transmit_IT()
1232 hsmbus->XferSize = MAX_NBYTE_SIZE; in HAL_SMBUS_Slave_Transmit_IT()
1236 hsmbus->XferSize = Size; in HAL_SMBUS_Slave_Transmit_IT()
1240 if ((hsmbus->XferSize < hsmbus->XferCount) && (hsmbus->XferSize == MAX_NBYTE_SIZE)) in HAL_SMBUS_Slave_Transmit_IT()
1242 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Slave_Transmit_IT()
1243 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in HAL_SMBUS_Slave_Transmit_IT()
1249 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Slave_Transmit_IT()
1254 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in HAL_SMBUS_Slave_Transmit_IT()
1256 hsmbus->XferSize--; in HAL_SMBUS_Slave_Transmit_IT()
1257 hsmbus->XferCount--; in HAL_SMBUS_Slave_Transmit_IT()
1263 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ADDR); in HAL_SMBUS_Slave_Transmit_IT()
1266 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Slave_Transmit_IT()
1272 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_TX | SMBUS_IT_ADDR); in HAL_SMBUS_Slave_Transmit_IT()
1291 HAL_StatusTypeDef HAL_SMBUS_Slave_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t … in HAL_SMBUS_Slave_Receive_IT() argument
1297 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_Slave_Receive_IT()
1301 hsmbus->ErrorCode = HAL_SMBUS_ERROR_INVALID_PARAM; in HAL_SMBUS_Slave_Receive_IT()
1306 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR | SMBUS_IT_RX); in HAL_SMBUS_Slave_Receive_IT()
1309 __HAL_LOCK(hsmbus); in HAL_SMBUS_Slave_Receive_IT()
1311 hsmbus->State = (HAL_SMBUS_STATE_SLAVE_BUSY_RX | HAL_SMBUS_STATE_LISTEN); in HAL_SMBUS_Slave_Receive_IT()
1312 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Slave_Receive_IT()
1315 hsmbus->Instance->CR1 |= I2C_CR1_SBC; in HAL_SMBUS_Slave_Receive_IT()
1318 hsmbus->Instance->CR2 &= ~I2C_CR2_NACK; in HAL_SMBUS_Slave_Receive_IT()
1321 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Slave_Receive_IT()
1322 hsmbus->XferSize = Size; in HAL_SMBUS_Slave_Receive_IT()
1323 hsmbus->XferCount = Size; in HAL_SMBUS_Slave_Receive_IT()
1324 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Slave_Receive_IT()
1327 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Slave_Receive_IT()
1334 … if (((SMBUS_GET_PEC_MODE(hsmbus) != 0UL) && (hsmbus->XferSize == 2U)) || (hsmbus->XferSize == 1U)) in HAL_SMBUS_Slave_Receive_IT()
1336 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Slave_Receive_IT()
1341 … SMBUS_TransferConfig(hsmbus, 0, 1, hsmbus->XferOptions | SMBUS_RELOAD_MODE, SMBUS_NO_STARTSTOP); in HAL_SMBUS_Slave_Receive_IT()
1346 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ADDR); in HAL_SMBUS_Slave_Receive_IT()
1349 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Slave_Receive_IT()
1355 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_RX | SMBUS_IT_ADDR); in HAL_SMBUS_Slave_Receive_IT()
1371 HAL_StatusTypeDef HAL_SMBUS_EnableListen_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_EnableListen_IT() argument
1373 hsmbus->State = HAL_SMBUS_STATE_LISTEN; in HAL_SMBUS_EnableListen_IT()
1376 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_ADDR); in HAL_SMBUS_EnableListen_IT()
1387 HAL_StatusTypeDef HAL_SMBUS_DisableListen_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_DisableListen_IT() argument
1390 if (hsmbus->State == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_DisableListen_IT()
1392 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_DisableListen_IT()
1395 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR); in HAL_SMBUS_DisableListen_IT()
1411 HAL_StatusTypeDef HAL_SMBUS_EnableAlert_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_EnableAlert_IT() argument
1414 hsmbus->Instance->CR1 |= I2C_CR1_ALERTEN; in HAL_SMBUS_EnableAlert_IT()
1417 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ALERT); in HAL_SMBUS_EnableAlert_IT()
1420 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_ALERT); in HAL_SMBUS_EnableAlert_IT()
1430 HAL_StatusTypeDef HAL_SMBUS_DisableAlert_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_DisableAlert_IT() argument
1433 hsmbus->Instance->CR1 &= ~I2C_CR1_ALERTEN; in HAL_SMBUS_DisableAlert_IT()
1436 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ALERT); in HAL_SMBUS_DisableAlert_IT()
1451 HAL_StatusTypeDef HAL_SMBUS_IsDeviceReady(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint32_… in HAL_SMBUS_IsDeviceReady() argument
1461 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_IsDeviceReady()
1463 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_BUSY) != RESET) in HAL_SMBUS_IsDeviceReady()
1469 __HAL_LOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1471 hsmbus->State = HAL_SMBUS_STATE_BUSY; in HAL_SMBUS_IsDeviceReady()
1472 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_IsDeviceReady()
1477 hsmbus->Instance->CR2 = SMBUS_GENERATE_START(hsmbus->Init.AddressingMode, DevAddress); in HAL_SMBUS_IsDeviceReady()
1483 tmp1 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1484 tmp2 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF); in HAL_SMBUS_IsDeviceReady()
1493 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_IsDeviceReady()
1496 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT; in HAL_SMBUS_IsDeviceReady()
1499 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1504 tmp1 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1505 tmp2 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF); in HAL_SMBUS_IsDeviceReady()
1509 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF) == RESET) in HAL_SMBUS_IsDeviceReady()
1512 if (SMBUS_WaitOnFlagUntilTimeout(hsmbus, SMBUS_FLAG_STOPF, RESET, Timeout) != HAL_OK) in HAL_SMBUS_IsDeviceReady()
1518 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1521 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_IsDeviceReady()
1524 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1531 if (SMBUS_WaitOnFlagUntilTimeout(hsmbus, SMBUS_FLAG_STOPF, RESET, Timeout) != HAL_OK) in HAL_SMBUS_IsDeviceReady()
1537 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in HAL_SMBUS_IsDeviceReady()
1540 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1547 hsmbus->Instance->CR2 |= I2C_CR2_STOP; in HAL_SMBUS_IsDeviceReady()
1550 if (SMBUS_WaitOnFlagUntilTimeout(hsmbus, SMBUS_FLAG_STOPF, RESET, Timeout) != HAL_OK) in HAL_SMBUS_IsDeviceReady()
1556 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1563 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_IsDeviceReady()
1566 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT; in HAL_SMBUS_IsDeviceReady()
1569 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1592 void HAL_SMBUS_EV_IRQHandler(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_EV_IRQHandler() argument
1596 uint32_t tmpisrvalue = READ_REG(hsmbus->Instance->ISR); in HAL_SMBUS_EV_IRQHandler()
1597 uint32_t tmpcr1value = READ_REG(hsmbus->Instance->CR1); in HAL_SMBUS_EV_IRQHandler()
1609 if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_TX) == HAL_SMBUS_STATE_SLAVE_BUSY_TX) in HAL_SMBUS_EV_IRQHandler()
1611 (void)SMBUS_Slave_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1614 else if ((hsmbus->State & HAL_SMBUS_STATE_MASTER_BUSY_TX) == HAL_SMBUS_STATE_MASTER_BUSY_TX) in HAL_SMBUS_EV_IRQHandler()
1616 (void)SMBUS_Master_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1634 if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_RX) == HAL_SMBUS_STATE_SLAVE_BUSY_RX) in HAL_SMBUS_EV_IRQHandler()
1636 (void)SMBUS_Slave_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1639 else if ((hsmbus->State & HAL_SMBUS_STATE_MASTER_BUSY_RX) == HAL_SMBUS_STATE_MASTER_BUSY_RX) in HAL_SMBUS_EV_IRQHandler()
1641 (void)SMBUS_Master_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1657 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_EV_IRQHandler()
1659 (void)SMBUS_Slave_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1670 void HAL_SMBUS_ER_IRQHandler(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_ER_IRQHandler() argument
1672 SMBUS_ITErrorHandler(hsmbus); in HAL_SMBUS_ER_IRQHandler()
1681 __weak void HAL_SMBUS_MasterTxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_MasterTxCpltCallback() argument
1684 UNUSED(hsmbus); in HAL_SMBUS_MasterTxCpltCallback()
1697 __weak void HAL_SMBUS_MasterRxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_MasterRxCpltCallback() argument
1700 UNUSED(hsmbus); in HAL_SMBUS_MasterRxCpltCallback()
1712 __weak void HAL_SMBUS_SlaveTxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_SlaveTxCpltCallback() argument
1715 UNUSED(hsmbus); in HAL_SMBUS_SlaveTxCpltCallback()
1728 __weak void HAL_SMBUS_SlaveRxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_SlaveRxCpltCallback() argument
1731 UNUSED(hsmbus); in HAL_SMBUS_SlaveRxCpltCallback()
1746 __weak void HAL_SMBUS_AddrCallback(SMBUS_HandleTypeDef *hsmbus, uint8_t TransferDirection, in HAL_SMBUS_AddrCallback() argument
1750 UNUSED(hsmbus); in HAL_SMBUS_AddrCallback()
1765 __weak void HAL_SMBUS_ListenCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_ListenCpltCallback() argument
1768 UNUSED(hsmbus); in HAL_SMBUS_ListenCpltCallback()
1781 __weak void HAL_SMBUS_ErrorCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_ErrorCallback() argument
1784 UNUSED(hsmbus); in HAL_SMBUS_ErrorCallback()
1816 uint32_t HAL_SMBUS_GetState(const SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_GetState() argument
1819 return hsmbus->State; in HAL_SMBUS_GetState()
1828 uint32_t HAL_SMBUS_GetError(const SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_GetError() argument
1830 return hsmbus->ErrorCode; in HAL_SMBUS_GetError()
1853 static HAL_StatusTypeDef SMBUS_Master_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t StatusFlags) in SMBUS_Master_ISR() argument
1858 __HAL_LOCK(hsmbus); in SMBUS_Master_ISR()
1863 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in SMBUS_Master_ISR()
1867 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ACKF; in SMBUS_Master_ISR()
1870 SMBUS_Flush_TXDR(hsmbus); in SMBUS_Master_ISR()
1873 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
1877 hsmbus->ErrorCallback(hsmbus); in SMBUS_Master_ISR()
1879 HAL_SMBUS_ErrorCallback(hsmbus); in SMBUS_Master_ISR()
1885 SMBUS_ITErrorHandler(hsmbus); in SMBUS_Master_ISR()
1888 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in SMBUS_Master_ISR()
1891 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Master_ISR()
1894 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in SMBUS_Master_ISR()
1897 SMBUS_RESET_CR2(hsmbus); in SMBUS_Master_ISR()
1901 __HAL_SMBUS_DISABLE(hsmbus); in SMBUS_Master_ISR()
1903 hsmbus->PreviousState = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1904 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1907 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
1910 __HAL_SMBUS_ENABLE(hsmbus); in SMBUS_Master_ISR()
1914 hsmbus->MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1916 HAL_SMBUS_MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1919 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in SMBUS_Master_ISR()
1925 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Master_ISR()
1928 hsmbus->pBuffPtr++; in SMBUS_Master_ISR()
1930 if ((hsmbus->XferSize > 0U)) in SMBUS_Master_ISR()
1932 hsmbus->XferSize--; in SMBUS_Master_ISR()
1933 hsmbus->XferCount--; in SMBUS_Master_ISR()
1938 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Master_ISR()
1941 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in SMBUS_Master_ISR()
1944 SMBUS_RESET_CR2(hsmbus); in SMBUS_Master_ISR()
1946 hsmbus->PreviousState = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1947 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1950 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
1954 hsmbus->MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1956 HAL_SMBUS_MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1967 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Master_ISR()
1970 hsmbus->pBuffPtr++; in SMBUS_Master_ISR()
1973 hsmbus->XferSize--; in SMBUS_Master_ISR()
1974 hsmbus->XferCount--; in SMBUS_Master_ISR()
1979 hsmbus->Instance->TXDR = *hsmbus->pBuffPtr; in SMBUS_Master_ISR()
1982 hsmbus->pBuffPtr++; in SMBUS_Master_ISR()
1985 hsmbus->XferSize--; in SMBUS_Master_ISR()
1986 hsmbus->XferCount--; in SMBUS_Master_ISR()
1990 if ((hsmbus->XferCount != 0U) && (hsmbus->XferSize == 0U)) in SMBUS_Master_ISR()
1992 DevAddress = (uint16_t)(hsmbus->Instance->CR2 & I2C_CR2_SADD); in SMBUS_Master_ISR()
1994 if (hsmbus->XferCount > MAX_NBYTE_SIZE) in SMBUS_Master_ISR()
1996 SMBUS_TransferConfig(hsmbus, DevAddress, MAX_NBYTE_SIZE, in SMBUS_Master_ISR()
1997 (SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE)), in SMBUS_Master_ISR()
1999 hsmbus->XferSize = MAX_NBYTE_SIZE; in SMBUS_Master_ISR()
2003 hsmbus->XferSize = hsmbus->XferCount; in SMBUS_Master_ISR()
2004 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in SMBUS_Master_ISR()
2008 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in SMBUS_Master_ISR()
2010 hsmbus->XferSize--; in SMBUS_Master_ISR()
2011 hsmbus->XferCount--; in SMBUS_Master_ISR()
2015 else if ((hsmbus->XferCount == 0U) && (hsmbus->XferSize == 0U)) in SMBUS_Master_ISR()
2018 if (SMBUS_GET_STOP_MODE(hsmbus) != SMBUS_AUTOEND_MODE) in SMBUS_Master_ISR()
2021 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in SMBUS_Master_ISR()
2024 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Master_ISR()
2025 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2026 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2029 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2033 hsmbus->MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2035 HAL_SMBUS_MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2038 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in SMBUS_Master_ISR()
2040 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Master_ISR()
2041 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2042 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2045 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2049 hsmbus->MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2051 HAL_SMBUS_MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2067 if (hsmbus->XferCount == 0U) in SMBUS_Master_ISR()
2070 if (hsmbus->pBuffPtr == NULL) in SMBUS_Master_ISR()
2073 hsmbus->Instance->CR2 |= I2C_CR2_STOP; in SMBUS_Master_ISR()
2076 else if (SMBUS_GET_STOP_MODE(hsmbus) != SMBUS_AUTOEND_MODE) in SMBUS_Master_ISR()
2082 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in SMBUS_Master_ISR()
2085 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Master_ISR()
2086 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2087 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2090 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2094 hsmbus->MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2096 HAL_SMBUS_MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2099 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in SMBUS_Master_ISR()
2101 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Master_ISR()
2102 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2103 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2106 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2110 hsmbus->MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2112 HAL_SMBUS_MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2132 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2143 static HAL_StatusTypeDef SMBUS_Slave_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t StatusFlags) in SMBUS_Slave_ISR() argument
2149 __HAL_LOCK(hsmbus); in SMBUS_Slave_ISR()
2157 if (hsmbus->XferCount == 0U) in SMBUS_Slave_ISR()
2160 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in SMBUS_Slave_ISR()
2163 SMBUS_Flush_TXDR(hsmbus); in SMBUS_Slave_ISR()
2166 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2172 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in SMBUS_Slave_ISR()
2176 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2177 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_TX); in SMBUS_Slave_ISR()
2178 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_RX); in SMBUS_Slave_ISR()
2181 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX | SMBUS_IT_TX); in SMBUS_Slave_ISR()
2184 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ACKF; in SMBUS_Slave_ISR()
2187 SMBUS_Flush_TXDR(hsmbus); in SMBUS_Slave_ISR()
2190 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2194 hsmbus->ErrorCallback(hsmbus); in SMBUS_Slave_ISR()
2196 HAL_SMBUS_ErrorCallback(hsmbus); in SMBUS_Slave_ISR()
2202 TransferDirection = (uint8_t)(SMBUS_GET_DIR(hsmbus)); in SMBUS_Slave_ISR()
2203 SlaveAddrCode = (uint16_t)(SMBUS_GET_ADDR_MATCH(hsmbus)); in SMBUS_Slave_ISR()
2207 __HAL_SMBUS_DISABLE_IT(hsmbus, SMBUS_IT_ADDRI); in SMBUS_Slave_ISR()
2210 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2214 hsmbus->AddrCallback(hsmbus, TransferDirection, SlaveAddrCode); in SMBUS_Slave_ISR()
2216 HAL_SMBUS_AddrCallback(hsmbus, TransferDirection, SlaveAddrCode); in SMBUS_Slave_ISR()
2222 if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_RX) == HAL_SMBUS_STATE_SLAVE_BUSY_RX) in SMBUS_Slave_ISR()
2225 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Slave_ISR()
2228 hsmbus->pBuffPtr++; in SMBUS_Slave_ISR()
2230 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2231 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2233 if (hsmbus->XferCount == 1U) in SMBUS_Slave_ISR()
2238 hsmbus->XferOptions &= ~SMBUS_RELOAD_MODE; in SMBUS_Slave_ISR()
2239 SMBUS_TransferConfig(hsmbus, 0, 1, hsmbus->XferOptions, SMBUS_NO_STARTSTOP); in SMBUS_Slave_ISR()
2241 else if (hsmbus->XferCount == 0U) in SMBUS_Slave_ISR()
2244 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Slave_ISR()
2247 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2248 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_RX); in SMBUS_Slave_ISR()
2251 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2255 hsmbus->SlaveRxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2257 HAL_SMBUS_SlaveRxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2263 SMBUS_TransferConfig(hsmbus, 0, 1, in SMBUS_Slave_ISR()
2264 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in SMBUS_Slave_ISR()
2268 hsmbus->Instance->CR2 &= ~I2C_CR2_NACK; in SMBUS_Slave_ISR()
2271 else if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_TX) == HAL_SMBUS_STATE_SLAVE_BUSY_TX) in SMBUS_Slave_ISR()
2273 if ((hsmbus->XferCount != 0U) && (hsmbus->XferSize == 0U)) in SMBUS_Slave_ISR()
2275 if (hsmbus->XferCount > MAX_NBYTE_SIZE) in SMBUS_Slave_ISR()
2277 SMBUS_TransferConfig(hsmbus, 0, MAX_NBYTE_SIZE, in SMBUS_Slave_ISR()
2278 (SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE)), in SMBUS_Slave_ISR()
2280 hsmbus->XferSize = MAX_NBYTE_SIZE; in SMBUS_Slave_ISR()
2284 hsmbus->XferSize = hsmbus->XferCount; in SMBUS_Slave_ISR()
2285 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in SMBUS_Slave_ISR()
2289 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in SMBUS_Slave_ISR()
2291 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2292 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2308 if (hsmbus->XferCount > 0U) in SMBUS_Slave_ISR()
2311 hsmbus->Instance->TXDR = *hsmbus->pBuffPtr; in SMBUS_Slave_ISR()
2314 hsmbus->pBuffPtr++; in SMBUS_Slave_ISR()
2316 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2317 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2320 if (hsmbus->XferCount == 0U) in SMBUS_Slave_ISR()
2324 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Slave_ISR()
2325 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2326 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_TX); in SMBUS_Slave_ISR()
2329 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2333 hsmbus->SlaveTxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2335 HAL_SMBUS_SlaveTxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2347 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in SMBUS_Slave_ISR()
2350 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_RXNE) != RESET) in SMBUS_Slave_ISR()
2353 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Slave_ISR()
2356 hsmbus->pBuffPtr++; in SMBUS_Slave_ISR()
2358 if ((hsmbus->XferSize > 0U)) in SMBUS_Slave_ISR()
2360 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2361 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2366 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX | SMBUS_IT_TX); in SMBUS_Slave_ISR()
2369 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR); in SMBUS_Slave_ISR()
2372 hsmbus->Instance->CR2 |= I2C_CR2_NACK; in SMBUS_Slave_ISR()
2375 SMBUS_RESET_CR2(hsmbus); in SMBUS_Slave_ISR()
2378 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in SMBUS_Slave_ISR()
2381 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ADDR); in SMBUS_Slave_ISR()
2383 hsmbus->XferOptions = 0; in SMBUS_Slave_ISR()
2384 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2385 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Slave_ISR()
2388 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2392 hsmbus->ListenCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2394 HAL_SMBUS_ListenCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2400 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2411 static void SMBUS_Enable_IRQ(SMBUS_HandleTypeDef *hsmbus, uint32_t InterruptRequest) in SMBUS_Enable_IRQ() argument
2442 __HAL_SMBUS_ENABLE_IT(hsmbus, tmpisr); in SMBUS_Enable_IRQ()
2451 static void SMBUS_Disable_IRQ(SMBUS_HandleTypeDef *hsmbus, uint32_t InterruptRequest) in SMBUS_Disable_IRQ() argument
2454 uint32_t tmpstate = hsmbus->State; in SMBUS_Disable_IRQ()
2467 if ((SMBUS_GET_ALERT_ENABLED(hsmbus) == 0UL) in SMBUS_Disable_IRQ()
2486 if ((SMBUS_GET_ALERT_ENABLED(hsmbus) == 0UL) in SMBUS_Disable_IRQ()
2505 if (SMBUS_GET_ALERT_ENABLED(hsmbus) == 0UL) in SMBUS_Disable_IRQ()
2515 __HAL_SMBUS_DISABLE_IT(hsmbus, tmpisr); in SMBUS_Disable_IRQ()
2523 static void SMBUS_ITErrorHandler(SMBUS_HandleTypeDef *hsmbus) in SMBUS_ITErrorHandler() argument
2525 uint32_t itflags = READ_REG(hsmbus->Instance->ISR); in SMBUS_ITErrorHandler()
2526 uint32_t itsources = READ_REG(hsmbus->Instance->CR1); in SMBUS_ITErrorHandler()
2534 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_BERR; in SMBUS_ITErrorHandler()
2537 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_BERR); in SMBUS_ITErrorHandler()
2544 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_OVR; in SMBUS_ITErrorHandler()
2547 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_OVR); in SMBUS_ITErrorHandler()
2554 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ARLO; in SMBUS_ITErrorHandler()
2557 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ARLO); in SMBUS_ITErrorHandler()
2564 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_BUSTIMEOUT; in SMBUS_ITErrorHandler()
2567 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_TIMEOUT); in SMBUS_ITErrorHandler()
2574 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ALERT; in SMBUS_ITErrorHandler()
2577 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ALERT); in SMBUS_ITErrorHandler()
2584 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_PECERR; in SMBUS_ITErrorHandler()
2587 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_PECERR); in SMBUS_ITErrorHandler()
2591 SMBUS_Flush_TXDR(hsmbus); in SMBUS_ITErrorHandler()
2594 tmperror = hsmbus->ErrorCode; in SMBUS_ITErrorHandler()
2603 tmpstate = hsmbus->State; in SMBUS_ITErrorHandler()
2610 hsmbus->PreviousState = HAL_SMBUS_STATE_READY; in SMBUS_ITErrorHandler()
2611 hsmbus->State = HAL_SMBUS_STATE_LISTEN; in SMBUS_ITErrorHandler()
2617 hsmbus->ErrorCallback(hsmbus); in SMBUS_ITErrorHandler()
2619 HAL_SMBUS_ErrorCallback(hsmbus); in SMBUS_ITErrorHandler()
2633 static HAL_StatusTypeDef SMBUS_WaitOnFlagUntilTimeout(SMBUS_HandleTypeDef *hsmbus, uint32_t Flag, in SMBUS_WaitOnFlagUntilTimeout() argument
2639 while ((FlagStatus)(__HAL_SMBUS_GET_FLAG(hsmbus, Flag)) == Status) in SMBUS_WaitOnFlagUntilTimeout()
2646 hsmbus->PreviousState = hsmbus->State; in SMBUS_WaitOnFlagUntilTimeout()
2647 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_WaitOnFlagUntilTimeout()
2650 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT; in SMBUS_WaitOnFlagUntilTimeout()
2653 __HAL_UNLOCK(hsmbus); in SMBUS_WaitOnFlagUntilTimeout()
2668 static void SMBUS_Flush_TXDR(SMBUS_HandleTypeDef *hsmbus) in SMBUS_Flush_TXDR() argument
2672 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_TXIS) != RESET) in SMBUS_Flush_TXDR()
2674 hsmbus->Instance->TXDR = 0x00U; in SMBUS_Flush_TXDR()
2678 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_TXE) == RESET) in SMBUS_Flush_TXDR()
2680 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_TXE); in SMBUS_Flush_TXDR()
2704 static void SMBUS_TransferConfig(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t Size, in SMBUS_TransferConfig() argument
2708 assert_param(IS_SMBUS_INSTANCE(hsmbus->Instance)); in SMBUS_TransferConfig()
2713 MODIFY_REG(hsmbus->Instance->CR2, in SMBUS_TransferConfig()
2727 static void SMBUS_ConvertOtherXferOptions(SMBUS_HandleTypeDef *hsmbus) in SMBUS_ConvertOtherXferOptions() argument
2732 if (hsmbus->XferOptions == SMBUS_OTHER_FRAME_NO_PEC) in SMBUS_ConvertOtherXferOptions()
2734 hsmbus->XferOptions = SMBUS_FIRST_FRAME; in SMBUS_ConvertOtherXferOptions()
2739 else if (hsmbus->XferOptions == SMBUS_OTHER_FRAME_WITH_PEC) in SMBUS_ConvertOtherXferOptions()
2741 hsmbus->XferOptions = SMBUS_FIRST_FRAME | SMBUS_SENDPEC_MODE; in SMBUS_ConvertOtherXferOptions()
2747 else if (hsmbus->XferOptions == SMBUS_OTHER_AND_LAST_FRAME_NO_PEC) in SMBUS_ConvertOtherXferOptions()
2749 hsmbus->XferOptions = SMBUS_FIRST_AND_LAST_FRAME_NO_PEC; in SMBUS_ConvertOtherXferOptions()
2755 else if (hsmbus->XferOptions == SMBUS_OTHER_AND_LAST_FRAME_WITH_PEC) in SMBUS_ConvertOtherXferOptions()
2757 hsmbus->XferOptions = SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC; in SMBUS_ConvertOtherXferOptions()