I2C Driver for Raspberry Pi programmer needed
Pages: 1 2
Dave Higton (1515) 3497 posts |
No; RISC OS only supports one IIC bus. |
Jeffrey Lee (213) 6048 posts |
Not any more. Sometime over a year ago I updated OS_IICOp to allow the bus number to be specified in the top byte of R1. |
Dave Higton (1515) 3497 posts |
Sure, but anyone who wants to attempt re-use of my code should be aware that it uses programmed I/O, so any attempt to access one IIC bus under interrupt while another bus is in use, is probably going to cause a failure. |
Tank (53) 374 posts |
Finally got round to building an add-on board for the Pi with some GPIO I2C expanders fitted. |
Tank (53) 374 posts |
Just as we get this working, Rev 2 board appears. The I2C’s have been swapped over, so I2C1 will now be on the expansion header. |
Jeffrey Lee (213) 6048 posts |
I guess I’d better hurry up and make it so that the GPIO HAL device can report the board revision. Updating the IIC code to cope with the changed bus is probably also something I can do. |
Dave Higton (1515) 3497 posts |
IIC: I’m on the case. It would seem sensible that the HAL be able to report board revision. I’ve been able to read it, so it wouldn’t be a show-stopper if it isn’t available from the HAL, though. Clearly the HAL must read board revision very early on; the IIC code needs its result. |
John Ballance (21) 85 posts |
Hi Dave The HAL will be aware of the switch. Ideally the HAL code would swap things around seamlessly for the user? Reason for swap is that the camera will flood its IIC, so the one put to GPIO is in another block.. it should actually get a look in when the camera is busy |
Dave Higton (1515) 3497 posts |
Exactly what I am working on.
Yes. I was looking through the HAL documentation yesterday to see if the interface to read the board revision is there, but I couldn’t find it. I’d be happy to provide the code for it – I’ve got it prototyped in BASIC, and anyway if the HAL doesn’t provide it for me then I have to provide it for myself. It’s not a big deal, obviously; I’d just like to follow a defined interface. I don’t think the HAL needs to provide another call specifically for the board revision; I’m sure it could be returned as extra information in one of the existing HAL calls. |
Dave Higton (1515) 3497 posts |
The code to swap IIC0 and IIC1 according to board revision went into CVS last night, so should be in this morning’s ROM build and source tarball. I tested it yesterday evening on a Rev 1 and a Rev 2 board, and all seems well. |
Dan Corneanu (1787) 2 posts |
Hello, Best regards, |
Dave Higton (1515) 3497 posts |
Yes. |
Rick Murray (539) 13806 posts |
Using OS_IICOp you ought to be able to do: However, the easier to use IIC_Control does not, so you need to do two atomic operations: The IIC specification (Oct 2012, p9) says (my highlight):
The purpose of repeated-start is to prevent the bus being claimed by other communications in a multi-master setup. If, however, the setup is for a single master (which I think is the case in most of the dev boards; or can the GPU act as an IIC Master?) then it will suffice to use two calls to IIC_Control, one to write data, the other to read it. References:
|
Rick Murray (539) 13806 posts |
I’ve added IIC_Control to the documentation; and since the wiki uses an unholy mish-mash of Textile and Wiki syntax, I used my “person profile page” as a playpen – some of you might be amused by it. (^_^) |
Dan Corneanu (1787) 2 posts |
Thx for the quick reply. I am running Risc Os on a Raspberry Pi. |
Rick Murray (539) 13806 posts |
Ah… The MLX90614 is not IIC, it is SMBus. In general the two are compatible, but note that SMBus specifies a minimum clock speed (>10kHz and no more than 100kHz) and has a 35mS timeout baked into the protocol. IIC is much looser in this respect (I “talked” to a teletext chip while single-stepping code in TurboC++’s debugger and it worked !). That the two are “compatible” is good, but if an SMBus device falls over on an IIC bus (or vice versa), we probably shouldn’t be too surprised. ;-) |
Pages: 1 2