Index: App/Common.h =================================================================== diff -u -r8ca991f9c04d8d301ada71eabc297f514b0d6cf8 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Common.h (.../Common.h) (revision 8ca991f9c04d8d301ada71eabc297f514b0d6cf8) +++ App/Common.h (.../Common.h) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -84,76 +84,6 @@ #define MAKE_WORD_OF_BYTES(h,l) ((((U16)(h) << SHIFT_8_BITS_FOR_BYTE_SHIFT) & MASK_OFF_LSB) | ((U16)(l) & MASK_OFF_MSB)) #define MAKE_LONG_OF_WORDS(h,l) ((((U32)(h) << SHIFT_16_BITS_FOR_WORD_SHIFT) & MASK_OFF_LSW) | ((U32)(l) & MASK_OFF_MSW)) -// **** Script Support Definitions **** - -#define OVERRIDE_KEY 0xCCC33C33 -#define OVERRIDE_RESET 0x00000000 - -// DATA_DECL - declares an overrideable data variable -// t = data's type -// t_name = name for data's structure type -// d_name = name for data's variable -// i_val = data's initial value -// o_val = data's initial override value -#define DATA_DECL( t, t_name, d_name, i_val, o_val ) \ -struct t_name \ -{ \ - t data; \ - t ovInitData; \ - t ovData; \ - U32 override; \ -}; \ -static struct t_name d_name = { i_val, o_val, o_val, OVERRIDE_RESET } - -// DATA_GET_PROTOTYPE - declares a function prototype for a DATA getter function -// t = data's type -// f_name = name for DATA getter function -#define DATA_GET_PROTOTYPE( t, f_name ) t f_name( void ) - -// DATA_GET - creates a getter function for a DATA -// t = data's type -// f_name = name for DATA getter function -// d_name = name of data's variable -#define DATA_GET( t, f_name, d_name ) \ -t f_name( void ) \ -{ \ - t result = d_name.data; \ - if ( OVERRIDE_KEY == d_name.override ) \ - { \ - result = d_name.ovData; \ - } \ - return result; \ -} - -// DATA_OVERRIDE_FUNC - creates an override and a reset override function for a DATA -// t = data's type -// o_name = name for override function -// r_name = name for reset override function -// d_name = name of data's variable -#define DATA_OVERRIDE_FUNC( t, o_name, r_name, d_name ) \ -BOOL o_name( t value ) \ -{ \ - BOOL result = FALSE; \ - if ( TRUE == isTestingActivated() ) \ - { \ - result = TRUE; \ - d_name.ovData = value; \ - d_name.override = OVERRIDE_KEY; \ - } \ - return result; \ -} \ -BOOL r_name( void ) \ -{ \ - BOOL result = FALSE; \ - if ( TRUE == isTestingActivated() ) \ - { \ - result = TRUE; \ - d_name.override = OVERRIDE_RESET; \ - d_name.ovData = d_name.ovInitData; \ - } \ - return result; \ -} - // **** VectorCAST Definitions **** #ifdef _VECTORCAST_ @@ -170,4 +100,7 @@ #endif +// include test support definitions and macros +#include "TestSupport.h" + #endif Index: App/Controllers/AlarmLamp.c =================================================================== diff -u -r40a959e1341c8964f872df462ac3a2d874e3b0b3 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) +++ App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -286,7 +286,7 @@ * @details * Inputs : none * Outputs : currentLampPattern - * @param state : override state for the alarm lamp pattern + * @param value : override state for the alarm lamp pattern * @return TRUE if override successful, FALSE if not *************************************************************************/ DATA_OVERRIDE_FUNC( LAMP_PATTERN_T, testSetCurrentLampPatternOverride, testResetCurrentLampPatternOverride, currentLampPattern ) Index: App/Controllers/AlarmLamp.h =================================================================== diff -u -r40a959e1341c8964f872df462ac3a2d874e3b0b3 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Controllers/AlarmLamp.h (.../AlarmLamp.h) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) +++ App/Controllers/AlarmLamp.h (.../AlarmLamp.h) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -42,7 +42,7 @@ DATA_GET_PROTOTYPE( LAMP_PATTERN_T, getCurrentAlarmLampPattern ); -BOOL testSetCurrentLampPatternOverride( LAMP_PATTERN_T state ); +BOOL testSetCurrentLampPatternOverride( LAMP_PATTERN_T value ); BOOL testResetCurrentLampPatternOverride( void ); #endif Index: App/Controllers/Buttons.c =================================================================== diff -u -r40a959e1341c8964f872df462ac3a2d874e3b0b3 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Controllers/Buttons.c (.../Buttons.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) +++ App/Controllers/Buttons.c (.../Buttons.c) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -356,7 +356,7 @@ * @details * Inputs : none * Outputs : dataOffButtonState - * @param state : override state for the off button + * @param value : override state for the off button * @return TRUE if override successful, FALSE if not *************************************************************************/ DATA_OVERRIDE_FUNC( BUTTON_STATE_T, testSetOffButtonStateOverride, testResetOffButtonStateOverride, dataOffButtonState ) @@ -370,7 +370,7 @@ * @details * Inputs : none * Outputs : dataStopButtonState - * @param state : override state for the stop button + * @param value : override state for the stop button * @return TRUE if override successful, FALSE if not *************************************************************************/ DATA_OVERRIDE_FUNC( BUTTON_STATE_T, testSetStopButtonStateOverride, testResetStopButtonStateOverride, dataStopButtonState ) Index: App/Controllers/Buttons.h =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Controllers/Buttons.h (.../Buttons.h) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Controllers/Buttons.h (.../Buttons.h) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -39,9 +39,9 @@ DATA_GET_PROTOTYPE( BUTTON_STATE_T, getOffButtonState ); DATA_GET_PROTOTYPE( BUTTON_STATE_T, getStopButtonState ); -BOOL testSetOffButtonStateOverride( BUTTON_STATE_T state ); +BOOL testSetOffButtonStateOverride( BUTTON_STATE_T value ); BOOL testResetOffButtonStateOverride( void ); -BOOL testSetStopButtonStateOverride( BUTTON_STATE_T state ); +BOOL testSetStopButtonStateOverride( BUTTON_STATE_T value ); BOOL testResetStopButtonStateOverride( void ); #endif Index: App/Modes/ModeInitPOST.c =================================================================== diff -u -r40a959e1341c8964f872df462ac3a2d874e3b0b3 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) +++ App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -18,6 +18,7 @@ #include #include "Common.h" #include "CPLD.h" +#include "FPGA.h" #include "OperationModes.h" #include "WatchdogMgmt.h" #include "ModeInitPOST.h" @@ -29,6 +30,7 @@ POST_STATE_START = 0, POST_STATE_ALARM_LAMP, POST_STATE_STUCK_BUTTON, + POST_STATE_FPGA, POST_STATE_WATCHDOG, POST_STATE_COMPLETED, POST_STATE_FAILED, @@ -108,6 +110,11 @@ postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_FPGA: + testStatus = execFPGATest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_WATCHDOG: testStatus = execWatchdogTest(); handlePOSTStatus( testStatus ); // ignoring return value because last test Index: App/Services/FPGA.c =================================================================== diff -u -r447eb904c9deb9536c04c9cc0e009a0b26b55573 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Services/FPGA.c (.../FPGA.c) (revision 447eb904c9deb9536c04c9cc0e009a0b26b55573) +++ App/Services/FPGA.c (.../FPGA.c) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -40,6 +40,7 @@ } FPGA_STATE_T; #define FPGA_PAGE_SIZE 256 +#define FPGA_EXPECTED_ID 0x59 #define FPGA_WRITE_CMD_BUFFER_LEN (FPGA_PAGE_SIZE+8) #define FPGA_READ_CMD_BUFFER_LEN 8 @@ -76,36 +77,15 @@ typedef struct { - U08 gap1; - U08 bloodLeakLow; - U08 bloodLeakHigh; - U08 gap2; - U08 gap3; - U08 adc1bLow; - U08 adc1bMid; - U08 adc1bHigh; - U08 adc2bLow; - U08 adc2bMid; - U08 adc2bHigh; - U08 dialysateTemp1Low; - U08 dialysateTemp1Mid; - U08 dialysateTemp1High; - U08 venousPressureLow; - U08 venousPressureMid; - U08 venousPressureHigh; - U08 arterialPressureLow; - U08 arterialPressureMid; - U08 arterialPressureHigh; - U08 gap4; - U08 adc1aLow; - U08 adc1aMid; - U08 adc1aHigh; - U08 adc2aLow; - U08 adc2aMid; - U08 adc2aHigh; - U08 dialysateTemp2Low; - U08 dialysateTemp2Mid; - U08 dialysateTemp2High; + U16 bloodLeak; + U32 adc1b; + U32 adc2b; + U32 dialysateTemp1; + U32 venousPressure; + U32 arterialPressure; + U32 adc1a; + U32 adc2a; + U32 dialysateTemp2; } FPGA_SENSORS_T; typedef struct @@ -260,12 +240,6 @@ fpgaDMAReadRespControlRecord.ELSOFFSET = 0; // not used fpgaDMAReadRespControlRecord.FRDOFFSET = 0; // not used fpgaDMAReadRespControlRecord.FRSOFFSET = 0; // not used - - // TODO - this is a DMA xmit and recv via loopback test -// setupDMAForWriteResp( 8 ); -// setupDMAForWriteCmd( 8 ); -// startDMAReceiptOfWriteResp(); -// startDMAWriteCmd(); } /************************************************************************* @@ -592,6 +566,28 @@ } /************************************************************************* + * @brief execFPGATest + * The execFPGATest function executes the FPGA self-test. \n + * @details + * Inputs : fpgaHeader + * Outputs : none + * @param none + * @return passed, or failed + *************************************************************************/ +SELF_TEST_STATUS_T execFPGATest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; + + // check FPGA reported correct ID + if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) + { + result = SELF_TEST_STATUS_PASSED; + } + + return result; +} + +/************************************************************************* * @brief setupDMAForWriteCmd * The setupDMAForWriteCmd function sets the byte count for the next DMA \n * write command to the FPGA. Index: App/Services/FPGA.h =================================================================== diff -u -r40a959e1341c8964f872df462ac3a2d874e3b0b3 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Services/FPGA.h (.../FPGA.h) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) +++ App/Services/FPGA.h (.../FPGA.h) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -27,13 +27,11 @@ void initFPGA( void ); void execFPGAIn( void ); void execFPGAOut( void ); +SELF_TEST_STATUS_T execFPGATest( void ); void signalFPGAReceiptCompleted( void ); void signalFPGATransmitCompleted( void ); -U08 getFPGAId( void ); -U08 getFPGARev( void ); -U08 getFPGADiag( void ); U16 getFPGAStatus( void ); void setFPGAControl( U16 ctrl ); Index: App/Services/SystemComm.c =================================================================== diff -u -r447eb904c9deb9536c04c9cc0e009a0b26b55573 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Services/SystemComm.c (.../SystemComm.c) (revision 447eb904c9deb9536c04c9cc0e009a0b26b55573) +++ App/Services/SystemComm.c (.../SystemComm.c) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -659,6 +659,10 @@ handleTestStopButtonStateOverrideRequest( message ); break; + case MSG_ID_WATCHDOG_TASK_CHECKIN_OVERRIDE: + handleTestWatchdogCheckInStateOverrideRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: App/Services/SystemCommMessages.c =================================================================== diff -u -r8ca991f9c04d8d301ada71eabc297f514b0d6cf8 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 8ca991f9c04d8d301ada71eabc297f514b0d6cf8) +++ App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -22,6 +22,7 @@ #include "AlarmLamp.h" #include "Buttons.h" #include "MsgQueues.h" +#include "WatchdogMgmt.h" #include "SystemCommMessages.h" #include "SystemComm.h" @@ -34,12 +35,6 @@ U08 confirmed; // 1 = confirmed, 0 = rejected/timed out } OFF_BUTTON_MESSAGE_FROM_UI_CARGO_T; -typedef struct -{ - U08 reset; - U32 state; -} TEST_OVERRIDE_CARGO_T; - #pragma pack(pop) // ********** private data ********** @@ -227,7 +222,7 @@ testerLoggedIn = FALSE; } // respond to would be tester - sendTestAckResponseMsg( MSG_ID_TESTER_LOGIN_REQUEST, testerLoggedIn ); + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); } /************************************************************************* @@ -253,7 +248,7 @@ result = addToMsgQueue( MSG_Q_IN, &hdMessage ); // respond to request - sendTestAckResponseMsg( MSG_ID_HD_MESSAGE, result ); + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /************************************************************************* @@ -271,18 +266,22 @@ TEST_OVERRIDE_CARGO_T cargo; BOOL result; - memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); - - if ( FALSE == (BOOL)(cargo.reset) ) + // verify cargo length + if ( sizeof(TEST_OVERRIDE_CARGO_T) == message->hdr.cargoLen ) { - result = testSetOffButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); + + if ( FALSE == (BOOL)(cargo.reset) ) + { + result = testSetOffButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); + } + else + { + result = testResetOffButtonStateOverride(); + } } - else - { - result = testResetOffButtonStateOverride(); - } // respond to request - sendTestAckResponseMsg( MSG_ID_OFF_BUTTON_STATE_OVERRIDE, result ); + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /************************************************************************* @@ -300,18 +299,22 @@ TEST_OVERRIDE_CARGO_T cargo; BOOL result; - memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); - - if ( FALSE == (BOOL)(cargo.reset) ) + // verify cargo length + if ( sizeof(TEST_OVERRIDE_CARGO_T) == message->hdr.cargoLen ) { - result = testSetStopButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); + + if ( FALSE == (BOOL)(cargo.reset) ) + { + result = testSetStopButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); + } + else + { + result = testResetStopButtonStateOverride(); + } } - else - { - result = testResetStopButtonStateOverride(); - } // respond to request - sendTestAckResponseMsg( MSG_ID_STOP_BUTTON_STATE_OVERRIDE, result ); + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /************************************************************************* @@ -329,18 +332,54 @@ TEST_OVERRIDE_CARGO_T cargo; BOOL result; - memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); - - if ( FALSE == (BOOL)(cargo.reset) ) + // verify cargo length + if ( sizeof(TEST_OVERRIDE_CARGO_T) == message->hdr.cargoLen ) { - result = testSetCurrentLampPatternOverride( (LAMP_PATTERN_T)(cargo.state) ); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); + + if ( FALSE == (BOOL)(cargo.reset) ) + { + result = testSetCurrentLampPatternOverride( (LAMP_PATTERN_T)(cargo.state) ); + } + else + { + result = testResetCurrentLampPatternOverride(); + } } - else + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief handleTestAlarmLampPatternOverrideRequest + * The handleTestAlarmLampPatternOverrideRequest function handles a request to \n + * override the alarm lamp pattern. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_CARGO_T cargo; + BOOL result; + + // verify cargo length + if ( sizeof(TEST_OVERRIDE_ARRAY_CARGO_T) == message->hdr.cargoLen ) { - result = testResetCurrentLampPatternOverride(); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_ARRAY_CARGO_T) ); + + if ( FALSE == (BOOL)(cargo.reset) ) + { + result = testSetWatchdogTaskCheckInOverride( cargo.index, (BOOL)(cargo.state) ); + } + else + { + result = testResetWatchdogTaskCheckInOverride( cargo.index ); + } } // respond to request - sendTestAckResponseMsg( MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE, result ); + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - Index: App/Services/SystemCommMessages.h =================================================================== diff -u -r40a959e1341c8964f872df462ac3a2d874e3b0b3 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) +++ App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -32,6 +32,7 @@ MSG_ID_OFF_BUTTON_STATE_OVERRIDE, MSG_ID_STOP_BUTTON_STATE_OVERRIDE, MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE, + MSG_ID_WATCHDOG_TASK_CHECKIN_OVERRIDE, NUM_OF_MSG_IDS } MSG_ID_T; @@ -59,4 +60,7 @@ // MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ); +// MSG_ID_WATCHDOG_TASK_CHECKIN_OVERRIDE: +void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ); + #endif Index: App/Services/WatchdogMgmt.c =================================================================== diff -u -r8ba82119080b77f804fa2b3edadd11422f57371b -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) +++ App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -16,6 +16,7 @@ #include "Common.h" #include "CPLD.h" +#include "SystemCommMessages.h" #include "Timers.h" #include "WatchdogMgmt.h" @@ -35,10 +36,10 @@ // ********** private data ********** -static BOOL watchdogExpired = FALSE; static U32 lastWatchdogPetTime = 0; -static BOOL watchdogTaskCheckedIn[NUM_OF_TASKS]; +DATA_ARRAY_DECL( BOOL, TaskCheckIns, NUM_OF_TASKS, watchdogTaskCheckedIn ); + static WATCHDOG_SELF_TEST_STATE_T watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; static U32 watchdogSelfTestTimerCount = 0; @@ -47,6 +48,7 @@ static void resetWDTaskCheckIns( void ); static BOOL haveAllTasksCheckedIn( void ); static void petWatchdog( void ); +static DATA_ARRAY_GET_PROTOTYPE( BOOL, hasTaskGeneralCheckedIn, task ); /************************************************************************* * @brief initWatchdogMgmt @@ -59,11 +61,19 @@ *************************************************************************/ void initWatchdogMgmt( void ) { - watchdogExpired = FALSE; + U32 i; + lastWatchdogPetTime = 0; watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; watchdogSelfTestTimerCount = 0; - resetWDTaskCheckIns(); + // initialize task check-ins to false + for ( i = 0; i < NUM_OF_TASKS; i++ ) + { + watchdogTaskCheckedIn[i].data = FALSE; + watchdogTaskCheckedIn[i].ovData = FALSE; + watchdogTaskCheckedIn[i].ovInitData = FALSE; + watchdogTaskCheckedIn[i].override = OVERRIDE_RESET; + } } /************************************************************************* @@ -95,7 +105,7 @@ // check to see if watchdog has expired if ( getCPLDWatchdogExpired() == PIN_SIGNAL_HIGH ) { - watchdogExpired = TRUE; + // TODO - watchdog expired fault } } @@ -113,26 +123,11 @@ { if ( task < NUM_OF_TASKS ) { - watchdogTaskCheckedIn[task] = TRUE; + watchdogTaskCheckedIn[task].data = TRUE; } } /************************************************************************* - * @brief hasWatchdogExpired - * The hasWatchdogExpired function determines whether the watchdog has /n - * expired. - * @details - * Inputs : watchdogExpired - * Outputs : none - * @param none - * @return TRUE if watchdog has expired, FALSE if not. - *************************************************************************/ -BOOL hasWatchdogExpired( void ) -{ - return watchdogExpired; -} - -/************************************************************************* * @brief execWatchdogTest * The execWatchdogTest function executes the watchdog test. \n * This function should be called periodically until a pass or fail \n @@ -201,7 +196,7 @@ // initialize task check-ins to false for ( i = 0; i < NUM_OF_TASKS; i++ ) { - watchdogTaskCheckedIn[i] = FALSE; + watchdogTaskCheckedIn[i].data = FALSE; } } @@ -223,7 +218,7 @@ // check that each task has checked in for ( i = 0; i < NUM_OF_TASKS; i++ ) { - if ( FALSE == watchdogTaskCheckedIn[i] ) + if ( FALSE == hasTaskGeneralCheckedIn( i ) ) { result = FALSE; break; @@ -234,6 +229,18 @@ } /************************************************************************* + * @brief hasTaskGeneralCheckedIn + * The hasTaskGeneralCheckedIn function gets the check-in state of a given /n + * task. + * @details + * Inputs : watchdogTaskCheckedIn[] + * Outputs : none + * @param task : ID of task to check + * @return TRUE if given task has checked in, FALSE if not + *************************************************************************/ +static DATA_ARRAY_GET( BOOL, hasTaskGeneralCheckedIn, task, NUM_OF_TASKS-1, watchdogTaskCheckedIn, FALSE ) + +/************************************************************************* * @brief petWatchdog * The petWatchdog function pets the watchdog by pulsing the CPLD WD pet /n * signal. @@ -253,3 +260,46 @@ // remember when we last pet the watchdog lastWatchdogPetTime = getMSTimerCount(); } + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/************************************************************************* + * @brief testSetWatchdogTaskCheckInOverride and testResetWatchdogTaskCheckInOverride + * The testSetWatchdogTaskCheckInOverride function overrides the state of the \n + * task check-in with the watchdog management with a given check-in state. \n + * The testResetWatchdogTaskCheckInOverride function resets the override of the \n + * state of the check-in with the watchdog management. + * @details + * Inputs : none + * Outputs : watchdogTaskCheckedIn[] + * @param task : ID of task to override check-in state for + * @param value : override state for the given task ID + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +DATA_ARRAY_OVERRIDE_FUNC( BOOL, testSetWatchdogTaskCheckInOverride, testResetWatchdogTaskCheckInOverride, watchdogTaskCheckedIn, task, NUM_OF_TASKS-1 ) + + + + + + + + + + + + + + + + + + + + + + Index: App/Services/WatchdogMgmt.h =================================================================== diff -u -r9aec79f151c686b730888c98f70f53ad958fe9b5 -rcda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd --- App/Services/WatchdogMgmt.h (.../WatchdogMgmt.h) (revision 9aec79f151c686b730888c98f70f53ad958fe9b5) +++ App/Services/WatchdogMgmt.h (.../WatchdogMgmt.h) (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -35,7 +35,9 @@ void initWatchdogMgmt( void ); void execWatchdogMgmt( void ); void checkInWithWatchdogMgmt( TASK_T task ); -BOOL hasWatchdogExpired( void ); SELF_TEST_STATUS_T execWatchdogTest( void ); +BOOL testSetWatchdogTaskCheckInOverride( U32 task, BOOL value ); +BOOL testResetWatchdogTaskCheckInOverride( U32 task ); + #endif Index: App/TestSupport.h =================================================================== diff -u --- App/TestSupport.h (revision 0) +++ App/TestSupport.h (revision cda7aca3cdae3f3a2c2bcefc009f96a9bf6e4bdd) @@ -0,0 +1,202 @@ +/************************************************************************** +* +* Copyright (c) 2019-2019 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file Common.h +* +* @date 19-Sep-2019 +* @author S. Nash +* +* @brief Header file for common definitions and types. +* +**************************************************************************/ + +#ifndef __TEST_SUPPORT_H__ +#define __TEST_SUPPORT_H__ + +// ***************************** OVERRIDE DEFINITIONS & MACROS ************************************* + +#define OVERRIDE_KEY 0xCCC33C33 +#define OVERRIDE_RESET 0x00000000 + +#pragma pack(push,1) + +typedef struct +{ + U08 reset; + U32 state; +} TEST_OVERRIDE_CARGO_T; + +typedef struct +{ + U08 reset; + U32 state; + U32 index; +} TEST_OVERRIDE_ARRAY_CARGO_T; + +#pragma pack(pop) + +// DATA_DECL - declares an overrideable data variable +// t = data's type +// t_name = name for data's structure type +// d_name = name for data's variable +// i_val = data's initial value +// o_val = data's initial override value +#define DATA_DECL( t, t_name, d_name, i_val, o_val ) \ +struct t_name \ +{ \ + t data; \ + t ovInitData; \ + t ovData; \ + U32 override; \ +}; \ +static struct t_name d_name = { i_val, o_val, o_val, OVERRIDE_RESET } + +// DATA_ARRAY_DECL - declares an overrideable data array +// t = data's type +// t_name = name for data's structure type +// s = array's size +// d_name = name for data array +#define DATA_ARRAY_DECL( t, t_name, s, d_name ) \ +struct t_name \ +{ \ + t data; \ + t ovInitData; \ + t ovData; \ + U32 override; \ +}; \ +static struct t_name d_name[s] + +// DATA_GET_PROTOTYPE - declares a function prototype for a DATA getter function +// t = data's type +// f_name = name for DATA getter function +#define DATA_GET_PROTOTYPE( t, f_name ) t f_name( void ) + +// DATA_ARRAY_GET_PROTOTYPE - declares a function prototype for a DATA array getter function +// t = data's type +// f_name = name for DATA getter function +// i_name = name for array's index parameter +#define DATA_ARRAY_GET_PROTOTYPE( t, f_name, i_name ) t f_name( U32 i_name ) + +// DATA_GET - creates a getter function for a DATA +// t = data's type +// f_name = name for DATA getter function +// d_name = name of data's variable +#define DATA_GET( t, f_name, d_name ) \ +t f_name( void ) \ +{ \ + t result = d_name.data; \ + if ( OVERRIDE_KEY == d_name.override ) \ + { \ + result = d_name.ovData; \ + } \ + return result; \ +} + +// DATA_ARRAY_GET - creates a getter function for a DATA +// t = data's type +// f_name = name for DATA getter function +// i_name = name for DATA array's index parameter +// max = DATA array's maximum index +// d_name = name of data's variable +// f_val = value to return if index is out of range +#define DATA_ARRAY_GET( t, f_name, i_name, max, d_name, f_val ) \ +t f_name( U32 i_name ) \ +{ \ + t result = f_val; \ + if ( i_name <= max ) \ + { \ + if ( OVERRIDE_KEY == d_name[i_name].override ) \ + { \ + result = d_name[i_name].ovData; \ + } \ + else \ + { \ + result = d_name[i_name].data; \ + } \ + } \ + else \ + { \ + /* TODO - s/w fault */ \ + } \ + return result; \ +} + +// DATA_OVERRIDE_FUNC - creates an override and a reset override function for a DATA +// t = data's type +// o_name = name for override function +// r_name = name for reset override function +// d_name = name of data's variable +#define DATA_OVERRIDE_FUNC( t, o_name, r_name, d_name ) \ +BOOL o_name( t value ) \ +{ \ + BOOL result = FALSE; \ + if ( TRUE == isTestingActivated() ) \ + { \ + result = TRUE; \ + d_name.ovData = value; \ + d_name.override = OVERRIDE_KEY; \ + } \ + return result; \ +} \ +BOOL r_name( void ) \ +{ \ + BOOL result = FALSE; \ + if ( TRUE == isTestingActivated() ) \ + { \ + result = TRUE; \ + d_name.override = OVERRIDE_RESET; \ + d_name.ovData = d_name.ovInitData; \ + } \ + return result; \ +} + +// DATA_ARRAY_OVERRIDE_FUNC - creates an override and a reset override function for a DATA array +// t = data's type +// o_name = name for override function +// r_name = name for reset override function +// d_name = name of data's variable +// i_name = name of DATA array's index parameter +// max = DATA array's maximum index +#define DATA_ARRAY_OVERRIDE_FUNC( t, o_name, r_name, d_name, i_name, max ) \ +BOOL o_name( U32 i_name, t value ) \ +{ \ + BOOL result = FALSE; \ + if ( i_name <= max ) \ + { \ + if ( TRUE == isTestingActivated() ) \ + { \ + result = TRUE; \ + d_name[i_name].ovData = value; \ + d_name[i_name].override = OVERRIDE_KEY; \ + } \ + } \ + else \ + { \ + /* TODO - s/w fault */ \ + } \ + return result; \ +} \ +BOOL r_name( U32 i_name ) \ +{ \ + BOOL result = FALSE; \ + if ( i_name <= max ) \ + { \ + if ( TRUE == isTestingActivated() ) \ + { \ + result = TRUE; \ + d_name[i_name].override = OVERRIDE_RESET; \ + d_name[i_name].ovData = d_name[i_name].ovInitData; \ + } \ + } \ + else \ + { \ + /* TODO - s/w fault */ \ + } \ + return result; \ +} + +#endif