tasks.c 9.34 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12
/**************************************************************************
 * \file     Tasks.c
 * \brief    Task list
 * \details
 * \author   Zhang Xuan
 * \version  V1.0.0
 * \date     07-Sep-2018
 * \par      History:
 *           V1.0.0 Initial release
 * \par      Copyright:
 *           (c) Heilongjiang TYW Electronics co., LTD
 ******************************************************************************/
hu's avatar
hu committed
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
#include "r_typedefs.h"
#include "Sys_Scheduler.h"
#include "rh850_macros.h"

#include "Analog_Signals.h"
#include "RTC.h"

#include "Watchdog.h"

#include "debugger.h"
#include "Emulated_EEPROM.h"

#include "r_ddb_api.h"
#include "r_wm_api.h"
#include "Graphic.h"

#include "CAN_Communication_Matrix.h"

#include "PowerManagement.h"
#include "System_Monitor.h"
#include "Common_Interface.h"

#include "Services_ODO_User.h"
#include "Data_CoolantTemperature.h"
#include "Data_VehicleSpeed.h"
#include "Data_EngineSpeed.h"
#include "AC_TEMP.h"
#include "Data_Time.h"
#include "Data_Gear.h"
#include "Data_Voltmeter.h"
#include "Data_WET.h"
#include "Data_AirPressure.h"
#include "Data_Fuel_User.h"
#include "Services_Mileage.h"
//#include "Services_ODO.h"
#include "Services_Mileage.h"
//#include "Services_Trip.h"
#include "Speed_PPK_Out.h"
#include "Service_TPMS.h"
#include "Service_OFF_Time.h"

#include "Flash_synchronizer.h"
#include "Line_in.h"
#include "Telltales.h"
#include "GUI.h"
#include "Key.h"
#include "Menu.h"

#include "GUI_Interface.h"
#include "Popup_Scheduler.h"
#include "Popups.h"

#include "GaugesInterface.h"
#include "DisplaySch_user.h"

#include "Sound_Scheduler.h"
#include "Sound_Player.h"
#include "BGLInterface.h"
#include "BackLight_APP.h"
#include "CD4051.h"
#include "dr7f701441.dvf.h"
#include "GPIO.h"
#include "DoCAN_ISO15765.h"
#include "UDS_ISO14229_Server.h"
#include "Maintenance.h"
#include "Data_FuelConsump.h"

#include "IS31FL3236.h"
#include "Individual_ECU_Comm.h"
#include "TimerB.h"

#include "BU98R10.h"
#include "SEG_DISPLAY.h"

#include "Buzzer.h"
hu's avatar
hu committed
88
#include "CAN_FUNC.h"
hu's avatar
hu committed
89 90

/*******************************************************************************
hu's avatar
hu committed
91 92 93 94
 *                                                                              *
 *   系统常规运行模式(SYS_MODE_OFF / SYS_MODE_ON / SYS_MODE_STANDBY )任务列表   *
 *                                                                              *
 *******************************************************************************/
hu's avatar
hu committed
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

/*==============================================================================
伪实时任务
------------------------------------------------------------------------------*/

void Sys_Run_Mode_Pseudo_Real_Time_Tasks(void)
{
    Power_Management_Service();
    DoCAN_Communication_Service();
    UDS_Server_Application_Service();
    IS31_Service();
    BU98R10_Update_Service();
}
/*============================================================================*/

/*==============================================================================
2ms周期执行任务
------------------------------------------------------------------------------*/
void Sys_Run_Mode_2ms_Tasks(void)
{
    UDS_KL15_init();
    Analog_Signal_Conv_Service();
    Sys_Status_Update_Service();
    Common_Input_Para();
    Gauges_Time_Xms_Count(2);
    UDS_10ms_Service();
}
/*============================================================================*/
/*==============================================================================
10ms周期执行任务
------------------------------------------------------------------------------*/
void Sys_Run_Mode_5ms_Tasks(void)
{
    COM_RX_Process();
    Flash_Sync_Signal_Generation_Service();
}

/*==============================================================================
10ms周期执行任务
------------------------------------------------------------------------------*/
void Sys_Run_Mode_10ms_Tasks(void)
{
hu's avatar
hu committed
137
    DisplayServices();
hu's avatar
hu committed
138 139 140 141
    loc_Display_Service();
    Data_Mileage_Write_EEPROM();
    Line_In_Debounce_Service();
    Telltales_Management();
hu's avatar
hu committed
142
    // Test_LED_AllLight();
hu's avatar
hu committed
143 144
    Key_Service();
    CAN_BUSOFF_Recover();
hu's avatar
hu committed
145

hu's avatar
hu committed
146
    /*表头调度函数 added by yutian*/
hu's avatar
hu committed
147
    UserGaugeSchedule(); /*在主循环中调用*/
hu's avatar
hu committed
148
    /*end*/
149
    CD4051B_ReadSignal_Serviece();
hu's avatar
hu committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
    Sound_Play_Service();

    Can_BusOff_Fun();

    Fuel_User_KL15_ON_Processing_Service();
}
/*============================================================================*/

