Index: Accel.c =================================================================== diff -u -r17fdefc3752a193c0d2d495f1497cc8c1e35c406 -ra89fd55052e2e467f9ae2fdc828e84272c142022 --- Accel.c (.../Accel.c) (revision 17fdefc3752a193c0d2d495f1497cc8c1e35c406) +++ Accel.c (.../Accel.c) (revision a89fd55052e2e467f9ae2fdc828e84272c142022) @@ -496,14 +496,6 @@ SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_EXCESSIVE_TILT, x, y ) #endif } - } - else if ( ( TRUE == tiltErrorDetected ) && ( ( fabs( x ) > MAX_TILT_ANGLE_TO_CLEAR_ALARM ) || ( fabs( y ) > MAX_TILT_ANGLE_TO_CLEAR_ALARM ) ) ) - { -#ifdef _DG_ - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_EXCESSIVE_TILT, x, y ) -#else - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_EXCESSIVE_TILT, x, y ) -#endif } else if ( ( TRUE == tiltErrorDetected ) && ( ( fabs( x ) > MAX_TILT_ANGLE_TO_CLEAR_ALARM ) || ( fabs( y ) > MAX_TILT_ANGLE_TO_CLEAR_ALARM ) ) ) { @@ -512,7 +504,7 @@ #else SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_EXCESSIVE_TILT, x, y ) #endif - } + } else if ( ( fabs( x ) <= MAX_TILT_ANGLE_TO_CLEAR_ALARM ) && ( fabs( y ) <= MAX_TILT_ANGLE_TO_CLEAR_ALARM ) ) { accelTiltErrorTimerCounter = 0; Index: MessageSupport.c =================================================================== diff -u -r17fdefc3752a193c0d2d495f1497cc8c1e35c406 -ra89fd55052e2e467f9ae2fdc828e84272c142022 --- MessageSupport.c (.../MessageSupport.c) (revision 17fdefc3752a193c0d2d495f1497cc8c1e35c406) +++ MessageSupport.c (.../MessageSupport.c) (revision a89fd55052e2e467f9ae2fdc828e84272c142022) @@ -15,6 +15,7 @@ * ***************************************************************************/ +#include "MessageSupport.h" #include "SystemCommMessages.h" #include "Utilities.h" @@ -28,9 +29,9 @@ /*********************************************************************//** * @brief - * The broadcastData function broadcasts data. + * The broadcastData function queues a broadcast message for transmission. * @details Inputs: none - * @details Outputs: load cell data msg constructed and queued + * @details Outputs: broadcast data msg constructed and queued * @param msgID message ID of the data is broadcast * @param buffer comm buffer ID * @param dataPtr pointer to the start of the buffer @@ -48,7 +49,10 @@ msg.hdr.msgID = msgID; msg.hdr.payloadLen = length; - memcpy( payloadPtr, dataPtr, length ); + if ( ( length > 0 ) && ( dataPtr != 0 ) ) + { + memcpy( payloadPtr, dataPtr, length ); + } // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); Index: MessageSupport.h =================================================================== diff -u -rdae0bc97eb180f6c1fd5a57b8e3ec4307d1a89af -ra89fd55052e2e467f9ae2fdc828e84272c142022 --- MessageSupport.h (.../MessageSupport.h) (revision dae0bc97eb180f6c1fd5a57b8e3ec4307d1a89af) +++ MessageSupport.h (.../MessageSupport.h) (revision a89fd55052e2e467f9ae2fdc828e84272c142022) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2021-2021 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 MessageSupport.h +* @file MessageSupport.h * -* @author (last) Dara Navaei -* @date (last) 01-Oct-2021 +* @author (last) Dara Navaei +* @date (last) 10-Sep-2021 * -* @author (original) Dara Navaei -* @date (original) 01-Oct-2021 +* @author (original) Dara Navaei +* @date (original) 10-Sep-2021 * ***************************************************************************/ Index: NVDataMgmt.c =================================================================== diff -u -r17fdefc3752a193c0d2d495f1497cc8c1e35c406 -ra89fd55052e2e467f9ae2fdc828e84272c142022 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 17fdefc3752a193c0d2d495f1497cc8c1e35c406) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision a89fd55052e2e467f9ae2fdc828e84272c142022) @@ -2280,7 +2280,7 @@ writtenRecordStatus = NVDATAMGMT_RECORD_NOT_CHECKED; // Issue the write command - Fapi_issueProgrammingCommand( (U32*)memoryPtr, structPtr, jobSpecs.maxWriteBufferSize, 0x00, 0, Fapi_DataOnly ); + Fapi_issueProgrammingCommand ( (U32*)memoryPtr, structPtr, jobSpecs.maxWriteBufferSize, 0x00, 0, Fapi_DataOnly ); } } } @@ -3270,9 +3270,12 @@ } DG_FLOW_SENSORS_CAL_RECORD_T* flow = &dgCalibrationRecord.dgCalibrationGroups.flowSensorsCalRecord; - record = (POLYNOMIAL_CAL_PAYLOAD_T*)&flow->flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ]; - isHardwareRecordValid = isPolynomialRecordValid( record ); - isCalRecordValid = isCalRecordValid == FALSE ? FALSE : isHardwareRecordValid; + for ( i = 0; i < NUM_OF_CAL_DATA_FLOW_SENSORS; i++ ) + { + record = (POLYNOMIAL_CAL_PAYLOAD_T*)&flow->flowSensors[ i ]; + isHardwareRecordValid = isPolynomialRecordValid( record ); + isCalRecordValid = isCalRecordValid == FALSE ? FALSE : isHardwareRecordValid; + } DG_LOAD_CELLS_CAL_RECORD_T* load = &dgCalibrationRecord.dgCalibrationGroups.loadCellsCalRecord; for ( i = 0; i < NUM_OF_CAL_DATA_LOAD_CELLS; i++ ) Index: NVDataMgmtDGRecords.h =================================================================== diff -u -r17fdefc3752a193c0d2d495f1497cc8c1e35c406 -ra89fd55052e2e467f9ae2fdc828e84272c142022 --- NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 17fdefc3752a193c0d2d495f1497cc8c1e35c406) +++ NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision a89fd55052e2e467f9ae2fdc828e84272c142022) @@ -48,6 +48,7 @@ typedef enum dg_flow_sensors { CAL_DATA_RO_PUMP_FLOW_SENSOR = 0, ///< RO pump flow sensor. + CAL_DATA_DIALYSATE_FLOW_SENSOR, ///< RO pump dialysate flow sensor. NUM_OF_CAL_DATA_FLOW_SENSORS, ///< Number of flow sensors. } CAL_DATA_DG_FLOW_SENSORS_T; @@ -200,7 +201,7 @@ POLYNOMIAL_CAL_PAYLOAD_T flowSensors[ NUM_OF_CAL_DATA_FLOW_SENSORS ]; ///< Flow sensors to calibrate. // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be // reduced, so #define was not used for the size of the array - POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ 3 ]; ///< Reserved space for future flow sensors. + POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ 2 ]; ///< Reserved space for future flow sensors. } DG_FLOW_SENSORS_CAL_RECORD_T; /// Load cells calibration structure Index: RTC.c =================================================================== diff -u -r17fdefc3752a193c0d2d495f1497cc8c1e35c406 -ra89fd55052e2e467f9ae2fdc828e84272c142022 --- RTC.c (.../RTC.c) (revision 17fdefc3752a193c0d2d495f1497cc8c1e35c406) +++ RTC.c (.../RTC.c) (revision a89fd55052e2e467f9ae2fdc828e84272c142022) @@ -24,10 +24,6 @@ #include "Timers.h" #include "Utilities.h" -#ifdef USE_LIBRARY_TIME_FUNCTIONS -#include // For epoch conversion functions mktime and gmtime -#endif - /** * @addtogroup RTC * @{ @@ -121,19 +117,8 @@ #define MAX_ALLOWED_RTC_RAM_ADDRESS 512U ///< Max allowed RTC RAM legal address (512) #define TEN 10U ///< Ten #define YEAR_2000 2000U ///< Year 2000 -#ifndef USE_LIBRARY_TIME_FUNCTIONS - #define EPOCH_BASE_YEAR 1970U ///< Reference year to calculate epoch (1970) -#else - #define EPOCH_BASE_YEAR 1900U ///< Reference year to calculate epoch (1900) - #define YEAR_1900_TO_1970_SECONDS_DIFF 2208988800U ///< Difference in seconds from 1/1/1900 to 1/1/1970 (2208988800) - /// Six hour offset is needed because TI library works in CST. - #define OFFSET_6_HRS (6 * MIN_PER_HOUR * SEC_PER_MIN) +#define EPOCH_BASE_YEAR 1970U ///< Reference year to calculate epoch (1970) - #ifdef _VECTORCAST_ - #define LOCAL_TO_GTM_TIME_CONVERSION 8U ///< Local time to GTM conversion for VectorCAST - #endif -#endif - #define SECS_IN_HOUR 3600 ///< Number of seconds in an hour. #define MONTHS_IN_YEAR 12 ///< Number of months in a year. #define LEAP_YEAR_MONTH ( 2 - 1 ) ///< Leap year month is February. Subtract 1 month for zero-based months. @@ -235,10 +220,6 @@ static U08 convertDecimal2BCD( U08 decimal ); static U32 convertDateTime2Epoch( RTC_TIMESTAMP_T dateTime ); static BOOL convertEpoch2DateTime( U32 epoch ); -#ifdef USE_LIBRARY_TIME_FUNCTIONS -static U32 convertTime2Epoch( void ); -static void convertEpoch2Time( U32 epoch ); -#endif static void updateReadTimestampStruct( void ); static BOOL setMibSPIBufferLength( U16 length ); static void prepBufferForReadCommand( U08 length ); // Puts the read command @@ -339,11 +320,7 @@ { BOOL result; -#ifndef USE_LIBRARY_TIME_FUNCTIONS result = convertEpoch2DateTime( epoch ); -#else - convertEpoch2Time( epoch ); -#endif result = setRTCTimestamp( RTCNewTimestampStruct.seconds, RTCNewTimestampStruct.minutes, RTCNewTimestampStruct.hours, @@ -921,76 +898,8 @@ return result; } -#ifdef USE_LIBRARY_TIME_FUNCTIONS /*********************************************************************//** * @brief - * The convertTime2Epoch converts the time into epoch (seconds from Jan 1 1970). - * @details Inputs: RTCTimestampStruct - * @details Outputs: none - * @return time in epoch as a U32 - *************************************************************************/ -static U32 convertTime2Epoch( void ) -{ - struct tm t; - time_t epochTime; - t.tm_sec = RTCTimestampStruct.seconds; - t.tm_min = RTCTimestampStruct.minutes; - t.tm_hour = RTCTimestampStruct.hours; - t.tm_mday = RTCTimestampStruct.days; - // In epoch conversion, the months are 0-11 - // so the months is decremented - t.tm_mon = RTCTimestampStruct.months - 1; - t.tm_year = RTCTimestampStruct.years + YEAR_2000 - EPOCH_BASE_YEAR; - // Disabled daylight saving - // If daylight saving is not disabled, MinGW in VectorCAST - // may or may not calculate the value right - t.tm_isdst= 0; - -#ifdef _VECTORCAST_ - // MinGW in VectorCAST assumes the time is local while - // the time is in GMT so 8 hours is subtracted from the hour - // to simulate GMT for VectorCAST - t.tm_hour = t.tm_hour - LOCAL_TO_GTM_TIME_CONVERSION; - epochTime = mktime(&t); -#else - epochTime = mktime(&t); - epochTime = epochTime - YEAR_1900_TO_1970_SECONDS_DIFF; -#endif - - return (U32)epochTime; -} -#endif - -#ifdef USE_LIBRARY_TIME_FUNCTIONS -/*********************************************************************//** - * @brief - * The convertEpoch2Time converts a given epoch date/time to a date/time - * structure that can be used to set the clock. - * @details Inputs: none - * @details Outputs: RTCNewTimestampStruct - * @param epoch epoch time stamp (seconds since 1/1/1970) - * @return none - *************************************************************************/ -static void convertEpoch2Time( U32 epoch ) -{ - struct tm *ptm; - - // Convert epoch to date/time structure - epoch += YEAR_1900_TO_1970_SECONDS_DIFF; - epoch -= OFFSET_6_HRS; // For some reason, TI works in CST time zone instead of GMT - ptm = gmtime( &epoch ); - // Copy date/time stamp to our structure - RTCNewTimestampStruct.years = ptm->tm_year + EPOCH_BASE_YEAR; // epoch is seconds from 1/1/1900. - RTCNewTimestampStruct.months = ptm->tm_mon + 1; // months from gmtime() are 0..11 - convert to 1..12. - RTCNewTimestampStruct.days = ptm->tm_mday; - RTCNewTimestampStruct.hours = ptm->tm_hour; - RTCNewTimestampStruct.minutes = ptm->tm_min; - RTCNewTimestampStruct.seconds = ptm->tm_sec; -} -#endif - -/*********************************************************************//** - * @brief * The updateReadTimestampStruct function updates the time structure * after every read. * @details Inputs: RTCTimestampStruct @@ -1324,10 +1233,12 @@ RTC_DATA_T data; updateReadTimestampStruct(); -#ifndef USE_LIBRARY_TIME_FUNCTIONS lastEpochTime = convertDateTime2Epoch( RTCTimestampStruct ); + timeCounter = 1; +#ifdef _DG_ + broadcastData( MSG_ID_RTC_EPOCH, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&lastEpochTime, sizeof( U32 ) ); #else - lastEpochTime = convertTime2Epoch(); + broadcastData( MSG_ID_RTC_EPOCH, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&lastEpochTime, sizeof( U32 ) ); #endif timeCounter = 1; data.epochTime = lastEpochTime;