eepromManage.h 6 KB
Newer Older
李俭双's avatar
李俭双 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

#ifndef _S6J3360_EE_MANAGE_H_
#define _S6J3360_EE_MANAGE_H_



#pragma pack(1)  /* 必须保留 */

typedef unsigned char    ee_uint8_t;
typedef unsigned short   ee_uint16_t;
typedef unsigned int     ee_uint32_t;
    

#define    READ_FAIL                      0x0000
#define    READING                        0x0001
#define    READ_COMPLETE                  0x0002

#define    WRITE_FAIL                     0x0000
#define    WRITING                        0x0001 
#define    WRITE_COMPLETE                 0x0002



typedef enum
{
    distance_1m = 1,
    distance_10m = 10,
    distance_100m = 100,
    distance_1000m = 1000,
}StorageDistance_t;


typedef enum
{
    AT24C04 = 4,
    AT24C16 = 16,
}DeviceNo_t;
      
typedef struct
{
    ee_uint32_t Odo;
    ee_uint32_t Trip;
    ee_uint32_t Trip1;
    ee_uint8_t  IsTripClear;
    ee_uint8_t  IsTrip1Clear;
}Mileage_t;

extern ee_uint16_t            OdoValidAddress;
/* 读取库版本号 */
extern        ee_uint8_t*       eeprom_getVersion(void);

/*-------------------------------------------------------------------------
* Function Name  : eeprom_1ms_timeCount
* Description    : 中断中调用 必须中断时间 >= 1ms,这个时间影响写的整体速度
* Input          : 
* Output         : 
* Return         :
* onther         :
--------------------------------------------------------------------------*/
extern        void                   eeprom_1ms_timeCount(void);  
    
    
/*-------------------------------------------------------------------------
* Function Name  : eeprom_SetParameter
* Description    :
* Input          : device_No:芯片型号 AT24C04 or AT24C16 
                   StorageDistance :相邻两次存储数据间隔,两次存储数据之差必须大于这个间隔
                    distance_1m = 0,
                    distance_10m = 10,
                    distance_100m = 100,
                    distance_1000m = 1000
* Output         : 
* Return         :
* onther         :
--------------------------------------------------------------------------*/
extern        void                   eeprom_SetParameter(DeviceNo_t device_No,StorageDistance_t StorageDistance);
    
    
/*-------------------------------------------------------------------------
* Function Name  : eeprom_ClearOdoSection
* Description    : 清零ODO,但是清零完成不死机
* Input          : 
* Output         : 
* Return         :
* onther         :
--------------------------------------------------------------------------*/
extern        void                   eeprom_ClearOdoSection(void);
    
/*-------------------------------------------------------------------------
* Function Name  : eeprom_WriteRecord
* Description    :
* Input          : address ; 0~xxx
                   recordDatas:存储数据指针
                   record_len : 记录长度
* Output         : 
* Return         :
                  #define    WRITE_FAIL                     0x0000
                  #define    WRITING                        0x0001 
                  #define    WRITE_COMPLETE                 0x0002
* onther         :
--------------------------------------------------------------------------*/
extern        ee_uint16_t        eeprom_WriteRecord(ee_uint16_t address,ee_uint8_t* recordDatas,ee_uint16_t record_len);
    
    
/*-------------------------------------------------------------------------
* Function Name  : eeprom_ReadRecord
* Description    :
* Input          : address ; 0~xxx
                   recordDatas:存储数据指针
                   record_len : 记录长度
* Output         : 
* Return         :
                  #define    READ_FAIL                      0x0000
                  #define    READING                        0x0001
                  #define    READ_COMPLETE                  0x0002
* onther         :
--------------------------------------------------------------------------*/
extern        ee_uint16_t        eeprom_ReadRecord(ee_uint16_t address,ee_uint8_t* recordDatas,ee_uint16_t record_len);
    
    
/*-------------------------------------------------------------------------
* Function Name  : eeprom_WriteODO
* Description    :
* Input          : StorageDistance 必须与 eeprom_SetParameter设置的一致
                   u32_odo 单位必须与 StorageDistance 保持一致
                   每次唤醒必须执行读 调用eeprom_ReadODO,因为有些信息休眠无法保存
* Output         : 
* Return         :
                  #define    WRITE_FAIL                     0x0000
                  #define    WRITING                        0x0001 
                  #define    WRITE_COMPLETE                 0x0002
* onther         :
--------------------------------------------------------------------------*/
extern        ee_uint16_t       eeprom_WriteODO(Mileage_t *MileageInfo,StorageDistance_t StorageDistance,ee_uint8_t ign); 
    
    
/*-------------------------------------------------------------------------
* Function Name  : eeprom_ReadODO
* Description    :
* Input          : 
* Output         : 
* Return         :
                  #define    READ_FAIL                      0x0000
                  #define    READING                        0x0001
                  #define    READ_COMPLETE                  0x0002
* onther         :
--------------------------------------------------------------------------*/
extern        ee_uint16_t       eeprom_ReadODO(Mileage_t *MileageInfo);


/*-------------------------------------------------------------------------
get state infomation
--------------------------------------------------------------------------*/
extern        ee_uint16_t         eeprom_getWriteState(void);
extern        ee_uint16_t         eeprom_getReadState(void);
extern        ee_uint16_t         eeprom_getOdoCurWriteAddress(void);
extern        ee_uint32_t         eeprom_getOdoLastWriteValue(void);

/***30电只存储一次调用**/
/*extern void SetEEWriteDressToLib(ee_uint16_t EEWriteDressDate);

extern ee_uint16_t GetEEWriteDressToRam(void);*/
    
#pragma pack () /* 必须保留 */    
    
#endif /* _S6J3360_EE_MANAGE_H_ */