FuelConfig.h 5.11 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
typedef struct _FuelStruct
{
hu's avatar
hu committed
48 49 50 51
    uint16_t FuelShortCircuitR;
    uint16_t FuelOpenCircuitR;
    uint16_t DisplayZoneBoundary[22];
    uint16_t FuelCapacityBoundary[22];
hu's avatar
hu committed
52
} FuelStruct;
hu's avatar
hu committed
53 54

extern void InitFuelParamter(FuelStruct *para);
hu's avatar
hu committed
55
extern uint8_t *GetFuelLibVersion(void);
hu's avatar
hu committed
56

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

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

hu's avatar
hu committed
61 62 63
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
64

hu's avatar
hu committed
65 66 67
extern void SetPowerSt(uint8_t n);
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
68

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

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

enum
{
    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
87
};
hu's avatar
hu committed
88 89
extern uint8_t GetFuelFSM_St(void);
extern uint16_t GetFuelResistance(void); // unit:ohm,accuracy:0.1
hu's avatar
hu committed
90

hu's avatar
hu committed
91 92
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
93 94

// AFC & DrivingRange
hu's avatar
hu committed
95 96
typedef struct _AFC_INIT
{
hu's avatar
hu committed
97 98 99 100 101 102
    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
103
} AFC_INIT;
hu's avatar
hu committed
104 105 106
extern void InitAFC(AFC_INIT *data);
extern void ResetAFC(AFC_INIT *data);

hu's avatar
hu committed
107 108
typedef struct _AFC_PARA
{
hu's avatar
hu committed
109 110 111 112
    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
113
} AFC_PARA;
hu's avatar
hu committed
114 115
extern void SetAFCPara(AFC_PARA *data);

hu's avatar
hu committed
116 117
typedef struct _DAFC_PARA
{
hu's avatar
hu committed
118 119
    uint32_t DAFC_FuelConsumeSum; // unit:ul    (ul:m->ml:km->L:1000km)
    uint32_t DAFC_ODO;            // unit:m
hu's avatar
hu committed
120 121 122 123 124 125
} DAFC_PARA;
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())

typedef struct _DR_PARA
{
hu's avatar
hu committed
126 127
    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
128 129 130 131 132
} DR_PARA;
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
hu's avatar
hu committed
133 134
extern uint16_t GetDRMileage(void); // unit:km,accuracy:1
extern uint16_t GetCurAFC(void);    // unit:L,accuracy:0.1
hu's avatar
hu committed
135 136

// display afc
hu's avatar
hu committed
137
extern void DAFC_Reset(AFC_INIT *data);
hu's avatar
hu committed
138
extern uint16_t DAFC_GetAFC(void); // unit:L,accuracy:0.1
hu's avatar
hu committed
139
// display afc end
hu's avatar
hu committed
140

hu's avatar
hu committed
141
extern void SetIgnOffRefuelThreshold(uint8_t data);
hu's avatar
hu committed
142

hu's avatar
hu committed
143
#endif