/*############################################################################################*/
/*############################################################################################*/
/**
 * \file 	SRDMemoryMapping.h
 * \author 	Thibaut LALUQUE 3D-Ouest
 * \date 	21/11/2014
 * \version 1.0
 * \brief 	Headerfile for SRD Memory Mapping.
 * \details All Right Reserved.
*/
/*############################################################################################*/
/*############################################################################################*/
#ifndef __SRDMEMORYMAPPING_H__
#define __SRDMEMORYMAPPING_H__

/*############################################################################################*/
/*## INCLUDES ################################################################################*/
/*############################################################################################*/

/*############################################################################################*/
/*## END INCLUDES ############################################################################*/
/*############################################################################################*/


/*############################################################################################*/
/*## DEFINES #################################################################################*/
/*############################################################################################*/
/*----------------------------------------------------------------------------*/
/**
 * \brief Define the memory index of all data in the SRD RFID memory.
 */
///@{
/*----------------------------------------------------------------------------*/
#define SRD_MEMORY_MAPPING_ADDR_VERSION		(0U)
#define SRD_MEMORY_MAPPING_ADDR_CTRL		(1U)
#define SRD_MEMORY_MAPPING_ADDR_STATUS		(2U)
#define SRD_MEMORY_MAPPING_ADDR_ERROR		(3U)
#define SRD_MEMORY_MAPPING_ADDR_DEBUG		(4U)
#define SRD_MEMORY_MAPPING_ADDR_ACTIVATION_DEPTH		(5U)
#define SRD_MEMORY_MAPPING_ADDR_FILTER_MSB	(6U)
#define SRD_MEMORY_MAPPING_ADDR_FILTER_LSB	(7U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_MEAS0_MSB	(8U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_MEAS0_LSB	(9U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_MEAS1_MSB	(10U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_MEAS1_LSB	(11U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_DEPTH0_MSB	(12U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_DEPTH0_LSB	(13U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_DEPTH1_MSB	(14U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_DEPTH1_LSB	(15U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_OFFSET_MSB	(16U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_OFFSET_LSB	(17U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_CHECKSUM_MSB	(18U)
#define SRD_MEMORY_MAPPING_ADDR_CAL_CHECKSUM_LSB	(19U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER0	(20U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER1	(21U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER2	(22U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER3	(23U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER4	(24U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER5	(25U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER6	(26U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER7	(27U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER8	(28U)
#define SRD_MEMORY_MAPPING_ADDR_SERIAL_NUMBER9	(29U)
#define SRD_MEMORY_MAPPING_ADDR_CHECKSUM_GENE_MSB	(30U)
#define SRD_MEMORY_MAPPING_ADDR_CHECKSUM_GENE_LSB	(31U)
#define SRD_MEMORY_MAPPING_ADDR_BAT_LEVEL_LSB	(32U)
#define SRD_MEMORY_MAPPING_ADDR_CAP_LEVEL_LSB	(33U)
#define SRD_MEMORY_MAPPING_ADDR_PERIOD_MSB	(34U)
#define SRD_MEMORY_MAPPING_ADDR_PERIOD_LSB	(35U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_INIT_MSB	(36U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_INIT_LSB	(37U)
#define SRD_MEMORY_MAPPING_ADDR_ISENS_INIT_MSB	(38U)
#define SRD_MEMORY_MAPPING_ADDR_ISENS_INIT_LSB	(39U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_CHECK_MSB	(40U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_CHECK_LSB	(41U)
#define SRD_MEMORY_MAPPING_ADDR_ISENS_CHECK_MSB	(42U)
#define SRD_MEMORY_MAPPING_ADDR_ISENS_CHECK_LSB	(43U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_ACTIV_MSB	(44U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_ACTIV_LSB	(45U)
#define SRD_MEMORY_MAPPING_ADDR_FB_BEFORE_LSB	(46U)
#define SRD_MEMORY_MAPPING_ADDR_FB_CHECK_LSB	(47U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_MAX_MSB	(48U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_MAX_LSB	(49U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_INIT_MIN_MSB	(50U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_INIT_MIN_LSB	(51U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_INIT_MAX_MSB	(52U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_INIT_MAX_LSB	(53U)
#define SRD_MEMORY_MAPPING_ADDR_ANA_PRESS_INIT_CHECKSUM	(54U)
#define SRD_MEMORY_MAPPING_ADDR_MIN_BATTERY_VOLTAGE		(55U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER1	(56U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER2	(57U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER3	(58U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER4	(59U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER5	(60U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER6	(61U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER7	(62U)
#define SRD_MEMORY_MAPPING_ADDR_SRD_NUMBER8	(63U)
///@}

