打印

GD32F1x0_Firmware_Library_v3.1.0 i2c demo有问题

[复制链接]
871|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
tincal|  楼主 | 2022-3-28 20:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
一直卡在标红这行,请问有知道的么,谢谢

int main(void)
{
    int i;

    /* RCU config */
    rcu_config();
    /* GPIO config */
    gpio_config();
    /* I2C config */
    i2c_config();

    for(i=0; i<16; i++){
        i2c_transmitter=i+0x80;
    }

    /* wait until I2C bus is idle */
    while(i2c_flag_get(BOARD_I2C, I2C_FLAG_I2CBSY));
    /* send a start condition to I2C bus */
    i2c_start_on_bus(BOARD_I2C);
    /* wait until SBSEND bit is set */
    while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_SBSEND));
    /* send slave address to I2C bus */
    i2c_master_addressing(BOARD_I2C, I2C_SLAVE_ADDRESS7, I2C_TRANSMITTER);
    /* wait until ADDSEND bit is set */
    while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_ADDSEND));
    /* clear ADDSEND bit */
    i2c_flag_clear(BOARD_I2C, I2C_STAT0_ADDSEND);
    /* wait until the transmit data buffer is empty */
    while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_TBE));

    for(i=0; i<16; i++){
        /* data transmission */
        i2c_data_transmit(BOARD_I2C, i2c_transmitter);
        /* wait until the TBE bit is set */
        while(!i2c_flag_get(BOARD_I2C, I2C_FLAG_TBE));
    }
    /* send a stop condition to I2C bus */
    i2c_stop_on_bus(BOARD_I2C);
    while(I2C_CTL0(BOARD_I2C)&0x0200);

    /* infinite loop */
    while(1){
    }
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

5

帖子

0

粉丝