操作GD32F150芯片的硬件I2C2,已经设置系统时钟了,但操作寄存器时无法写入数据。
void I2C_Configuration(void)
{
/* Enable BOARD_I2C APB1 clock */
RCC_APB1PeriphClock_Enable(RCC_APB1PERIPH_I2C2,ENABLE);
I2C_InitPara I2C_InitStructure;
I2C_InitStructure.I2C_Protocol = I2C_PROTOCOL_I2C;
I2C_InitStructure.I2C_DutyCycle = I2C_DUTYCYCLE_2;
I2C_InitStructure.I2C_BitRate = 100000;
I2C_InitStructure.I2C_AddressingMode = I2C_ADDRESSING_MODE_7BIT;
I2C_InitStructure.I2C_DeviceAddress = I2C_OWN_ADDRESS7;
I2C_Init(BOARD_I2C, &I2C_InitStructure);
I2C_Enable(BOARD_I2C,ENABLE);
}
|