#include "appTask.h" #include "uds.h" #include "uds_user.h" #include "stdint.h" #include "drivers/flexcan/flexcan_drv.h" #include "hwctrl.h" #include "TLE94x1.h" #include "string.h" #include "SEGGER_RTT.h" #include "MotorCtrl.h" #include "canuser.h" #include "key.h" #include "scm_canmatrix-binutil.h" #include "FanHeat.h" #include "MemoryTask.h" #include "LIN_Master.h" #include "SeatMassage.h" /******************************************************************************* * the defines ******************************************************************************/ #define UDS_RECV_BUF (2056) #define UDS_SEND_BUF (512) /* Indication value with boot loader request from asw */ #define ASW_BOOT_REQ_ACTIVE (0x55AAAA55ul) uint8_t udsSendBuf[UDS_SEND_BUF] = {0}; uint8_t udsRecvBuf[UDS_RECV_BUF] = {0}; extern McuType mcu; UdsType udsObj; int64_t Get_Cur_Time_Stamp(void); Uds_ParamsType udsParam = { .isotpParams.framePadding = true, .isotpParams.blockSize = 0, .isotpParams.recvPhysId = UDS_PHYS_RECV_MSG_ID, .isotpParams.recvFuncId = UDS_FUNC_RECV_MSG_ID, .isotpParams.sendid = UDS_PHYS_RESP_MSG_ID, .isotpParams.sendBuf = udsSendBuf, .isotpParams.sendBufSize = UDS_SEND_BUF, .isotpParams.recvBuf = udsRecvBuf, .isotpParams.recvBufSize = UDS_RECV_BUF, .isotpParams.debug = NULL, .isotpParams.sendCanMsg = FlexCanBoot_TxMessage, .isotpParams.getTimeMs = Get_Cur_Time_Stamp, .p2Server_ms = 50, .p2xServer_10ms = 500, .s3Server_ms = 5000, }; int64_t timer_1ms = 0; volatile uint32_t gSystick1msEvent = 0, gSystick1msCnt = 0, gTestRunCnt = 0, gTestIoEn = 0, gSysTick1sCnt = 0; #pragma location = ".bss.no_init" static uint32_t sAswBoot_Req; // int64_t Get_Cur_Time_Stamp(void) { return timer_1ms; } void Asw_SetBootloaderRequest(void) { sAswBoot_Req = ASW_BOOT_REQ_ACTIVE; } void SysTick_Handler(void) { gSystick1msEvent++; timer_1ms++; Uds_Tick(&udsObj); Lin_TimeoutService(); } void PowerOnTask(void) { static uint16_t powerOnCnt=0; static uint8_t flagSBCInitClr=0; if (powerOnCnt <= 20) { powerOnCnt++; } if (powerOnCnt > 20 && flagSBCInitClr ==0) { flagSBCInitClr = 1; SBC_Write_Reg(SBC_SYS_STATUS_CTRL_0, 0, NULL); } } void appTask(void) { if(gSystick1msEvent > 0u) { if(udsObj.session == UDS_SESSION_PROGRAMMING) { Asw_SetBootloaderRequest(); ResetDrv_SoftwareResetModule(&mcu.resetDrv, RESETDRV_SWRESET_SYS); } gSystick1msEvent--; gSystick1msCnt++; gSysTick1sCnt++; MsgTask(&udsObj); CurrentDetect(); HallDetecte(); if (gSystick1msCnt % 5 == 0) { KeyScanTask(); KeyProTask(); MemoryMainTask(); } if (gSystick1msCnt % 10 == 0) { LIN_Master_task(); MotorCtrl_Maintask(); FanHeatMainTaks(); } if (gSystick1msCnt % 50 == 0) { SBC_WD_Trigger(); WdgDrv_Refresh(&mcu.wdgDrv); PowerOnTask(); SeatMassage_task(); } if(gSystick1msCnt % 1000 == 0) { //TrgMuxDrv_GenSWTrigger(&obj->trgMuxDrv, 1); //adcResult[0] = AdcDrv_GetRn(&obj->adc0Drv, 0); //AdcDrv_SwTrg(&obj->adc0Drv); } if (gSystick1msCnt >= 10000) { gSystick1msCnt = 0; SEGGER_RTT_printf(0,"app running\n"); } } } void appTaskInit(void) { /* UDS init */ Uds_UserInit(&udsObj, &udsParam); MotorCtrl_Init(); power_ctrl(1); FanHeatInit(); MemoryTaskInit(); SeatMassage_Init(); }