This is the mail archive of the
ecos-devel@sourceware.org
mailing list for the eCos project.
CYG_I2C_BITBANG_SDA_OUTPUT
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Bart Veer <bartv at ecoscentric dot com>
- Cc: eCos Devel <ecos-devel at ecos dot sourceware dot org>
- Date: Fri, 14 Sep 2007 14:10:36 +0200
- Subject: CYG_I2C_BITBANG_SDA_OUTPUT
Hi Bart
I've a college who is implementing a BitBang I2C bus driver. He has
discovered that the documentation is missing something. It does not
describe the use of CYG_I2C_BITBANG_SDA_OUTPUT.
Setting the SDA to an output is clear. However does it have to take
care of how it is driven, ie High/Low? eg consider the code:
// We have read the last bit. SDA is still an input, SCL is low.
// We need to switch SDA to an output and send the ack/nak
(*banger)(mash, CYG_I2C_BITBANG_SDA_OUTPUT);
(*banger)(mash, nak ? CYG_I2C_BITBANG_SDA_HIGH : CYG_I2C_BITBANG_SDA_LOW);
If the last driven state of SDA was high, and nak is false, it could
be that the call for CYG_I2C_BITBANG_SDA_OUTPUT sets SDA to high, and
then the next statement puts it low again, causing a short spike. Is
this a problem? Should it first read the current state of SDA, set the
drive level and then flip it to an output?
Thanks
Andrew