#include "main.h" SMBUS_HandleTypeDef hsmbus1; UART_HandleTypeDef huart2; /* USER CODE BEGIN PV */ uint8_t receive_buffer[8]={0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64}; uint8_t Start_uart_flag=0; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_USART2_UART_Init(void); static void MX_I2C1_SMBUS_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART2_UART_Init(); MX_I2C1_SMBUS_Init(); HAL_SMBUS_EnableListen_IT(&hsmbus1); while (1) { HAL_SMBUS_Slave_Receive_IT(&hsmbus1, receive_buffer, 8, SMBUS_FIRST_AND_LAST_FRAME_NO_PEC ); } } void I2C1_IRQHandler(void) { /* USER CODE BEGIN I2C1_IRQn 0 */ /* USER CODE END I2C1_IRQn 0 */ if (hsmbus1.Instance->ISR & (SMBUS_FLAG_BERR | SMBUS_FLAG_ARLO | SMBUS_FLAG_OVR | SMBUS_FLAG_TIMEOUT | SMBUS_FLAG_ALERT | SMBUS_FLAG_PECERR)) { HAL_SMBUS_ER_IRQHandler(&hsmbus1); } else { HAL_SMBUS_EV_IRQHandler(&hsmbus1); HAL_SMBUS_EnableListen_IT(&hsmbus1); } /* USER CODE BEGIN I2C1_IRQn 1 */ /* USER CODE END I2C1_IRQn 1 */ }