Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -r90f6438e80dbe0a32472a076a0d1bc54db65d15a -r1bbf9da32e622975efed00b1a7589387a9829440 --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 90f6438e80dbe0a32472a076a0d1bc54db65d15a) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 1bbf9da32e622975efed00b1a7589387a9829440) @@ -32,9 +32,9 @@ // ********** private data ********** -static U32 commBufferByteCount[NUM_OF_COMM_BUFFERS][DOUBLE_BUFFERS]; // for each buffer, how many bytes does it contain? (also index to next available) -static U32 activeDoubleBuffer[NUM_OF_COMM_BUFFERS]; // for each buffer, which double buffer is being fed right now? -static U08 commBuffers[NUM_OF_COMM_BUFFERS][DOUBLE_BUFFERS][COMM_BUFFER_LENGTH]; // each is double buffered to avoid thread contention +static U32 commBufferByteCount[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ]; // for each buffer, how many bytes does it contain? (also index to next available) +static U32 activeDoubleBuffer[ NUM_OF_COMM_BUFFERS ]; // for each buffer, which double buffer is being fed right now? +static U08 commBuffers[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ][ COMM_BUFFER_LENGTH ]; // each is double buffered to avoid thread contention // ********** private function prototypes ********** @@ -57,13 +57,13 @@ // reset and zero out all buffers for ( b = 0; b < NUM_OF_COMM_BUFFERS; b++ ) { - activeDoubleBuffer[b] = 0; + activeDoubleBuffer[ b ] = 0; for ( d = 0; d < DOUBLE_BUFFERS; d++ ) { - commBufferByteCount[b][d] = 0; + commBufferByteCount[ b ][ d ] = 0; for ( i = 0; i < COMM_BUFFER_LENGTH; i++ ) { - commBuffers[b][d][i] = 0; + commBuffers[ b ][ d ][ i ] = 0; } } } @@ -97,20 +97,20 @@ // add requires brief thread protection because there may be multiple sources for transmits trying to add data to a buffer. _disable_IRQ(); - activeBuffer = activeDoubleBuffer[buffer]; - currentActiveBufCount = commBufferByteCount[buffer][activeBuffer]; + activeBuffer = activeDoubleBuffer[ buffer ]; + currentActiveBufCount = commBufferByteCount[ buffer ][ activeBuffer ]; // check to make sure buffer is not too full to service this add if ( len <= ( COMM_BUFFER_LENGTH - currentActiveBufCount ) ) { U08 *buffPtr; // buffer destination for added data // adjust buffer count per this data add (also reserves space to add data before releasing thread protection) - commBufferByteCount[buffer][activeBuffer] += len; + commBufferByteCount[ buffer ][ activeBuffer ] += len; // release thread protection _enable_IRQ(); // set destination pointer to end of active buffer data - buffPtr = &commBuffers[buffer][activeBuffer][currentActiveBufCount]; + buffPtr = &commBuffers[ buffer ][ activeBuffer ][ currentActiveBufCount ]; // copy source data to destination buffer memcpy( buffPtr, data, len ); // data successfully added to buffer @@ -159,9 +159,9 @@ // verify size of get if ( ( len <= ( COMM_BUFFER_LENGTH * DOUBLE_BUFFERS ) ) && ( len <= numberOfBytesInCommBuffer( buffer ) ) ) { - U32 activeBuffer = activeDoubleBuffer[buffer]; + U32 activeBuffer = activeDoubleBuffer[ buffer ]; U32 inactiveBuffer = ( activeBuffer == 0 ? 1 : 0 ); - U32 bytesInInactiveBuffer = commBufferByteCount[buffer][inactiveBuffer]; + U32 bytesInInactiveBuffer = commBufferByteCount[ buffer ][ inactiveBuffer ]; U32 sizeOfFirstConsumption = MIN( len, bytesInInactiveBuffer ); // see what we can get from inactive buffer @@ -218,22 +218,22 @@ // verify size of peek if ( ( len <= ( COMM_BUFFER_LENGTH * DOUBLE_BUFFERS ) ) && ( len <= numberOfBytesInCommBuffer( buffer ) ) ) { - U32 activeBuffer = activeDoubleBuffer[buffer]; + U32 activeBuffer = activeDoubleBuffer[ buffer ]; U32 inactiveBuffer = ( activeBuffer == 0 ? 1 : 0 ); - U32 bytesInInactiveBuffer = commBufferByteCount[buffer][inactiveBuffer]; + U32 bytesInInactiveBuffer = commBufferByteCount[ buffer ][ inactiveBuffer ]; if ( len <= bytesInInactiveBuffer ) { - memcpy( data, &commBuffers[buffer][inactiveBuffer][0], len ); + memcpy( data, &commBuffers[ buffer ][ inactiveBuffer ][ 0 ], len ); numOfBytesPeeked = len; } else // will need to get the rest from active buffer { U32 remNumOfBytes = len - bytesInInactiveBuffer; U08 *remPtr = data + bytesInInactiveBuffer; - memcpy( data, &commBuffers[buffer][inactiveBuffer][0], bytesInInactiveBuffer ); - memcpy( remPtr, &commBuffers[buffer][activeBuffer][0], remNumOfBytes ); + memcpy( data, &commBuffers[ buffer ][ inactiveBuffer ][ 0 ], bytesInInactiveBuffer ); + memcpy( remPtr, &commBuffers[ buffer ][ activeBuffer ][ 0 ], remNumOfBytes ); numOfBytesPeeked = bytesInInactiveBuffer + remNumOfBytes; } } @@ -268,7 +268,7 @@ // verify given buffer if ( buffer < NUM_OF_COMM_BUFFERS ) { - result = commBufferByteCount[buffer][0] + commBufferByteCount[buffer][1]; + result = commBufferByteCount[ buffer ][ 0 ] + commBufferByteCount[ buffer ][ 1 ]; } else // invalid buffer { @@ -292,13 +292,13 @@ *************************************************************************/ static U32 switchDoubleBuffer( COMM_BUFFER_T buffer ) { - U32 activeBuffer = activeDoubleBuffer[buffer]; + U32 activeBuffer = activeDoubleBuffer[ buffer ]; U32 inactiveBuffer = ( activeBuffer == 0 ? 1 : 0 ); // ensure inactive buffer is reset before making active - commBufferByteCount[buffer][inactiveBuffer] = 0; + commBufferByteCount[ buffer ][ inactiveBuffer ] = 0; // switch buffers - activeDoubleBuffer[buffer] = inactiveBuffer; + activeDoubleBuffer[ buffer ] = inactiveBuffer; // return the new active buffer (was just inactive) return inactiveBuffer; @@ -319,21 +319,21 @@ *************************************************************************/ static void getDataFromInactiveBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ) { - U32 activeBuffer = activeDoubleBuffer[buffer]; + U32 activeBuffer = activeDoubleBuffer[ buffer ]; U32 inactiveBuffer = ( activeBuffer == 0 ? 1 : 0 ); - U32 bytesInInactiveBuffer = commBufferByteCount[buffer][inactiveBuffer]; + U32 bytesInInactiveBuffer = commBufferByteCount[ buffer ][ inactiveBuffer ]; // get the requested data from inactive buffer - memcpy( data, &commBuffers[buffer][inactiveBuffer][0], len ); + memcpy( data, &commBuffers[ buffer ][ inactiveBuffer ][ 0 ], len ); if ( len < bytesInInactiveBuffer ) { - U08 *endPtr = (&commBuffers[buffer][inactiveBuffer][0] + len); + U08 *endPtr = (&commBuffers[ buffer ][ inactiveBuffer ][ 0 ] + len); // move un-consumed data in inactive buffer to start of inactive buffer - memcpy( &commBuffers[buffer][inactiveBuffer][0], endPtr, (bytesInInactiveBuffer - len) ); + memcpy( &commBuffers[ buffer ][ inactiveBuffer ][ 0 ], endPtr, ( bytesInInactiveBuffer - len ) ); // reduce byte count for inactive buffer by # of bytes consumed - commBufferByteCount[buffer][inactiveBuffer] -= len; + commBufferByteCount[ buffer ][ inactiveBuffer ] -= len; } else {