Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa -r37a9fd8f15e413db5337371a7d1a1cb65567af7c --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 37a9fd8f15e413db5337371a7d1a1cb65567af7c) @@ -1,37 +1,46 @@ /************************************************************************** * -* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2022 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 ModeInitPOST.c * -* @author (last) Dara Navaei -* @date (last) 10-Nov-2021 +* @author (last) Darren Cox +* @date (last) 10-Mar-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ +#include "reg_crc.h" // Used to hold reset reason code at startup before bits get cleared +#include "reg_system.h" // Used to access exception status registers for reset reason code at startup + #include "Accel.h" #include "AlarmLamp.h" #include "BloodFlow.h" +#include "BloodLeak.h" #include "Buttons.h" #include "Compatible.h" #include "CPLD.h" #include "DialInFlow.h" +#include "DialOutFlow.h" +#include "Fans.h" #include "FPGA.h" #include "Integrity.h" #include "ModeInitPOST.h" #include "NVDataMgmt.h" #include "OperationModes.h" +#include "PresOccl.h" #include "RTC.h" #include "SafetyShutdown.h" #include "SyringePump.h" +#include "system.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" +#include "Temperatures.h" #include "Valves.h" #include "WatchdogMgmt.h" @@ -68,6 +77,8 @@ static DG_VERSIONS_T dgVersion = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ///< Version and compatibility information reported by DG. static U32 startPOSTDelayCounter = 0; ///< Start POST delay counter. +extern U32 savedResetReasonCode; ///< Saved reset reason code from sys_startup.c. + // ********** private function prototypes ********** static HD_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); @@ -150,10 +161,7 @@ { initiatePowerOff(); } - else - { - postState = POST_STATE_WATCHDOG; - } + postState = POST_STATE_WATCHDOG; break; case POST_STATE_WATCHDOG: @@ -185,11 +193,21 @@ postState = handlePOSTStatus( testStatus ); break; - case POST_STATE_DIALYSATE_FLOW: + case POST_STATE_DIALYSATE_INLET_FLOW: testStatus = execDialInFlowTest(); postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_DIALYSATE_OUTLET_FLOW: + testStatus = execDialOutFlowTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case POST_STATE_BLOOD_LEAK: + testStatus = execBloodLeakSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_VALVES: testStatus = execValvesSelfTest(); postState = handlePOSTStatus( testStatus ); @@ -200,12 +218,20 @@ postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_PRES_OCCL: + testStatus = execPresOcclSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_ALARM_AUDIO: -#ifndef DISABLE_ALARM_AUDIO - testStatus = execAlarmAudioSelfTest(); -#else - testStatus = SELF_TEST_STATUS_PASSED; -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ALARM_AUDIO ) != SW_CONFIG_ENABLE_VALUE ) + { + testStatus = execAlarmAudioSelfTest(); + } + else + { + testStatus = SELF_TEST_STATUS_PASSED; + } postState = handlePOSTStatus( testStatus ); break; @@ -215,14 +241,35 @@ break; case POST_STATE_ACCELEROMETER: -#ifndef DISABLE_ACCELS - testStatus = execAccelTest(); -#else - testStatus = SELF_TEST_STATUS_PASSED; + +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ACCELEROMETERS ) != SW_CONFIG_ENABLE_VALUE ) #endif + { + testStatus = execAccelTest(); + } +#ifndef _RELEASE_ + else + { + testStatus = SELF_TEST_STATUS_PASSED; + } +#endif postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_TEMPERATURES: + testStatus = execTemperaturesSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + // NOTE: fans self test must be called after temperatures since the + // temperatures must get their calibration first before the fans start monitoring + // for RPM out of range + case POST_STATE_FANS: + testStatus = execFansSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_STUCK_BUTTON: testStatus = execStuckButtonTest(); postState = handlePOSTStatus( testStatus ); @@ -386,6 +433,10 @@ { HD_POST_STATE_T result = postState; +#ifdef BOARD_WITH_NO_HARDWARE + testStatus = SELF_TEST_STATUS_PASSED; +#endif + if ( testStatus == SELF_TEST_STATUS_PASSED ) { // Broadcast passed POST result @@ -426,17 +477,20 @@ // when the event data can be sent if ( ++startPOSTDelayCounter > START_POST_DELAY_COUNT ) { + U32 resetReason = systemREG1->SYSESR | crcREG->PSA_SIGREGL1; // power-on reset bit preserved in an unused CRC register + + systemREG1->SYSESR = systemREG1->SYSESR; // clear reset bit(s) after logging event so subsequent resets can be properly identified as not being power-on resets. + sendUIVersionRequest(); // Send the startup event - SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_STARTUP, 0, 0 ) + SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_STARTUP, resetReason, systemREG1->GBLSTAT ) // log startup event w/ reset reason(s) bits + SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_STARTUP, systemREG1->DEV, 0x12345678 ) // log startup event w/ device ID bits + // Send the first submode change event. It is the mode Init and it does not start from a previous // mode previous and current are both published as Init SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_OP_MODE_CHANGE, MODE_INIT, MODE_INIT ) state = POST_STATE_FW_INTEGRITY; -#ifdef SKIP_POST - state = DG_POST_STATE_COMPLETED; -#endif startPOSTDelayCounter = 0; }