public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
* CYG_I2C_BITBANG_SDA_OUTPUT
@ 2007-09-14 12:10 Andrew Lunn
  2007-09-14 12:24 ` CYG_I2C_BITBANG_SDA_OUTPUT Gary Thomas
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Lunn @ 2007-09-14 12:10 UTC (permalink / raw)
  To: Bart Veer; +Cc: eCos Devel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: CYG_I2C_BITBANG_SDA_OUTPUT
  2007-09-14 12:10 CYG_I2C_BITBANG_SDA_OUTPUT Andrew Lunn
@ 2007-09-14 12:24 ` Gary Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: Gary Thomas @ 2007-09-14 12:24 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Bart Veer, eCos Devel

Andrew Lunn wrote:
> 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?

I'm not speaking in any official capacity wrt the I2C code, but:

Normally, one would set the state of the bit before making
it an output.  Most hardware will latch the value and it
simply has no effect until the output drivers are enabled.
So, I'd reverse the above statements.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-14 12:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-14 12:10 CYG_I2C_BITBANG_SDA_OUTPUT Andrew Lunn
2007-09-14 12:24 ` CYG_I2C_BITBANG_SDA_OUTPUT Gary Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).