jnivard wrote:I
This function will set the 10bit addressing flag on an i2c_msg structure:
def 10bit(m):
m.flags |= I2C_M_TEN
With this you can mark reads and writes as using 10-bit addressing like this:
i2c.transaction(
10bit(writing_bytes(1,2,3,4)),
10bit(reading(2))
Going by what I could find with a bit of googling, the Quick2Wire API supports "repeated start" mode naturally: just pass multiple i2c_msgs to the I2CMaster.transaction method and all the transfers will be done with no stop/start in between.
--Nat
Well, it doesn't work then. That is essentially the root of the problem. If this worked there would be no problem with any code that uses ioctl to access /dev/i2c-x. Nothing can work(for this particular issue) with the existing kernel i2c drivers (Rasbian Wheezy 2013-02-09). If it did, this entire thread would be discussing a spurious non-existent issue. You've been side tracked a bit by the 10-bit addressing references. The references to 10-bit addressing are here only because they point to a section in the Broadcom manual that suggests how you might be able to 'hack' a repeated start. It has nothing really to do with 10 bit addressing. Using the 10 bit address flag in your ioctl structures won't solve this issue at all.
As far as I can see, the Quick2Wire code uses the standard ioctl structures to read/write to the device file. In that case. it doesn't matter how many messages you pass at once within the ioctl data structure. On the current implementation within Raspberry Pi, there will be a stop signal sent after each message. This is contrary to the recommended implementation for i2c_transfer but there you go. It's early days for Rasbian / RPi
Whether your external device works OK with this is down to the individual device. Most devices expect repeated starts ( that's how the conversations are described within their datasheets ) but as they don't actively do anything when a stop signal is received ( other than know the transfer is over) everything works fine. The particular devices discussed here actively reset their register (read from) address to 0x00 on receipt of a stop signal so you're stuck in that case. You cannot set a particular register to read from.
Two workarounds discussed in this thread
1. The hack in bcm2835 library - manages to produce the required repeated start.
2. Simply read multiple bytes starting at address 0x00 and figure out which byte you are interested in.
In either case, what it means is that you can probably use any of these devices on the Raspberry Pi either by using the bcm2835 directly in C or wrapped for some other language -
or -- you can use any existing library for Python or whatever provided that the device will let you read a stream of bytes starting at address 0x00 . You would have to check the device datasheet for that.
Hope it helps
Mark