
/*
********************************************************************************************************
*  @Module        FRAM
*  @Filename     FRAM.H
*  @Project        SST-3000
*------------------------------------------------------------------------------------------------------
*  @Controller     AT90CAN32
*
   @Compiler      AVR GCC

   @ Frequency   Using external clock 16MHz
 
   @Codegenerator 0.1
 
   @Description    I2C Device driver
 
--------------------------------------------------------------------------------------------------------
  @Date          2013-03-15 15:15:00
 
********************************************************************************************************
*/


#ifndef _FRAM_H_
#define _FRAM_H_


#ifdef _FRAM_C_
#define _FRAM
#else
#define _FRAM	extern
#endif


/*
*********************************************************************************************************
 									@Macros
*********************************************************************************************************
*/

#define WRITE_FRAM(Ver, Type)	Write_FRAM(&Ver,Type,  sizeof( Ver ))

#define READ_FRAM(Ver, Type)    Read_FRAM(&Ver, Type,  sizeof( Ver ) )

/*
*********************************************************************************************************
									 @Defines
*********************************************************************************************************
*/


#define FRAM_ADDRES		0xA0

#define FRAM_Default_Data_Initialization  0xaa

#define FRAM_BaseAddr		0x0a
#define FRAM_One_Write_Addr  FRAM_BaseAddr-1

#define FRAM_History_Day_04hr  FRAM_BaseAddr+4
#define FRAM_History_Day_08hr  FRAM_History_Day_04hr+4
#define FRAM_History_Day_12hr  FRAM_History_Day_08hr+4
#define FRAM_History_Day_16hr  FRAM_History_Day_12hr+4
#define FRAM_History_Day_20hr  FRAM_History_Day_16hr+4
#define FRAM_History_Day_24hr  FRAM_History_Day_20hr+4
		
#define FRAM_History_Week_04hr  FRAM_History_Day_24hr+4
#define FRAM_History_Week_08hr  FRAM_History_Week_04hr+4
#define FRAM_History_Week_12hr  FRAM_History_Week_08hr+4
#define FRAM_History_Week_16hr  FRAM_History_Week_12hr+4
#define FRAM_History_Week_20hr  FRAM_History_Week_16hr+4
#define FRAM_History_Week_24hr  FRAM_History_Week_20hr+4

		
#define FRAM_History_Month_04hr  FRAM_History_Week_24hr+4
#define FRAM_History_Month_08hr  FRAM_History_Month_04hr+4
#define FRAM_History_Month_12hr  FRAM_History_Month_08hr+4
#define FRAM_History_Month_16hr  FRAM_History_Month_12hr+4
#define FRAM_History_Month_20hr  FRAM_History_Month_16hr+4
#define FRAM_History_Month_24hr  FRAM_History_Month_20hr+4

#define FRAM_History_7Week_Mon  FRAM_History_Month_24hr+4
#define FRAM_History_7Week_Tue  FRAM_History_7Week_Mon+4
#define FRAM_History_7Week_Wed  FRAM_History_7Week_Tue+4
#define FRAM_History_7Week_Thu  FRAM_History_7Week_Wed+4
#define FRAM_History_7Week_Fri  FRAM_History_7Week_Thu+4
#define FRAM_History_7Week_Sat  FRAM_History_7Week_Fri+4
#define FRAM_History_7Week_Sun  FRAM_History_7Week_Sat+4
	
#define FRAM_History_7Month_7  FRAM_History_7Week_Sun+4
#define FRAM_History_7Month_6  FRAM_History_7Month_7+4
#define FRAM_History_7Month_5  FRAM_History_7Month_6+4
#define FRAM_History_7Month_4  FRAM_History_7Month_5+4
#define FRAM_History_7Month_3  FRAM_History_7Month_4+4
#define FRAM_History_7Month_2  FRAM_History_7Month_3+4
#define FRAM_History_7Month_1  FRAM_History_7Month_2+4


/*
*********************************************************************************************************
*
* 					 				@Typedefs
*
*********************************************************************************************************
* /

typedef struct _FRAM_DB{

	U8		One_Write_Addr;

	U8		BaseAddr;

	U16     History_Day_04hr;
	U16     History_Day_08hr;
	U16     History_Day_12hr;
	U16     History_Day_16hr;
	U16     History_Day_20hr;
	U16     History_Day_24hr;
		
	U16     History_Week_04hr;
	U16     History_Week_08hr;
	U16     History_Week_12hr;
	U16     History_Week_16hr;
	U16     History_Week_20hr;
	U16     History_Week_24hr;

		
	U16     History_Month_04hr;
	U16     History_Month_08hr;
	U16     History_Month_12hr;
	U16     History_Month_16hr;
	U16     History_Month_20hr;
	U16     History_Month_24hr;

	U16		History_7Week_Mon;
	U16		History_7Week_Tue;
	U16		History_7Week_Wed;
	U16		History_7Week_Thu;
	U16		History_7Week_Fri;
	U16		History_7Week_Sat;
	U16		History_7Week_Sun;
	
	U16		History_7Month_7;
	U16		History_7Month_6;
	U16		History_7Month_5;
	U16		History_7Month_4;
	U16		History_7Month_3;
	U16		History_7Month_2;
	U16		History_7Month_1;
	
		
}FRAM_STRUCT;


/*
*********************************************************************************************************
 									@@Global Variables
*********************************************************************************************************
*/

//_FRAM FRAM_STRUCT FRAM;



/*
*********************************************************************************************************
 									@FND_Driver  Method Functions
*********************************************************************************************************
*/
_FRAM  U8 FRAM_Return_Byte_Read(U16 Address, U8 *Data);
_FRAM  void FRAM_Default_Data_Init(void);

_FRAM  void Put_FRAM(U16 Write_Addres, U8 *Write_Data,  U8 Write_Length);
_FRAM  void Get_FRAM(U16 Read_Addres, U8 *Read_Data,  U8 Read_Length);

_FRAM  void Write_FRAM(void *pWrite_Val, char *Type,  U8 Write_Length );

_FRAM  void Read_FRAM(void *pRead_Val, char *Type,  U8 Read_Length );

_FRAM  void FRAM_Byte_Write(U16 Address, U8 Data);

_FRAM  void FRAM_Byte_Read(U16 Address, U8 *Data);

_FRAM  void FRAM_Data_Restore(void);


#endif	//_FRAM_H_



