FuelConfig.h 5.34 KB
Newer Older
hu's avatar
hu committed
1 2
#ifndef _FUELCONFIG_H
#define _FUELCONFIG_H
hu's avatar
hu committed
3

hu's avatar
hu committed
4 5 6 7 8
#include "TYW_stdint.h"

//typedef unsigned short INT16U;
//typedef unsigned char INT8_t;
//typedef unsigned int INT32_t;
hu's avatar
hu committed
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
#define DISPLAY_BOUNDARY_ES         1500u
#define DISPLAY_BOUNDARY_1          1500u
#define DISPLAY_BOUNDARY_2          1373u
#define DISPLAY_BOUNDARY_3          1191u
#define DISPLAY_BOUNDARY_4          1009u
#define DISPLAY_BOUNDARY_5          848u
#define DISPLAY_BOUNDARY_6          697u
#define DISPLAY_BOUNDARY_7          545u
#define DISPLAY_BOUNDARY_8          436u
#define DISPLAY_BOUNDARY_9          345u
#define DISPLAY_BOUNDARY_10         254u
#define DISPLAY_BOUNDARY_11         188u
#define DISPLAY_BOUNDARY_12         132u
#define DISPLAY_BOUNDARY_13         84u
#define DISPLAY_BOUNDARY_FS         65u

#define BOUNDARY_FUEL_ES            0u
#define BOUNDARY_FUEL_1             400u
#define BOUNDARY_FUEL_2             720u
#define BOUNDARY_FUEL_3             860u
#define BOUNDARY_FUEL_4             1040u
#define BOUNDARY_FUEL_5             1428u
#define BOUNDARY_FUEL_6             2577u
#define BOUNDARY_FUEL_7             3750u
#define BOUNDARY_FUEL_8             4931u
#define BOUNDARY_FUEL_9             5536u
#define BOUNDARY_FUEL_10            5724u
#define BOUNDARY_FUEL_11            6491u
#define BOUNDARY_FUEL_12            6850u
#define BOUNDARY_FUEL_13            7199u
#define BOUNDARY_FUEL_FS            7600u

#define FUEL_R_MIN_VAL 40u   /* 10 X ohm */
#define FUEL_R_MAX_VAL 3000u /* 10 X ohm */
hu's avatar
hu committed
44

45 46 47


//Fuel Config
hu's avatar
hu committed
48 49
typedef struct _FuelStruct
{
hu's avatar
hu committed
50 51 52 53
    uint16_t FuelShortCircuitR;
    uint16_t FuelOpenCircuitR;
    uint16_t DisplayZoneBoundary[22];
    uint16_t FuelCapacityBoundary[22];
hu's avatar
hu committed
54
} FuelStruct;
hu's avatar
hu committed
55 56

extern void InitFuelParamter(FuelStruct *para);
57 58 59
extern uint8_t *GetFuelSaveData(uint16_t *len);
extern void SetFuelSaveData(uint8_t *data, uint16_t len);
extern uint8_t* GetFuelLibVersion(void);
hu's avatar
hu committed
60

61
extern void FuelFSM(uint16_t FuelResistance);     //unit:ohm,accuracy:0.1
hu's avatar
hu committed
62

63
extern void SetMaxFuelBlockNum(uint8_t n); //call after InitFuelParamter(),default 12,max 20
hu's avatar
hu committed
64

65 66 67
extern void SetFuelSensorRecoverGroupCnt(uint16_t n);       //1:500ms,2:1000ms,3:1500ms.......,range:5s(10)-30min(3600)
extern void SetFuelSensorOpenCircuitGroupCnt(uint16_t n);   //1:500ms,2:1000ms,3:1500ms.......,range:5s(10)-30min(3600)
extern void SetFuelSensorShortCircuitGroupCnt(uint16_t n);  //1:500ms,2:1000ms,3:1500ms.......,range:5s(10)-30min(3600)
hu's avatar
hu committed
68

hu's avatar
hu committed
69
extern void SetPowerSt(uint8_t n);
70 71
extern uint8_t GetFuelSeg(void); //Segment, range:0~8
extern uint8_t GetFuelStep(void); //Pointer or Mono TFT stepless,range:0,10~((MaxFuelBlockNum + 1) * 10)  0,10:E,   ((MaxFuelBlockNum + 1) * 10):F
hu's avatar
hu committed
72

73
extern uint16_t GetFuelCapacityVal(void); //unit:L,accuracy:0.1
hu's avatar
hu committed
74

