Index: firmware/App/Controllers/DialysateFlow.c =================================================================== diff -u -r834620c604c7aaea0a123e4fb558d31e43ac5bf3 -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Controllers/DialysateFlow.c (.../DialysateFlow.c) (revision 834620c604c7aaea0a123e4fb558d31e43ac5bf3) +++ firmware/App/Controllers/DialysateFlow.c (.../DialysateFlow.c) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -8,7 +8,7 @@ * @file DialysateFlow.c * * @author (last) H. Nguyen -* @date (last) 19-Oct-2021 +* @date (last) 21-Oct-2021 * * @author (original) H. Nguyen * @date (original) 19-Oct-2021 @@ -35,10 +35,10 @@ #define FLOW_SENSOR_ZERO_READING 0xFFFF ///< Flow sensor reading indicates zero flow (or flow lower than can be detected by sensor). -#define FLOW_SAMPLES_TO_AVERAGE ( 250 / TASK_PRIORITY_INTERVAL ) ///< Averaging flow data over 250 ms intervals. +#define FLOW_SAMPLES_TO_AVERAGE ( 1000 / TASK_PRIORITY_INTERVAL ) ///< Averaging flow data over 1000 ms intervals. #define FLOW_AVERAGE_MULTIPLIER ( 1.0 / (F32)FLOW_SAMPLES_TO_AVERAGE ) ///< Optimization - multiplying is faster than dividing. -#define DIALYSATE_FLOW_ADC_TO_LPM_FACTOR 5555 ///< Conversion factor from pulse period (2us units) to flow rate (L/min) for dialysate flow rate (divide this by pulse period). +#define DIALYSATE_FLOW_ADC_TO_LPM_FACTOR 300 ///< Conversion factor from pulse period (2us units) to flow rate (L/min) for dialysate flow rate (divide this by pulse period). #define FLOW_OUT_OF_RANGE_PERSISTENT_INTERVAL ( 12 * MS_PER_SECOND ) ///< Flow out of range time out in counts. // ********** private data ********** @@ -78,7 +78,6 @@ measuredFlowReadingsSum = 0; flowFilterCounter = 0; dialysateFlowDataPublicationTimerCounter = 0; - } /*********************************************************************//** @@ -93,7 +92,7 @@ *************************************************************************/ void execDialysateFlowMeterMonitor( void ) { - U16 dialysateFlowReading = getFPGADialysateMeterFlowRate(); + U16 dialysateFlowReading = getFPGADialysateFlowRate(); // Update sum for flow average calculation measuredFlowReadingsSum += (S32)dialysateFlowReading; @@ -191,17 +190,16 @@ * TEST SUPPORT FUNCTIONS *************************************************************************/ - /*********************************************************************//** * @brief - * The testSetDialysateMeterDataPublishIntervalOverride function overrides the + * The testSetDialysateFlowDataPublishIntervalOverride function overrides the * Dialysate flow data publish interval. * @details Inputs: dialysateFlowDataPublishInterval * @details Outputs: dialysateFlowDataPublishInterval * @param: value : override Dialysate flow data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetDialysateMeterDataPublishIntervalOverride( U32 value ) +BOOL testSetDialysateFlowDataPublishIntervalOverride( U32 value ) { BOOL result = FALSE; @@ -218,11 +216,33 @@ /*********************************************************************//** * @brief + * The testResetDialysateFlowDataPublishIntervalOverride function resets the + * override of the dialysate flow data publish interval. + * @details Inputs: dialysateFlowDataPublishInterval + * @details Outputs: dialysateFlowDataPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetDialysateFlowDataPublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + dialysateFlowDataPublishInterval.override = OVERRIDE_RESET; + dialysateFlowDataPublishInterval.ovData = dialysateFlowDataPublishInterval.ovInitData; + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetMeasuredDialysateFlowRateOverride function overrides the measured * Dialysate flow rate. * @details Inputs: measuredDialysateFlowRateLPM * @details Outputs: measuredDialysateFlowRateLPM - * @param: value : override measured Dialysate flow motor speed (in L/min) + * @param: value : override measured Dialysate flow rate * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetMeasuredDialysateFlowRateOverride( F32 value ) @@ -240,4 +260,28 @@ return result; } +/*********************************************************************//** + * @brief + * The testResetMeasuredDialysateFlowRateOverride function resets the override + * of the measured dialysate flow rate. + * @details Inputs: measuredDialysateFlowRateLPM + * @details Outputs: measuredDialysateFlowRateLPM + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testResetMeasuredDialysateFlowRateOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + measuredDialysateFlowRateLPM.data = measuredDialysateFlowRateLPM.ovInitData; + measuredDialysateFlowRateLPM.override = OVERRIDE_RESET; + measuredDialysateFlowRateLPM.ovInitData = 0.0; + measuredDialysateFlowRateLPM.ovData = 0.0; + result = TRUE; + } + + return result; +} + /**@}*/ Index: firmware/App/Controllers/DialysateFlow.h =================================================================== diff -u -r41f49a0643c7cfa35c9c99fb9ac4e6410c968dc5 -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Controllers/DialysateFlow.h (.../DialysateFlow.h) (revision 41f49a0643c7cfa35c9c99fb9ac4e6410c968dc5) +++ firmware/App/Controllers/DialysateFlow.h (.../DialysateFlow.h) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -8,7 +8,7 @@ * @file DialysateFlow.h * * @author (last) H. Nguyen -* @date (last) 19-Oct-2021 +* @date (last) 21-Oct-2021 * * @author (original) H. Nguyen * @date (original) 19-Oct-2021 @@ -23,15 +23,15 @@ /** * @defgroup Dialysate Flow Meter * @brief Dialysate flow rate monitor module. Monitors the dialysate flow meter. - * The dialysate flow meter is manufactured by ?, PN: ? + * The dialysate flow meter is manufactured by Swiss Flow, PN: 0045 * * @addtogroup Dialysate Flow Meter * @{ */ // ********** public definitions ********** -#define MAX_DIALYSATE_FLOWRATE_LPM 1.4 ///< Maximum target Dialysate flow rate in L/min. -#define MIN_DIALYSATE_FLOWRATE_LPM 0.2 ///< Minimum target Dialysate flow rate in L/min. +#define MAX_DIALYSATE_FLOWRATE_LPM 2.00 ///< Maximum target Dialysate flow rate in L/min. +#define MIN_DIALYSATE_FLOWRATE_LPM 0.05 ///< Minimum target Dialysate flow rate in L/min. /// Dialysate flow meter data struct. typedef struct @@ -41,13 +41,19 @@ // ********** public function prototypes ********** +void initDialysateFlowMeter( void ); + void execDialysateFlowMeterMonitor( void ); + F32 getMeasuredDialysateFlowRate( void ); -void initDialysateFlowMeter( void ); -//BOOL isDialysateFlowMeterRunning( void ); -BOOL testSetDialysateMeterDataPublishIntervalOverride( U32 value ); -BOOL testSetTargetDialysateMeterFlow( F32 flow ); +BOOL testSetDialysateFlowDataPublishIntervalOverride( U32 value ); +BOOL testResetDialysateFlowDataPublishIntervalOverride( void ); + +BOOL testSetMeasuredDialysateFlowRateOverride( F32 flow ); +BOOL testResetMeasuredDialysateFlowRateOverride( void ); + + /**@}*/ #endif Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r52763239a17119a1ffab1fb53e8eedf992ae800c -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 52763239a17119a1ffab1fb53e8eedf992ae800c) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -1,15 +1,15 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 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 FPGA.c * -* @author (last) Peman Montazemi -* @date (last) 09-Mar-2021 +* @author (last) H. Nguyen +* @date (last) 21-Oct-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -1188,12 +1188,12 @@ /*********************************************************************//** * @brief - * The getFPGAROPumpFlowRate function gets the latest RO flow rate. - * @details Inputs: fpgaSensorReadings.fpgaROFlowRate - * @details Outputs: none - * @return last RO flow rate reading + * The getFPGADialysateFlowRate function gets the latest dialysate flow rate. + * @details Inputs: None + * @details Outputs: fpgaSensorReadings.fpgaDialysateFlowRate + * @return last dialysate flow rate reading *************************************************************************/ -U16 getFPGADialysateMeterFlowRate( void ) +U16 getFPGADialysateFlowRate( void ) { return fpgaSensorReadings.fpgaDialysateFlowRate; } Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r52763239a17119a1ffab1fb53e8eedf992ae800c -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 52763239a17119a1ffab1fb53e8eedf992ae800c) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 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 FPGA.h * -* @author (last) Quang Nguyen -* @date (last) 24-Aug-2020 +* @author (last) H. Nguyen +* @date (last) 21-Oct-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -53,7 +53,7 @@ void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ); U16 getFPGAValveStates( void ); U16 getFPGAROPumpFlowRate( void ); -U16 getFPGADialysateMeterFlowRate( void ); +U16 getFPGADialysateFlowRate( void ); U16 getFPGADrainPumpSpeed( void ); U32 getFPGALoadCellA1( void ); U32 getFPGALoadCellA2( void ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r7537349102446481ceb93be0147b757323652f24 -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 7537349102446481ceb93be0147b757323652f24) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -1092,10 +1092,18 @@ handleTestROMeasuredFlowOverrideRequest( message ); break; + case MSG_ID_DIALYSATE_MEASURED_FLOW_OVERRIDE: + handleTestDialysateMeasuredFlowOverrideRequest( message ); + break; + case MSG_ID_RO_PUMP_SEND_INTERVAL_OVERRIDE: handleTestROPumpDataBroadcastIntervalOverrideRequest( message ); break; + case MSG_ID_DIALYSATE_FLOW_SEND_INTERVAL_OVERRIDE: + handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( message ); + break; + case MSG_ID_DRAIN_PUMP_SET_RPM_OVERRIDE: handleTestDrainPumpRPMOverrideRequest( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rc9444670e4c9a0d18375ea2687538c421200fac3 -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c9444670e4c9a0d18375ea2687538c421200fac3) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 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 SystemCommMessages.c * -* @author (last) Quang Nguyen -* @date (last) 26-Aug-2020 +* @author (last) H. Nguyen +* @date (last) 21-Oct-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -31,6 +31,7 @@ #include "MsgQueues.h" #include "NVDataMgmt.h" #include "OperationModes.h" +#include "DialysateFlow.h" #include "Pressures.h" #include "Reservoirs.h" #include "RTC.h" @@ -55,7 +56,7 @@ #ifdef DEBUG_ENABLED #define DEBUG_EVENT_MAX_TEXT_LEN 40 #endif - + #define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. #pragma pack(push,1) @@ -66,43 +67,43 @@ } BLOCKED_MSGS_DATA_T; #pragma pack(pop) -// ********** private data ********** - -static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. +// ********** private data ********** + +static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. static volatile U16 nextSeqNo = 1; ///< Next sequence number. /// List of message IDs that are requested not to be transmitted. static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -// ********** private function prototypes ********** - -static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); -static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); - -/*********************************************************************//** - * @brief - * The serializeMessage function serializes a given message into a given - * array of bytes. A sequence # is added to the message here and the ACK - * bit of the sequence # is set if ACK is required per parameter. A sync byte - * is inserted at the beginning of the message and an 8-bit CRC is appended to - * the end of the message. The message is queued for transmission in the given buffer. - * @details Inputs: none - * @details Outputs: given data array populated with serialized message data and queued for transmit. - * @param msg message to serialize - * @param buffer outgoing buffer that message should be queued in - * @param ackReq is an acknowledgement from receiver required? - * @return size (in bytes) of serialized message populated in given data array. - *************************************************************************/ -U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) -{ - BOOL result = FALSE; - BOOL error = FALSE; + +// ********** private function prototypes ********** + +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); +static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); + +/*********************************************************************//** + * @brief + * The serializeMessage function serializes a given message into a given + * array of bytes. A sequence # is added to the message here and the ACK + * bit of the sequence # is set if ACK is required per parameter. A sync byte + * is inserted at the beginning of the message and an 8-bit CRC is appended to + * the end of the message. The message is queued for transmission in the given buffer. + * @details Inputs: none + * @details Outputs: given data array populated with serialized message data and queued for transmit. + * @param msg message to serialize + * @param buffer outgoing buffer that message should be queued in + * @param ackReq is an acknowledgement from receiver required? + * @return size (in bytes) of serialized message populated in given data array. + *************************************************************************/ +U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) +{ + BOOL result = FALSE; + BOOL error = FALSE; BOOL blocked = FALSE; - U32 msgSize = 0; - U32 sizeMod, sizePad; - U32 i; - U08 crc; - U08 data[ MAX_ACK_MSG_SIZE ]; // byte array to populate with message data - + U32 msgSize = 0; + U32 sizeMod, sizePad; + U32 i; + U08 crc; + U08 data[ MAX_ACK_MSG_SIZE ]; // byte array to populate with message data + // Check to see if tester has requested this message not be transmitted if ( TRUE == isTestingActivated() ) { @@ -120,69 +121,69 @@ // Serialize and queue message for transmission unless this message is blocked if ( blocked != TRUE ) { - // prefix data with message sync byte - data[ msgSize++ ] = MESSAGE_SYNC_BYTE; - - // set sequence # and ACK bit (unless this is an ACK to a received message) - if ( msg.hdr.msgID != MSG_ID_ACK ) - { - // thread protect next sequence # access & increment - _disable_IRQ(); - msg.hdr.seqNo = nextSeqNo; - nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); - _enable_IRQ(); - if ( TRUE == ackReq ) - { - msg.hdr.seqNo *= -1; - } - } - - // calculate message CRC - crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); - - // serialize message header data - memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); - msgSize += sizeof( MESSAGE_HEADER_T ); - - // serialize message payload (only used bytes per payloadLen field) - memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); - msgSize += msg.hdr.payloadLen; - - // add 8-bit CRC - data[ msgSize++ ] = crc; - - // pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) - sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; - sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); - for ( i = 0; i < sizePad; i++ ) - { - data[ msgSize++ ] = 0; - } - - // if ACK required, add to pending ACK list - if ( TRUE == ackReq ) - { - if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) - { - error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) - } - } - - if ( FALSE == error ) - { - // add serialized message data to appropriate out-going comm buffer - result = addToCommBuffer( buffer, data, msgSize ); - } + // prefix data with message sync byte + data[ msgSize++ ] = MESSAGE_SYNC_BYTE; + + // set sequence # and ACK bit (unless this is an ACK to a received message) + if ( msg.hdr.msgID != MSG_ID_ACK ) + { + // thread protect next sequence # access & increment + _disable_IRQ(); + msg.hdr.seqNo = nextSeqNo; + nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); + _enable_IRQ(); + if ( TRUE == ackReq ) + { + msg.hdr.seqNo *= -1; + } + } + + // calculate message CRC + crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); + + // serialize message header data + memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); + msgSize += sizeof( MESSAGE_HEADER_T ); + + // serialize message payload (only used bytes per payloadLen field) + memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); + msgSize += msg.hdr.payloadLen; + + // add 8-bit CRC + data[ msgSize++ ] = crc; + + // pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) + sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; + sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); + for ( i = 0; i < sizePad; i++ ) + { + data[ msgSize++ ] = 0; + } + + // if ACK required, add to pending ACK list + if ( TRUE == ackReq ) + { + if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) + { + error = TRUE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + } + } + + if ( FALSE == error ) + { + // add serialized message data to appropriate out-going comm buffer + result = addToCommBuffer( buffer, data, msgSize ); + } } else { result = TRUE; // If message blocked, return successful transmission } - - return result; -} + return result; +} + /*********************************************************************//** * @brief * The sendACKMsg function constructs and queues for transmit an ACK message @@ -420,115 +421,115 @@ /*********************************************************************//** * @brief * The broadcastRTCEpoch function constructs an epoch msg to be broadcast - * and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: RTC time and date in epoch - * @param epoch Current time and date in epoch - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastRTCEpoch( U32 epoch ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_RTC_EPOCH; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &epoch, sizeof( U32 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: RTC time and date in epoch + * @param epoch Current time and date in epoch + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastRTCEpoch( U32 epoch ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_RTC_EPOCH; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &epoch, sizeof( U32 ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } -/*********************************************************************//** - * @brief - * The broadcastLoadCellData function sends out load cell data. - * @details Inputs: none - * @details Outputs: load cell data msg constructed and queued - * @param loadCell which is the loadcells data structure pointer - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastLoadCellData( LOAD_CELL_DATA_T *loadCell ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_LOAD_CELL_READINGS; - msg.hdr.payloadLen = sizeof( LOAD_CELL_DATA_T ); - - memcpy( payloadPtr, loadCell, sizeof( LOAD_CELL_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; +/*********************************************************************//** + * @brief + * The broadcastLoadCellData function sends out load cell data. + * @details Inputs: none + * @details Outputs: load cell data msg constructed and queued + * @param loadCell which is the loadcells data structure pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastLoadCellData( LOAD_CELL_DATA_T *loadCell ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_LOAD_CELL_READINGS; + msg.hdr.payloadLen = sizeof( LOAD_CELL_DATA_T ); + + memcpy( payloadPtr, loadCell, sizeof( LOAD_CELL_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } -/*********************************************************************//** - * @brief - * The broadcastValvesStates function sends out DG valves states. - * @details Inputs: none - * @details Outputs: Valves states msg constructed and queued - * @param valvesStates valves states - * refer to setFPGAValveStates function in FPGA.c for details - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastValvesStates( U16 valvesStates ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_VALVES_STATES; - msg.hdr.payloadLen = sizeof( U16 ); - - memcpy( payloadPtr, &valvesStates, sizeof( U16 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} +/*********************************************************************//** + * @brief + * The broadcastValvesStates function sends out DG valves states. + * @details Inputs: none + * @details Outputs: Valves states msg constructed and queued + * @param valvesStates valves states + * refer to setFPGAValveStates function in FPGA.c for details + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastValvesStates( U16 valvesStates ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; -/*********************************************************************//** - * @brief - * The broadcastHeatersData function sends out DG heaters data - * @details Inputs: none - * @details Outputs: heaters data msg constructed and queued - * @param heatersData which is the heaters data structure pointer - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHeatersData ( HEATERS_DATA_T *heatersData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_VALVES_STATES; + msg.hdr.payloadLen = sizeof( U16 ); - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_HEATERS_DATA; - msg.hdr.payloadLen = sizeof( HEATERS_DATA_T ); - - memcpy( payloadPtr, heatersData, sizeof( HEATERS_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} + memcpy( payloadPtr, &valvesStates, sizeof( U16 ) ); + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + /*********************************************************************//** * @brief + * The broadcastHeatersData function sends out DG heaters data + * @details Inputs: none + * @details Outputs: heaters data msg constructed and queued + * @param heatersData which is the heaters data structure pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastHeatersData ( HEATERS_DATA_T *heatersData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_HEATERS_DATA; + msg.hdr.payloadLen = sizeof( HEATERS_DATA_T ); + + memcpy( payloadPtr, heatersData, sizeof( HEATERS_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The broadcastDrainPumpData function sends out the drain pump data. * @details Inputs: none * @details Outputs: Drain pump data msg constructed and queued @@ -616,12 +617,9 @@ /*********************************************************************//** * @brief - * The broadcastROPumpData function sends out RO pump data. - * @details Inputs: none - * @details Outputs: RO pump data msg constructed and queued - * @param tgtPressure target pressure for RO pump in PSI - * @param measFlow measure RO flow rate in LPM - * @param setPWM set PWM duty cycle in % + * The broadcastDialysateFlowData function sends out dialysate flow data. + * @details Inputs: measuredDialysateFlowRate + * @details Outputs: dialysate flow data message constructed and queued * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastDialysateFlowData( const DIALYSATE_FLOW_METER_DATA_T * const flowData ) @@ -2200,15 +2198,15 @@ } -/*********************************************************************//** - * @brief - * The handleTestROMeasuredFlowOverrideRequest function handles a request to - * override the RO flow rate. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestROMeasuredFlowOverrideRequest function handles a request to + * override the RO flow rate. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -2234,6 +2232,38 @@ /*********************************************************************//** * @brief + * The handleTestDialysateMeasuredFlowOverrideRequest function handles a request to + * override the Dialysate flow rate. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialysateMeasuredFlowOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredDialysateFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialysateFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for RO pump data. * @details Inputs: none @@ -2266,6 +2296,38 @@ /*********************************************************************//** * @brief + * The handleTestDialysateFlowDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for dialysate flow data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetDialysateFlowDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDialysateFlowDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestDrainPumpRPMOverrideRequest function handles a request to * override the drain pump speed set point (in RPM). * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r52763239a17119a1ffab1fb53e8eedf992ae800c -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 52763239a17119a1ffab1fb53e8eedf992ae800c) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 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 SystemCommMessages.h * -* @author (last) Quang Nguyen -* @date (last) 24-Aug-2020 +* @author (last) H. Nguyen +* @date (last) 22-Oct-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -260,9 +260,15 @@ // MSG_ID_RO_MEASURED_FLOW_OVERRIDE: void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIALYSATE_MEASURED_FLOW_OVERRIDE: +void handleTestDialysateMeasuredFlowOverrideRequest( MESSAGE_T *message ); + // MSG_ID_RO_PUMP_SEND_INTERVAL_OVERRIDE: void handleTestROPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIALYSATE_FLOW_SEND_INTERVAL_OVERRIDE: +void handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + // MSG_ID_DRAIN_PUMP_SET_RPM_OVERRIDE void handleTestDrainPumpRPMOverrideRequest( MESSAGE_T *message ); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r52763239a17119a1ffab1fb53e8eedf992ae800c -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 52763239a17119a1ffab1fb53e8eedf992ae800c) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 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 TaskPriority.c * -* @author (last) Quang Nguyen -* @date (last) 25-Aug-2020 +* @author (last) H. Nguyen +* @date (last) 21-Oct-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -101,6 +101,11 @@ execFluidLeak(); #endif + +#ifdef DIALYSATE_FLOW_METER_ENABLED + // Monitor dialysate flow meter + execDialysateFlowMeterMonitor(); +#endif // Second pass for FPGA execFPGAOut(); @@ -112,13 +117,6 @@ // SET_TASK_OFF(); // TODO - uncomment and define TASK_TIMING_OUTPUT_ENABLED to monitor this tasks timing #endif -#ifdef DIALYSATE_FLOW_METER_ENABLED - // Monitor dialysate flow meter - execDialysateFlowMeterMonitor(); -#endif - - - } /**@}*/ Index: firmware/source/sys_main.c =================================================================== diff -u -r52763239a17119a1ffab1fb53e8eedf992ae800c -r1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d --- firmware/source/sys_main.c (.../sys_main.c) (revision 52763239a17119a1ffab1fb53e8eedf992ae800c) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 1c2f96bf994157b11c0c32ddaf96fc91a9a1da1d) @@ -178,6 +178,7 @@ initInterrupts(); initFPGA(); initInternalADC(); + initDialysateFlowMeter(); initPressures(); initLoadCell(); initNVDataMgmt(); @@ -202,7 +203,6 @@ initFluidLeak(); initOperationModes(); initIntegrity(); - initDialysateFlowMeter(); } /*************************************************************************