1.硬件I2C设置
2. I2CS_Scan 扫描函数
uint16_t IICs_scan(void)
{
unsigned char address=2;
uint8_t flag ;
printf ("Start_IIC_Scan\r\n");
for(address=2;address<0xFE;address+=2)//0xFE=254,设置为偶数
{
flag=HAL_I2C_Master_Transmit(&hi2c2 ,address,0,0,1000);
if(flag==HAL_OK )
{
printf ("address:0x%02x\r\n",address);
}
}
}
3.效果图