This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Request for comments on CYG_I2C_BITBANG_SCL_LOW_SDA_INPUT patch
- From: Øyvind Harboe <oyvind dot harboe at zylin dot com>
- To: ecos-discuss at ecos dot sourceware dot org
- Date: Mon, 06 Mar 2006 11:41:28 +0100
- Subject: [ECOS] Request for comments on CYG_I2C_BITBANG_SCL_LOW_SDA_INPUT patch
I've assembled a patch for a race condition where SDA can be changed
before SCL is stable low.
My I2C + hardware skills are fairly shaky, so any and all comments are
most welcome!
--
Øyvind Harboe
http://www.zylin.com
Index: current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/i2c/current/ChangeLog,v
retrieving revision 1.4
diff -r1.4 ChangeLog
0a1,5
> 2006-03-06 Øyvind Harboe <oyvind.harboe@zylin.com>
>
> * Clarified documentation. SCL must be set to low before
> SDA is set to high for CYG_I2C_BITBANG_SCL_LOW_SDA_INPUT.
>
Index: current/doc/i2c.sgml
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/i2c/current/doc/i2c.sgml,v
retrieving revision 1.3
diff -r1.3 i2c.sgml
802a803,816
> Normally, this should be synonymous to CYG_I2C_BITBANG_SCL_LOW. However,
> some I2C hardware implementations have a dubious implementation of
> SDA-high where they pull SDA high instead of simply letting SDA float
> to high via a pullup resistor. Such hardware implementations are vulnerable to
> race conditions due to master & slave pulling SDA in oposite directions.
> </para><para>
> CYG_I2C_BITBANG_SCL_LOW_SDA_INPUT is an attempt to alleviate these problems
> by pulling SCL low and pulling SDA high in an 'atomic' operation.
> </para><para>
> The I2C spec forbids changes in SDA until SCL is stable low. Although
> the master can set SCL and SDA in a near atomic operation, due to electric
> delays, etc. the slave can interpret this as SDA canging before SCL, which is
> not what was intended(in fact it can be interpreted as a start/stop condition).
> </para><para>
808,809c822,823
< the SCL line and switching SDA to an input in an atomic or near-atomic
< operation.
---
> the SCL line and switching SDA to an input. Note that SCL must be
> stable low before SDA is set to input.
Index: current/src/i2c.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/i2c/current/src/i2c.cxx,v
retrieving revision 1.3
diff -r1.3 i2c.cxx
298a299,302
> // SCL is stable low, we can now drop SDA
> (*banger)(mash, CYG_I2C_BITBANG_SDA_HIGH);
> HAL_DELAY_US(delay);
>
358a363,365
> // SCL is stable low, we can now drop SDA
> (*banger)(mash, CYG_I2C_BITBANG_SDA_HIGH);
> HAL_DELAY_US(delay);
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss