Prototype: void SpiReadData(unsigned char *data, unsigned short size);
I just looked at this, evnt_buff is a pointer, so +10 just advances it to the pRxPacket of struct sSpiInformation. This would be just past the header information... so pointing to actual data now.
This one is setting the pointer to 1034 into the pRxPacket ... let's see if we can figure this out...
Here's what I think is happening:
enter void SPI_DMA_IntHandler(void)
data_to_recv = 0;
is cleared
STREAM_TO_UINT16((char *)(evnt_buff + SPI_HEADER_SIZE), HCI_DATA_LENGTH_OFFSET, data_to_recv);
data_to_recv gets set to a new 16bit unsigned int value of data length. evnt_buff points to the Rx stream, and HCI_DATA_LENGTH_OFFSET is the offset into the stream where the Rx data length is stored.
// Read the last portion of data
//
//
// We need to read the rest of data..
//
data_to_recv -= SPI_WINDOW_SIZE;
This suggests data_to_recv is already larger than SPI_WINDOW_SIZE (1024) so it's trying to get the last portion of data that is larger than 1024. evnt_buff = sSpiInformation.pRxPacket coming in here, so I'm guessing at this point the Rx buffer is filled up to 1024 plus 10 for header info.
if (!((HEADERS_SIZE_EVNT + data_to_recv) & 1))
{
data_to_recv++;
}
Some kind of error correction...
SpiReadData(sSpiInformation.pRxPacket + 10 + SPI_WINDOW_SIZE, data_to_recv);
and then the good part, we start reading the rest of the data at Rx start address + 10 for header info + 1024 from first portion of read. And we tack on (data_to_recv) in size 16bit values to the end of the Rx buffer.
At least that's what pretty close to what I think it's doing.