qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] i2c data address question was Re: [PATCH RFC] i2c-tiny-


From: Paolo Bonzini
Subject: Re: [Qemu-devel] i2c data address question was Re: [PATCH RFC] i2c-tiny-usb
Date: Wed, 9 Dec 2015 18:04:44 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


On 09/12/2015 17:40, Tim Sander wrote:
>> > If there is no slave at the requested address, i2c_start_transfer will
>> > return 1.
> Ok, that works. Now probably the last problem i see is that i fail to set the 
> data-address of the i2c-device?
> I know the correct offset address for accesses on the bus e.g. 
> i2cget -y 0 0x50 2
> where 2 is an example offset for the access to this device. 
> 
> So any hint how setting the data-address on the i2c bus in qemu works?

If you have a data address, you probably want to use functions like
smbus_read_byte that do the right write-read sequence for you:

    if (i2c_start_transfer(bus, addr, 0)) {
        return -1;
    }
    i2c_send(bus, command);
    i2c_start_transfer(bus, addr, 1);
    data = i2c_recv(bus);
    i2c_nack(bus);
    i2c_end_transfer(bus);

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]