Mini can app

Dependencies:   mbed mbed-STM32F103C8T6

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers heatcontrol.h Source File

heatcontrol.h

00001 #ifndef __HEATCONTROL_H
00002 #define __HEATCONTROL_H
00003 #include "stdint.h"
00004 #include "wiced_types.h"
00005 
00006 
00007 #define HEATFAULTCYCLELENGTH 102
00008 #define HEATFAULTCYCLEHOLDOFF -240
00009 
00010 
00011 typedef enum {HEATCALLOFF=0, HEATCALLON=1, HEATCALLINIT=2, HEATCALLLONGRUN=3} heatcall;
00012 
00013 
00014 #define IDLE 0
00015 
00016 #define HEATERSTATECOUNT 1
00017 #define RESETHEATTIME 60*60*8; // 8hours
00018 #define LIN_RX_BUFFER_SIZE    64
00019 #define LIN_UART              WICED_UART_2
00020 
00021 
00022 extern struct sHeatVars heaterState[HEATERSTATECOUNT];
00023 
00024 struct sHeatVars {
00025     int primeFuelPumpCount;
00026     wiced_bool_t heatCallDetected;
00027     int heaterDetected;
00028     wiced_bool_t OBAltitude;
00029     int initTimer;
00030     int tasksequence;
00031     uint16_t currentError; // default FF
00032     char heatOn; // default 0
00033     wiced_bool_t primeFuelPump;
00034     wiced_bool_t altitudeMode;
00035     uint16_t errorHistory[8];
00036     unsigned char errorChangeFlag; // default 0
00037     char heatcontrolstate; // default 0
00038     int lastRequest;// default = 0;
00039     int lastResponse;//default = 0;
00040     int noResponseCount;//default = 0;
00041     char retryHC;// = 0;
00042     char heatrunning;// = 0;
00043     char reset_fault_codes; // WICED_FALSE
00044     wiced_bool_t isAnalogHeater; // wiced_false
00045     volatile unsigned int tickcount; // default 0
00046     volatile unsigned int resettick; // default 0
00047     unsigned char linbuff[35];
00048     unsigned char linpoint;// = 0;
00049     unsigned char working;// = 0;
00050     volatile long heattime; //= 0
00051     volatile long heatresettime;
00052     long heaterRuntime;
00053     unsigned long setpoint;
00054     char reportflag; //= 0-
00055     unsigned volatile long preheattime;// = 0;
00056     unsigned long heaterSetpointChange;
00057     char bustype;
00058     char heaternum;
00059     int battV;
00060     int altitude;
00061     int32_t heaterTemp;
00062     int flameTemp;
00063     int inletTemp;
00064     int outletTemp;
00065     int internalAltitude;
00066     double rawAltitude;
00067 };
00068 
00069 
00070 #define HEATERTYPENONE 0
00071 #define HEATERTYPECAN 1
00072 #define HEATERTYPELIN 2
00073 
00074 void initHeaterState(struct sHeatVars *s);
00075 void InitLinUart(struct sHeatVars *s);
00076 void InitCAN();
00077 void doHeatTask(struct sHeatVars *s);
00078 void doHeatTaskCAN(struct sHeatVars *s);
00079 void doHeatLogicTask(struct sHeatVars *s);
00080 void WakeHeater(struct sHeatVars *s);
00081 
00082 
00083 void set_heat_con(struct sHeatVars* s, heatcall on_off);
00084 void show_heat_con(void);
00085 void resetFaultCodes(struct sHeatVars* s);
00086 void primeFuelPump(struct sHeatVars* s);
00087 
00088 unsigned char get_heater_fault_code(void);
00089 void get_heater_status_str(char * status);
00090 void setHeatSetpoint(struct sHeatVars* s, int setpoint);
00091 
00092 #endif
00093