Index: NVDataMgmt.c =================================================================== diff -u -r1c6b2c1fcaf8beaee746f59c744af5097197fa9e -r89f99fccb9ae7dda71cfef84d4ea8cb59502fa9a --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 1c6b2c1fcaf8beaee746f59c744af5097197fa9e) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 89f99fccb9ae7dda71cfef84d4ea8cb59502fa9a) @@ -84,7 +84,6 @@ #define LAST_DISINFECTION_DATE_ADDRESS 0x00000060 // 96 //TODO remove ///< Last disinfection date start address in RTC RAM (96). #define DG_SCHEDULER_RECORD_START_ADDRESS 0x00000070 // 112 ///< DG scheduler record start address in RTC RAM (112). - // Data addresses in EEPROM #define CALIBRATION_RECORD_START_ADDRESS ( BANK7_SECTOR0_START_ADDRESS + sizeof(MFG_RECORD_T) ) ///< Calibration record start address in EEPROM. @@ -99,19 +98,11 @@ #define CAL_DATA_MAX_MESSAGE_DFFIRENCE 1 ///< Calibration data receive message different from the previous message. #define CAL_DATA_FIRST_RECEIVING_MSG_NUM 1 ///< Calibration data first receiving message number. #define SYSTEM_DATA_NV_MEM_START_ADDRESS BANK7_SECTOR0_START_ADDRESS + 2048 ///< System record storage start address in NV memory. -#ifdef _DG_ -#define DG_CAL_RECORD_BYTE_SIZE ( sizeof(DG_CALIBRATION_GROUPS_T) + sizeof(U16) ) ///< DG calibration record byte size. + +#define RECORD_BYTE_SIZE(r) ( sizeof(r) + sizeof(U16) ) ///< Record byte size macro. // Padding length calculation: (DG struct size % bytes to write(16) == 0 ? 0 : (DG struct size / bytes to write(16)) + 1) * bytes to write(16) -#define DG_CAL_PADDING_LENGTH ( DG_CAL_RECORD_BYTE_SIZE % MAX_EEPROM_WRITE_BUFFER_BYTES == 0 ? \ - 0 : ( (U32)(DG_CAL_RECORD_BYTE_SIZE / MAX_EEPROM_WRITE_BUFFER_BYTES) + 1 ) )* \ - MAX_EEPROM_WRITE_BUFFER_BYTES ///< DG calibration padding length that is calculated with the size of the cal structures. -#define DG_SYS_RECORD_BYTE_SIZE ( sizeof(DG_SYSTEM_RECORD_T) + sizeof(U16) ) ///< DG system record byte size. -// Padding length calculation: (DG struct size % bytes to write(16) == 0 ? 0 : (DG struct size / bytes to write(16)) + 1) * bytes to write(16) -#define DG_SYS_PADDING_LENGTH ( DG_SYS_RECORD_BYTE_SIZE % MAX_EEPROM_WRITE_BUFFER_BYTES == 0 ? \ - 0 : ( (U32)(DG_SYS_RECORD_BYTE_SIZE / MAX_EEPROM_WRITE_BUFFER_BYTES) + 1 ) )* \ - MAX_EEPROM_WRITE_BUFFER_BYTES ///< DG system padding length that is calculated with the size of the system structure. -#else if _HD_ -#endif +/// DG padding length macro that is calculated with the size of the provided structure. +#define RECORD_PADDING_LENGTH(r, b) ( RECORD_BYTE_SIZE(r) % b == 0 ? 0 : ( (U32)(RECORD_BYTE_SIZE(r) / b) + 1 ) ) * b /// NVDataMgmt self-test states enumeration. typedef enum NVDataMgmt_Self_Test_States @@ -316,23 +307,26 @@ typedef struct { DG_CALIBRATION_GROUPS_T dgCalibrationGroups; ///< DG calibration groups. - U08 padding[ DG_CAL_PADDING_LENGTH - DG_CAL_RECORD_BYTE_SIZE ]; ///< DG calibration record padding byte array. + U08 padding[ RECORD_PADDING_LENGTH(DG_CALIBRATION_GROUPS_T, MAX_EEPROM_WRITE_BUFFER_BYTES) - + RECORD_BYTE_SIZE(DG_CALIBRATION_GROUPS_T) ]; ///< DG calibration record padding byte array. U16 crc; ///< CRC for the DG calibration record structure. } DG_CALIBRATION_RECORD_T; /// DG system group structure typedef struct { DG_SYSTEM_RECORD_T dgSystemRecord; ///< DG system record. - U08 padding[ DG_SYS_PADDING_LENGTH - DG_SYS_RECORD_BYTE_SIZE ]; ///< DG system group padding byte array. + U08 padding[ RECORD_PADDING_LENGTH(DG_SYSTEM_RECORD_T, MAX_EEPROM_WRITE_BUFFER_BYTES) - + RECORD_BYTE_SIZE(DG_SYSTEM_RECORD_T) ]; ///< DG system group padding byte array. U16 crc; ///< CRC for the DG system group structure. } DG_SYSTEM_GROUP_T; /// DG service record structure typedef struct { DG_LAST_SERVICE_RECORD_T dgLastServiceRecord; ///< DG last service record. - U08 padding[ 0 ]; ///< DG last service group padding. + U08 padding[ RECORD_PADDING_LENGTH(DG_LAST_SERVICE_RECORD_T, MAX_EEPROM_WRITE_BUFFER_BYTES) - + RECORD_BYTE_SIZE(DG_LAST_SERVICE_RECORD_T) ]; ///< DG last service group padding. U16 crc; ///< CRC for the DG last service structure. } DG_LAST_SERVICE_GROUP_T; @@ -356,13 +350,14 @@ // Calibration variables #ifdef _DG_ -static DG_CALIBRATION_RECORD_T dgCalibrationRecord; ///< DG calibration record. -static DG_SYSTEM_GROUP_T dgSystemGroup; ///< DG system group (including padding and final CRC). +static DG_CALIBRATION_RECORD_T dgCalibrationRecord; ///< DG calibration record structure (including padding and final CRC). +static DG_SYSTEM_GROUP_T dgSystemGroup; ///< DG system group structure (including padding and final CRC). +static DG_LAST_SERVICE_GROUP_T dgLastServiceGroup; ///< DG last service group structure (including padding and final CRC). // Process records specifications const PROCESS_RECORD_SPECS_T RECORDS_SPECS [ NUM_OF_NVDATMGMT_RECORDS_JOBS ] = { {BANK7_SECTOR0_START_ADDRESS, sizeof(DG_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_CALIBRATION_RECORD_T), (U08*)&dgCalibrationRecord, (U08*)&(dgCalibrationRecord.crc)}, // NVDATAMGMT_CALIBRATION_RECORD {SYSTEM_DATA_NV_MEM_START_ADDRESS, sizeof(DG_SYSTEM_GROUP_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_SYSTEM_GROUP_T), (U08*)&dgSystemGroup, (U08*)&dgSystemGroup.crc}, // NVDATAMGMT_SYSTEM_RECORD - {LAST_SERVICE_RECORD_START_ADDRESS, sizeof(DG_LAST_SERVICE_RECORD_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, 0, 0}, // NVDATAMGMT_PROCESS_LAST_SERVICE_RECORD + {LAST_SERVICE_RECORD_START_ADDRESS, sizeof(DG_LAST_SERVICE_RECORD_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgLastServiceGroup, (U08*)&dgLastServiceGroup.crc}, // NVDATAMGMT_PROCESS_LAST_SERVICE_RECORD {DG_SCHEDULER_RECORD_START_ADDRESS, sizeof(DG_SCHEDULER_RECORD_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, 0, 0} // NVDATAMGMT_SCHEDULER_RECORD }; #else if _HD_ @@ -927,6 +922,15 @@ return status; } +BOOL getLastServiceRecord( void ) +{ + +} +BOOL setLastServiceRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ) +{ + +} + /*********************************************************************//** * @brief * The getDGPressureSensorsCalibrationRecord function returns the DG pressure Index: NVDataMgmt.h =================================================================== diff -u -r45f39d237e109f91b4b7e40fdb2dc00bd673eef0 -r89f99fccb9ae7dda71cfef84d4ea8cb59502fa9a --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 45f39d237e109f91b4b7e40fdb2dc00bd673eef0) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision 89f99fccb9ae7dda71cfef84d4ea8cb59502fa9a) @@ -456,6 +456,9 @@ BOOL getSystemRecord( void ); BOOL setSystemRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ); +BOOL getLastServiceRecord( void ); +BOOL setLastServiceRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ); + DG_PRES_SENSORS_CAL_RECORD_T getDGPressureSensorsCalibrationRecord( void ); void getDGFlowSensorsCalibrationRecord( U08* buffer );