stm32 i2c中断接收,一直不能收到,配置如下,ST的FAE请帮助解答,谢谢! 各位大神,如有遇到类似问题,请提供解决方案, 我的配置如下: void I2C_Master_Receive_Config(I2C_DataStruct *st_RxData, uint8_t u8_MemAddr, uint8_t *pu8_Data, uint16_t u16_Size ) { uint32_t u32_TimeOut; if (((uint8_t *)NULL == pu8_Data) || (0 == u16_Size)) { return; } st_RxData->pu8_BuffPtr = pu8_Data; st_RxData->u16_Size = u16_Size; //I2C_Master_Config(&gst_RxData,u8_MemAddr,st_RxData->u16_Size, I2C_GENERATE_START_READ,I2C_ISR_TC); u32_TimeOut = GET_SYSTEM_TICK_VALUE(); while (__HAL_I2C_GET_FLAG(I2C_ISR_BUSY)) { if (GET_SYSTEM_TICK_ECLIPSE(u32_TimeOut) > CHECK_STATUS_TIMEROUT_TICK) { break; } } /* 1: send 1 byte EEPROM start address */ I2C_TransferConfig(I2C1_SLAVE_ADDR, 1, I2C_CR2_AUTOEND, I2C_GENERATE_START_WRITE); u32_TimeOut = GET_SYSTEM_TICK_VALUE(); while (!__HAL_I2C_GET_FLAG(I2C_ISR_TXIS)) { if (GET_SYSTEM_TICK_ECLIPSE(u32_TimeOut) > CHECK_STATUS_TIMEROUT_TICK) { break; } } I2C_CHANNEL->TXDR = u8_MemAddr; u32_TimeOut = GET_SYSTEM_TICK_VALUE(); /* Wait until TXE flag is set */ while (!__HAL_I2C_GET_FLAG(I2C_ISR_TC)) { if (GET_SYSTEM_TICK_ECLIPSE(u32_TimeOut) > CHECK_STATUS_TIMEROUT_TICK) { break; } } if (u16_Size > TXRX_DATA_MAX) { st_RxData->u16_Count = TXRX_DATA_MAX; } else { st_RxData->u16_Count = u16_Size; } if ((st_RxData->u16_Count == TXRX_DATA_MAX) && (st_RxData->u16_Count < u16_Size)) { I2C_TransferConfig(I2C1_SLAVE_ADDR, st_RxData->u16_Count, I2C_CR2_RELOAD, I2C_GENERATE_START_READ); } else { I2C_TransferConfig(I2C1_SLAVE_ADDR, st_RxData->u16_Count, I2C_CR2_AUTOEND, I2C_GENERATE_START_READ); } I2C_CHANNEL->CR1 |= I2C_CR1_NACKIE | I2C_CR1_RXIE | I2C_CR1_TCIE;// | I2C_CR1_STOPIE; |
好的 |