All Forums
 Microsoft Windows CE
 CE Drivers
 eVC - I2C Driver Wrapper Class and Sample
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

ctacke

877 Posts

Posted - 02 Mar 2004 :  13:04:26  Show Profile  Email Poster
I2C Class and DS1631 Sample

This is a base class that custom I2C device implementations can derive from. An example of a derived class for using a DS1631 thermometer is also included.

The ADS I2C bus driver on the AGX and BitsyX uses the WriteFile and ReadFile APIs to put data on or read data off the bus. To give control over setting the start and stop conditions, data passed in must be in an IIC_MESSAGE struct format. The data length passed to the actual WriteFile or ReadFile APIs is not used, the uDataLength is the value used. uDataLength is the length of bus data bytes only, it is *not* the size of the IIC_MESSAGE struct.

*Any* data written to the bus, including a command to read, must be done with WriteFile. ReadFile is only used to retrieve data. Due to the variety of I2C devices in the market, it is not possible for the driver to know how much data or the data format expected in either a write or a read, so using values for the uDataLength that are unexpected by the client device can cause either the driver or bus to go to an unknown state.

Key APIs Used

CreateFile
ReadFile
WriteFile
CloseHandle

Lines of Code: 211

NOTES:
  • This sample currently requires the following builds:
    BitsyX: CE build 4.20.05 or later
    AGX: CE build 4.20.04 or later.


  • Older systems may require hardware modifications for the I2C bus to work properly. For details, see Topic 884 for the BitsyX and Topic 1044 for the AGX.



Important
This class uses the deprecated IIC1: driver, which we no longer support.
If you use this code, update the class constructor in I2C.CPP to use the I2C1: driver.


Source Download
Rev 4 - June 28, 2007


Additional References
ADSerror.h (topic)



Edited 21-Nov-2006 by akidder: Add note about that IIC1: driver in this code should be replaced by I2C1:
Edited by akider 20-Jul-07: Replace Rev 3 - Mar 11, 2004 link with rev 4.

ctacke

877 Posts

Posted - 11 Mar 2004 :  12:52:55  Show Profile  Email Poster
Rev 3 Update: DS1307 Class

We've added a new class to the test code: DS1307. This class can be used to read and write to the Dallas DS1307 Real-Time Clock (RTC) which is on all standard BitsyX and AGX configurations.
Go to Top of Page

cbadr

154 Posts

Posted - 28 Jun 2007 :  15:30:57  Show Profile  Email Poster
Rev 4 Update: Detects All Devices on Bus

This application tests writing to RTC RAM (1 byte at a time, then 4 bytes at a time). It then reads the RTC time and writes back with manipulated minute byte.

A third test was added to detect all devices responding to a read call on the I2C bus.
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.03 seconds. Snitz Forums 2000