/*==============================================================================
20ms周期执行任务
------------------------------------------------------------------------------*/
void Sys_Run_Mode_20ms_Tasks(void)
{
    Individual_ECU_Comm_Processing_Service();
    Coolant_Processing_Service();
    Tacho_Processing_Service();
    Speed_Processing_Service();
    Telltales_Left_Right_Management_Service();
    AirPressure_Processing_Service();
    Voltmeter_Processing_Service();
    Sound_Management_Service();
hu's avatar
hu committed
171
    CD4051B_Debounce_Service();
hu's avatar
hu committed
172 173 174
    Seg_Display_Service();
    Seg_Buffer_Commit();
    BU98R10_Update_Request();
hu's avatar
hu committed
175
    Buzzer_Track_Play_Service();
hu's avatar
hu committed
176 177 178 179 180 181 182 183 184
}
/*============================================================================*/

/*==============================================================================
50ms周期执行任务
------------------------------------------------------------------------------*/

void Sys_Run_Mode_50ms_Tasks(void)
{
hu's avatar
hu committed
185

hu's avatar
hu committed
186 187 188 189
    Data_Time_Calibration();
    Data_Service_Gear_Processing();
    Speed_PPK_Processing();
    Sound_Scheduling_Service();
hu's avatar
hu committed
190
    // BGTask();
hu's avatar
hu committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204
    IS31_Scan_Refresh();
}
/*============================================================================*/

/*==============================================================================
100ms周期执行任务
------------------------------------------------------------------------------*/
void Sys_Run_Mode_100ms_Tasks(void)
{

    BL_Management_service();
    RTE_RTC_Services_100Ms_Cbk();
    Data_ODO_Processing();
    Data_Trip_Processing();
hu's avatar
hu committed
205
    // Data_Avg_Speed_Processing();
hu's avatar
hu committed
206 207 208 209
    Data_TPMS_Value_Processing();
    Data_Service_Gear_Processing();
    Data_Ambient_Temperature_Processing();

hu's avatar
hu committed
210 211 212 213 214
    // Display_Schedule_Service();/*显示函数入口*/
    // Menu_Display_Service();
    // External_Influence_ENERGY_RECOVERY_LEVEL_Select();
    // LongTimeNoKey_Operation();
    // Menu_Get_Battery_Sts_Exist();
hu's avatar
hu committed
215 216
    Popups_Management_Service();
    Popup_Scheduling_Service();
hu's avatar
hu committed
217

hu's avatar
hu committed
218 219
    /*CAN 数据处理*/
    Drive_Info_IC1_STATUS_Rx();
hu's avatar
hu committed
220 221 222 223 224

    /*加速度计算*/
    Data_Acc_Speed_Processing();
    /*高速路一般路报警判断*/
    Data_GsLYbL_Speed_Processing();
hu's avatar
hu committed
225 226 227 228
}
/*============================================================================*/

/*******************************************************************************
hu's avatar
hu committed
229 230 231 232
 *                                                                              *
 *                     系统休眠模式(SYS_MODE_SLEEP)任务列表                     *
 *                                                                              *
 *******************************************************************************/
hu's avatar
hu committed
233 234 235 236 237 238 239 240 241
/*==============================================================================
休眠模式下执行的后台任务
------------------------------------------------------------------------------*/
void Sys_Sleep_Mode_Tasks(void)
{
}
/*============================================================================*/

/*******************************************************************************
hu's avatar
hu committed
242 243 244 245
 *                                                                              *
 *                           精确的50us计时任务列表                             *
 *                                                                              *
 *******************************************************************************/
hu's avatar
hu committed
246 247 248 249 250 251
/*==============================================================================
精确的50us计时任务 禁止添加修改列表中的任务
------------------------------------------------------------------------------*/
void Sys_Exact_50us_Tasks(void)
{
    static uint16_t PerCounter = 0u;
hu's avatar
hu committed
252
    Sys_Rolling();
hu's avatar
hu committed
253 254 255
    COM_NM_Process();
    COM_TX_Process();
    DoCAN_Timer_Update(50);
hu's avatar
hu committed
256
    // TimerB_Fre_Timeout(50);
257
    Cal_Veh_Cycle(SPEED_SIGNAL_PWM_IN); /*车速输入,非捕获方式 20211018*/
hu's avatar
hu committed
258 259 260 261 262 263 264 265 266 267 268
    PerCounter++;
    if (PerCounter >= 20 * 5)
    {
        PerCounter = 0u;
        SEG_LCD_Window_Control_Service();
    }
    Buzzer_Play_ISR();
}
/*============================================================================*/

/*******************************************************************************
hu's avatar
hu committed
269 270 271 272
 *                                                                              *
 *                           精确的100ms计时任务列表                            *
 *                                                                              *
 *******************************************************************************/
hu's avatar
hu committed
273 274 275 276 277 278 279 280 281 282 283
/*==============================================================================
精确的100ms计时任务 禁止添加修改列表中的任务
------------------------------------------------------------------------------*/
void Sys_Exact_100ms_Tasks(void)
{
    Data_Mileage_ISR();
    Service_OFF_Timing_Process();
    Fuel_User_KL15_OFF_Processing_Service();
}
/*============================================================================*/

hu's avatar
hu committed
284
void APP_Startup_Init(uint8_t startMode)
hu's avatar
hu committed
285 286 287
{
    Power_Management_Init(startMode);
}