/*----------------------------------------------------------------------------*/
/**
 * \def SRD_MEMORY_NBR_BYTE
 * \brief Define the number of byte used in the SRD RFID memory.
 */
/*----------------------------------------------------------------------------*/
#define SRD_MEMORY_NBR_BYTE		(64U)

/*----------------------------------------------------------------------------*/
/**
 * \def SRD_MEMORY_NBR_BLOCK
 * \brief Define the number of block used in the SRD RFID memory.
 */
/*----------------------------------------------------------------------------*/
#define SRD_MEMORY_NBR_BLOCK	(16U)
/*############################################################################################*/
/*## END DEFINES #############################################################################*/
/*############################################################################################*/



/*############################################################################################*/
/*## TYPEDEF/STRUCT/ENUM/UNION ###############################################################*/
/*############################################################################################*/
/*----------------------------------------------------------------------------*/
/**
 * \struct tSRDEeprom
 * \brief Structure used to represent and store SRD RFID memory.
 */
/*----------------------------------------------------------------------------*/
typedef struct {
	unsigned char version;		/*!< SRD Firmware revision */

	union {
		struct {
			unsigned char RSVD0					:	1;		/*!< RESERVED */
			unsigned char rfAccessInProgress	:	1;		/*!< RF access in progress  flag */
			unsigned char rfDiag				:	1;		/*!< Rf Diag flag */
			unsigned char rfSynchro				:	1;		/*!< Rf synchro flag */
			unsigned char RSVD1					:	4;		/*!< RESERVED */
		}bits;					/*!< Bit access */
		unsigned char all;		/*!< global byte access */
	} ctrlModule;				/*!< Control module field */

	union {
		struct {
			unsigned char RSVD0					:	1;	/*!< RESERVED */
			unsigned char mcuMemoryAccess		:	1;	/*!< MCU memory access in pogress */
			unsigned char RSVD1					:	6;	/*!< RESERVED */
		}bits;					/*!< Bit access */
		unsigned char all;		/*!< Global byte access */
	} statusModule;				/*!< module status field */

	union {
		struct {
			unsigned char output	:	1;		/*!< Error output load */
			unsigned char pressure	:	1;		/*!< Error pressure */
			unsigned char current	:	1;		/*!< Error current */
			unsigned char timer		:	1;		/*!< Error timer */
			unsigned char battery	:	1;		/*!< Error battery */
			unsigned char supercap	:	1;		/*!< Error super cap */
			unsigned char eeprom	:	1;		/*!< Error EEPROM */
			unsigned char watchdog	:	1;		/*!< Error Watchdog */
		}bits;					/*!< Bit access */
		unsigned char all;		/*!< Global byte access */
	} errorStatus;				/*!< Error status field */

	unsigned char debug;			/*!< Debug */
	unsigned char activationDepth;	/*!< Activation depth */
	unsigned char filterMSB;		/*!< Filter MSB */
	unsigned char filterLSB;		/*!< Filter LSB */
	unsigned char calMeas0MSB;		/*!< Calibration measure MSB point 0 */
	unsigned char calMeas0LSB;		/*!< Calibration measure LSB point 0 */
	unsigned char calMeas1MSB;		/*!< Calibration measure MSB point 1 */
	unsigned char calMeas1LSB;		/*!< Calibration measure LSB point 1 */
	unsigned char calDepth0MSB;		/*!< Calibration depth MSB point 0 */
	unsigned char calDepth0LSB;		/*!< Calibration depth LSB point 0 */
	unsigned char calDepth1MSB;		/*!< Calibration depth MSB point 1 */
	unsigned char calDepth1LSB;		/*!< Calibration depth LSB point 1 */
	unsigned char calOffsetMSB;		/*!< Calibration offset MSB */
	unsigned char calOffsetLSB;		/*!< Calibration offset lSB */
	unsigned char calCheckSumMSB;	/*!< Calibration checksum MSB */
	unsigned char calCheckSumLSB;	/*!< Calibration checksum LSB */
	unsigned char serial0;			/*!< Serial byte 0 */
	unsigned char serial1;			/*!< Serial byte 1 */
	unsigned char serial2;			/*!< Serial byte 2 */
	unsigned char serial3;			/*!< Serial byte 3 */
	unsigned char serial4;			/*!< Serial byte 4 */
	unsigned char serial5;			/*!< Serial byte 5 */
	unsigned char serial6;			/*!< Serial byte 6 */
	unsigned char serial7;			/*!< Serial byte 7 */
	unsigned char serial8;			/*!< Serial byte 8 */
	unsigned char serial9;			/*!< Serial byte 9 */
	unsigned char checksumGenMSB;	/*!< Checksum MSB */
	unsigned char checksumGenLSB;	/*!< Checksum LSB */
	unsigned char batLevelLSB;		/*!< Battery level */
	unsigned char capLevelLSB;		/*!< Super capacitor level */
	unsigned char periodMSB;		/*!< period MSB */
	unsigned char periodLSB;		/*!< PeriodLSB */
	unsigned char anaPressInitMSB;	/*!< Analog pressure at the startup MSB */
	unsigned char anaPressInitLSB;	/*!< Analog pressure at the startup LSB */
	unsigned char iSensInitMSB;		/*!< iSens at the startup MSB */
	unsigned char iSensInitLSB;		/*!< iSens at the startup LSB */
	unsigned char anaPressCheckMSB;	/*!< Analog pressure check MSB */
	unsigned char anaPressCheckLSB;	/*!< Analog pressure check LSB */
	unsigned char iSensCheckMSB;	/*!< iSens check MSB */
	unsigned char iSensCheckLSB;	/*!< iSens check LSB */
	unsigned char anaPressActivMSB;	/*!< Analog pressure activation MSB */
	unsigned char anaPressActivLSB;	/*!< Analog pressure activation LSB */
	unsigned char FBBeforeLSB;		/*!< Flotation bag before activation LSB */
	unsigned char FBCehckLSB;		/*!< Flotation back check LSB */
	unsigned char anaPressMaxMSB;	/*!< Maximum analog pressure MSB */
	unsigned char anaPressMaxLSB;	/*!< Maximum analog pressure LSB */
	unsigned char anaPressInitMinMSB;	/*!< Analog pressure initialization min MSB */
	unsigned char anaPressInitMinLSB;	/*!< Analog pressure initialization min LSB */
	unsigned char anaPressInitMaxMSB;	/*!< Analog pressure initialization max MSB */
	unsigned char anaPressInitMaxLSB;	/*!< Analog pressure initialization max LSB */
	unsigned char anaPressInitChecksum;
	unsigned char minBatteryVoltage;
	unsigned char SRDSerial1;
	unsigned char SRDSerial2;
	unsigned char SRDSerial3;
	unsigned char SRDSerial4;
	unsigned char SRDSerial5;
	unsigned char SRDSerial6;
	unsigned char SRDSerial7;
	unsigned char SRDSerial8;
}tSRDEeprom;
/*############################################################################################*/
/*## END TYPEDEF/STRUCT/ENUM/UNION ###########################################################*/
/*############################################################################################*/



/*############################################################################################*/
/*## VARIABLES ###############################################################################*/
/*############################################################################################*/

/*############################################################################################*/
/*## END VARIABLES ###########################################################################*/
/*############################################################################################*/



/*############################################################################################*/
/*## DECLARATION FONCTIONS ###################################################################*/
/*############################################################################################*/

/*############################################################################################*/
/*## END DECLARATION FONCTIONS ###############################################################*/
/*############################################################################################*/
#endif
