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_ALL_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()
316hsmbus->MasterTxCpltCallback = HAL_SMBUS_MasterTxCpltCallback; /* Legacy weak MasterTxCpltCallback… in HAL_SMBUS_Init()
317hsmbus->MasterRxCpltCallback = HAL_SMBUS_MasterRxCpltCallback; /* Legacy weak MasterRxCpltCallback… in HAL_SMBUS_Init()
318hsmbus->SlaveTxCpltCallback = HAL_SMBUS_SlaveTxCpltCallback; /* Legacy weak SlaveTxCpltCallback … in HAL_SMBUS_Init()
319hsmbus->SlaveRxCpltCallback = HAL_SMBUS_SlaveRxCpltCallback; /* Legacy weak SlaveRxCpltCallback … in HAL_SMBUS_Init()
320hsmbus->ListenCpltCallback = HAL_SMBUS_ListenCpltCallback; /* Legacy weak ListenCpltCallback … in HAL_SMBUS_Init()
321hsmbus->ErrorCallback = HAL_SMBUS_ErrorCallback; /* Legacy weak ErrorCallback … in HAL_SMBUS_Init()
322hsmbus->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_ALL_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_ALL_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_ALL_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()
602 HAL_StatusTypeDef HAL_SMBUS_RegisterCallback(SMBUS_HandleTypeDef *hsmbus, in HAL_SMBUS_RegisterCallback() argument
611 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterCallback()
617 __HAL_LOCK(hsmbus); 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()
695 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_RegisterCallback()
717 HAL_StatusTypeDef HAL_SMBUS_UnRegisterCallback(SMBUS_HandleTypeDef *hsmbus, in HAL_SMBUS_UnRegisterCallback() argument
723 __HAL_LOCK(hsmbus); in HAL_SMBUS_UnRegisterCallback()
725 if (HAL_SMBUS_STATE_READY == hsmbus->State) in HAL_SMBUS_UnRegisterCallback()
730hsmbus->MasterTxCpltCallback = HAL_SMBUS_MasterTxCpltCallback; /* Legacy weak MasterTxCpltCallback… in HAL_SMBUS_UnRegisterCallback()
734hsmbus->MasterRxCpltCallback = HAL_SMBUS_MasterRxCpltCallback; /* Legacy weak MasterRxCpltCallback… in HAL_SMBUS_UnRegisterCallback()
738hsmbus->SlaveTxCpltCallback = HAL_SMBUS_SlaveTxCpltCallback; /* Legacy weak SlaveTxCpltCallback … in HAL_SMBUS_UnRegisterCallback()
742hsmbus->SlaveRxCpltCallback = HAL_SMBUS_SlaveRxCpltCallback; /* Legacy weak SlaveRxCpltCallback … in HAL_SMBUS_UnRegisterCallback()
746hsmbus->ListenCpltCallback = HAL_SMBUS_ListenCpltCallback; /* Legacy weak ListenCpltCallback … in HAL_SMBUS_UnRegisterCallback()
750hsmbus->ErrorCallback = HAL_SMBUS_ErrorCallback; /* Legacy weak ErrorCallback … in HAL_SMBUS_UnRegisterCallback()
754hsmbus->MspInitCallback = HAL_SMBUS_MspInit; /* Legacy weak MspInit … in HAL_SMBUS_UnRegisterCallback()
758hsmbus->MspDeInitCallback = HAL_SMBUS_MspDeInit; /* Legacy weak MspDeInit … in HAL_SMBUS_UnRegisterCallback()
763 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterCallback()
770 else if (HAL_SMBUS_STATE_RESET == hsmbus->State) in HAL_SMBUS_UnRegisterCallback()
775hsmbus->MspInitCallback = HAL_SMBUS_MspInit; /* Legacy weak MspInit … in HAL_SMBUS_UnRegisterCallback()
779hsmbus->MspDeInitCallback = HAL_SMBUS_MspDeInit; /* Legacy weak MspDeInit … in HAL_SMBUS_UnRegisterCallback()
784 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterCallback()
794 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterCallback()
801 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_UnRegisterCallback()
813 HAL_StatusTypeDef HAL_SMBUS_RegisterAddrCallback(SMBUS_HandleTypeDef *hsmbus, in HAL_SMBUS_RegisterAddrCallback() argument
821 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterAddrCallback()
826 __HAL_LOCK(hsmbus); in HAL_SMBUS_RegisterAddrCallback()
828 if (HAL_SMBUS_STATE_READY == hsmbus->State) in HAL_SMBUS_RegisterAddrCallback()
830 hsmbus->AddrCallback = pCallback; in HAL_SMBUS_RegisterAddrCallback()
835 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_RegisterAddrCallback()
842 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_RegisterAddrCallback()
853 HAL_StatusTypeDef HAL_SMBUS_UnRegisterAddrCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_UnRegisterAddrCallback() argument
858 __HAL_LOCK(hsmbus); in HAL_SMBUS_UnRegisterAddrCallback()
860 if (HAL_SMBUS_STATE_READY == hsmbus->State) in HAL_SMBUS_UnRegisterAddrCallback()
862 hsmbus->AddrCallback = HAL_SMBUS_AddrCallback; /* Legacy weak AddrCallback */ in HAL_SMBUS_UnRegisterAddrCallback()
867 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK; in HAL_SMBUS_UnRegisterAddrCallback()
874 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_UnRegisterAddrCallback()
938 HAL_StatusTypeDef HAL_SMBUS_Master_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, in HAL_SMBUS_Master_Transmit_IT() argument
946 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_Master_Transmit_IT()
949 __HAL_LOCK(hsmbus); in HAL_SMBUS_Master_Transmit_IT()
951 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_TX; in HAL_SMBUS_Master_Transmit_IT()
952 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Master_Transmit_IT()
954 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Master_Transmit_IT()
955 hsmbus->XferCount = Size; in HAL_SMBUS_Master_Transmit_IT()
956 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Master_Transmit_IT()
960 if (hsmbus->pBuffPtr == NULL) in HAL_SMBUS_Master_Transmit_IT()
962 hsmbus->XferOptions &= ~SMBUS_AUTOEND_MODE; in HAL_SMBUS_Master_Transmit_IT()
967 hsmbus->XferSize = MAX_NBYTE_SIZE; in HAL_SMBUS_Master_Transmit_IT()
971 hsmbus->XferSize = Size; in HAL_SMBUS_Master_Transmit_IT()
976 if ((hsmbus->XferSize < hsmbus->XferCount) && (hsmbus->XferSize == MAX_NBYTE_SIZE)) in HAL_SMBUS_Master_Transmit_IT()
978 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Transmit_IT()
979 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in HAL_SMBUS_Master_Transmit_IT()
988 tmp = hsmbus->XferOptions; in HAL_SMBUS_Master_Transmit_IT()
990 if ((hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_TX) && \ in HAL_SMBUS_Master_Transmit_IT()
993 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Master_Transmit_IT()
1000 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Master_Transmit_IT()
1003 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Transmit_IT()
1004 hsmbus->XferOptions, in HAL_SMBUS_Master_Transmit_IT()
1010 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in HAL_SMBUS_Master_Transmit_IT()
1012 hsmbus->XferSize--; in HAL_SMBUS_Master_Transmit_IT()
1013 hsmbus->XferCount--; in HAL_SMBUS_Master_Transmit_IT()
1018 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Master_Transmit_IT()
1023 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_TX); in HAL_SMBUS_Master_Transmit_IT()
1044 HAL_StatusTypeDef HAL_SMBUS_Master_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uin… in HAL_SMBUS_Master_Receive_IT() argument
1052 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_Master_Receive_IT()
1055 __HAL_LOCK(hsmbus); in HAL_SMBUS_Master_Receive_IT()
1057 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_RX; in HAL_SMBUS_Master_Receive_IT()
1058 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Master_Receive_IT()
1061 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Master_Receive_IT()
1062 hsmbus->XferCount = Size; in HAL_SMBUS_Master_Receive_IT()
1063 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Master_Receive_IT()
1067 if (hsmbus->pBuffPtr == NULL) in HAL_SMBUS_Master_Receive_IT()
1069 hsmbus->XferOptions &= ~SMBUS_AUTOEND_MODE; in HAL_SMBUS_Master_Receive_IT()
1074 hsmbus->XferSize = MAX_NBYTE_SIZE; in HAL_SMBUS_Master_Receive_IT()
1078 hsmbus->XferSize = Size; in HAL_SMBUS_Master_Receive_IT()
1083 if ((hsmbus->XferSize < hsmbus->XferCount) && (hsmbus->XferSize == MAX_NBYTE_SIZE)) in HAL_SMBUS_Master_Receive_IT()
1085 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Receive_IT()
1086 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in HAL_SMBUS_Master_Receive_IT()
1095 tmp = hsmbus->XferOptions; in HAL_SMBUS_Master_Receive_IT()
1097 if ((hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_RX) && \ in HAL_SMBUS_Master_Receive_IT()
1100 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Master_Receive_IT()
1107 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Master_Receive_IT()
1110 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Master_Receive_IT()
1111 hsmbus->XferOptions, in HAL_SMBUS_Master_Receive_IT()
1117 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Master_Receive_IT()
1122 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_RX); in HAL_SMBUS_Master_Receive_IT()
1141 HAL_StatusTypeDef HAL_SMBUS_Master_Abort_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress) in HAL_SMBUS_Master_Abort_IT() argument
1143 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_Master_Abort_IT()
1146 __HAL_LOCK(hsmbus); in HAL_SMBUS_Master_Abort_IT()
1150 if (hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_TX) in HAL_SMBUS_Master_Abort_IT()
1152 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_TX; in HAL_SMBUS_Master_Abort_IT()
1154 else if (hsmbus->PreviousState == HAL_SMBUS_STATE_MASTER_BUSY_RX) in HAL_SMBUS_Master_Abort_IT()
1156 hsmbus->State = HAL_SMBUS_STATE_MASTER_BUSY_RX; in HAL_SMBUS_Master_Abort_IT()
1164 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Master_Abort_IT()
1168 SMBUS_TransferConfig(hsmbus, DevAddress, 1, SMBUS_AUTOEND_MODE, SMBUS_NO_STARTSTOP); in HAL_SMBUS_Master_Abort_IT()
1171 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Master_Abort_IT()
1176 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in HAL_SMBUS_Master_Abort_IT()
1178 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_TX); in HAL_SMBUS_Master_Abort_IT()
1180 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in HAL_SMBUS_Master_Abort_IT()
1182 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_RX); in HAL_SMBUS_Master_Abort_IT()
1206 HAL_StatusTypeDef HAL_SMBUS_Slave_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t… in HAL_SMBUS_Slave_Transmit_IT() argument
1212 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_Slave_Transmit_IT()
1216 hsmbus->ErrorCode = HAL_SMBUS_ERROR_INVALID_PARAM; in HAL_SMBUS_Slave_Transmit_IT()
1221 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR | SMBUS_IT_TX); in HAL_SMBUS_Slave_Transmit_IT()
1224 __HAL_LOCK(hsmbus); in HAL_SMBUS_Slave_Transmit_IT()
1226 hsmbus->State = (HAL_SMBUS_STATE_SLAVE_BUSY_TX | HAL_SMBUS_STATE_LISTEN); in HAL_SMBUS_Slave_Transmit_IT()
1227 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Slave_Transmit_IT()
1230 hsmbus->Instance->CR1 |= I2C_CR1_SBC; in HAL_SMBUS_Slave_Transmit_IT()
1233 hsmbus->Instance->CR2 &= ~I2C_CR2_NACK; in HAL_SMBUS_Slave_Transmit_IT()
1236 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Slave_Transmit_IT()
1237 hsmbus->XferCount = Size; in HAL_SMBUS_Slave_Transmit_IT()
1238 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Slave_Transmit_IT()
1241 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Slave_Transmit_IT()
1245 hsmbus->XferSize = MAX_NBYTE_SIZE; in HAL_SMBUS_Slave_Transmit_IT()
1249 hsmbus->XferSize = Size; in HAL_SMBUS_Slave_Transmit_IT()
1253 if ((hsmbus->XferSize < hsmbus->XferCount) && (hsmbus->XferSize == MAX_NBYTE_SIZE)) in HAL_SMBUS_Slave_Transmit_IT()
1255 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, in HAL_SMBUS_Slave_Transmit_IT()
1256 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in HAL_SMBUS_Slave_Transmit_IT()
1262 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Slave_Transmit_IT()
1267 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in HAL_SMBUS_Slave_Transmit_IT()
1269 hsmbus->XferSize--; in HAL_SMBUS_Slave_Transmit_IT()
1270 hsmbus->XferCount--; in HAL_SMBUS_Slave_Transmit_IT()
1276 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ADDR); in HAL_SMBUS_Slave_Transmit_IT()
1279 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Slave_Transmit_IT()
1285 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_TX | SMBUS_IT_ADDR); in HAL_SMBUS_Slave_Transmit_IT()
1304 HAL_StatusTypeDef HAL_SMBUS_Slave_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t … in HAL_SMBUS_Slave_Receive_IT() argument
1310 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_Slave_Receive_IT()
1314 hsmbus->ErrorCode = HAL_SMBUS_ERROR_INVALID_PARAM; in HAL_SMBUS_Slave_Receive_IT()
1319 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR | SMBUS_IT_RX); in HAL_SMBUS_Slave_Receive_IT()
1322 __HAL_LOCK(hsmbus); in HAL_SMBUS_Slave_Receive_IT()
1324 hsmbus->State = (HAL_SMBUS_STATE_SLAVE_BUSY_RX | HAL_SMBUS_STATE_LISTEN); in HAL_SMBUS_Slave_Receive_IT()
1325 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_Slave_Receive_IT()
1328 hsmbus->Instance->CR1 |= I2C_CR1_SBC; in HAL_SMBUS_Slave_Receive_IT()
1331 hsmbus->Instance->CR2 &= ~I2C_CR2_NACK; in HAL_SMBUS_Slave_Receive_IT()
1334 hsmbus->pBuffPtr = pData; in HAL_SMBUS_Slave_Receive_IT()
1335 hsmbus->XferSize = Size; in HAL_SMBUS_Slave_Receive_IT()
1336 hsmbus->XferCount = Size; in HAL_SMBUS_Slave_Receive_IT()
1337 hsmbus->XferOptions = XferOptions; in HAL_SMBUS_Slave_Receive_IT()
1340 SMBUS_ConvertOtherXferOptions(hsmbus); in HAL_SMBUS_Slave_Receive_IT()
1347 … if (((SMBUS_GET_PEC_MODE(hsmbus) != 0UL) && (hsmbus->XferSize == 2U)) || (hsmbus->XferSize == 1U)) in HAL_SMBUS_Slave_Receive_IT()
1349 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in HAL_SMBUS_Slave_Receive_IT()
1354 … SMBUS_TransferConfig(hsmbus, 0, 1, hsmbus->XferOptions | SMBUS_RELOAD_MODE, SMBUS_NO_STARTSTOP); in HAL_SMBUS_Slave_Receive_IT()
1359 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ADDR); in HAL_SMBUS_Slave_Receive_IT()
1362 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_Slave_Receive_IT()
1368 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_RX | SMBUS_IT_ADDR); in HAL_SMBUS_Slave_Receive_IT()
1384 HAL_StatusTypeDef HAL_SMBUS_EnableListen_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_EnableListen_IT() argument
1386 hsmbus->State = HAL_SMBUS_STATE_LISTEN; in HAL_SMBUS_EnableListen_IT()
1389 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_ADDR); in HAL_SMBUS_EnableListen_IT()
1400 HAL_StatusTypeDef HAL_SMBUS_DisableListen_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_DisableListen_IT() argument
1403 if (hsmbus->State == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_DisableListen_IT()
1405 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_DisableListen_IT()
1408 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR); in HAL_SMBUS_DisableListen_IT()
1424 HAL_StatusTypeDef HAL_SMBUS_EnableAlert_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_EnableAlert_IT() argument
1427 hsmbus->Instance->CR1 |= I2C_CR1_ALERTEN; in HAL_SMBUS_EnableAlert_IT()
1430 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ALERT); in HAL_SMBUS_EnableAlert_IT()
1433 SMBUS_Enable_IRQ(hsmbus, SMBUS_IT_ALERT); in HAL_SMBUS_EnableAlert_IT()
1443 HAL_StatusTypeDef HAL_SMBUS_DisableAlert_IT(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_DisableAlert_IT() argument
1446 hsmbus->Instance->CR1 &= ~I2C_CR1_ALERTEN; in HAL_SMBUS_DisableAlert_IT()
1449 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ALERT); in HAL_SMBUS_DisableAlert_IT()
1464 HAL_StatusTypeDef HAL_SMBUS_IsDeviceReady(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint32_… in HAL_SMBUS_IsDeviceReady() argument
1474 if (hsmbus->State == HAL_SMBUS_STATE_READY) in HAL_SMBUS_IsDeviceReady()
1476 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_BUSY) != RESET) in HAL_SMBUS_IsDeviceReady()
1482 __HAL_LOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1484 hsmbus->State = HAL_SMBUS_STATE_BUSY; in HAL_SMBUS_IsDeviceReady()
1485 hsmbus->ErrorCode = HAL_SMBUS_ERROR_NONE; in HAL_SMBUS_IsDeviceReady()
1490 hsmbus->Instance->CR2 = SMBUS_GENERATE_START(hsmbus->Init.AddressingMode, DevAddress); in HAL_SMBUS_IsDeviceReady()
1496 tmp1 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1497 tmp2 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF); in HAL_SMBUS_IsDeviceReady()
1506 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_IsDeviceReady()
1509 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT; in HAL_SMBUS_IsDeviceReady()
1512 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1517 tmp1 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1518 tmp2 = __HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF); in HAL_SMBUS_IsDeviceReady()
1522 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_AF) == RESET) in HAL_SMBUS_IsDeviceReady()
1525 if (SMBUS_WaitOnFlagUntilTimeout(hsmbus, SMBUS_FLAG_STOPF, RESET, Timeout) != HAL_OK) in HAL_SMBUS_IsDeviceReady()
1531 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1534 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_IsDeviceReady()
1537 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1544 if (SMBUS_WaitOnFlagUntilTimeout(hsmbus, SMBUS_FLAG_STOPF, RESET, Timeout) != HAL_OK) in HAL_SMBUS_IsDeviceReady()
1550 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in HAL_SMBUS_IsDeviceReady()
1553 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1560 hsmbus->Instance->CR2 |= I2C_CR2_STOP; in HAL_SMBUS_IsDeviceReady()
1563 if (SMBUS_WaitOnFlagUntilTimeout(hsmbus, SMBUS_FLAG_STOPF, RESET, Timeout) != HAL_OK) in HAL_SMBUS_IsDeviceReady()
1569 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in HAL_SMBUS_IsDeviceReady()
1576 hsmbus->State = HAL_SMBUS_STATE_READY; in HAL_SMBUS_IsDeviceReady()
1579 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT; in HAL_SMBUS_IsDeviceReady()
1582 __HAL_UNLOCK(hsmbus); in HAL_SMBUS_IsDeviceReady()
1605 void HAL_SMBUS_EV_IRQHandler(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_EV_IRQHandler() argument
1609 uint32_t tmpisrvalue = READ_REG(hsmbus->Instance->ISR); in HAL_SMBUS_EV_IRQHandler()
1610 uint32_t tmpcr1value = READ_REG(hsmbus->Instance->CR1); in HAL_SMBUS_EV_IRQHandler()
1622 if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_TX) == HAL_SMBUS_STATE_SLAVE_BUSY_TX) in HAL_SMBUS_EV_IRQHandler()
1624 (void)SMBUS_Slave_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1627 else if ((hsmbus->State & HAL_SMBUS_STATE_MASTER_BUSY_TX) == HAL_SMBUS_STATE_MASTER_BUSY_TX) in HAL_SMBUS_EV_IRQHandler()
1629 (void)SMBUS_Master_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1647 if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_RX) == HAL_SMBUS_STATE_SLAVE_BUSY_RX) in HAL_SMBUS_EV_IRQHandler()
1649 (void)SMBUS_Slave_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1652 else if ((hsmbus->State & HAL_SMBUS_STATE_MASTER_BUSY_RX) == HAL_SMBUS_STATE_MASTER_BUSY_RX) in HAL_SMBUS_EV_IRQHandler()
1654 (void)SMBUS_Master_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1670 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in HAL_SMBUS_EV_IRQHandler()
1672 (void)SMBUS_Slave_ISR(hsmbus, tmpisrvalue); in HAL_SMBUS_EV_IRQHandler()
1683 void HAL_SMBUS_ER_IRQHandler(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_ER_IRQHandler() argument
1685 SMBUS_ITErrorHandler(hsmbus); in HAL_SMBUS_ER_IRQHandler()
1694 __weak void HAL_SMBUS_MasterTxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_MasterTxCpltCallback() argument
1697 UNUSED(hsmbus); in HAL_SMBUS_MasterTxCpltCallback()
1710 __weak void HAL_SMBUS_MasterRxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_MasterRxCpltCallback() argument
1713 UNUSED(hsmbus); in HAL_SMBUS_MasterRxCpltCallback()
1725 __weak void HAL_SMBUS_SlaveTxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_SlaveTxCpltCallback() argument
1728 UNUSED(hsmbus); in HAL_SMBUS_SlaveTxCpltCallback()
1741 __weak void HAL_SMBUS_SlaveRxCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_SlaveRxCpltCallback() argument
1744 UNUSED(hsmbus); in HAL_SMBUS_SlaveRxCpltCallback()
1759 __weak void HAL_SMBUS_AddrCallback(SMBUS_HandleTypeDef *hsmbus, uint8_t TransferDirection, in HAL_SMBUS_AddrCallback() argument
1763 UNUSED(hsmbus); in HAL_SMBUS_AddrCallback()
1778 __weak void HAL_SMBUS_ListenCpltCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_ListenCpltCallback() argument
1781 UNUSED(hsmbus); in HAL_SMBUS_ListenCpltCallback()
1794 __weak void HAL_SMBUS_ErrorCallback(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_ErrorCallback() argument
1797 UNUSED(hsmbus); in HAL_SMBUS_ErrorCallback()
1829 uint32_t HAL_SMBUS_GetState(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_GetState() argument
1832 return hsmbus->State; in HAL_SMBUS_GetState()
1841 uint32_t HAL_SMBUS_GetError(SMBUS_HandleTypeDef *hsmbus) in HAL_SMBUS_GetError() argument
1843 return hsmbus->ErrorCode; in HAL_SMBUS_GetError()
1866 static HAL_StatusTypeDef SMBUS_Master_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t StatusFlags) in SMBUS_Master_ISR() argument
1871 __HAL_LOCK(hsmbus); in SMBUS_Master_ISR()
1876 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in SMBUS_Master_ISR()
1880 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ACKF; in SMBUS_Master_ISR()
1883 SMBUS_Flush_TXDR(hsmbus); in SMBUS_Master_ISR()
1886 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
1890 hsmbus->ErrorCallback(hsmbus); in SMBUS_Master_ISR()
1892 HAL_SMBUS_ErrorCallback(hsmbus); in SMBUS_Master_ISR()
1898 SMBUS_ITErrorHandler(hsmbus); in SMBUS_Master_ISR()
1901 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in SMBUS_Master_ISR()
1904 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Master_ISR()
1907 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in SMBUS_Master_ISR()
1910 SMBUS_RESET_CR2(hsmbus); in SMBUS_Master_ISR()
1914 __HAL_SMBUS_DISABLE(hsmbus); in SMBUS_Master_ISR()
1916 hsmbus->PreviousState = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1917 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1920 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
1923 __HAL_SMBUS_ENABLE(hsmbus); in SMBUS_Master_ISR()
1927 hsmbus->MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1929 HAL_SMBUS_MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1932 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in SMBUS_Master_ISR()
1938 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Master_ISR()
1941 hsmbus->pBuffPtr++; in SMBUS_Master_ISR()
1943 if ((hsmbus->XferSize > 0U)) in SMBUS_Master_ISR()
1945 hsmbus->XferSize--; in SMBUS_Master_ISR()
1946 hsmbus->XferCount--; in SMBUS_Master_ISR()
1951 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Master_ISR()
1954 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in SMBUS_Master_ISR()
1957 SMBUS_RESET_CR2(hsmbus); in SMBUS_Master_ISR()
1959 hsmbus->PreviousState = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1960 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
1963 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
1967 hsmbus->MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1969 HAL_SMBUS_MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
1980 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Master_ISR()
1983 hsmbus->pBuffPtr++; in SMBUS_Master_ISR()
1986 hsmbus->XferSize--; in SMBUS_Master_ISR()
1987 hsmbus->XferCount--; in SMBUS_Master_ISR()
1992 hsmbus->Instance->TXDR = *hsmbus->pBuffPtr; in SMBUS_Master_ISR()
1995 hsmbus->pBuffPtr++; in SMBUS_Master_ISR()
1998 hsmbus->XferSize--; in SMBUS_Master_ISR()
1999 hsmbus->XferCount--; in SMBUS_Master_ISR()
2003 if ((hsmbus->XferCount != 0U) && (hsmbus->XferSize == 0U)) in SMBUS_Master_ISR()
2005 DevAddress = (uint16_t)(hsmbus->Instance->CR2 & I2C_CR2_SADD); in SMBUS_Master_ISR()
2007 if (hsmbus->XferCount > MAX_NBYTE_SIZE) in SMBUS_Master_ISR()
2009 SMBUS_TransferConfig(hsmbus, DevAddress, MAX_NBYTE_SIZE, in SMBUS_Master_ISR()
2010 (SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE)), in SMBUS_Master_ISR()
2012 hsmbus->XferSize = MAX_NBYTE_SIZE; in SMBUS_Master_ISR()
2016 hsmbus->XferSize = hsmbus->XferCount; in SMBUS_Master_ISR()
2017 SMBUS_TransferConfig(hsmbus, DevAddress, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in SMBUS_Master_ISR()
2021 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in SMBUS_Master_ISR()
2023 hsmbus->XferSize--; in SMBUS_Master_ISR()
2024 hsmbus->XferCount--; in SMBUS_Master_ISR()
2028 else if ((hsmbus->XferCount == 0U) && (hsmbus->XferSize == 0U)) in SMBUS_Master_ISR()
2031 if (SMBUS_GET_STOP_MODE(hsmbus) != SMBUS_AUTOEND_MODE) in SMBUS_Master_ISR()
2034 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in SMBUS_Master_ISR()
2037 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Master_ISR()
2038 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2039 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2042 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2046 hsmbus->MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2048 HAL_SMBUS_MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2051 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in SMBUS_Master_ISR()
2053 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Master_ISR()
2054 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2055 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2058 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2062 hsmbus->MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2064 HAL_SMBUS_MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2080 if (hsmbus->XferCount == 0U) in SMBUS_Master_ISR()
2083 if (hsmbus->pBuffPtr == NULL) in SMBUS_Master_ISR()
2086 hsmbus->Instance->CR2 |= I2C_CR2_STOP; in SMBUS_Master_ISR()
2089 else if (SMBUS_GET_STOP_MODE(hsmbus) != SMBUS_AUTOEND_MODE) in SMBUS_Master_ISR()
2095 if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_TX) in SMBUS_Master_ISR()
2098 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Master_ISR()
2099 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2100 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2103 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2107 hsmbus->MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2109 HAL_SMBUS_MasterTxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2112 else if (hsmbus->State == HAL_SMBUS_STATE_MASTER_BUSY_RX) in SMBUS_Master_ISR()
2114 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Master_ISR()
2115 hsmbus->PreviousState = hsmbus->State; in SMBUS_Master_ISR()
2116 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Master_ISR()
2119 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2123 hsmbus->MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2125 HAL_SMBUS_MasterRxCpltCallback(hsmbus); in SMBUS_Master_ISR()
2145 __HAL_UNLOCK(hsmbus); in SMBUS_Master_ISR()
2156 static HAL_StatusTypeDef SMBUS_Slave_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t StatusFlags) in SMBUS_Slave_ISR() argument
2162 __HAL_LOCK(hsmbus); in SMBUS_Slave_ISR()
2170 if (hsmbus->XferCount == 0U) in SMBUS_Slave_ISR()
2173 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in SMBUS_Slave_ISR()
2176 SMBUS_Flush_TXDR(hsmbus); in SMBUS_Slave_ISR()
2179 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2185 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF); in SMBUS_Slave_ISR()
2189 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2190 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_TX); in SMBUS_Slave_ISR()
2191 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_RX); in SMBUS_Slave_ISR()
2194 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX | SMBUS_IT_TX); in SMBUS_Slave_ISR()
2197 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ACKF; in SMBUS_Slave_ISR()
2200 SMBUS_Flush_TXDR(hsmbus); in SMBUS_Slave_ISR()
2203 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2207 hsmbus->ErrorCallback(hsmbus); in SMBUS_Slave_ISR()
2209 HAL_SMBUS_ErrorCallback(hsmbus); in SMBUS_Slave_ISR()
2215 TransferDirection = (uint8_t)(SMBUS_GET_DIR(hsmbus)); in SMBUS_Slave_ISR()
2216 SlaveAddrCode = (uint16_t)(SMBUS_GET_ADDR_MATCH(hsmbus)); in SMBUS_Slave_ISR()
2220 __HAL_SMBUS_DISABLE_IT(hsmbus, SMBUS_IT_ADDRI); in SMBUS_Slave_ISR()
2223 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2227 hsmbus->AddrCallback(hsmbus, TransferDirection, SlaveAddrCode); in SMBUS_Slave_ISR()
2229 HAL_SMBUS_AddrCallback(hsmbus, TransferDirection, SlaveAddrCode); in SMBUS_Slave_ISR()
2235 if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_RX) == HAL_SMBUS_STATE_SLAVE_BUSY_RX) in SMBUS_Slave_ISR()
2238 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Slave_ISR()
2241 hsmbus->pBuffPtr++; in SMBUS_Slave_ISR()
2243 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2244 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2246 if (hsmbus->XferCount == 1U) in SMBUS_Slave_ISR()
2251 hsmbus->XferOptions &= ~SMBUS_RELOAD_MODE; in SMBUS_Slave_ISR()
2252 SMBUS_TransferConfig(hsmbus, 0, 1, hsmbus->XferOptions, SMBUS_NO_STARTSTOP); in SMBUS_Slave_ISR()
2254 else if (hsmbus->XferCount == 0U) in SMBUS_Slave_ISR()
2257 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX); in SMBUS_Slave_ISR()
2260 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2261 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_RX); in SMBUS_Slave_ISR()
2264 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2268 hsmbus->SlaveRxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2270 HAL_SMBUS_SlaveRxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2276 SMBUS_TransferConfig(hsmbus, 0, 1, in SMBUS_Slave_ISR()
2277 SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE), in SMBUS_Slave_ISR()
2281 hsmbus->Instance->CR2 &= ~I2C_CR2_NACK; in SMBUS_Slave_ISR()
2284 else if ((hsmbus->State & HAL_SMBUS_STATE_SLAVE_BUSY_TX) == HAL_SMBUS_STATE_SLAVE_BUSY_TX) in SMBUS_Slave_ISR()
2286 if ((hsmbus->XferCount != 0U) && (hsmbus->XferSize == 0U)) in SMBUS_Slave_ISR()
2288 if (hsmbus->XferCount > MAX_NBYTE_SIZE) in SMBUS_Slave_ISR()
2290 SMBUS_TransferConfig(hsmbus, 0, MAX_NBYTE_SIZE, in SMBUS_Slave_ISR()
2291 (SMBUS_RELOAD_MODE | (hsmbus->XferOptions & SMBUS_SENDPEC_MODE)), in SMBUS_Slave_ISR()
2293 hsmbus->XferSize = MAX_NBYTE_SIZE; in SMBUS_Slave_ISR()
2297 hsmbus->XferSize = hsmbus->XferCount; in SMBUS_Slave_ISR()
2298 SMBUS_TransferConfig(hsmbus, 0, (uint8_t)hsmbus->XferSize, hsmbus->XferOptions, in SMBUS_Slave_ISR()
2302 if (SMBUS_GET_PEC_MODE(hsmbus) != 0UL) in SMBUS_Slave_ISR()
2304 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2305 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2321 if (hsmbus->XferCount > 0U) in SMBUS_Slave_ISR()
2324 hsmbus->Instance->TXDR = *hsmbus->pBuffPtr; in SMBUS_Slave_ISR()
2327 hsmbus->pBuffPtr++; in SMBUS_Slave_ISR()
2329 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2330 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2333 if (hsmbus->XferCount == 0U) in SMBUS_Slave_ISR()
2337 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_TX); in SMBUS_Slave_ISR()
2338 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2339 hsmbus->State &= ~((uint32_t)HAL_SMBUS_STATE_SLAVE_BUSY_TX); in SMBUS_Slave_ISR()
2342 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2346 hsmbus->SlaveTxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2348 HAL_SMBUS_SlaveTxCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2360 if ((hsmbus->State & HAL_SMBUS_STATE_LISTEN) == HAL_SMBUS_STATE_LISTEN) in SMBUS_Slave_ISR()
2363 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_RXNE) != RESET) in SMBUS_Slave_ISR()
2366 *hsmbus->pBuffPtr = (uint8_t)(hsmbus->Instance->RXDR); in SMBUS_Slave_ISR()
2369 hsmbus->pBuffPtr++; in SMBUS_Slave_ISR()
2371 if ((hsmbus->XferSize > 0U)) in SMBUS_Slave_ISR()
2373 hsmbus->XferSize--; in SMBUS_Slave_ISR()
2374 hsmbus->XferCount--; in SMBUS_Slave_ISR()
2379 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_RX | SMBUS_IT_TX); in SMBUS_Slave_ISR()
2382 SMBUS_Disable_IRQ(hsmbus, SMBUS_IT_ADDR); in SMBUS_Slave_ISR()
2385 hsmbus->Instance->CR2 |= I2C_CR2_NACK; in SMBUS_Slave_ISR()
2388 SMBUS_RESET_CR2(hsmbus); in SMBUS_Slave_ISR()
2391 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_STOPF); in SMBUS_Slave_ISR()
2394 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ADDR); in SMBUS_Slave_ISR()
2396 hsmbus->XferOptions = 0; in SMBUS_Slave_ISR()
2397 hsmbus->PreviousState = hsmbus->State; in SMBUS_Slave_ISR()
2398 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_Slave_ISR()
2401 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2405 hsmbus->ListenCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2407 HAL_SMBUS_ListenCpltCallback(hsmbus); in SMBUS_Slave_ISR()
2413 __HAL_UNLOCK(hsmbus); in SMBUS_Slave_ISR()
2424 static void SMBUS_Enable_IRQ(SMBUS_HandleTypeDef *hsmbus, uint32_t InterruptRequest) in SMBUS_Enable_IRQ() argument
2455 __HAL_SMBUS_ENABLE_IT(hsmbus, tmpisr); in SMBUS_Enable_IRQ()
2464 static void SMBUS_Disable_IRQ(SMBUS_HandleTypeDef *hsmbus, uint32_t InterruptRequest) in SMBUS_Disable_IRQ() argument
2467 uint32_t tmpstate = hsmbus->State; in SMBUS_Disable_IRQ()
2480 if ((SMBUS_GET_ALERT_ENABLED(hsmbus) == 0UL) in SMBUS_Disable_IRQ()
2499 if ((SMBUS_GET_ALERT_ENABLED(hsmbus) == 0UL) in SMBUS_Disable_IRQ()
2518 if (SMBUS_GET_ALERT_ENABLED(hsmbus) == 0UL) in SMBUS_Disable_IRQ()
2528 __HAL_SMBUS_DISABLE_IT(hsmbus, tmpisr); in SMBUS_Disable_IRQ()
2536 static void SMBUS_ITErrorHandler(SMBUS_HandleTypeDef *hsmbus) in SMBUS_ITErrorHandler() argument
2538 uint32_t itflags = READ_REG(hsmbus->Instance->ISR); in SMBUS_ITErrorHandler()
2539 uint32_t itsources = READ_REG(hsmbus->Instance->CR1); in SMBUS_ITErrorHandler()
2547 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_BERR; in SMBUS_ITErrorHandler()
2550 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_BERR); in SMBUS_ITErrorHandler()
2557 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_OVR; in SMBUS_ITErrorHandler()
2560 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_OVR); in SMBUS_ITErrorHandler()
2567 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ARLO; in SMBUS_ITErrorHandler()
2570 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ARLO); in SMBUS_ITErrorHandler()
2577 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_BUSTIMEOUT; in SMBUS_ITErrorHandler()
2580 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_TIMEOUT); in SMBUS_ITErrorHandler()
2587 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_ALERT; in SMBUS_ITErrorHandler()
2590 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_ALERT); in SMBUS_ITErrorHandler()
2597 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_PECERR; in SMBUS_ITErrorHandler()
2600 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_PECERR); in SMBUS_ITErrorHandler()
2604 SMBUS_Flush_TXDR(hsmbus); in SMBUS_ITErrorHandler()
2607 tmperror = hsmbus->ErrorCode; in SMBUS_ITErrorHandler()
2616 tmpstate = hsmbus->State; in SMBUS_ITErrorHandler()
2623 hsmbus->PreviousState = HAL_SMBUS_STATE_READY; in SMBUS_ITErrorHandler()
2624 hsmbus->State = HAL_SMBUS_STATE_LISTEN; in SMBUS_ITErrorHandler()
2630 hsmbus->ErrorCallback(hsmbus); in SMBUS_ITErrorHandler()
2632 HAL_SMBUS_ErrorCallback(hsmbus); in SMBUS_ITErrorHandler()
2646 static HAL_StatusTypeDef SMBUS_WaitOnFlagUntilTimeout(SMBUS_HandleTypeDef *hsmbus, uint32_t Flag, in SMBUS_WaitOnFlagUntilTimeout() argument
2652 while ((FlagStatus)(__HAL_SMBUS_GET_FLAG(hsmbus, Flag)) == Status) in SMBUS_WaitOnFlagUntilTimeout()
2659 hsmbus->PreviousState = hsmbus->State; in SMBUS_WaitOnFlagUntilTimeout()
2660 hsmbus->State = HAL_SMBUS_STATE_READY; in SMBUS_WaitOnFlagUntilTimeout()
2663 hsmbus->ErrorCode |= HAL_SMBUS_ERROR_HALTIMEOUT; in SMBUS_WaitOnFlagUntilTimeout()
2666 __HAL_UNLOCK(hsmbus); in SMBUS_WaitOnFlagUntilTimeout()
2681 static void SMBUS_Flush_TXDR(SMBUS_HandleTypeDef *hsmbus) in SMBUS_Flush_TXDR() argument
2685 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_TXIS) != RESET) in SMBUS_Flush_TXDR()
2687 hsmbus->Instance->TXDR = 0x00U; in SMBUS_Flush_TXDR()
2691 if (__HAL_SMBUS_GET_FLAG(hsmbus, SMBUS_FLAG_TXE) == RESET) in SMBUS_Flush_TXDR()
2693 __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_TXE); in SMBUS_Flush_TXDR()
2717 static void SMBUS_TransferConfig(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t Size, in SMBUS_TransferConfig() argument
2721 assert_param(IS_SMBUS_ALL_INSTANCE(hsmbus->Instance)); in SMBUS_TransferConfig()
2726 MODIFY_REG(hsmbus->Instance->CR2, in SMBUS_TransferConfig()
2740 static void SMBUS_ConvertOtherXferOptions(SMBUS_HandleTypeDef *hsmbus) in SMBUS_ConvertOtherXferOptions() argument
2745 if (hsmbus->XferOptions == SMBUS_OTHER_FRAME_NO_PEC) in SMBUS_ConvertOtherXferOptions()
2747 hsmbus->XferOptions = SMBUS_FIRST_FRAME; in SMBUS_ConvertOtherXferOptions()
2752 else if (hsmbus->XferOptions == SMBUS_OTHER_FRAME_WITH_PEC) in SMBUS_ConvertOtherXferOptions()
2754 hsmbus->XferOptions = SMBUS_FIRST_FRAME | SMBUS_SENDPEC_MODE; in SMBUS_ConvertOtherXferOptions()
2760 else if (hsmbus->XferOptions == SMBUS_OTHER_AND_LAST_FRAME_NO_PEC) in SMBUS_ConvertOtherXferOptions()
2762 hsmbus->XferOptions = SMBUS_FIRST_AND_LAST_FRAME_NO_PEC; in SMBUS_ConvertOtherXferOptions()
2768 else if (hsmbus->XferOptions == SMBUS_OTHER_AND_LAST_FRAME_WITH_PEC) in SMBUS_ConvertOtherXferOptions()
2770 hsmbus->XferOptions = SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC; in SMBUS_ConvertOtherXferOptions()