板子使用 单片机GD32F130
然后使用GD32F1x0_Firmware_Library_v3.1.0里面的例程Examples\I2C\Slave_receiver
main函数代码如下
int main(void)
{
int i;
/* RCU config */
rcu_config();
/* GPIO config */
gpio_config();
/* I2C config */
i2c_config();
i=0;
/* wait until ADDSEND bit is set */
while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_ADDSEND));
/* clear ADDSEND bit */
i2c_flag_clear(BOARD_I2C, I2C_FLAG_ADDSEND);
for(i=0; i<16; i++){
/* wait until the RBNE bit is set */
while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_RBNE));
/* read a data byte from I2C_DATA */
i2c_receiver = i2c_data_receive(BOARD_I2C);
}
/* wait until the STPDET bit is set */
while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_STPDET));
/* clear the STPDET bit */
i2c_enable(BOARD_I2C);
while(1){
}
}
然后用主机却探测不到 该从机,请问哪里还需要修改的,谢谢
|