hu's avatar
hu committed
75 76 77 78 79 80 81
enum
{
    FuelSensorNormal,
    FuelSensorShortCircuit,
    FuelSensorOpenCircuit,
    FuelSensorPreFault,
};
hu's avatar
hu committed
82
extern uint8_t GetFuelSensorState(void);
hu's avatar
hu committed
83 84 85

enum
{
86 87 88 89 90
    FUEL_ST_IGN_ON_PROCESS = 1,     //1
    FUEL_ST_POWER_ON_ADD_FUEL,  //2
    FUEL_ST_VEHICLE_RUN,        //3
    FUEL_ST_IGN_OFF_PROCESS,    //4
    FUEL_ST_IGN_OFF,            //5
hu's avatar
hu committed
91
};
hu's avatar
hu committed
92
extern uint8_t GetFuelFSM_St(void);
93 94 95 96
extern uint16_t GetFuelResistance(void); //unit:ohm,accuracy:0.1

extern void SetPowerDnStep(uint8_t step);   //call every ign on  (after InitFuelParamter())
extern uint8_t GetPowerDnStep(void);    //every 10km or ign off or refuel(FUEL_ST_POWER_ON_ADD_FUEL->FUEL_ST_VEHICLE_RUN) record
hu's avatar
hu committed
97 98 99


// AFC & DrivingRange
hu's avatar
hu committed
100 101
typedef struct _AFC_INIT
{
102 103 104 105 106 107
    uint8_t CalcAFCMaxNum;    //max 100km,default 50
    uint16_t AFCMin;  //unit:L,accuracy:0.1
    uint16_t AFCMax;  //unit:L,accuracy:0.1
    uint16_t AFCPreinstall;   //unit:L,accuracy:0.1
    uint32_t CurODO;      // unit:m,accuracy:1
    uint32_t MaxDRMileage;    //unit:km,accuracy:0.01
hu's avatar
hu committed
108
} AFC_INIT;
hu's avatar
hu committed
109
extern void InitAFC(AFC_INIT *data);
110 111
extern uint8_t *GetDrivingRangeSaveData(uint16_t *len);
extern void SetDrivingRangeSaveData(uint8_t *data, uint16_t len);
hu's avatar
hu committed
112 113
extern void ResetAFC(AFC_INIT *data);

hu's avatar
hu committed
114 115
typedef struct _AFC_PARA
{
hu's avatar
hu committed
116 117 118 119
    uint32_t CurODO;      // unit:m,accuracy:1
    uint16_t FuleConsume; // unit:ul,accuracy:1
    uint16_t RPM;         // unit:RPM,accuracy:1
    uint8_t Speed;        // unit:km/h,accuracy:1
hu's avatar
hu committed
120
} AFC_PARA;
hu's avatar
hu committed
121 122
extern void SetAFCPara(AFC_PARA *data);

hu's avatar
hu committed
123 124
typedef struct _DAFC_PARA
{
125 126
    uint32_t DAFC_FuelConsumeSum;  //unit:ul    (ul:m->ml:km->L:1000km)
    uint32_t DAFC_ODO;             //unit:m
hu's avatar
hu committed
127
} DAFC_PARA;
128 129
extern void DAFC_GetPowerDownPara(DAFC_PARA *data);   //call every 10km or ign off or reset afc
extern void DAFC_SetPowerDownPara(DAFC_PARA *data);   //call every KL30 OFF -> KL30 ON (after InitAFC())
hu's avatar
hu committed
130 131 132

typedef struct _DR_PARA
{
133 134
    uint32_t DR_FuelConsumeSum;     //unit:ul    (ul:m->ml:km->L:1000km)
    uint32_t DR_Mileage;            //unit:km,accuracy:0.01
hu's avatar
hu committed
135
} DR_PARA;
136 137 138 139 140 141
extern void DR_GetPowerDownPara(DR_PARA *data);      //call every 10km or ign off
extern void DR_SetPowerDownPara(DR_PARA *data);      //call every KL30 OFF -> KL30 ON (after InitAFC())

extern void AFCTimerCall(void); //must per 10ms interrupt
extern uint16_t GetDRMileage(void);  //unit:km,accuracy:1
extern uint16_t GetCurAFC(void); //unit:L,accuracy:0.1
hu's avatar
hu committed
142 143


144
//display afc
hu's avatar
hu committed
145
extern void DAFC_Reset(AFC_INIT *data);
146 147
extern uint16_t DAFC_GetAFC(void);  //unit:L,accuracy:0.1
//display afc end
hu's avatar
hu committed
148

hu's avatar
hu committed
149
extern void SetIgnOffRefuelThreshold(uint8_t data);
hu's avatar
hu committed
150

hu's avatar
hu committed
151
#endif
152 153 154 155 156 157