Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -rf43eb0d0f168ea14b846d0c24f0ad0cb30784d3f -re6c4c61c793a91f9ed9dfe969e01bdeee565347d --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision f43eb0d0f168ea14b846d0c24f0ad0cb30784d3f) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision e6c4c61c793a91f9ed9dfe969e01bdeee565347d) @@ -8,7 +8,7 @@ * @file Switches.c * * @author (last) Dara Navaei -* @date (last) 14-Jun-2022 +* @date (last) 24-Jul-2022 * * @author (original) Dara Navaei * @date (original) 24-Jul-2021 @@ -100,8 +100,11 @@ currentSwitchStatus = ( getFPGADialysateCapStatus() != 0 ? STATE_OPEN : STATE_CLOSED ); break; - // NOTE: the default case was removed since this switch case is executed using a for loop so the default - // case is never called. The default case is unreachable in development testing. +#ifndef _VECTORCAST_ + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_SWITCH_SELECTED, i ); + break; +#endif } // Check if the current switch status is not the same as the recorded data @@ -115,16 +118,23 @@ // If the debounce time has been elapsed, update the switch status to the new status else if ( TRUE == didTimeout( switchesStatus[ i ].debounceStartTime, SWITCHES_DEBOUNCE_TIME_MS ) ) { - if ( CONCENTRATE_CAP == i ) + switch ( i ) { - SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_CONCENTRATE_CAP_SWITCH_CHANGE, - (U32)switchesStatus[ i ].status.data, (U32)currentSwitchStatus ); + case CONCENTRATE_CAP: + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_CONCENTRATE_CAP_SWITCH_CHANGE, (U32)switchesStatus[ i ].status.data, (U32)currentSwitchStatus ); + break; + + case DIALYSATE_CAP: + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_DIALYSATE_CAP_SWITCH_CHANGE, (U32)switchesStatus[ i ].status.data, (U32)currentSwitchStatus ); + break; + +#ifndef _VECTORCAST_ + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_SWITCH_SELECTED, i ); + break; +#endif } - else if ( DIALYSATE_CAP == i ) - { - SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_DIALYSATE_CAP_SWITCH_CHANGE, - (U32)switchesStatus[ i ].status.data, (U32)currentSwitchStatus ); - } + switchesStatus[ i ].debounceStartTime = 0; switchesStatus[ i ].status.data = currentSwitchStatus; }