itsanjan / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Ability to generate repeated start requests in Wire library. #663

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From Gene Apperson via Rick Anderson:

"I’m proposing to add overloaded variants for the functions:
requestFrom and beginTransmission. Each of these variants would add
two parameters: The first added parameter specifies no start, normal
start, or repeated start to begin the transaction. The second
parameter specifies whether or not to assert a stop on the bus at the
end of the transaction.

 These two overloads would be strict supersets of the current
functions, and using them, I believe any legal bus transaction or
combination of transactions could be performed."

Original issue reported on code.google.com by dmel...@gmail.com on 1 Oct 2011 at 6:41

GoogleCodeExporter commented 9 years ago
I strongly support a change to permit Repeated Start operations on I2C. There 
are several chips which require repeated starts to work usefully, notably any 
which require a read address to be sent.

However, I would like to suggest a different method. Rather than require 
additional parameters (which in my view complicates the documentation), I 
suggest that, when requestFrom is called, the library examines the state of the 
transmit buffer. If it has not yet been transmitted (ie endTransmission has not 
been called), then it should start the transmission with an internal option 
that causes the repeated start state to be entered and the requestFrom 
operation to be chained onto it.

Since Send followed by requestFrom is not normal usage, this should not 
significantly impact any existing use. A possible correct existing use would be 
where an application builds the next transmission buffer while reading the 
previous response, but this strikes me as rather exotic for common arduino use 
and I doubt that precluding it would be a serious problem.

This solution does not preclude Gene's suggestion : it would be possible to 
implement additional parameters as he suggests if there are devices which 
cannot be driven in this way. However, it would be more convenient if the 
parameter requesting no STOP were added to endTransmission rather than 
beginTransmission. This seems to me more intuitive in any case.

Original comment by artgod...@gmail.com on 26 Nov 2011 at 5:41

GoogleCodeExporter commented 9 years ago
Here is a diff that supports repeated starts in both read and write 
transactions.

Original comment by ToddKrei...@gmail.com on 17 Feb 2012 at 12:27

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 19 Feb 2012 at 12:54

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/2f29f898de9c8375b37269c26948be59a515e8
01

Thanks Todd!

Original comment by dmel...@gmail.com on 19 Feb 2012 at 1:06