tasks.c 9.44 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 88 89 90 91 92
#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_AdBule.h"
#include "Data_ADAS.h"
#include "Data_Voltmeter.h"
#include "Data_WET.h"
#include "Data_DrivingSupport.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
93 94 95 96
 *                                                                              *
 *   系统常规运行模式(SYS_MODE_OFF / SYS_MODE_ON / SYS_MODE_STANDBY )任务列表   *
 *                                                                              *
 *******************************************************************************/
hu's avatar
hu committed
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 137 138

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

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
139
    DisplayServices();
hu's avatar
hu committed
140 141 142 143
    loc_Display_Service();
    Data_Mileage_Write_EEPROM();
    Line_In_Debounce_Service();
    Telltales_Management();
hu's avatar
hu committed
144
    // Test_LED_AllLight();
hu's avatar
hu committed
145 146
    Key_Service();
    CAN_BUSOFF_Recover();
hu's avatar
hu committed
147

hu's avatar
hu committed
148
    /*表头调度函数 added by yutian*/
hu's avatar
hu committed
149
    UserGaugeSchedule(); /*在主循环中调用*/
hu's avatar
hu committed
150
    /*end*/
151
    CD4051B_ReadSignal_Serviece();
hu's avatar
hu committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
    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();
    AdBule_Processing_Service();
    ADAS_Processing_Service();
    DrivingSupport_Processing_Service();
    AirPressure_Processing_Service();
    Voltmeter_Processing_Service();
    Sound_Management_Service();
hu's avatar
hu committed
176
    CD4051B_Debounce_Service();
hu's avatar
hu committed
177 178 179
    Seg_Display_Service();
    Seg_Buffer_Commit();
    BU98R10_Update_Request();
hu's avatar
hu committed
180
    Buzzer_Track_Play_Service();
hu's avatar
hu committed
181 182 183 184 185 186 187 188 189
}
/*============================================================================*/

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

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

hu's avatar
hu committed
191 192 193 194
    Data_Time_Calibration();
    Data_Service_Gear_Processing();
    Speed_PPK_Processing();
    Sound_Scheduling_Service();
hu's avatar
hu committed
195
    // BGTask();
hu's avatar
hu committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209
    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
210
    // Data_Avg_Speed_Processing();
hu's avatar
hu committed
211 212 213 214
    Data_TPMS_Value_Processing();
    Data_Service_Gear_Processing();
    Data_Ambient_Temperature_Processing();

hu's avatar
hu committed
215 216 217 218 219
    // Display_Schedule_Service();/*显示函数入口*/
    // Menu_Display_Service();
    // External_Influence_ENERGY_RECOVERY_LEVEL_Select();
    // LongTimeNoKey_Operation();
    // Menu_Get_Battery_Sts_Exist();
hu's avatar
hu committed
220 221
    Popups_Management_Service();
    Popup_Scheduling_Service();
hu's avatar
hu committed
222 223 224 225 226 227 228 229




    /*加速度计算*/
    Data_Acc_Speed_Processing();
    /*高速路一般路报警判断*/
    Data_GsLYbL_Speed_Processing();
hu's avatar
hu committed
230 231 232 233
}
/*============================================================================*/

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

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

/*******************************************************************************
hu's avatar
hu committed
274 275 276 277
 *                                                                              *
 *                           精确的100ms计时任务列表                            *
 *                                                                              *
 *******************************************************************************/
hu's avatar
hu committed
278 279 280 281 282 283 284 285 286 287 288
/*==============================================================================
精确的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
289
void APP_Startup_Init(uint8_t startMode)
hu's avatar
hu committed
290 291 292
{
    Power_Management_Init(startMode);
}