All Forums
 Hardware
 Ethernet, IR, Serial, CAN and high speed data
 WaitForSingleObject and I2C
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

tscott

4 Posts

Posted - 29 Feb 2008 :  17:36:24  Show Profile
Is there some way to avoid polling for data on the I2C bus? I'd like to get an event or use a thread wait on a sync object tied to receiving data on the I2C bus.

Something like WaitForSingleObject() with a timeout.

I've seen the I2C samples for reading/writing to the DS1307, but they were all procedural calls with some Sleep() calls.

Also, do the ADS I2C drivers on WinCE support overlapped I/O?

ctacke

877 Posts

Posted - 29 Feb 2008 :  18:00:00  Show Profile  Email Poster
I'm not certain what you're asking. I2C is a master/slave bus, so to get data from a device, you must put data on the bus first. So you're not really polling, you're writing a command and then reading the response. See the sample I2C application, which has DS1307 sample code (and it doesn't use Sleep that I recall).

Also, what do you need overlapped I/O for? The I2C doesn't allow multiple devices talking at the same time, so I'm not certain what you'd need overlapped support for.
Go to Top of Page

tscott

4 Posts

Posted - 29 Feb 2008 :  18:34:03  Show Profile
Thanks for the reply.

Well, what happens if I do a read after writing a command, and the device doesn't reply because it's dead, bus error, who knows? Does the read block? Or do I just get back a buffer full of zeros (or garbage)?

I'm trying to program around some potential failure modes.

You're right, there isn't a sleep in DS1307. I think it's in in DeviceDetectionTest(), but I'm not sure why it's there.
Go to Top of Page

cbadr

154 Posts

Posted - 04 Mar 2008 :  16:11:58  Show Profile  Email Poster
As Chris has suggested, please take a look at the sample application code downloadable from topic 1402. It includes error codes and error handling examples. When a read operation fails, you usually receive a NACK or the operation times out, which can be captured by GetLastError() function. Please contact us if you need more specific help with designing your application.
Go to Top of Page

tscott

4 Posts

Posted - 04 Mar 2008 :  18:09:50  Show Profile
Great info, thanks to you both.
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.02 seconds. Snitz Forums 2000