STM32里I2C_CheckEvent函数我们应该是相当熟悉了,在每次发送数据后我们都需要检验相应的EVx(x = 0,1,2,,,)事件是否有发送。
函数定义如下:
1 ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, uint32_t I2C_EVENT) 2 { 3 uint32_t lastevent = 0; 4 uint32_t flag1 = 0, flag2 = 0; 5 ErrorStatus status = ERROR; 6 7 /* Check the parameters */ 8 assert_param(IS_I2C_ALL_PERIPH(I2Cx)); 9 assert_param(IS_I2C_EVENT(I2C_EVENT)); 10 11 /* Read the I2Cx status register */ 12 flag1 = I2Cx->SR1; 13 flag2 = I2Cx->SR2; 14 flag2 = flag2 << 16; 15