main.h 7.36 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
/******************************************************************************
文 件 名:main.h
功能描述:主程序头文件
作    者:张暄
版    本:V1.0
日    期:2016.11.1
******************************************************************************/

#ifndef _MAIN_H_
#define _MAIN_H_

#include <hidef.h>            /* common defines and macros */
#include "derivative.h"       /* derivative-specific definitions */
#include "stdint.h"
#include "comdef.h"
#include "CRG.h"
#include "API.h"
#include "GPIO.h"
#include "PWM.h"
//#include "MSCAN0_J1939.h"
//#include "DoCAN_J1939.h"
#include "DoCAN_ISO15765_Config.h"
#include "DoCAN_ISO15765.h"
#include "SCI0_UART.h"
#include "SCI1_UART.h"       
#include "Analog_Signal_Conversion.h"
#include "Communication_Over_CAN.h"
#include "Simulated_IIC_Master.h"
#include "PowerManagement.h"
#include "LED.h"
#include "Line_In.h"
#include "EEPROM_24Cxx_Remap.h"
#include "Stepper_Motor.h"
#include "UDS_ISO14229_Services.h"
#include "UDS_ISO14229_Server.h"
#include "Non_volatile_Memorys.h"
#include "Flash_synchronizer.h"
#include "TFT_LCD.h"
#include "Data_Processor.h"
#include "Warning_Processor.h"
#include "Line_In.h"
#include "Segmented_Gauges.h "
#include "Telltales.h"
#include "BackLight.h"
#include "Popup_Scheduler.h"
#include "Popups.h"
#include "Drive_Info.h"
#include "TFT_LCD.h" 
#include "LCD_SEG.h"
#include "GUI.h"
#include "Gauges.h"
#include "IPC.h"
#include "TSzhen.h"
 
#include "PowerManagement.h"
#include "Buzzer.h"
/******************************************************************************
任务周期与分组
******************************************************************************/
60
#define   TASK_1ms_ALL          if (ScheduleUpdate.Task.Flag1ms)
崔立宝's avatar
崔立宝 committed
61

62 63
#define   TASK_2ms_GROUP_0      if ((ScheduleUpdate.Task.Flag2ms) && (TaskGroup.ID2ms == 0))
#define   TASK_2ms_GROUP_1      if ((ScheduleUpdate.Task.Flag2ms) && (TaskGroup.ID2ms == 1))
崔立宝's avatar
崔立宝 committed
64

65 66 67 68 69 70 71 72 73 74
#define   TASK_10ms_GROUP_0     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 0))
#define   TASK_10ms_GROUP_1     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 1))
#define   TASK_10ms_GROUP_2     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 2))
#define   TASK_10ms_GROUP_3     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 3))
#define   TASK_10ms_GROUP_4     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 4))
#define   TASK_10ms_GROUP_5     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 5))
#define   TASK_10ms_GROUP_6     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 6))
#define   TASK_10ms_GROUP_7     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 7))
#define   TASK_10ms_GROUP_8     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 8))
#define   TASK_10ms_GROUP_9     if ((ScheduleUpdate.Task.Flag10ms) && (TaskGroup.ID10ms == 9))
崔立宝's avatar
崔立宝 committed
75

76 77 78 79 80 81 82 83 84 85
#define   TASK_20ms_GROUP_0     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 0))
#define   TASK_20ms_GROUP_1     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 1))
#define   TASK_20ms_GROUP_2     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 2))
#define   TASK_20ms_GROUP_3     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 3))
#define   TASK_20ms_GROUP_4     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 4))
#define   TASK_20ms_GROUP_5     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 5))
#define   TASK_20ms_GROUP_6     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 6))
#define   TASK_20ms_GROUP_7     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 7))
#define   TASK_20ms_GROUP_8     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 8))
#define   TASK_20ms_GROUP_9     if ((ScheduleUpdate.Task.Flag20ms) && (TaskGroup.ID20ms == 9))
崔立宝's avatar
崔立宝 committed
86

