Index: firmware/App/Services/FPGA.c =================================================================== diff -u -raa7b1f5f68aae23c1c52b32658fcb625c29accfb -r0c439ddcf7e4d3d4bf63df679eacf2f12f01255f --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision aa7b1f5f68aae23c1c52b32658fcb625c29accfb) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 0c439ddcf7e4d3d4bf63df679eacf2f12f01255f) @@ -329,9 +329,6 @@ static FPGA_HEADER_T fpgaHeader; ///< Record of last received FPGA header data. static FPGA_SENSORS_T fpgaSensorReadings; ///< Record of last received FPGA priority sensor data. static FPGA_ACTUATORS_T fpgaActuatorSetPoints; ///< Record of next transmitted FPGA priority actuator data. -#ifdef READ_FPGA_ASYNC_DATA -static FPGA_SENSORS_ASYNC_T fpgaSensorReadingsAsync; ///< Record of last received async (as needed) FPGA sensor data. -#endif #ifndef DEBUG_ENABLED static U16 currentFPGATimerCount_ms; ///< Current FPGA timer count in ms. @@ -344,10 +341,6 @@ static FPGA_STATE_T handleFPGAReceiveHeaderState( void ); static FPGA_STATE_T handleFPGAWriteAllActuatorsState( void ); static FPGA_STATE_T handleFPGAReceiveAllSensorsState( void ); -#ifdef READ_FPGA_ASYNC_DATA -static FPGA_STATE_T handleFPGAReceiveAllSensorsAsyncState( void ); -static FPGA_STATE_T handleFPGAReadAllSensorsAsyncState( void ); -#endif static void resetFPGACommFlags( void ); static void setupDMAForWriteCmd( U32 bytes2Transmit ); @@ -569,12 +562,6 @@ fpgaState = handleFPGAReceiveAllSensorsState(); break; -#ifdef READ_FPGA_ASYNC_DATA - case FPGA_STATE_RCV_ALL_SENSORS_ASYNC: - fpgaState = handleFPGAReceiveAllSensorsAsyncState(); - break; -#endif - case FPGA_STATE_FAILED: // Do nothing - we will be stuck here break; @@ -633,12 +620,6 @@ // Do nothing - we will be stuck here break; -#ifdef READ_FPGA_ASYNC_DATA - case FPGA_STATE_READ_ALL_SENSORS_ASYNC: - fpgaState = handleFPGAReadAllSensorsAsyncState(); - break; -#endif - default: if ( fpgaState >= NUM_OF_FPGA_STATES ) { @@ -816,11 +797,7 @@ fpgaCommRetryCount = 0; // Capture the read values memcpy( &fpgaSensorReadings, &fpgaReadResponseBuffer[ FPGA_READ_RSP_HDR_LEN ], sizeof( FPGA_SENSORS_T ) ); -#ifndef READ_FPGA_ASYNC_DATA result = FPGA_STATE_WRITE_ALL_ACTUATORS; -#else - result = FPGA_STATE_READ_ALL_SENSORS_ASYNC; -#endif } else // Bad CRC { @@ -843,92 +820,8 @@ return result; } -#ifdef READ_FPGA_ASYNC_DATA /*********************************************************************//** * @brief - * The handleFPGAReadAllSensorsAsyncState function handles the FPGA state where - * the read async sensors command is sent to the FPGA. - * @details Inputs: none - * @details Outputs: read async sensors command sent to FPGA - * @return next FPGA state - *************************************************************************/ -static FPGA_STATE_T handleFPGAReadAllSensorsAsyncState( void ) -{ - FPGA_STATE_T result = FPGA_STATE_RCV_ALL_SENSORS_ASYNC; - U16 crc; - - // Construct read command to read low priority async registers starting at address 0x200 - fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; - fpgaReadCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_BULK_ASYNC_READ_START_ADDR ); - fpgaReadCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_BULK_ASYNC_READ_START_ADDR ); - fpgaReadCmdBuffer[ 3 ] = sizeof(FPGA_SENSORS_ASYNC_T); - crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN ); - fpgaReadCmdBuffer[ 4 ] = GET_MSB_OF_WORD( crc ); - fpgaReadCmdBuffer[ 5 ] = GET_LSB_OF_WORD( crc ); - // Prep DMA for sending the read cmd and receiving the response - fpgaReadCommandInProgress = TRUE; - setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_SENSORS_ASYNC_T) + FPGA_CRC_LEN ); - setupDMAForReadCmd( FPGA_READ_CMD_HDR_LEN + FPGA_CRC_LEN ); - startDMAReceiptOfReadResp(); - startDMAReadCmd(); - - return result; -} - -/*********************************************************************//** - * @brief - * The handleFPGAReceiveAllSensorsAsyncState function handles the FPGA state - * where the bulk async read response should be ready to parse. - * @details Inputs: none - * @details Outputs: async sensor values updated - * @return next FPGA state - *************************************************************************/ -static FPGA_STATE_T handleFPGAReceiveAllSensorsAsyncState( void ) -{ - FPGA_STATE_T result = FPGA_STATE_READ_ALL_SENSORS_ASYNC; - - // If bulk read command is ACK'd, collect the readings - if ( TRUE == fpgaReadCommandResponseReceived ) - { - // Did FPGA Ack the read command? - if ( fpgaReadResponseBuffer[ 0 ] == FPGA_READ_CMD_ACK ) - { - U32 rspSize = FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_SENSORS_ASYNC_T); - U32 crcPos = rspSize; - U16 crc = MAKE_WORD_OF_BYTES( fpgaReadResponseBuffer[ crcPos ], fpgaReadResponseBuffer[ crcPos + 1 ] ); - - // Does the FPGA response CRC check out? - if ( crc == crc16( fpgaReadResponseBuffer, rspSize ) ) - { - fpgaCommRetryCount = 0; - // Capture the read values - memcpy( &fpgaSensorReadingsAsync, &fpgaReadResponseBuffer[ FPGA_READ_RSP_HDR_LEN ], sizeof( FPGA_SENSORS_ASYNC_T ) ); - result = FPGA_STATE_WRITE_ALL_ACTUATORS; - } - else // Bad CRC - { - fpgaCommRetryCount++; - } - } - else // Read command was NAK'd - { - fpgaCommRetryCount++; - } - } - else // No response to read command - { - fpgaCommRetryCount++; - } - - // Should not be any data received at this time - consumeUnexpectedData(); - - return result; -} -#endif - -/*********************************************************************//** - * @brief * The execFPGATest function executes the FPGA self-test. * @details Inputs: fpgaHeader * @details Outputs: none