Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r03e051ef654a1bff100da02483645c4e9d0b7a30 -r26f63d0260a3c35277e3e6dbca3573c253775318 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 03e051ef654a1bff100da02483645c4e9d0b7a30) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 26f63d0260a3c35277e3e6dbca3573c253775318) @@ -21,6 +21,8 @@ #include "Heaters.h" #include "LoadCell.h" #include "ModeFill.h" +#include "NVDataMgmtDGRecords.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "Pressures.h" @@ -106,7 +108,7 @@ static BOOL isWaterQualityGood( void ); static BOOL checkDialysateTemperature( void ); static void handleDialysateMixing( F32 measuredROFlowRate_mL_min ); -static void getAvgFillFlowRateFromRTCRAM( void ); +static void setFillInfoToRTCRAM( void ); /*********************************************************************//** * @brief @@ -126,7 +128,10 @@ dialysateConductivityTotal = 0.0; conductivitySampleCount = 0; concentratePumpPrimeCount = 0; - fillStatus.fillFlowRateAverage = 0.79; // TODO change this to 0 once RTC RAM is implemented + // Get the heaters info form the NV data management + DG_HEATERS_RECORD_T heaterInfo = getHeatersInfoReocrd(); + // If the data in the NV data management was not initialized properly, set it to 0 otherwise, set the average flow rate + fillStatus.fillFlowRateAverage = ( heaterInfo.averageFillFlow - 0.0 < NEARLY_ZERO ? 0.0 : heaterInfo.averageFillFlow ); fillStatus.fillFlowRateRunningSum = 0.0; fillStatus.fillSampleCounter = 0; fillStatus.fillTemperatureRunningSum = 0.0; @@ -183,7 +188,7 @@ checkInletWaterTemperature(); checkInletPressure(); checkRORejectionRatio(); - getAvgFillFlowRateFromRTCRAM(); + setFillInfoToRTCRAM(); // TODO: Check for open straw door status and alarm if closed // Check if run out of time to fill the reservoir @@ -572,6 +577,9 @@ // Get the last fill temperature before leaving to Generation Idle fillStatus.fillLastTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + // Write the latest fill data into the RTC RAM for heaters control + setFillInfoToRTCRAM(); + requestNewOperationMode( DG_MODE_GENE ); } @@ -657,9 +665,21 @@ #endif } -static void getAvgFillFlowRateFromRTCRAM( void ) +/*********************************************************************//** + * @brief + * The setFillInfoToRTCRAM function writes the fill information to the RTC + * RAM at the end of each fill. This information is used for dialysate temperature + * control. + * @details Inputs: fillStatus.fillFlowRateAverage + * @details Outputs: none + * @return none + *************************************************************************/ +static void setFillInfoToRTCRAM( void ) { + DG_HEATERS_RECORD_T record; + record.averageFillFlow = fillStatus.fillFlowRateAverage; + setHeatersInfoRecord( (U08*)&record ); }