87 88 89 90 91 92 93 94 95 96
#define   TASK_50ms_GROUP_0     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 0))
#define   TASK_50ms_GROUP_1     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 1))
#define   TASK_50ms_GROUP_2     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 2))
#define   TASK_50ms_GROUP_3     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 3))
#define   TASK_50ms_GROUP_4     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 4))
#define   TASK_50ms_GROUP_5     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 5))
#define   TASK_50ms_GROUP_6     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 6))
#define   TASK_50ms_GROUP_7     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 7))
#define   TASK_50ms_GROUP_8     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 8))
#define   TASK_50ms_GROUP_9     if ((ScheduleUpdate.Task.Flag50ms) && (TaskGroup.ID50ms == 9))
崔立宝's avatar
崔立宝 committed
97

98 99 100 101 102 103 104 105 106 107
#define   TASK_100ms_GROUP_0    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 0))
#define   TASK_100ms_GROUP_1    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 1))
#define   TASK_100ms_GROUP_2    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 2))
#define   TASK_100ms_GROUP_3    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 3))
#define   TASK_100ms_GROUP_4    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 4))
#define   TASK_100ms_GROUP_5    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 5))
#define   TASK_100ms_GROUP_6    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 6))
#define   TASK_100ms_GROUP_7    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 7))
#define   TASK_100ms_GROUP_8    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 8))
#define   TASK_100ms_GROUP_9    if ((ScheduleUpdate.Task.Flag100ms) && (TaskGroup.ID100ms == 9))
崔立宝's avatar
崔立宝 committed
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

/******************************************************************************
任务调度表
******************************************************************************/
static const uint8_t TaskScheduleTable[10] = {0x07, 0x0F, 0x17, 0x0F, 0x07,
    0x0F, 0x17, 0x0F, 0x27, 0x0F };

/******************************************************************************
结构体声明
******************************************************************************/
//extern   uint8_t   Fuel_Seg ;
/*** 调度更新标志位定义结构 ***/
typedef struct
{
  uint8_t     Flag1ms     :   1;
  uint8_t     Flag2ms     :   1;
  uint8_t     Flag10ms    :   1;
  uint8_t     Flag20ms    :   1;
  uint8_t     Flag50ms    :   1;
  uint8_t     Flag100ms   :   1;
  uint8_t                 :   2;
} ScheduleUpdateStruct;

/*** 调度更新标志联合体 ***/
typedef union
{
  uint8_t              TaskFlagAll;
  ScheduleUpdateStruct Task;
} ScheduleUpdateUnion;

/*** 任务分组编号结构 ***/
typedef struct
{
  uint8_t     ID2ms;
  uint8_t     ID10ms;
  uint8_t     ID20ms;
  uint8_t     ID50ms;
  uint8_t     ID100ms;
  uint8_t     ID500ms;
} TaskGroupStruct;

149 150
extern uint16_t DataDTE;
extern uint8_t  Fuel_Seg, FuelStatus;
崔立宝's avatar
崔立宝 committed
151

152
extern uint16_t DataAvgFuelConsByLF; 
崔立宝's avatar
崔立宝 committed
153

154 155 156 157 158 159
extern uint16_t FuelConsumeSum;
extern INT16U   FuelResistanceV;
extern uint8_t  AverageFuel_LL;
extern uint8_t  AverageFuel_LH;
extern uint8_t  AverageFuel_HL;
extern uint8_t  AverageFuel_HH;
崔立宝's avatar
崔立宝 committed
160 161 162 163 164
extern uint16_t TankLevel_temp;
/******************************************************************************
函数声明
******************************************************************************/
void Task_Scheduler_Init(void);
165 166
void Task_Scheduling_Service(void); /* 此函数需要被实时调用 */
void Factory_ClearOdoM(void);       //生产清理大计里程
崔立宝's avatar
崔立宝 committed
167 168
void Fuel_Process(void);
#endif