|
@@ -662,7 +662,7 @@ Std_ReturnType CanIf_SendMessage(uint8 ControllerId, Can_Msg_Type CanMsg)
|
|
|
u8TimeOut--;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else //send message fail, we need to recover the send function by make the can controller bus off
|
|
|
{
|
|
|
Can_MainFunction_BusOff();
|
|
|
}
|
|
@@ -699,7 +699,7 @@ Can_Msg_Type Can_GetMsgInfo(Can_IdType id, uint8 length, uint8 *sdu)
|
|
|
void CanIf_ControllerBusOff(uint8 ControllerId)
|
|
|
{
|
|
|
(void)ControllerId;
|
|
|
- Can_SetControllerMode(ControllerId, CAN_CS_STARTED);
|
|
|
+ Can_SetControllerMode(ControllerId, CAN_CS_STARTED); //if the bus off occured, we need to restart the can controller
|
|
|
}
|
|
|
|
|
|
void CanIf_ControllerModeIndication(uint8 ControllerId, Can_ControllerStateType ControllerMode)
|
|
@@ -1016,6 +1016,14 @@ void MCUSleep(void)
|
|
|
// coreInit();
|
|
|
}
|
|
|
|
|
|
+void LPTMR_WakeUp_Notification(void)
|
|
|
+{
|
|
|
+ Mcu_InitClock(McuClockSettingConfig_0);
|
|
|
+ Mcu_SetMode(McuModeSettingConf_Run);
|
|
|
+ Gpt_StopTimer(GptConf_GptChannelConfiguration_GptChannelConfiguration_LPTMR);
|
|
|
+ Gpt_DisableWakeup(GptConf_GptChannelConfiguration_GptChannelConfiguration_LPTMR);
|
|
|
+ Gpt_DisableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_LPTMR);
|
|
|
+}
|
|
|
|
|
|
void SystemDeinit(void)
|
|
|
{
|
|
@@ -1042,7 +1050,7 @@ void SystemDeinit(void)
|
|
|
|
|
|
Adc_DeInit();
|
|
|
|
|
|
- Gpt_DisableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);
|
|
|
+// Gpt_DisableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);
|
|
|
|
|
|
Gpt_DeInit();
|
|
|
|
|
@@ -1075,13 +1083,20 @@ void MCUEnterSleep(void)
|
|
|
{
|
|
|
if(pdTRUE == xSemaphoreTake(sleep_mutex,1) && Fota_Process_Going == false)
|
|
|
{
|
|
|
- extern boolean Uart_4G_Task_Sleep_FLag;
|
|
|
- WdgDeInit();
|
|
|
- Std_ReturnType Ret = E_NOT_OK;
|
|
|
- uint8 appConfigWriteTimes = 0;
|
|
|
- do
|
|
|
+ // if the IO wakeup exists(high side), the mcu should not go to vlps, either.
|
|
|
+ Dio_LevelType wakeup1,wakeup2 = STD_HIGH;
|
|
|
+ wakeup1 = Dio_ReadChannel(DioConf_DioChannel_PTB0_GPIO_IN_MCU_WAKEUP1);
|
|
|
+ wakeup2 = Dio_ReadChannel(DioConf_DioChannel_PTE2_GPIO_IN_MCU_WAKEUP2);
|
|
|
+
|
|
|
+ if(wakeup1==STD_LOW && wakeup2 == STD_LOW)
|
|
|
{
|
|
|
- waitForSleepFlag = true;
|
|
|
+ extern boolean Uart_4G_Task_Sleep_FLag;
|
|
|
+ WdgDeInit();
|
|
|
+ Std_ReturnType Ret = E_NOT_OK;
|
|
|
+ uint8 appConfigWriteTimes = 0;
|
|
|
+ do
|
|
|
+ {
|
|
|
+ waitForSleepFlag = true;
|
|
|
|
|
|
//save the app configure before power off
|
|
|
if(Ret == E_NOT_OK)
|
|
@@ -1092,20 +1107,19 @@ void MCUEnterSleep(void)
|
|
|
}
|
|
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(10));
|
|
|
- }while(Uart_4G_Task_Sleep_FLag == false || (Ret == E_NOT_OK && appConfigWriteTimes<5) );
|
|
|
+ }while(Uart_4G_Task_Sleep_FLag == false || (Ret == E_NOT_OK && appConfigWriteTimes<5) );
|
|
|
|
|
|
- vTaskDelete(Uart_Hal_RecvTask_Handle);
|
|
|
- vTaskDelete(Uart_Hal_SendTask_Handle);
|
|
|
- vTaskDelete(CanTask_Handle);
|
|
|
- vTaskDelete(GpsTask_Handle);
|
|
|
- vTaskDelete(Uart_4G_Task_Handle);
|
|
|
-// vTaskDelete(MainTask_Handle);
|
|
|
+ vTaskDelete(Uart_Hal_RecvTask_Handle);
|
|
|
+ vTaskDelete(Uart_Hal_SendTask_Handle);
|
|
|
+ vTaskDelete(CanTask_Handle);
|
|
|
+ vTaskDelete(GpsTask_Handle);
|
|
|
+ vTaskDelete(Uart_4G_Task_Handle);
|
|
|
+// vTaskDelete(MainTask_Handle);
|
|
|
|
|
|
- SystemDeinit();
|
|
|
+ SystemDeinit();
|
|
|
|
|
|
- MCUSleep();
|
|
|
-// WdgInit();
|
|
|
-// DoResetECUWithWdg();
|
|
|
+ MCUSleep();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1146,7 +1160,7 @@ void SystemModulesInit(void)
|
|
|
/* Initialize Mcl module */
|
|
|
Mcl_Init(NULL_PTR);
|
|
|
|
|
|
- SEGGER_RTT_Init();
|
|
|
+// SEGGER_RTT_Init();
|
|
|
|
|
|
|
|
|
/* Initializes an UART driver*/
|
|
@@ -1181,6 +1195,13 @@ void SystemModulesInit(void)
|
|
|
Adc_Init(&Adc_Config_VS_0);
|
|
|
#endif /* ADC_PRECOMPILE_SUPPORT == STD_ON */
|
|
|
|
|
|
+ //the calibration is needed to increase the ADC accuracy
|
|
|
+ Adc_CalibrationStatusType CalibStatus;
|
|
|
+ Adc_Calibrate(AdcHwUnit_1, &CalibStatus);
|
|
|
+ if (CalibStatus.Adc_UnitSelfTestStatus == E_NOT_OK)
|
|
|
+ {
|
|
|
+ // if so, the adc is failed to Calibrate;
|
|
|
+ }
|
|
|
/* Partition only if it was not partitioned before for EERAM with code 0x4 */
|
|
|
// Eep_DepartParitition(T_EEEPROM_SIZE);
|
|
|
/* Initialize Eep driver */
|
|
@@ -1206,7 +1227,7 @@ void SystemModulesInit(void)
|
|
|
Gpt_Init(&Gpt_Config_VS_0);
|
|
|
|
|
|
/* Enable the Gpt notification to periodically service the Wdg */
|
|
|
- Gpt_EnableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);
|
|
|
+// Gpt_EnableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);
|
|
|
|
|
|
Icu_DeInit();
|
|
|
|