Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r1e323172095bb1ca6969f65976049c9fbe19c489 -r53dd658c22a8e91597304b1aff96fee43b7b8c49 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 53dd658c22a8e91597304b1aff96fee43b7b8c49) @@ -47,7 +47,7 @@ #define BLOOD_LEAK_CARRIAGE_RETURN_ASCII 13 ///< Blood leak set point sequence carriage return character in ASCII. #define BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH 7 ///< Blood leak set point sequence maximum length. -#define BLOOD_LEAK_WAIT_2_READ_SET_POINT ( 0.5 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Blood leak wait to read set point in counts. +#define BLOOD_LEAK_WAIT_2_READ_SET_POINT ( 1 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Blood leak wait to read set point in counts. #define BLOOD_LEAK_MAX_SET_POINT_WRITE_TRIALS 3 ///< Blood leak maximum number of trials to write the set point. /// Defined states for the blood leak detector state machine. @@ -149,13 +149,8 @@ // Check if there is a new calibration data available if ( TRUE == isNewCalibrationRecordAvailable() ) { - // TODO figure out a way to process this data - // TODO for testing only remove - bloodLeakCalRecord.setPoint = 123; - // TODO for testing only remove the top - U32 length = sizeof( HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T ); - getCalibrationRecord2Driver( CAL_GET_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, ALARM_ID_HD_BLOOD_LEAK_INVALID_CAL_RECORD ); + getCalibrationRecord2Driver( GET_CAL_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, ALARM_ID_HD_BLOOD_LEAK_INVALID_CAL_RECORD ); // Force the state machine to go back to set the set point that has been received from // the calibration data @@ -232,7 +227,7 @@ U32 length = sizeof( HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T ); ALARM_ID_T alarm = ALARM_ID_HD_BLOOD_LEAK_INVALID_CAL_RECORD; - BOOL calStatus = getCalibrationRecord2Driver( CAL_GET_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, alarm ); + BOOL calStatus = getCalibrationRecord2Driver( GET_CAL_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, alarm ); if ( TRUE == calStatus ) { @@ -269,7 +264,7 @@ setFPGABloodLeakUARTControl( (U08)command ); } - if ( bloodLeakUARTCmdIndex > BLOOD_LEAK_STARTUP_SEQ_LENGTH - 1 ) + if ( bloodLeakUARTCmdIndex >= BLOOD_LEAK_STARTUP_SEQ_LENGTH ) { bloodLeakUARTCmdIndex = 0; state = BLOOD_LEAK_CHECK_SET_POINT_STATE; @@ -294,14 +289,14 @@ { BLOOD_LEAK_STATES_T state = BLOOD_LEAK_CHECK_SET_POINT_STATE; - U32 bloodLeakSetPoint = (U32)getFPGABloodLeakDetectSetPoint(); + U16 bloodLeakSetPoint = getFPGABloodLeakDetectSetPoint(); - if ( bloodLeakSetPoint != bloodLeakCalRecord.crc ) + if ( bloodLeakSetPoint != bloodLeakCalRecord.setPoint ) { if ( bloodLeakCurrentSetPointWriteTry < BLOOD_LEAK_MAX_SET_POINT_WRITE_TRIALS ) { prepareSetPointSeq(); - + bloodLeakCurrentSetPointWriteTry++; state = BLOOD_LEAK_SET_SET_POINT_STATE; } else @@ -585,7 +580,7 @@ // Set point was divided up for find out the number of digits // so it is reinstated again for the rest of the calculations - setPoint = bloodLeakCalRecord.crc; + setPoint = bloodLeakCalRecord.setPoint; // Convert the set point number to the equivalent ASCII number with the unsigned integer data type sprintf( tempCharBuffer, "%u", setPoint );