Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r844f98879b7425c207b58562e623ab960adbc357 -r935694e8acbb551be64549e014d1f1963cf6240d --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 844f98879b7425c207b58562e623ab960adbc357) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 935694e8acbb551be64549e014d1f1963cf6240d) @@ -23,8 +23,10 @@ #include "Comm.h" #include "Compatible.h" #include "FPGA.h" +#include "OperationModes.h" #include "PersistentAlarm.h" #include "SystemCommMessages.h" +#include "Timers.h" #include "Utilities.h" /** @@ -110,6 +112,8 @@ #define FRONT_DOOR_SWITCH_MASK 0x0010 ///< Front door switch bit mask. Bit 4 of the GPIO register. #define PUMP_TRACK_SWITCH_MASK 0x0020 ///< Pump track switch bit mask. Bit 5 of the GPIO register. +#define PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE 1 ///< Tolerance for processor clock speed check against FPGA clock. + // FPGA Sensors Record #pragma pack(push,1) /// Record structure for FPGA header read. @@ -299,6 +303,9 @@ static FPGA_SENSORS_ASYNC_T fpgaSensorReadingsAsync; ///< Record of last received async (as needed) FPGA sensor data. #endif +static U16 currentFPGATimerCount_ms; ///< Current FPGA timer count in ms. +static U32 currentTimerCount_ms; ///< Current processor timer count in ms. + // ********** private function prototypes ********** static FPGA_STATE_T handleFPGAReadHeaderState( void ); @@ -924,6 +931,33 @@ /*********************************************************************//** * @brief + * The execFPGAClockSpeedTest function verifies the processor clock speed + * against the FPGA clock. + * @details Inputs: fpgaHeader + * @details Outputs: none + * @return passed, or failed + *************************************************************************/ +void execFPGAClockSpeedTest( void ) +{ + U16 const newFPGATimerCount_ms = getFPGATimerCount(); + U32 const newTimerCount_ms = getMSTimerCount(); + U32 const diffFPGATimerCount = (U32)u16DiffWithWrap( currentFPGATimerCount_ms, newFPGATimerCount_ms ); + U32 const diffTimerCount = u32DiffWithWrap( currentTimerCount_ms, newTimerCount_ms ); + + if ( getCurrentOperationMode() > MODE_INIT ) + { + if ( abs( diffFPGATimerCount - diffTimerCount ) > PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_CLOCK_SPEED_CHECK_FAILURE, diffFPGATimerCount, diffTimerCount ); + } + } + + currentFPGATimerCount_ms = newFPGATimerCount_ms; + currentTimerCount_ms = newTimerCount_ms; +} + +/*********************************************************************//** + * @brief * The consumeUnexpectedData function checks to see if a byte is sitting in * the SCI2 received data register. * @details Inputs: fpgaHeader Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r844f98879b7425c207b58562e623ab960adbc357 -r935694e8acbb551be64549e014d1f1963cf6240d --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 844f98879b7425c207b58562e623ab960adbc357) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 935694e8acbb551be64549e014d1f1963cf6240d) @@ -46,6 +46,7 @@ void execFPGAIn( void ); void execFPGAOut( void ); SELF_TEST_STATUS_T execFPGATest( void ); +void execFPGAClockSpeedTest( void ); void signalFPGAReceiptCompleted( void ); void signalFPGATransmitCompleted( void ); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -rcef6b0392becf60c69cf4e517701ba22642f072a -r935694e8acbb551be64549e014d1f1963cf6240d --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision cef6b0392becf60c69cf4e517701ba22642f072a) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 935694e8acbb551be64549e014d1f1963cf6240d) @@ -61,6 +61,9 @@ #ifndef BOARD_WITH_NO_HARDWARE // 1st pass for FPGA execFPGAIn(); + + // Verify processor clock speed against FPGA clock + execFPGAClockSpeedTest(); #ifndef CAN_TEST // Monitor and process buttons