Permalink
Browse files

allow transmission of window offset

  • Loading branch information...
1 parent a5f2685 commit c49ad302320e9646aac35182958b01512ef655cd @wertarbyte committed Feb 25, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 usiTwiSlave.c
View
@@ -258,6 +258,7 @@ static volatile uint8_t rxTail;
static volatile void *tx_window_start;
static volatile void *tx_window_end;
static volatile void *tx_window_cur;
+static volatile size_t tx_window_offset;
/********************************************************************************
@@ -281,6 +282,7 @@ flushTwiBuffers(
tx_window_start = 0;
tx_window_end = 0;
tx_window_cur = 0;
+ tx_window_offset = 0;
} // end flushTwiBuffers
@@ -491,7 +493,9 @@ ISR( USI_OVERFLOW_VECTOR )
if ( USIDR & 0x01 )
{
overflowState = USI_SLAVE_SEND_DATA;
- tx_window_cur = tx_window_start;
+ tx_window_cur = tx_window_start+tx_window_offset;
+ /* the next request will start at 0 again */
+ tx_window_offset = 0;
}
else
{
@@ -554,11 +558,16 @@ ISR( USI_OVERFLOW_VECTOR )
// copy data from USIDR and send ACK
// next USI_SLAVE_REQUEST_DATA
case USI_SLAVE_GET_DATA_AND_SEND_ACK:
+#if 0
// put data into buffer
// Not necessary, but prevents warnings
rxHead = ( rxHead + 1 ) & TWI_RX_BUFFER_MASK;
rxBuf[ rxHead ] = USIDR;
// next USI_SLAVE_REQUEST_DATA
+#else
+ /* we assume that the data is an address offset */
+ tx_window_offset = USIDR;
+#endif
overflowState = USI_SLAVE_REQUEST_DATA;
SET_USI_TO_SEND_ACK( );
break;

0 comments on commit c49ad30

Please sign in to comment.