Skip to content

Commit

Permalink
Execute request call for each byte requested
Browse files Browse the repository at this point in the history
This reverses the change done in a503849. That change changed the API
(even if it wasn't in a way visible through the methods) and failed to
match the way the library was intended to be used.

This once again makes it possible to send bodies larger than the buffer.
  • Loading branch information
JasperHorn committed Dec 23, 2017
1 parent 860ad85 commit f0eb04f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion TinyWireS/usiTwiSlave.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ ISR( USI_OVERFLOW_VECTOR )
{
if ( USIDR & 0x01 )
{
USI_REQUEST_CALLBACK();
overflowState = USI_SLAVE_SEND_DATA;

This comment has been minimized.

Copy link
@bmbeyers

bmbeyers Sep 1, 2020

Here we keep the overflowState listed as USI_SLAVE_SEND_DATA, yet USI_REQUEST_CALLBACK() function was moved to USI_SLAVE_CHECK_REPLY_FROM_SEND_DATA case...

}
else
Expand All @@ -591,6 +590,9 @@ ISR( USI_OVERFLOW_VECTOR )
// Master write data mode: check reply and goto USI_SLAVE_SEND_DATA if OK,
// else reset USI
case USI_SLAVE_CHECK_REPLY_FROM_SEND_DATA:
// Execute request callback for each byte requested, as this is the intended
// behavior of this library
USI_REQUEST_CALLBACK();

This comment has been minimized.

Copy link
@bmbeyers

bmbeyers Sep 1, 2020

This needs to be removed from this case and instead placed in USI_SLAVE_SEND_DATA case.

if ( USIDR )
{
// if NACK, the master does not want more data
Expand Down

2 comments on commit f0eb04f

@skozmin83
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it fixes an issue, ##36, but, take a look at last @dersimn comment, f0eb04f commit broke simplest case with non-i2c-hardware supported devices. I have wemos d1 (esp8266) talking to attiny85. All esp8266 does: reads 1 byte from attiny85, requestEvent method on attiny85 is never getting called and from the code & saleae logs I can see it always returns 255, NACK (can provide SALEAE data if needed).

@bmbeyers
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added comments about where to move USI_REQUEST_CALLBACK() function to get the appropriate, expected behavior.

Please sign in to comment.