Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r53dd658c22a8e91597304b1aff96fee43b7b8c49 -r62cbfbbd0d1baa7b1f383510b7864921e2dfd054 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 53dd658c22a8e91597304b1aff96fee43b7b8c49) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 62cbfbbd0d1baa7b1f383510b7864921e2dfd054) @@ -34,7 +34,7 @@ #define BLOOD_LEAK_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the blood leak data is published on the CAN bus. #define BLOOD_LEAK_TIMEOUT_MS 500 ///< Blood leak detector timeout for zeroing and self-test (15 ms extended edge detection) -#define BLOOD_LEAK_PERSISTENCE ( 5 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Persistence for blood leak detected alarm. +#define BLOOD_LEAK_PERSISTENCE ( 10 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Persistence for blood leak detected alarm. #define BLOOD_LEAK_RESET_TX_FIFO 2 ///< Blood leak reset transmit FIFO command. #define BLOOD_LEAK_START_COMM_CTRL_U_ASCII 21 ///< Blood leak start communication command, ^U (Ctrl-U) in ascii. #define BLOOD_LEAK_UART_COMM_ACTIVE_LOW 0 ///< Blood leak UART communication active low command. @@ -92,6 +92,8 @@ BLOOD_LEAK_UART_COMM_ACTIVE_HIGH, BLOOD_LEAK_UART_COMM_ACTIVE_LOW }; +static U32 tempRemoveThis = 0; + // ********** private function prototypes ********** static BLOOD_LEAK_STATES_T handleBloodLeakStartupState( void ); @@ -151,6 +153,7 @@ { U32 length = sizeof( HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T ); getCalibrationRecord2Driver( GET_CAL_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, ALARM_ID_HD_BLOOD_LEAK_INVALID_CAL_RECORD ); + prepareSetPointSeq(); // Force the state machine to go back to set the set point that has been received from // the calibration data @@ -301,7 +304,7 @@ } else { - // TODO fault alarm that we cannot write to blood leak? + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SENSOR_SET_POINT_SET_FAILURE ); } } @@ -332,7 +335,7 @@ // The active high index is the length - 2 they are the last two elements U32 activeHighIndex = bloodLeakSetPointSeqLength - 2; - // Check if the current index towards the end of the buffer which are 1 and 0 + // Check if the current index towards the end of the buffer which are FIFO set and FIFO reset if( activeHighIndex > bloodLeakUARTCmdIndex ) { setFPGABloodLeakUARTTransmit( (U08)command ); @@ -343,17 +346,29 @@ } bloodLeakUARTCmdIndex++; + + // TODO remove + tempRemoveThis = getMSTimerCount(); + // TODO remove } else { - if ( ++bloodLeakWait2ReadSetPointCounter > BLOOD_LEAK_WAIT_2_READ_SET_POINT ) + // TODO remove this is temporary code + U16 bld = getFPGABloodLeakDetectSetPoint(); + if ( bld == bloodLeakCalRecord.setPoint ) { + U32 timeout = calcTimeSince(tempRemoveThis); + state = BLOOD_LEAK_INIT_STATE; + } + // TODo Remove this is temporary code + + /*if ( ++bloodLeakWait2ReadSetPointCounter > BLOOD_LEAK_WAIT_2_READ_SET_POINT ) + { bloodLeakWait2ReadSetPointCounter = 0; bloodLeakUARTCmdIndex = 0; - // Done with writing the set point state = BLOOD_LEAK_CHECK_SET_POINT_STATE; - } + }*/ } return state;