Index: App/Common.h =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Common.h (.../Common.h) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Common.h (.../Common.h) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -64,13 +64,25 @@ // **** Common Definitions **** -#define NEARLY_ZERO 0.00001 +#define NEARLY_ZERO 0.00001 +#define MASK_OFF_MSB 0x00FF +#define MASK_OFF_LSB 0xFF00 +#define MASK_OFF_MSW 0x0000FFFF +#define MASK_OFF_LSW 0xFFFF0000 +#define SHIFT_BITS_IN_BYTE 8 +#define SHIFT_BITS_IN_WORD 16 -#define CAP(v,u) ((v) > (u) ? (u) : (v)) -#define RANGE(v,l,u) ((v) > (u) ? (u) : ((v) < (l) ? (l) : (v))) -#define INC_WRAP(v,l,u) ((v) == (u) ? (l) : ((v)+1)) -#define MAX(a,b) ((a) < (b) ? (b) : (a)) -#define MIN(a,b) ((a) > (b) ? (b) : (a)) +#define CAP(v,u) ((v) > (u) ? (u) : (v)) +#define RANGE(v,l,u) ((v) > (u) ? (u) : ((v) < (l) ? (l) : (v))) +#define INC_WRAP(v,l,u) ((v) == (u) ? (l) : ((v)+1)) +#define MAX(a,b) ((a) < (b) ? (b) : (a)) +#define MIN(a,b) ((a) > (b) ? (b) : (a)) +#define GET_LSB_OF_WORD(w) ((U08)((w) & MASK_OFF_MSB)) +#define GET_MSB_OF_WORD(w) ((U08)(((w) >> SHIFT_BITS_IN_BYTE) & MASK_OFF_MSB)) +#define GET_LSW_OF_LONG(l) ((U16)((l) & MASK_OFF_MSW)) +#define GET_MSW_OF_LONG(l) ((U16)(((l) >> SHIFT_BITS_IN_WORD) & MASK_OFF_MSW)) +#define MAKE_WORD_OF_BYTES(h,l) ((((U16)(h) << SHIFT_BITS_IN_BYTE) & MASK_OFF_LSB) | ((U16)(l) & MASK_OFF_MSB)) +#define MAKE_LONG_OF_WORDS(h,l) ((((U32)(h) << SHIFT_BITS_IN_WORD) & MASK_OFF_LSW) | ((U32)(l) & MASK_OFF_MSW)) // **** Script Support Definitions **** Index: App/Controllers/AlarmLamp.c =================================================================== diff -u -r3323966fe741edbb36dffc78317ccf06ed93a68e -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 3323966fe741edbb36dffc78317ccf06ed93a68e) +++ App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -17,6 +17,7 @@ #include #include "Common.h" #include "CPLD.h" +#include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Timers.h" @@ -52,7 +53,7 @@ // ********** private data ********** -static LAMP_PATTERN_T currentLampPattern = LAMP_PATTERN_OFF; +DATA_DECL( LAMP_PATTERN_T, LampPattern, currentLampPattern, LAMP_PATTERN_OFF, LAMP_PATTERN_FAULT ); static LAMP_PATTERN_T pendingLampPattern = LAMP_PATTERN_OFF; static U32 currentLampPatternStep = 0; static U32 lampPatternStepTimer = 0; @@ -85,7 +86,6 @@ *************************************************************************/ void initAlarmLamp( void ) { - currentLampPattern = LAMP_PATTERN_OFF; pendingLampPattern = LAMP_PATTERN_OFF; currentLampPatternStep = 0; lampPatternStepTimer = 0; @@ -108,9 +108,9 @@ void execAlarmLamp( void ) { // if starting a new lamp pattern, reset pattern variables - if ( pendingLampPattern != currentLampPattern ) + if ( pendingLampPattern != currentLampPattern.data ) { - currentLampPattern = pendingLampPattern; + currentLampPattern.data = pendingLampPattern; currentLampPatternStep = 0; setAlarmLampToPatternStep(); @@ -122,10 +122,10 @@ } // control alarm lamp to currently set pattern (unless we're in manual pattern) - if ( currentLampPattern != LAMP_PATTERN_MANUAL ) + if ( getCurrentAlarmLampPattern() != LAMP_PATTERN_MANUAL ) { // if pattern step duration has elapsed, move to next step - if ( lampPatternStepTimer >= lampPatterns[currentLampPattern].duration[currentLampPatternStep] ) + if ( lampPatternStepTimer >= lampPatterns[getCurrentAlarmLampPattern()].duration[currentLampPatternStep] ) { // increment pattern step currentLampPatternStep++; @@ -170,10 +170,7 @@ * @param none * @return currentLampPattern *************************************************************************/ -LAMP_PATTERN_T getCurrentAlarmLampPattern( void ) -{ - return currentLampPattern; -} +DATA_GET( LAMP_PATTERN_T, getCurrentAlarmLampPattern, currentLampPattern ) /************************************************************************* * @brief execAlarmLampTest @@ -256,15 +253,15 @@ PIN_SIGNAL_STATE_T red = PIN_SIGNAL_LOW; lampPatternStepTimer = 0; - if ( lampPatterns[currentLampPattern].green[currentLampPatternStep] == LAMP_STATE_ON ) + if ( lampPatterns[getCurrentAlarmLampPattern()].green[currentLampPatternStep] == LAMP_STATE_ON ) { green = PIN_SIGNAL_HIGH; } - if ( lampPatterns[currentLampPattern].blue[currentLampPatternStep] == LAMP_STATE_ON ) + if ( lampPatterns[getCurrentAlarmLampPattern()].blue[currentLampPatternStep] == LAMP_STATE_ON ) { blue = PIN_SIGNAL_HIGH; } - if ( lampPatterns[currentLampPattern].red[currentLampPatternStep] == LAMP_STATE_ON ) + if ( lampPatterns[getCurrentAlarmLampPattern()].red[currentLampPatternStep] == LAMP_STATE_ON ) { red = PIN_SIGNAL_HIGH; } @@ -273,3 +270,24 @@ setCPLDLampBlue( blue ); setCPLDLampRed( red ); } + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/************************************************************************* + * @brief testSetCurrentLampPatternOverride and testResetCurrentLampPatternOverride + * The testSetCurrentLampPatternOverride function overrides the state of the \n + * current alarm lamp pattern with a given pattern. \n + * The testResetCurrentLampPatternOverride function resets the override of the \n + * state of the alarm lamp pattern. + * @details + * Inputs : none + * Outputs : currentLampPattern + * @param state : 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 -r3323966fe741edbb36dffc78317ccf06ed93a68e -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Controllers/AlarmLamp.h (.../AlarmLamp.h) (revision 3323966fe741edbb36dffc78317ccf06ed93a68e) +++ App/Controllers/AlarmLamp.h (.../AlarmLamp.h) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -38,7 +38,11 @@ void initAlarmLamp( void ); void execAlarmLamp( void ); void requestAlarmLampPattern( LAMP_PATTERN_T lampPattern ); -LAMP_PATTERN_T getCurrentAlarmLampPattern( void ); SELF_TEST_STATUS_T execAlarmLampTest( void ); +DATA_GET_PROTOTYPE( LAMP_PATTERN_T, getCurrentAlarmLampPattern ); + +BOOL testSetCurrentLampPatternOverride( LAMP_PATTERN_T state ); +BOOL testResetCurrentLampPatternOverride( void ); + #endif Index: App/Controllers/Buttons.c =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Controllers/Buttons.c (.../Buttons.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Controllers/Buttons.c (.../Buttons.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -14,8 +14,8 @@ * **************************************************************************/ -#include #include "Common.h" +#include "Buttons.h" #include "CPLD.h" #include "OperationModes.h" #include "SystemCommMessages.h" @@ -43,12 +43,10 @@ // ********** private data ********** DATA_DECL( BUTTON_STATE_T, OffButtonState, dataOffButtonState, BUTTON_STATE_RELEASED, BUTTON_STATE_PRESSED ); -//static BUTTON_STATE_T offButtonState = BUTTON_STATE_RELEASED; static BUTTON_STATE_T prevOffButtonState = BUTTON_STATE_RELEASED; static BOOL offButtonPressPending = FALSE; DATA_DECL( BUTTON_STATE_T, StopButtonState, dataStopButtonState, BUTTON_STATE_RELEASED, BUTTON_STATE_PRESSED ); -//static BUTTON_STATE_T stopButtonState = BUTTON_STATE_RELEASED; static BUTTON_STATE_T prevStopButtonState = BUTTON_STATE_RELEASED; static BOOL stopButtonPressPending = FALSE; static U32 stopButtonPendingTimer = 0; @@ -76,11 +74,9 @@ *************************************************************************/ void initButtons( void ) { - //offButtonState = BUTTON_STATE_RELEASED; prevOffButtonState = BUTTON_STATE_RELEASED; offButtonPressPending = FALSE; - //stopButtonState = BUTTON_STATE_RELEASED; prevStopButtonState = BUTTON_STATE_RELEASED; stopButtonPressPending = FALSE; stopButtonPendingTimer = 0; @@ -346,109 +342,36 @@ } - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /************************************************************************* - * @brief testSetOffButtonStateOverride + * @brief testSetOffButtonStateOverride and testResetOffButtonStateOverride * The testSetOffButtonStateOverride function overrides the state of the \n - * off button with a given state. + * off button with a given state. \n + * The testResetOffButtonStateOverride function resets the override of the \n + * state of the off button. * @details * Inputs : none * Outputs : dataOffButtonState * @param state : override state for the off button * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetOffButtonStateOverride( BUTTON_STATE_T state ) -{ - BOOL result = FALSE; +DATA_OVERRIDE_FUNC( BUTTON_STATE_T, testSetOffButtonStateOverride, testResetOffButtonStateOverride, dataOffButtonState ) - // verify test login successfully completed before executing override - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - dataOffButtonState.ovData = state; - dataOffButtonState.override = OVERRIDE_KEY; - } - - return result; -} - /************************************************************************* - * @brief testResetOffButtonStateOverride - * The testResetOffButtonStateOverride function resets the override of the \n - * state of the off button. - * @details - * Inputs : none - * Outputs : dataOffButtonState - * @param none - * @return TRUE if override reset successful, FALSE if not - *************************************************************************/ -BOOL testResetOffButtonStateOverride( void ) -{ - BOOL result = FALSE; - - // verify test login successfully completed before executing override reset - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - dataOffButtonState.override = OVERRIDE_RESET; - dataOffButtonState.ovData = dataOffButtonState.ovInitData; - } - - return result; -} - -/************************************************************************* - * @brief testSetStopButtonStateOverride + * @brief testSetStopButtonStateOverride and testResetStopButtonStateOverride * The testSetStopButtonStateOverride function overrides the state of the \n - * stop button with a given state. + * stop button with a given state. \n + * The testResetStopButtonStateOverride function resets the override of the \n + * state of the stop button. * @details * Inputs : none * Outputs : dataStopButtonState * @param state : override state for the stop button * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetStopButtonStateOverride( BUTTON_STATE_T state ) -{ - BOOL result = FALSE; +DATA_OVERRIDE_FUNC( BUTTON_STATE_T, testSetStopButtonStateOverride, testResetStopButtonStateOverride, dataStopButtonState ) - // verify test login successfully completed before executing override - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - dataStopButtonState.ovData = state; - dataStopButtonState.override = OVERRIDE_KEY; - } - - return result; -} - -/************************************************************************* - * @brief testResetStopButtonStateOverride - * The testResetStopButtonStateOverride function resets the override of the \n - * state of the stop button. - * @details - * Inputs : none - * Outputs : dataStopButtonState - * @param none - * @return TRUE if override reset successful, FALSE if not - *************************************************************************/ -BOOL testResetStopButtonStateOverride( void ) -{ - BOOL result = FALSE; - - // verify test login successfully completed before executing override reset - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - dataStopButtonState.override = OVERRIDE_RESET; - dataStopButtonState.ovData = dataStopButtonState.ovInitData; - } - - return result; -} - Index: App/Modes/ModeInitPOST.c =================================================================== diff -u -r3323966fe741edbb36dffc78317ccf06ed93a68e -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 3323966fe741edbb36dffc78317ccf06ed93a68e) +++ App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -75,9 +75,7 @@ *************************************************************************/ void transitionToInitAndPOSTMode( void ) { - // temporary test code - solid red alarm lamp requestAlarmLampPattern( LAMP_PATTERN_MANUAL ); - //setCPLDLampRed( PIN_SIGNAL_HIGH ); } /************************************************************************* Index: App/Services/CommInterrupts.c =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Services/CommInterrupts.c (.../CommInterrupts.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/CommInterrupts.c (.../CommInterrupts.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -15,6 +15,7 @@ * **************************************************************************/ +#include "can.h" #include "sci.h" #include "sys_dma.h" @@ -35,6 +36,21 @@ /************************************************************************* + * @brief canMessageNotification + * The canMessageNotification function handles CAN message notifications. + * @details + * Inputs : none + * Outputs : CAN message notification handled. + * @param node : which CAN controller + * @param messageBox : which message box triggered the message notification + * @return none + *************************************************************************/ +void canMessageNotification(canBASE_t *node, uint32 messageBox) +{ + handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); +} + +/************************************************************************* * @brief sciNotification * The sciNotification function handles UART communication error interrupts. \n * Frame and Over-run errors are handled. Index: App/Services/FPGA.c =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Services/FPGA.c (.../FPGA.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/FPGA.c (.../FPGA.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -16,32 +16,35 @@ * **************************************************************************/ -//#include // for memcpy() +#include // for memset(), memcpy() #include "sci.h" #include "sys_dma.h" #include "CommInterrupts.h" #include "SystemCommMessages.h" +#include "Utilities.h" #include "FPGA.h" // ********** private definitions ********** typedef enum FPGA_States { FPGA_STATE_START = 0, - FPGA_STATE_READ_VERS_AND_DIAG, - FPGA_STATE_RCV_VERS_AND_DIAG, + FPGA_STATE_READ_HEADER, + FPGA_STATE_RCV_HEADER, FPGA_STATE_WRITE_ALL_ACTUATORS, FPGA_STATE_RCV_ALL_SENSORS, FPGA_STATE_FAILED, NUM_OF_FPGA_STATES } FPGA_STATE_T; -#define FPGA_WRITE_CMD_BUFFER_LEN 16 +#define FPGA_PAGE_SIZE 256 + +#define FPGA_WRITE_CMD_BUFFER_LEN (FPGA_PAGE_SIZE+8) #define FPGA_READ_CMD_BUFFER_LEN 8 #define FPGA_WRITE_RSP_BUFFER_LEN 8 -#define FPGA_READ_RSP_BUFFER_LEN 100 +#define FPGA_READ_RSP_BUFFER_LEN (FPGA_PAGE_SIZE+8) #define FPGA_WRITE_CMD_CODE 0x55 #define FPGA_READ_CMD_CODE 0x5A @@ -63,14 +66,52 @@ #pragma pack(push,1) typedef struct { - U08 artBloodValveState; // arterial blood valve state - U08 venBloodValveState; // venous blood valve state + U08 fpgaId; + U08 fpgaRev; + U08 fpgaDiag; + U08 gap1; + U08 fpgaStatusLow; + U08 fpgaStatusHigh; + U08 fpgaControlLow; + U08 fpgaControlHigh; +} FPGA_HEADER_T; + +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; } FPGA_SENSORS_T; typedef struct { - U08 artBloodValveState; // arterial blood valve set state - U08 venBloodValveState; // venous blood valve set state } FPGA_ACTUATORS_T; #pragma pack(pop) @@ -81,16 +122,16 @@ static U32 fpgaReceiptCounter = 0; static U32 fpgaTransmitCounter = 0; +static BOOL fpgaWriteCommandInProgress = FALSE; +static BOOL fpgaReadCommandInProgress = FALSE; +static BOOL fpgaBulkWriteAndReadInProgress = FALSE; +static BOOL fpgaWriteCommandACKed = FALSE; +static BOOL fpgaReadCommandACKed = FALSE; -// FPGA received sensor data from DMA bulk read -static FPGA_SENSORS_T fpgaSensorReadings; -// FPGA transmit actuator set points via DMA bulk write -static FPGA_ACTUATORS_T fpgaActuatorSetPoints; - // FPGA comm buffers -static U08 fpgaWriteCmdBuffer[FPGA_WRITE_CMD_BUFFER_LEN];// = {1,2,3,4,5,6,7,8,0,0,0,0,0,0,0,0}; -static U08 fpgaReadCmdBuffer[FPGA_READ_CMD_BUFFER_LEN];// = {0,0,0,0,0,0,0,0}; -static U08 fpgaWriteResponseBuffer[FPGA_WRITE_RSP_BUFFER_LEN];// = {0,0,0,0,0,0,0,0}; +static U08 fpgaWriteCmdBuffer[FPGA_WRITE_CMD_BUFFER_LEN]; +static U08 fpgaReadCmdBuffer[FPGA_READ_CMD_BUFFER_LEN]; +static U08 fpgaWriteResponseBuffer[FPGA_WRITE_RSP_BUFFER_LEN]; static U08 fpgaReadResponseBuffer[FPGA_READ_RSP_BUFFER_LEN]; // DMA control records @@ -100,26 +141,18 @@ static g_dmaCTRL fpgaDMAReadRespControlRecord; // FPGA data +static FPGA_HEADER_T fpgaHeader; +static FPGA_SENSORS_T fpgaSensorReadings; +static FPGA_ACTUATORS_T fpgaActuatorSetPoints; -U08 fpgaId; // FPGA Id -U08 fpgaRev; // FPGA Revision -U08 fpgaDiag; // FPGA diagnostic register - -// sensor readings -DATA_DECL( OPN_CLS_STATE_T, ArtBloodValveState, dataArterialBloodValveState, STATE_CLOSED, STATE_CLOSED ); -DATA_DECL( OPN_CLS_STATE_T, VenBloodValveState, dataVenousBloodValveState, STATE_CLOSED, STATE_CLOSED ); - -// actuator set points -DATA_DECL( OPN_CLS_STATE_T, ArtBloodValveSetState, dataArterialBloodValveSetState, STATE_CLOSED, STATE_CLOSED ); -DATA_DECL( OPN_CLS_STATE_T, VenBloodValveSetState, dataVenousBloodValveSetState, STATE_CLOSED, STATE_CLOSED ); - // ********** private function prototypes ********** -static FPGA_STATE_T handleFPGAReadVersionAndDiagnosticState( void ); -static FPGA_STATE_T handleFPGAReceiveVersionAndDiagnosticState( void ); +static FPGA_STATE_T handleFPGAReadHeaderState( void ); +static FPGA_STATE_T handleFPGAReceiveHeaderState( void ); static FPGA_STATE_T handleFPGAWriteAllActuatorsState( void ); static FPGA_STATE_T handleFPGAReceiveAllSensorsState( void ); +static void resetFPGACommFlags( void ); static void setupDMAForWriteCmd( U32 bytes2Transmit ); static void startDMAWriteCmd( void ); static void setupDMAForWriteResp( U32 bytes2Receive ); @@ -140,6 +173,11 @@ *************************************************************************/ void initFPGA( void ) { + // initialize fpga data structures + memset( &fpgaHeader, 0, sizeof(FPGA_HEADER_T) ); + memset( &fpgaSensorReadings, 0, sizeof(FPGA_SENSORS_T) ); + memset( &fpgaActuatorSetPoints, 0, sizeof(FPGA_ACTUATORS_T) ); + // enable interrupt notifications for FPGA serial port sciEnableNotification( scilinREG, SCI_OE_INT | SCI_FE_INT ); @@ -233,6 +271,27 @@ } /************************************************************************* + * @brief resetFPGACommFlags + * The resetFPGACommFlags function resets the various fpga comm flags and \n + * counters. + * @details + * Inputs : none + * Outputs : fpga comm flags & counters reset + * @param none + * @return none + *************************************************************************/ +static void resetFPGACommFlags( void ) +{ + fpgaWriteCommandACKed = FALSE; + fpgaReadCommandACKed = FALSE; + fpgaWriteCommandInProgress = FALSE; + fpgaReadCommandInProgress = FALSE; + fpgaBulkWriteAndReadInProgress = FALSE; + fpgaTransmitCounter = 0; + fpgaReceiptCounter = 0; +} + +/************************************************************************* * @brief signalFPGAReceiptCompleted * The signalFPGAReceiptCompleted function increments a counter to indicate \n * that another DMA receipt from the FPGA has completed. @@ -245,6 +304,28 @@ void signalFPGAReceiptCompleted( void ) { fpgaReceiptCounter++; + // did FPGA Ack last command? + if ( TRUE == fpgaWriteCommandInProgress ) + { + fpgaWriteCommandInProgress = FALSE; + fpgaWriteCommandACKed = ( fpgaWriteResponseBuffer[0] == FPGA_WRITE_CMD_ACK ? TRUE : FALSE ); + } + else if ( TRUE == fpgaReadCommandInProgress ) + { + fpgaReadCommandInProgress = FALSE; + fpgaReadCommandACKed = ( fpgaReadResponseBuffer[0] == FPGA_READ_CMD_ACK ? TRUE : FALSE ); + } + // first receipt? + if ( 1 == fpgaReceiptCounter ) + { + // see if we want to follow up with a bulk read command + if ( TRUE == fpgaBulkWriteAndReadInProgress ) + { + fpgaBulkWriteAndReadInProgress = FALSE; + fpgaReadCommandInProgress = TRUE; + // TODO - initiate bulk read command + } + } } /************************************************************************* @@ -263,33 +344,30 @@ } /************************************************************************* - * @brief execFPGA - * The execFPGA function manages data exchanges with the FPGA. + * @brief execFPGAIn + * The execFPGA function manages incoming data exchanges with the FPGA. * @details - * Inputs : none - * Outputs : none + * Inputs : fpgaState + * Outputs : fpgaState * @param none * @return none *************************************************************************/ -void execFPGA( void ) +void execFPGAIn( void ) { + resetFPGACommFlags(); + + // FPGA incoming state machine switch ( fpgaState ) { case FPGA_STATE_START: - fpgaState = FPGA_STATE_READ_VERS_AND_DIAG; + fpgaState = FPGA_STATE_READ_HEADER; break; - case FPGA_STATE_READ_VERS_AND_DIAG: - fpgaState = handleFPGAReadVersionAndDiagnosticState(); + case FPGA_STATE_RCV_HEADER: + fpgaState = handleFPGAReceiveHeaderState(); break; - case FPGA_STATE_RCV_VERS_AND_DIAG: - fpgaState = handleFPGAReceiveVersionAndDiagnosticState(); - break; - case FPGA_STATE_WRITE_ALL_ACTUATORS: - fpgaState = handleFPGAWriteAllActuatorsState(); - break; case FPGA_STATE_RCV_ALL_SENSORS: fpgaState = handleFPGAReceiveAllSensorsState(); @@ -300,34 +378,86 @@ break; default: - // TODO - fault + if ( fpgaState >= NUM_OF_FPGA_STATES ) + { + // TODO - s/w fault + } + else + { + // ok, some states handled in the outgoing state machine + } break; } } /************************************************************************* - * @brief handleFPGAReadVersionAndDiagnosticState - * The handleFPGAReadVersionAndDiagnosticState function handles the FPGA state \n - * where the read version/diag command is sent to the FPGA. + * @brief execFPGAOut + * The execFPGAOut function manages outgoing data exchanges with the FPGA. * @details + * Inputs : fpgaState + * Outputs : fpgaState + * @param none + * @return none + *************************************************************************/ +void execFPGAOut( void ) +{ + resetFPGACommFlags(); + + // FPGA outgoing state machine + switch ( fpgaState ) + { + case FPGA_STATE_READ_HEADER: + fpgaState = handleFPGAReadHeaderState(); + break; + + + + case FPGA_STATE_WRITE_ALL_ACTUATORS: + fpgaState = handleFPGAWriteAllActuatorsState(); + break; + + case FPGA_STATE_FAILED: + // do nothing - we'll be stuck here + break; + + default: + if ( fpgaState >= NUM_OF_FPGA_STATES ) + { + // TODO - s/w fault + } + else + { + // ok, some states handled in the incoming state machine + } + break; + } +} + +/************************************************************************* + * @brief handleFPGAReadHeaderState + * The handleFPGAReadHeaderState function handles the FPGA state where \n + * the read header registers command is sent to the FPGA. + * @details * Inputs : none * Outputs : read command sent to FPGA * @param none * @return next FPGA state *************************************************************************/ -static FPGA_STATE_T handleFPGAReadVersionAndDiagnosticState( void ) +static FPGA_STATE_T handleFPGAReadHeaderState( void ) { - FPGA_STATE_T result = FPGA_STATE_RCV_VERS_AND_DIAG; + FPGA_STATE_T result = FPGA_STATE_RCV_HEADER; + U16 crc; // construct read command to read 3 registers starting at address 0 fpgaReadCmdBuffer[0] = FPGA_READ_CMD_CODE; fpgaReadCmdBuffer[1] = 0x00; // start at FPGA address 0 fpgaReadCmdBuffer[2] = 0x00; - fpgaReadCmdBuffer[3] = 0x03; // read 3 registers - fpgaReadCmdBuffer[4] = 0x00; // no CRC for now - fpgaReadCmdBuffer[5] = 0x00; // TODO - add a 16-bit CRC function to calculate CRC + fpgaReadCmdBuffer[3] = sizeof(FPGA_HEADER_T); + crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN ); + fpgaReadCmdBuffer[4] = GET_LSB_OF_WORD( crc ); + fpgaReadCmdBuffer[5] = GET_MSB_OF_WORD( crc ); // prep DMA for sending the read cmd and receiving the response - setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + 3 + FPGA_CRC_LEN ); + setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_HEADER_T) + FPGA_CRC_LEN ); setupDMAForReadCmd( FPGA_READ_CMD_HDR_LEN + FPGA_CRC_LEN ); startDMAReceiptOfReadResp(); startDMAReadCmd(); @@ -336,33 +466,29 @@ } /************************************************************************* - * @brief handleFPGAReceiveVersionAndDiagnosticState - * The handleFPGAReceiveVersionAndDiagnosticState function handles the FPGA state \n - * where the version/diag read response should be ready to parse. + * @brief handleFPGAReceiveHeaderState + * The handleFPGAReceiveHeaderState function handles the FPGA state \n + * where the header registers read response should be ready to take in. * @details * Inputs : none - * Outputs : version/diag values updated + * Outputs : header register values updated * @param none * @return next FPGA state *************************************************************************/ -static FPGA_STATE_T handleFPGAReceiveVersionAndDiagnosticState( void ) +static FPGA_STATE_T handleFPGAReceiveHeaderState( void ) { - FPGA_STATE_T result = FPGA_STATE_READ_VERS_AND_DIAG; + FPGA_STATE_T result = FPGA_STATE_READ_HEADER; - // did FPGA response? + // did we get an FPGA response? if ( fpgaReceiptCounter > 0 ) { - fpgaReceiptCounter = 0; - fpgaTransmitCounter = 0; // did FPGA Ack the read command? if ( fpgaReadResponseBuffer[0] == FPGA_READ_CMD_ACK ) { // does the FPGA response CRC check out? if ( 1 ) // TODO - check response CRC { // capture the read values - fpgaId = fpgaReadResponseBuffer[1]; - fpgaRev = fpgaReadResponseBuffer[2]; - fpgaDiag = fpgaReadResponseBuffer[3]; + memcpy( &fpgaHeader, fpgaReadResponseBuffer, sizeof(FPGA_HEADER_T) ); result = FPGA_STATE_WRITE_ALL_ACTUATORS; } } @@ -385,6 +511,11 @@ { FPGA_STATE_T result = FPGA_STATE_RCV_ALL_SENSORS; + fpgaWriteCommandInProgress = TRUE; + fpgaBulkWriteAndReadInProgress = TRUE; + // TODO - setup for bulk write and follow-up bulk read commands + // TODO - initiate bulk write command + return result; } @@ -402,6 +533,18 @@ { FPGA_STATE_T result = FPGA_STATE_WRITE_ALL_ACTUATORS; + // check commands success + if ( FALSE == fpgaWriteCommandACKed ) + { + // TODO - ??? + } + if ( FALSE == fpgaReadCommandACKed ) + { + // TODO - ??? + } + + // TODO - collect sensor readings + return result; } @@ -538,151 +681,76 @@ * The getFPGAId function gets the version read from the Id register \n * of the FPGA. * @details - * Inputs : fpgaId + * Inputs : fpgaHeader * Outputs : none * @param none * @return Id *************************************************************************/ U08 getFPGAId( void ) { - return fpgaId; + return fpgaHeader.fpgaId; } /************************************************************************* * @brief getFPGARev * The getFPGARev function gets the revision read from the Rev register \n * of the FPGA. * @details - * Inputs : fpgaRev + * Inputs : fpgaHeader * Outputs : none * @param none * @return Revision *************************************************************************/ U08 getFPGARev( void ) { - return fpgaRev; + return fpgaHeader.fpgaRev; } /************************************************************************* * @brief getFPGADiag * The getFPGADiag function gets the version read from the diagnostic register \n * of the FPGA. * @details - * Inputs : fpgaDiag + * Inputs : fpgaHeader * Outputs : none * @param none * @return fpgaDiag *************************************************************************/ U08 getFPGADiag( void ) { - return fpgaDiag; + return fpgaHeader.fpgaDiag; } /************************************************************************* - * @brief getArterialBloodValveState - * The getArterialBloodValveState function gets the latest arterial blood \n - * valve state read from the FPGA. + * @brief getFPGAStatus + * The getFPGAStatus function gets the version read from the diagnostic register \n + * of the FPGA. * @details - * Inputs : dataArterialBloodValveState + * Inputs : fpgaHeader * Outputs : none * @param none - * @return The last read state for the arterial blood valve + * @return fpgaDiag *************************************************************************/ -DATA_GET( OPN_CLS_STATE_T, getArterialBloodValveState, dataArterialBloodValveState ) +U16 getFPGAStatus( void ) +{ + U16 result = MAKE_WORD_OF_BYTES(fpgaHeader.fpgaStatusHigh,fpgaHeader.fpgaStatusLow); -/************************************************************************* - * @brief getArterialBloodValveSetState - * The getArterialBloodValveSetState function gets the current arterial blood \n - * valve set state that is being sent to the FPGA. - * @details - * Inputs : dataArterialBloodValveSetState - * Outputs : none - * @param none - * @return The current set state for the arterial blood valve - *************************************************************************/ -DATA_GET( OPN_CLS_STATE_T, getArterialBloodValveSetState, dataArterialBloodValveSetState ) + return result; +} /************************************************************************* - * @brief getVenousBloodValveState - * The getVenousBloodValveState function gets the latest venous blood \n - * valve state read from the FPGA. + * @brief getFPGADiag + * The getFPGADiag function gets the version read from the diagnostic register \n + * of the FPGA. * @details - * Inputs : dataVenousBloodValveState + * Inputs : fpgaHeader * Outputs : none * @param none - * @return The last read state for the venous blood valve + * @return fpgaDiag *************************************************************************/ -DATA_GET( OPN_CLS_STATE_T, getVenousBloodValveState, dataVenousBloodValveState ) +void setFPGAControl( U16 ctrl ) +{ + fpgaHeader.fpgaControlHigh = GET_MSB_OF_WORD( ctrl ); + fpgaHeader.fpgaControlLow = GET_MSB_OF_WORD( ctrl ); +} -/************************************************************************* - * @brief getVenousBloodValveSetState - * The getVenousBloodValveSetState function gets the current venous blood \n - * valve set state that is being sent to the FPGA. - * @details - * Inputs : dataVenousBloodValveSetState - * Outputs : none - * @param none - * @return The current set state for the venous blood valve - *************************************************************************/ -DATA_GET( OPN_CLS_STATE_T, getVenousBloodValveSetState, dataVenousBloodValveSetState ) - - - - -/************************************************************************* - * @brief testSetArterialBloodValveStateOverride and testResetArterialBloodValveStateOverride - * The testSetArterialBloodValveStateOverride function overrides the \n - * arterial blood valve state that is being read from the FPGA. \n - * The testResetArterialBloodValveStateOverride function resets a previous \n - * override of the arterial blood valve state back to sensed state. \n - * @details - * Inputs : none - * Outputs : dataArterialBloodValveState - * @param none - * @return TRUE if successful, FALSE if not - *************************************************************************/ -DATA_OVERRIDE_FUNC( OPN_CLS_STATE_T, testSetArterialBloodValveStateOverride, testResetArterialBloodValveStateOverride, dataArterialBloodValveState ) - -/************************************************************************* - * @brief testSetArterialBloodValveSetStateOverride and testResetArterialBloodValveSetStateOverride - * The testSetArterialBloodValveSetStateOverride function overrides the \n - * arterial blood valve set state that is being sent to the FPGA. \n - * The testResetArterialBloodValveSetStateOverride function resets a previous \n - * override of the arterial blood valve set state back to controlled state. - * @details - * Inputs : none - * Outputs : dataArterialBloodValveSetState - * @param none - * @return TRUE if successful, FALSE if not - *************************************************************************/ -DATA_OVERRIDE_FUNC( OPN_CLS_STATE_T, testSetArterialBloodValveSetStateOverride, testResetArterialBloodValveSetStateOverride, dataArterialBloodValveSetState ) - -/************************************************************************* - * @brief testSetVenousBloodValveStateOverride and testResetVenousBloodValveStateOverride - * The testSetVenousBloodValveStateOverride function overrides the \n - * venous blood valve state that is being read from the FPGA. \n - * The testResetVenousBloodValveStateOverride function resets a previous \n - * override of the venous blood valve state back to sensed state. - * @details - * Inputs : none - * Outputs : dataVenousBloodValveState - * @param none - * @return TRUE if successful, FALSE if not - *************************************************************************/ -DATA_OVERRIDE_FUNC( OPN_CLS_STATE_T, testSetVenousBloodValveStateOverride, testResetVenousBloodValveStateOverride, dataVenousBloodValveState ) - -/************************************************************************* - * @brief testSetVenousBloodValveSetStateOverride and testResetVenousBloodValveSetStateOverride - * The testSetVenousBloodValveSetStateOverride function overrides the \n - * venous blood valve state that is being read from the FPGA. \n - * The testResetVenousBloodValveSetStateOverride function resets a previous \n - * override of the venous blood valve set state back to controlled state. \n - * @details - * Inputs : none - * Outputs : dataVenousBloodValveSetState - * @param none - * @return TRUE if successful, FALSE if not - *************************************************************************/ -DATA_OVERRIDE_FUNC( OPN_CLS_STATE_T, testSetVenousBloodValveSetStateOverride, testResetVenousBloodValveSetStateOverride, dataVenousBloodValveSetState ) - - Index: App/Services/FPGA.h =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Services/FPGA.h (.../FPGA.h) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/FPGA.h (.../FPGA.h) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -25,28 +25,16 @@ // ********** public function prototypes ********** void initFPGA( void ); -void execFPGA( void ); +void execFPGAIn( void ); +void execFPGAOut( void ); + void signalFPGAReceiptCompleted( void ); void signalFPGATransmitCompleted( void ); U08 getFPGAId( void ); U08 getFPGARev( void ); U08 getFPGADiag( void ); +U16 getFPGAStatus( void ); +void setFPGAControl( U16 ctrl ); -DATA_GET_PROTOTYPE( OPN_CLS_STATE_T, getArterialBloodValveState ); -DATA_GET_PROTOTYPE( OPN_CLS_STATE_T, getArterialBloodValveSetState ); - -DATA_GET_PROTOTYPE( OPN_CLS_STATE_T, getVenousBloodValveState ); -DATA_GET_PROTOTYPE( OPN_CLS_STATE_T, getVenousBloodValveSetState ); - -BOOL testSetArterialBloodValveStateOverride( OPN_CLS_STATE_T state ); -BOOL testResetArterialBloodValveStateOverride( void ); -BOOL testSetArterialBloodValveSetStateOverride( OPN_CLS_STATE_T state ); -BOOL testResetArterialBloodValveSetStateOverride( void ); - -BOOL testSetVenousBloodValveStateOverride( OPN_CLS_STATE_T state ); -BOOL testResetVenousBloodValveStateOverride( void ); -BOOL testSetVenousBloodValveSetStateOverride( OPN_CLS_STATE_T state ); -BOOL testResetVenousBloodValveSetStateOverride( void ); - #endif Index: App/Services/SystemComm.c =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Services/SystemComm.c (.../SystemComm.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/SystemComm.c (.../SystemComm.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -150,21 +150,6 @@ } /************************************************************************* - * @brief canMessageNotification - * The canMessageNotification function handles CAN message notifications. - * @details - * Inputs : none - * Outputs : CAN message notification handled. - * @param node : which CAN controller - * @param messageBox : which message box triggered the message notification - * @return none - *************************************************************************/ -void canMessageNotification(canBASE_t *node, uint32 messageBox) -{ - handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); -} - -/************************************************************************* * @brief handleCANMsgInterrupt * The handleCANMsgInterrupt function handles a CAN message interrupt. \n * This may have occurred because a CAN packet transmission has completed \n Index: App/Services/SystemCommMessages.c =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -19,6 +19,7 @@ #include // for memcpy() #include "Common.h" +#include "AlarmLamp.h" #include "Buttons.h" #include "MsgQueues.h" #include "SystemCommMessages.h" @@ -36,8 +37,8 @@ typedef struct { U08 reset; - U08 button_state; -} BUTTON_STATE_OVERRIDE_CARGO_T; + U08 state; +} TEST_OVERRIDE_CARGO_T; #pragma pack(pop) @@ -48,6 +49,7 @@ // ********** private function prototypes ********** static U32 serializeMessage( MESSAGE_T msg, U08 *data ); +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); /************************************************************************* * @brief serializeMessage @@ -154,6 +156,55 @@ /************************************************************************* + * @brief isTestingActivated + * The isTestingActivated function determines whether a tester has successfully \n + * logged in to activate testing functionality. + * @details + * Inputs : testerLoggedIn + * Outputs : none + * @param none + * @return TRUE if a tester has logged in to activate testing, FALSE if not + *************************************************************************/ +BOOL isTestingActivated( void ) +{ + return testerLoggedIn; +} + +/************************************************************************* + * @brief sendTestAckResponseMsg + * The sendTestAckResponseMsg function constructs a simple response \n + * message for a handled test message and queues it for transmit on the \n + * appropriate UART channel. + * @details + * Inputs : none + * Outputs : response message constructed and queued for transmit. + * @param msgID : ID of handled message that we are responding to + * @param ack : TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; + U32 msgSize; + U08 data[PC_MESSAGE_PACKET_SIZE]; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.cargoLen = 1; + msg.cargo[0] = (U08)ack; + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) + msgSize = serializeMessage( msg, data ); + + // add serialized message data to appropriate comm buffer + result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); + + return result; +} + +/************************************************************************* * @brief handleTesterLogInRequest * The handleTesterLogInRequest function handles a request to login as a \n * tester. @@ -176,57 +227,36 @@ testerLoggedIn = FALSE; } // respond to would be tester - sendTesterLogInResponse(); + sendTestAckResponseMsg( MSG_ID_TESTER_LOGIN_REQUEST, testerLoggedIn ); } /************************************************************************* - * @brief sendTesterLogInResponse - * The sendTesterLogInResponse function constructs a tester login response \n - * msg and queues the msg for transmit on the appropriate UART channel. + * @brief handleTestHDMessageRequest + * The handleTestHDMessageRequest function handles a request to add an \n + * HD message to the received message queue. * @details * Inputs : none - * Outputs : Off button msg constructed and queued. - * @param none - * @return TRUE if msg successfully queued for transmit, FALSE if not + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none *************************************************************************/ -BOOL sendTesterLogInResponse( void ) +void handleTestHDMessageRequest( MESSAGE_T *message ) { + MESSAGE_WRAPPER_T hdMessage; + U32 msgLen = (U32)(message->hdr.cargoLen); + U08 *msgBytes = (U08*)(&(hdMessage)); BOOL result; - MESSAGE_T msg; - U32 msgSize; - U08 data[sizeof(MESSAGE_WRAPPER_T)+1+1+CAN_MESSAGE_CARGO_SIZE]; // must hold full (wrapped) message + sync + any CAN padding - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TESTER_LOGIN_REQUEST; - msg.hdr.cargoLen = 1; - msg.cargo[0] = (U08)testerLoggedIn; + memcpy( msgBytes, message->cargo, msgLen ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) - msgSize = serializeMessage( msg, data ); + // add HD message to received message queue + result = addToMsgQueue( MSG_Q_IN, &hdMessage ); - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); - - return result; + // respond to request + sendTestAckResponseMsg( MSG_ID_HD_MESSAGE, result ); } /************************************************************************* - * @brief isTestingActivated - * The isTestingActivated function determines whether a tester has successfully \n - * logged in to activate testing functionality. - * @details - * Inputs : testerLoggedIn - * Outputs : none - * @param none - * @return TRUE if a tester has logged in to activate testing, FALSE if not - *************************************************************************/ -BOOL isTestingActivated( void ) -{ - return testerLoggedIn; -} - -/************************************************************************* * @brief handleTestOffButtonStateOverrideRequest * The handleTestOffButtonStateOverrideRequest function handles a request to \n * override the state of the off button. @@ -238,57 +268,24 @@ *************************************************************************/ void handleTestOffButtonStateOverrideRequest( MESSAGE_T *message ) { - BUTTON_STATE_OVERRIDE_CARGO_T cargo; + TEST_OVERRIDE_CARGO_T cargo; BOOL result; - memcpy( &cargo, message->cargo, sizeof(BUTTON_STATE_OVERRIDE_CARGO_T) ); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); if ( FALSE == (BOOL)(cargo.reset) ) { - result = testSetOffButtonStateOverride( (BUTTON_STATE_T)(cargo.button_state) ); + result = testSetOffButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); } else { result = testResetOffButtonStateOverride(); } // respond to request - sendTestOffButtonStateOverrideResponse( result ); + sendTestAckResponseMsg( MSG_ID_OFF_BUTTON_STATE_OVERRIDE, result ); } /************************************************************************* - * @brief sendTestOffButtonStateOverrideResponse - * The sendTestOffButtonStateOverrideResponse function constructs an off \n - * button override response msg and queues the msg for transmit on the \n - * appropriate UART channel. - * @details - * Inputs : none - * Outputs : Off button override response msg constructed and queued. - * @param ack : TRUE if override successful, FALSE if not - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendTestOffButtonStateOverrideResponse( BOOL ack ) -{ - BOOL result; - MESSAGE_T msg; - U32 msgSize; - U08 data[sizeof(MESSAGE_WRAPPER_T)+1+1+CAN_MESSAGE_CARGO_SIZE]; // must hold full (wrapped) message + sync + any CAN padding - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_OFF_BUTTON_STATE_OVERRIDE; - msg.hdr.cargoLen = 1; - msg.cargo[0] = (U08)ack; - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) - msgSize = serializeMessage( msg, data ); - - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); - - return result; -} - -/************************************************************************* * @brief handleTestStopButtonStateOverrideRequest * The handleTestStopButtonStateOverrideRequest function handles a request to \n * override the stop button state. @@ -300,53 +297,50 @@ *************************************************************************/ void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ) { - BUTTON_STATE_OVERRIDE_CARGO_T cargo; + TEST_OVERRIDE_CARGO_T cargo; BOOL result; - memcpy( &cargo, message->cargo, sizeof(BUTTON_STATE_OVERRIDE_CARGO_T) ); + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); if ( FALSE == (BOOL)(cargo.reset) ) { - result = testSetStopButtonStateOverride( (BUTTON_STATE_T)(cargo.button_state) ); + result = testSetStopButtonStateOverride( (BUTTON_STATE_T)(cargo.state) ); } else { result = testResetStopButtonStateOverride(); } // respond to request - sendTestStopButtonStateOverrideResponse( result ); + sendTestAckResponseMsg( MSG_ID_STOP_BUTTON_STATE_OVERRIDE, result ); } /************************************************************************* - * @brief sendTestStopButtonStateOverrideResponse - * The sendTestStopButtonStateOverrideResponse function constructs a stop \n - * button override response msg and queues the msg for transmit on the \n - * appropriate UART channel. + * @brief handleTestAlarmLampPatternOverrideRequest + * The handleTestAlarmLampPatternOverrideRequest function handles a request to \n + * override the alarm lamp pattern. * @details * Inputs : none - * Outputs : stop button override response msg constructed and queued. - * @param ack : TRUE if override successful, FALSE if not - * @return TRUE if msg successfully queued for transmit, FALSE if not + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none *************************************************************************/ -BOOL sendTestStopButtonStateOverrideResponse( BOOL ack ) +void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ) { + TEST_OVERRIDE_CARGO_T cargo; BOOL result; - MESSAGE_T msg; - U32 msgSize; - U08 data[sizeof(MESSAGE_WRAPPER_T)+1+1+CAN_MESSAGE_CARGO_SIZE]; // must hold full (wrapped) message + sync + any CAN padding - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_STOP_BUTTON_STATE_OVERRIDE; - msg.hdr.cargoLen = 1; - msg.cargo[0] = (U08)ack; + memcpy( &cargo, message->cargo, sizeof(TEST_OVERRIDE_CARGO_T) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) - msgSize = serializeMessage( msg, data ); - - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, data, msgSize ); - - return result; + if ( FALSE == (BOOL)(cargo.reset) ) + { + result = testSetCurrentLampPatternOverride( (LAMP_PATTERN_T)(cargo.state) ); + } + else + { + result = testResetCurrentLampPatternOverride(); + } + // respond to request + sendTestAckResponseMsg( MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE, result ); } + Index: App/Services/SystemCommMessages.h =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -28,8 +28,10 @@ MSG_ID_OFF_BUTTON_PRESS, MSG_ID_FIRST_TESTER_MESSAGE = 8000, MSG_ID_TESTER_LOGIN_REQUEST = MSG_ID_FIRST_TESTER_MESSAGE, + MSG_ID_HD_MESSAGE, MSG_ID_OFF_BUTTON_STATE_OVERRIDE, MSG_ID_STOP_BUTTON_STATE_OVERRIDE, + MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE, NUM_OF_MSG_IDS } MSG_ID_T; @@ -43,15 +45,18 @@ // MSG_TESTER_LOG_IN void handleTesterLogInRequest( MESSAGE_T *message ); -BOOL sendTesterLogInResponse( void ); BOOL isTestingActivated( void ); +// MSG_ID_HD_MESSAGE +void handleTestHDMessageRequest( MESSAGE_T *message ); + // MSG_ID_OFF_BUTTON_STATE_OVERRIDE void handleTestOffButtonStateOverrideRequest( MESSAGE_T *message ); -BOOL sendTestOffButtonStateOverrideResponse( BOOL ack ); // MSG_ID_STOP_BUTTON_STATE_OVERRIDE void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ); -BOOL sendTestStopButtonStateOverrideResponse( BOOL ack ); +// MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE +void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ); + #endif Index: App/Tasks/TaskPriority.c =================================================================== diff -u -rcb47c5f896477ceae7597cb1a4191b3972e93f0d -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision cb47c5f896477ceae7597cb1a4191b3972e93f0d) +++ App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -32,11 +32,15 @@ void taskPriority( void ) { // 1st pass for FPGA - execFPGA(); + execFPGAIn(); // monitor and process buttons execButtons(); + + // 2nd pass for FPGA + execFPGAOut(); + // check in with watchdog manager checkInWithWatchdogMgmt( TASK_PRIORITY ); Index: Debug/ccsObjs.opt =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- Debug/ccsObjs.opt (.../ccsObjs.opt) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ Debug/ccsObjs.opt (.../ccsObjs.opt) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -1 +1 @@ -"./irqDispatch_a.obj" "./irqDispatch_c.obj" "./App/Controllers/AlarmLamp.obj" "./App/Controllers/Buttons.obj" "./App/Drivers/CPLD.obj" "./App/Drivers/SafetyShutdown.obj" "./App/Modes/ModeFault.obj" "./App/Modes/ModeInitPOST.obj" "./App/Modes/ModeOpParams.obj" "./App/Modes/ModePostTreat.obj" "./App/Modes/ModePreTreat.obj" "./App/Modes/ModePrescription.obj" "./App/Modes/ModeService.obj" "./App/Modes/ModeStandby.obj" "./App/Modes/ModeTreatment.obj" "./App/Modes/OperationModes.obj" "./App/Services/CommBuffers.obj" "./App/Services/CommInterrupts.obj" "./App/Services/FPGA.obj" "./App/Services/MsgQueues.obj" "./App/Services/SystemComm.obj" "./App/Services/SystemCommMessages.obj" "./App/Services/Timers.obj" "./App/Services/WatchdogMgmt.obj" "./App/Tasks/TaskBG.obj" "./App/Tasks/TaskGeneral.obj" "./App/Tasks/TaskPriority.obj" "./App/Tasks/TaskTimer.obj" "./source/can.obj" "./source/dabort.obj" "./source/errata_SSWF021_45.obj" "./source/esm.obj" "./source/gio.obj" "./source/lin.obj" "./source/mibspi.obj" "./source/notification.obj" "./source/pinmux.obj" "./source/rti.obj" "./source/sci.obj" "./source/sys_core.obj" "./source/sys_dma.obj" "./source/sys_intvecs.obj" "./source/sys_main.obj" "./source/sys_mpu.obj" "./source/sys_pcr.obj" "./source/sys_phantom.obj" "./source/sys_pmm.obj" "./source/sys_pmu.obj" "./source/sys_selftest.obj" "./source/sys_startup.obj" "./source/sys_vim.obj" "./source/system.obj" "../source/sys_link.cmd" -lrtsv7R4_T_le_v3D16_eabi.lib \ No newline at end of file +"./irqDispatch_a.obj" "./irqDispatch_c.obj" "./App/Controllers/AlarmLamp.obj" "./App/Controllers/Buttons.obj" "./App/Drivers/CPLD.obj" "./App/Drivers/SafetyShutdown.obj" "./App/Modes/ModeFault.obj" "./App/Modes/ModeInitPOST.obj" "./App/Modes/ModeOpParams.obj" "./App/Modes/ModePostTreat.obj" "./App/Modes/ModePreTreat.obj" "./App/Modes/ModePrescription.obj" "./App/Modes/ModeService.obj" "./App/Modes/ModeStandby.obj" "./App/Modes/ModeTreatment.obj" "./App/Modes/OperationModes.obj" "./App/Services/CommBuffers.obj" "./App/Services/CommInterrupts.obj" "./App/Services/FPGA.obj" "./App/Services/MsgQueues.obj" "./App/Services/SystemComm.obj" "./App/Services/SystemCommMessages.obj" "./App/Services/Timers.obj" "./App/Services/Utilities.obj" "./App/Services/WatchdogMgmt.obj" "./App/Tasks/TaskBG.obj" "./App/Tasks/TaskGeneral.obj" "./App/Tasks/TaskPriority.obj" "./App/Tasks/TaskTimer.obj" "./source/can.obj" "./source/dabort.obj" "./source/errata_SSWF021_45.obj" "./source/esm.obj" "./source/gio.obj" "./source/lin.obj" "./source/mibspi.obj" "./source/notification.obj" "./source/pinmux.obj" "./source/rti.obj" "./source/sci.obj" "./source/sys_core.obj" "./source/sys_dma.obj" "./source/sys_intvecs.obj" "./source/sys_main.obj" "./source/sys_mpu.obj" "./source/sys_pcr.obj" "./source/sys_phantom.obj" "./source/sys_pmm.obj" "./source/sys_pmu.obj" "./source/sys_selftest.obj" "./source/sys_startup.obj" "./source/sys_vim.obj" "./source/system.obj" "../source/sys_link.cmd" -lrtsv7R4_T_le_v3D16_eabi.lib \ No newline at end of file Index: Debug/makefile =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r40a959e1341c8964f872df462ac3a2d874e3b0b3 --- Debug/makefile (.../makefile) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ Debug/makefile (.../makefile) (revision 40a959e1341c8964f872df462ac3a2d874e3b0b3) @@ -31,6 +31,7 @@ "./App/Services/SystemComm.obj" \ "./App/Services/SystemCommMessages.obj" \ "./App/Services/Timers.obj" \ +"./App/Services/Utilities.obj" \ "./App/Services/WatchdogMgmt.obj" \ "./App/Tasks/TaskBG.obj" \ "./App/Tasks/TaskGeneral.obj" \ @@ -215,10 +216,10 @@ # Other Targets clean: -$(RM) $(BIN_OUTPUTS__QUOTED)$(EXE_OUTPUTS__QUOTED) - -$(RM) "irqDispatch_a.obj" "irqDispatch_c.obj" "App/Controllers/AlarmLamp.obj" "App/Controllers/Buttons.obj" "App/Drivers/CPLD.obj" "App/Drivers/SafetyShutdown.obj" "App/Modes/ModeFault.obj" "App/Modes/ModeInitPOST.obj" "App/Modes/ModeOpParams.obj" "App/Modes/ModePostTreat.obj" "App/Modes/ModePreTreat.obj" "App/Modes/ModePrescription.obj" "App/Modes/ModeService.obj" "App/Modes/ModeStandby.obj" "App/Modes/ModeTreatment.obj" "App/Modes/OperationModes.obj" "App/Services/CommBuffers.obj" "App/Services/CommInterrupts.obj" "App/Services/FPGA.obj" "App/Services/MsgQueues.obj" "App/Services/SystemComm.obj" "App/Services/SystemCommMessages.obj" "App/Services/Timers.obj" "App/Services/WatchdogMgmt.obj" "App/Tasks/TaskBG.obj" "App/Tasks/TaskGeneral.obj" "App/Tasks/TaskPriority.obj" "App/Tasks/TaskTimer.obj" "source/can.obj" "source/dabort.obj" "source/errata_SSWF021_45.obj" "source/esm.obj" "source/gio.obj" "source/lin.obj" "source/mibspi.obj" "source/notification.obj" "source/pinmux.obj" "source/rti.obj" - -$(RM) "source/sci.obj" "source/sys_core.obj" "source/sys_dma.obj" "source/sys_intvecs.obj" "source/sys_main.obj" "source/sys_mpu.obj" "source/sys_pcr.obj" "source/sys_phantom.obj" "source/sys_pmm.obj" "source/sys_pmu.obj" "source/sys_selftest.obj" "source/sys_startup.obj" "source/sys_vim.obj" "source/system.obj" - -$(RM) "irqDispatch_c.d" "App/Controllers/AlarmLamp.d" "App/Controllers/Buttons.d" "App/Drivers/CPLD.d" "App/Drivers/SafetyShutdown.d" "App/Modes/ModeFault.d" "App/Modes/ModeInitPOST.d" "App/Modes/ModeOpParams.d" "App/Modes/ModePostTreat.d" "App/Modes/ModePreTreat.d" "App/Modes/ModePrescription.d" "App/Modes/ModeService.d" "App/Modes/ModeStandby.d" "App/Modes/ModeTreatment.d" "App/Modes/OperationModes.d" "App/Services/CommBuffers.d" "App/Services/CommInterrupts.d" "App/Services/FPGA.d" "App/Services/MsgQueues.d" "App/Services/SystemComm.d" "App/Services/SystemCommMessages.d" "App/Services/Timers.d" "App/Services/WatchdogMgmt.d" "App/Tasks/TaskBG.d" "App/Tasks/TaskGeneral.d" "App/Tasks/TaskPriority.d" "App/Tasks/TaskTimer.d" "source/can.d" "source/errata_SSWF021_45.d" "source/esm.d" "source/gio.d" "source/lin.d" "source/mibspi.d" "source/notification.d" "source/pinmux.d" "source/rti.d" "source/sci.d" "source/sys_dma.d" "source/sys_main.d" "source/sys_pcr.d" "source/sys_phantom.d" "source/sys_pmm.d" - -$(RM) "source/sys_selftest.d" "source/sys_startup.d" "source/sys_vim.d" "source/system.d" + -$(RM) "irqDispatch_a.obj" "irqDispatch_c.obj" "App/Controllers/AlarmLamp.obj" "App/Controllers/Buttons.obj" "App/Drivers/CPLD.obj" "App/Drivers/SafetyShutdown.obj" "App/Modes/ModeFault.obj" "App/Modes/ModeInitPOST.obj" "App/Modes/ModeOpParams.obj" "App/Modes/ModePostTreat.obj" "App/Modes/ModePreTreat.obj" "App/Modes/ModePrescription.obj" "App/Modes/ModeService.obj" "App/Modes/ModeStandby.obj" "App/Modes/ModeTreatment.obj" "App/Modes/OperationModes.obj" "App/Services/CommBuffers.obj" "App/Services/CommInterrupts.obj" "App/Services/FPGA.obj" "App/Services/MsgQueues.obj" "App/Services/SystemComm.obj" "App/Services/SystemCommMessages.obj" "App/Services/Timers.obj" "App/Services/Utilities.obj" "App/Services/WatchdogMgmt.obj" "App/Tasks/TaskBG.obj" "App/Tasks/TaskGeneral.obj" "App/Tasks/TaskPriority.obj" "App/Tasks/TaskTimer.obj" "source/can.obj" "source/dabort.obj" "source/errata_SSWF021_45.obj" "source/esm.obj" "source/gio.obj" "source/lin.obj" "source/mibspi.obj" "source/notification.obj" "source/pinmux.obj" + -$(RM) "source/rti.obj" "source/sci.obj" "source/sys_core.obj" "source/sys_dma.obj" "source/sys_intvecs.obj" "source/sys_main.obj" "source/sys_mpu.obj" "source/sys_pcr.obj" "source/sys_phantom.obj" "source/sys_pmm.obj" "source/sys_pmu.obj" "source/sys_selftest.obj" "source/sys_startup.obj" "source/sys_vim.obj" "source/system.obj" + -$(RM) "irqDispatch_c.d" "App/Controllers/AlarmLamp.d" "App/Controllers/Buttons.d" "App/Drivers/CPLD.d" "App/Drivers/SafetyShutdown.d" "App/Modes/ModeFault.d" "App/Modes/ModeInitPOST.d" "App/Modes/ModeOpParams.d" "App/Modes/ModePostTreat.d" "App/Modes/ModePreTreat.d" "App/Modes/ModePrescription.d" "App/Modes/ModeService.d" "App/Modes/ModeStandby.d" "App/Modes/ModeTreatment.d" "App/Modes/OperationModes.d" "App/Services/CommBuffers.d" "App/Services/CommInterrupts.d" "App/Services/FPGA.d" "App/Services/MsgQueues.d" "App/Services/SystemComm.d" "App/Services/SystemCommMessages.d" "App/Services/Timers.d" "App/Services/Utilities.d" "App/Services/WatchdogMgmt.d" "App/Tasks/TaskBG.d" "App/Tasks/TaskGeneral.d" "App/Tasks/TaskPriority.d" "App/Tasks/TaskTimer.d" "source/can.d" "source/errata_SSWF021_45.d" "source/esm.d" "source/gio.d" "source/lin.d" "source/mibspi.d" "source/notification.d" "source/pinmux.d" "source/rti.d" "source/sci.d" "source/sys_dma.d" "source/sys_main.d" "source/sys_pcr.d" "source/sys_phantom.d" + -$(RM) "source/sys_pmm.d" "source/sys_selftest.d" "source/sys_startup.d" "source/sys_vim.d" "source/system.d" -$(RM) "irqDispatch_a.d" "source/dabort.d" "source/sys_core.d" "source/sys_intvecs.d" "source/sys_mpu.d" "source/sys_pmu.d" -@echo 'Finished clean' -@echo ' '