Index: App/Services/FPGA.c =================================================================== diff -u -rc8c2c1b2a5b2d4836d19fa3c719446c3089c4a36 -ra1c9eabfc633bc7e3ef370096b655b87a08e2e52 --- App/Services/FPGA.c (.../FPGA.c) (revision c8c2c1b2a5b2d4836d19fa3c719446c3089c4a36) +++ App/Services/FPGA.c (.../FPGA.c) (revision a1c9eabfc633bc7e3ef370096b655b87a08e2e52) @@ -476,8 +476,13 @@ // did FPGA Ack the read command? if ( fpgaReadResponseBuffer[0] == FPGA_READ_CMD_ACK ) { + U32 rspSize = FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_HEADER_T); + U32 crcPos = rspSize; + U16 crc = MAKE_WORD_OF_BYTES( fpgaReadResponseBuffer[crcPos+1], fpgaReadResponseBuffer[crcPos] ); + // does the FPGA response CRC check out? - if ( 1 ) // TODO - check response CRC + if ( crc == crc16( fpgaReadResponseBuffer, rspSize ) ) +// if ( 1 ) // TODO - remove when FPGA CRCs are implemented { fpgaCommRetryCount = 0; // capture the read values @@ -571,7 +576,7 @@ // check bulk write command success if ( ( FALSE == fpgaWriteCommandResponseReceived ) || ( fpgaWriteResponseBuffer[0] != FPGA_WRITE_CMD_ACK ) ) { - // TODO - ??? + fpgaCommRetryCount++; } // if bulk read command is ACK'd, collect the readings @@ -580,8 +585,13 @@ // did FPGA Ack the read command? if ( fpgaReadResponseBuffer[0] == FPGA_READ_CMD_ACK ) { + U32 rspSize = FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_SENSORS_T); + U32 crcPos = rspSize; + U16 crc = MAKE_WORD_OF_BYTES( fpgaReadResponseBuffer[crcPos+1], fpgaReadResponseBuffer[crcPos] ); + // does the FPGA response CRC check out? - if ( 1 ) // TODO - check response CRC + if ( crc == crc16( fpgaReadResponseBuffer, rspSize ) ) +// if ( 1 ) // TODO - remove when FPGA CRCs are implemented { fpgaCommRetryCount = 0; // capture the read values Index: App/Services/Utilities.c =================================================================== diff -u -r6c8c486d26306662402945537c5acaea2709d85b -ra1c9eabfc633bc7e3ef370096b655b87a08e2e52 --- App/Services/Utilities.c (.../Utilities.c) (revision 6c8c486d26306662402945537c5acaea2709d85b) +++ App/Services/Utilities.c (.../Utilities.c) (revision a1c9eabfc633bc7e3ef370096b655b87a08e2e52) @@ -86,4 +86,24 @@ return crc; } +/************************************************************************* + * @brief crc8 + * The crc8 function calculates a 8-bit CRC for a given range of bytes \n + * in memory. + * @details + * Inputs : none + * Outputs : none + * @param address : pointer to start address of memory range to calculate CRC for + * @param len : # of bytes in the memory range to calculate CRC for + * @return CRC + *************************************************************************/ +U08 crc8( U08 *address, U32 len ) +{ + U16 crc = 0; + // TODO - 8-bit CRC algorithm + + return crc; +} + + Index: App/Services/Utilities.h =================================================================== diff -u -r81ca79980a75ab71985d3d610bcef45fd6730458 -ra1c9eabfc633bc7e3ef370096b655b87a08e2e52 --- App/Services/Utilities.h (.../Utilities.h) (revision 81ca79980a75ab71985d3d610bcef45fd6730458) +++ App/Services/Utilities.h (.../Utilities.h) (revision a1c9eabfc633bc7e3ef370096b655b87a08e2e52) @@ -22,6 +22,7 @@ // ********** public function prototypes ********** -U16 crc16( U08 *address, U32 len ); +U16 crc16( U08 *address, U32 len ); +U08 crc8( U08 *address, U32 len ); #endif