Hi all, I'm using std peripheral library, and it's hangs when I try use I2C_EVENT, for example when I send data
void i2c_transmit(uint8_t byte) { I2C_SendData(I2C2, byte); while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_TRANSMITTED));// here hangs }
why? this is my i2c init
void i2c_init() { I2C_InitTypeDef I2C_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; RCC_APB1PeriphClockCmd(I2C2_RCC, ENABLE); RCC_APB2PeriphClockCmd(I2C_GPIO_RCC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; GPIO_Init(GPIOB, &GPIO_InitStructure); I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_OwnAddress1 = 0x00 ; I2C_InitStructure.I2C_Ack = I2C_Ack_Disable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = 100000 ; I2C_Init(I2C2, &I2C_InitStructure); I2C_Cmd(I2C2, ENABLE); }
Can anybody help me? Best regards