Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -rd8fa48ead3336b1fe090b42030a8648264831076 -r632bbd302a9ae48df66e40a6faadc3db0c164671 --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision d8fa48ead3336b1fe090b42030a8648264831076) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision 632bbd302a9ae48df66e40a6faadc3db0c164671) @@ -12,7 +12,6 @@ // ********** private definitions ********** #define SWITCHES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the switches data is published on the CAN bus. -#define FRONT_DOOR_SWITCH_BIT_MASK 0x00A0 ///< Front door switch bit mask. #define SWITCHES_FPGA_STATUS_CHECK_INTERVAL ( MS_PER_SECOND / ( 5 * TASK_GENERAL_INTERVAL ) ) ///< Switches FPGA status check interval. // ********** private data ********** @@ -53,18 +52,16 @@ /*********************************************************************//** * @brief * The execSwitches function executes the switches executive. - * @details Inputs: switchStatus - * @details Outputs: switchStatus + * @details Inputs: switchesFPGAStatusCheckCounter + * @details Outputs: switchStatus, switchesFPGAStatusCheckCounter * @return none *************************************************************************/ void execSwitches( void ) { if ( ++switchesFPGAStatusCheckCounter > SWITCHES_FPGA_STATUS_CHECK_INTERVAL ) { - U08 fpgaRegister = getFPGAGPIOCount(); + switchStatus[ FRONT_DOOR ].data = (U32)( getFPGAFrontDoorStatus() != 0 ? OPEN : CLOSED ); - switchStatus[ FRONT_DOOR ].data = fpgaRegister & FRONT_DOOR_SWITCH_BIT_MASK; - switchesFPGAStatusCheckCounter = 0; } @@ -95,8 +92,57 @@ return (SWITCH_STATUS_T)status; } +// ********** private functions ********** + /*********************************************************************//** * @brief + * The publishSwitchesData function broadcasts the switches data at the + * publication interval. + * @details Inputs: switchesDataPublicationCounter + * @details Outputs: switchesDataPublicationCounter + * @return none + *************************************************************************/ +static void publishSwitchesData( void ) +{ + if ( ++switchesDataPublicationCounter > getPublishSwitchesDataInterval() ) + { + SWITCHES_DATA_T data; + + data.frontDoor = (U32)getSwitchStatus( FRONT_DOOR ); + + switchesDataPublicationCounter = 0; + + broadcastSwitchesData( &data ); + } +} + +/*********************************************************************//** + * @brief + * The getPublishSwitchesDataInterval function returns the data + * publication interval either from the data or from the override. + * @details Inputs: switchesDataPublishInterval + * @details Outputs: none + * @return data publish interval + *************************************************************************/ +static U32 getPublishSwitchesDataInterval( void ) +{ + U32 result = switchesDataPublishInterval.data; + + if ( OVERRIDE_KEY == switchesDataPublishInterval.override ) + { + result = switchesDataPublishInterval.ovData; + } + + return result; +} + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief * The testSetSwitchesDataPublishIntervalOverride function overrides * the switches publish data interval. * @details Inputs: switchesDataPublishInterval @@ -195,50 +241,6 @@ return result; } -// ********** private functions ********** - -/*********************************************************************//** - * @brief - * The publishSwitchesData function broadcasts the switches data at the - * publication interval. - * @details Inputs: switchesDataPublicationCounter - * @details Outputs: switchesDataPublicationCounter - * @return none - *************************************************************************/ -static void publishSwitchesData( void ) -{ - if ( ++switchesDataPublicationCounter > getPublishSwitchesDataInterval() ) - { - SWITCHES_DATA_T data; - - data.frontDoor = (U32)getSwitchStatus( FRONT_DOOR ); - - switchesDataPublicationCounter = 0; - - broadcastSwitchesData( &data ); - } -} - -/*********************************************************************//** - * @brief - * The getPublishSwitchesDataInterval function returns the data - * publication interval either from the data or from the override. - * @details Inputs: switchesDataPublishInterval - * @details Outputs: none - * @return data publish interval - *************************************************************************/ -static U32 getPublishSwitchesDataInterval( void ) -{ - U32 result = switchesDataPublishInterval.data; - - if ( OVERRIDE_KEY == switchesDataPublishInterval.override ) - { - result = switchesDataPublishInterval.ovData; - } - - return result; -} - /**@}*/ Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -rabbad386f4cc94f315300dffef321fe8c03fbd52 -r632bbd302a9ae48df66e40a6faadc3db0c164671 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision abbad386f4cc94f315300dffef321fe8c03fbd52) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 632bbd302a9ae48df66e40a6faadc3db0c164671) @@ -119,14 +119,9 @@ switch ( postState ) { case POST_STATE_START: - postState = POST_STATE_FW_COMPATIBILITY; + postState = POST_STATE_FW_INTEGRITY; break; - case POST_STATE_FW_COMPATIBILITY: - testStatus = execFWCompatibilityTest(); - postState = handlePOSTStatus( testStatus ); - break; - case POST_STATE_FW_INTEGRITY: //testStatus = execIntegrityTest(); TODO what happened to this module? testStatus = SELF_TEST_STATUS_PASSED; @@ -216,6 +211,11 @@ postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_FW_COMPATIBILITY: + testStatus = execFWCompatibilityTest(); + postState = handlePOSTStatus( testStatus ); + break; + // Should be last POST (and last POST test must be a test that completes in a single call) case POST_STATE_FPGA: testStatus = execFPGATest(); Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rd8fa48ead3336b1fe090b42030a8648264831076 -r632bbd302a9ae48df66e40a6faadc3db0c164671 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision d8fa48ead3336b1fe090b42030a8648264831076) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 632bbd302a9ae48df66e40a6faadc3db0c164671) @@ -99,6 +99,8 @@ #define FPGA_PBO_TEMP_OFFSET 50.0 ///< Used in conversion of PBo temperature reading to deg C. #define FPGA_ALARM_AUDIO_VOLUME_SHIFT 3 ///< Shift alarm audio volume 3 bits to left before writing to register. +#define FRONT_DOOR_SWITCH_MASK 0x0010 ///< Front door switch bit mask. +#define FPGA_POWER_STATUS_MASK 0x0400 ///< FPGA power status bit mask. // FPGA Sensors Record #pragma pack(push,1) @@ -2294,16 +2296,29 @@ /*********************************************************************//** * @brief - * The getFPGAGPIOCount function reads the FPGA GPIO count. + * The getFPGAFrontDoorStatus function returns the FPGA front door status + * bit. * @details Inputs: none * @details Outputs: fpgaSensorReadings - * @return The current FPGA GPIO count + * @return front door FPGA status bit *************************************************************************/ -U16 getFPGAGPIOCount( void ) +U16 getFPGAFrontDoorStatus( void ) { - return fpgaSensorReadings.fpgaGPIO; + return ( fpgaSensorReadings.fpgaGPIO & FRONT_DOOR_SWITCH_MASK ); } +/*********************************************************************//** + * @brief + * The getFPGAPowerStatus function returns the FPGA power status bit. + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return FPGA power status bit + *************************************************************************/ +U16 getFPGAPowerStatus( void ) +{ + return ( fpgaSensorReadings.fpgaGPIO & FPGA_POWER_STATUS_MASK ); +} + #ifdef DEBUG_ENABLED /*********************************************************************//** * @brief Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rd8fa48ead3336b1fe090b42030a8648264831076 -r632bbd302a9ae48df66e40a6faadc3db0c164671 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision d8fa48ead3336b1fe090b42030a8648264831076) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 632bbd302a9ae48df66e40a6faadc3db0c164671) @@ -150,8 +150,10 @@ S16 getFPGAValveBloodArterialPosition( void ); U16 getFPGAValveBloodArterialCurrentCounts( void ); -U16 getFPGAGPIOCount( void ); +U16 getFPGAFrontDoorStatus( void ); +U16 getFPGAPowerStatus( void ); + // The PWM functions are only used during debugging #ifdef DEBUG_ENABLED void setFPGAValveDialyzerInletPWM( U16 count ); Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -rabbad386f4cc94f315300dffef321fe8c03fbd52 -r632bbd302a9ae48df66e40a6faadc3db0c164671 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision abbad386f4cc94f315300dffef321fe8c03fbd52) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 632bbd302a9ae48df66e40a6faadc3db0c164671) @@ -26,6 +26,7 @@ #include "OperationModes.h" #include "PresOccl.h" #include "RTC.h" +#include "Switches.h" #include "SystemComm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" @@ -94,6 +95,9 @@ // Control dialysate outlet pump execDialOutFlowController(); + + // Monitor switches + execSwitches(); #endif // Manage NVDataMgmt process record state machine