以下是库例子I2C的设置
void LM75_Init(void)
{
I2C_InitTypeDef I2C_InitStructure;
LM75_LowLevel_Init();
I2C_DeInit(LM75_I2C);
/*!< LM75_I2C Init */
I2C_InitStructure.I2C_Mode = I2C_Mode_SMBusHost;
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_ClockSpeed = LM75_I2C_SPEED;
I2C_Init(LM75_I2C, &I2C_InitStructure);
/*!< Enable SMBus Alert interrupt */
I2C_ITConfig(LM75_I2C, I2C_IT_ERR, ENABLE);
/*!< LM75_I2C Init */
I2C_Cmd(LM75_I2C, ENABLE);
}
SMBALERT的GPIO配成PB5
I2C_ITConfig(LM75_I2C, I2C_IT_ERR, ENABLE); 打开中断
I2C_InitStructure.I2C_Mode = I2C_Mode_SMBusHost; 是必须的吗?
怎么知道他的中断触发方式?
|
|