Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -r37a9fd8f15e413db5337371a7d1a1cb65567af7c -r556e92463ab2f246b151d31d8bcd96b3ee87ad3f --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision 37a9fd8f15e413db5337371a7d1a1cb65567af7c) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision 556e92463ab2f246b151d31d8bcd96b3ee87ad3f) @@ -16,6 +16,7 @@ ***************************************************************************/ #include "FPGA.h" +#include "NVDataMgmt.h" #include "Switches.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" @@ -30,8 +31,11 @@ #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 SWITCHES_DEBOUNCE_TIME_MS ( MS_PER_SECOND / 4 ) ///< Switches FPGA status check interval. -#define DATA_PUBLISH_COUNTER_START_COUNT 4 ///< Data publish counter start count. +#define DATA_PUBLISH_COUNTER_START_COUNT 90 ///< Data publish counter start count. +#define FRONT_DOOR_SWITCH_MASK 0x0010 ///< Front door switch bit mask. Bit 4 of the FPGA GPIO register. +#define PUMP_TRACK_SWITCH_MASK 0x0020 ///< Pump track switch bit mask. Bit 5 of the FPGA GPIO register. + /// Switch status structure typedef struct { @@ -93,16 +97,19 @@ switch ( i ) { case FRONT_DOOR: - currentSwitchStatus = ( 0 == getFPGAFrontDoorStatus() ? STATE_OPEN : STATE_CLOSED ); + currentSwitchStatus = ( FRONT_DOOR_SWITCH_MASK == getFPGAFrontDoorStatus() ? STATE_OPEN : STATE_CLOSED ); break; case PUMP_TRACK_SWITCH: - currentSwitchStatus = ( 0 == getFPGAPumpTrackSwitchStatus() ? STATE_OPEN : STATE_CLOSED ); + currentSwitchStatus = ( PUMP_TRACK_SWITCH_MASK == getFPGAPumpTrackSwitchStatus() ? STATE_OPEN : STATE_CLOSED ); break; +#ifndef _VECTORCAST_ + // The default cannot be reached in VectorCAST since the cases are run in a for loop default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_SWITCH_ID, i ) break; +#endif } // Check if the current switch status is not the same as the recorded data @@ -118,7 +125,6 @@ { switchesStatus[ i ].debounceStartTime = 0; // If the bit is 0, the door switch is open, because it is normally open switch - // TODO investigate the polarity of the pump track switch once it tied to the cartridge latch switchesStatus[ i ].status.data = currentSwitchStatus; } } @@ -128,15 +134,20 @@ } } - // Clear active Alarms - if ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - clearAlarmCondition( ALARM_ID_CARTRIDGE_DOOR_OPENED ); - } + // Clear active Alarms + if ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) + { + clearAlarmCondition( ALARM_ID_CARTRIDGE_DOOR_OPENED ); + } - if ( STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) ) - { - clearAlarmCondition( ALARM_ID_PUMP_TRACK_LATCH_OPENED ); + if ( STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) ) + { + clearAlarmCondition( ALARM_ID_PUMP_TRACK_LATCH_OPENED ); + } } publishSwitchesData(); @@ -187,7 +198,7 @@ { SWITCHES_DATA_T data; - data.frontDoor = (U32)getSwitchStatus( FRONT_DOOR ); + data.frontDoor = (U32)getSwitchStatus( FRONT_DOOR ); data.pumpTrackSwitch = (U32)getSwitchStatus( PUMP_TRACK_SWITCH ); switchesDataPublicationCounter = 0;