unsigned char I2c_read_byte(void)
{
    int i;
    unsigned char data;

    data = 0;
    SDA_IN;
    for(i = 0; i< 8; i++) {
        data <<= 1;
        I2C_DELAY;
        SCL_HIGH;
        I2C_DELAY;
        if (SDA_DETECT) data |= 0x01;
        SCL_LOW;
        I2C_DELAY;
    }
    I2c_ack_send();
    return data;
}
示例#2
0
unsigned char I2c_read_byte(int byteno)
{
    int i;
    unsigned char data;

    data = 0;
    SDA_IN;
     udelay(350);
    for(i = 0; i< 8; i++){
        data <<= 1;
        I2C_DELAY;
        SCL_HIGH;
        I2C_DELAY;
        if (SDA_DETECT) data |= 0x01;
        SCL_LOW;
        I2C_DELAY;
    }
    if(byteno == nack_flag)
    	I2c_nack_send();
    else
    	I2c_ack_send();
    return data;
}