/*================================================================================================== * Project : RTD AUTOSAR 4.4 * Platform : CORTEXM * Peripheral : S32K3XX * Dependencies : none * * Autosar Version : 4.4.0 * Autosar Revision : ASR_REL_4_4_REV_0000 * Autosar Conf.Variant : * SW Version : 1.0.0 * Build Version : S32K3_RTD_1_0_0_D2110_ASR_REL_4_4_REV_0000_20211007 * * (c) Copyright 2020 - 2021 NXP Semiconductors * All Rights Reserved. * * NXP Confidential. This software is owned or controlled by NXP and may only be * used strictly in accordance with the applicable license terms. By expressly * accepting such terms or by downloading, installing, activating and/or otherwise * using the software, you are agreeing that you have read, and that you agree to * comply with and are bound by, such license terms. If you do not agree to be * bound by the applicable license terms, then you may not retain, install, * activate or otherwise use the software. ==================================================================================================*/ /** * @file main.c * 主函数入口 * @addtogroup main_module main module documentation * @{ */ /* Including necessary configuration files. */ #include "Mcal.h" #include "CAN.h" #include "SchM_Can.h" #include "Mcu.h" #include "Mcl.h" #include "Port.h" #include "Dio.h" #include "Uart.h" #include "Eep.h" #include "Fls.h" #include "SchM_Fls.h" #include "Platform.h" #include "Lpuart_Uart_Ip_Irq.h" #include "Flexio_Uart_Ip_Irq.h" #include "Dma_Ip.h" #include "Dma_Ip_Irq.h" #include "Lpuart_Uart_Ip.h" #include "Gpt.h" #include "Wdg_43_Instance0.h" #include "Icu.h" /* User includes */ #include #include "hal_adapter.h" #include "Lpuart_Uart_Ip.h" #include "AppTaskMain.h" #include "AppTaskUart0.h" #include "AppTaskUart1.h" #include "AppTaskCan.h" #include "AppTaskGps.h" #include "Hal_Fls.h" #include "SEGGER_SYSVIEW.h" #include "cm_backtrace.h" #define APPNAME "S32K146_4G" #define HARDWARE_VERSION "V1.0.0" #define SOFTWARE_VERSION "V0.0.1" int main(void) { volatile int exit_code = 0; coreInit(); /* Initialize all pins*/ #if (PORT_PRECOMPILE_SUPPORT == STD_ON) Port_Init(NULL_PTR); #elif (PORT_PRECOMPILE_SUPPORT == STD_OFF) Port_Init(&Port_Config_VS_0); #endif SystemModulesInit(); //4G module power on Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON); Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON); //GPS module power on Dio_WriteChannel(DioConf_DioChannel_PTD1_GPIO_OUT_MCU_GPS_POW_EN, STD_ON); // // this function should be called in ADC Task at once // Adc_CalibrationStatusType CalibStatus; // Adc_Calibrate(AdcHwUnit_0, &CalibStatus); // if (CalibStatus.Adc_UnitSelfTestStatus == E_NOT_OK) // { // // if so, the adc is failed to Calibrate; // } // ADC_ReadValue(); // Boot_CheckDownlaodAPPStatus(); // Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_OFF); Mcu_ResetType bootreason; bootreason = Mcu_GetResetReason(); if(bootreason == MCU_STOP_ACKNOWLEDGE_ERROR_RESET) Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); else if(bootreason == MCU_MDM_AP_SYSTEM_RESET) Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); else if(bootreason == MCU_SW_RESET) { Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); } else if(bootreason == MCU_CORE_LOCKUP_RESET) Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); else if(bootreason == MCU_JTAG_RESET) { Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); } else if(bootreason == MCU_POWER_ON_RESET) { // Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); } else if(bootreason == MCU_EXTERNAL_PIN_RESET) { Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); } else if(bootreason == MCU_WATCHDOG_RESET) { // Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } else if(bootreason == MCU_CMU_LOSS_OF_CLOCK_RESET) { Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } else if(bootreason == MCU_LOSS_OF_LOCK_RESET) { // Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } else if(bootreason == MCU_LOSS_OF_CLOCK_RESET) { Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } else if(bootreason == MCU_LOW_OR_HIGH_VOLTAGE_DETECT_RESET) { // Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } else if(bootreason == MCU_NO_RESET_REASON) { Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); // Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } else if(bootreason == MCU_MULTIPLE_RESET_REASON) { // Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } else if(bootreason == MCU_RESET_UNDEFINED) { Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF); Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF); } #ifdef SEGGER_SYSTEMVIEW SEGGER_SYSVIEW_Conf(); #endif #ifdef SEGGER_RTT_PRINTF SEGGER_RTT_Init(); cm_backtrace_init(APPNAME,HARDWARE_VERSION,SOFTWARE_VERSION); SEGGER_RTT_printf("[%d] boot\r\n",__LINE__); #endif UartInit(); xTaskCreate(MainTask, (const char *const)"MainTask", 512, (void *)0, main_TASK_PRIORITY + 6, NULL); // xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 512, (void *)0, main_TASK_PRIORITY + 2, NULL); xTaskCreate(CanTask, (const char *const)"CanTask", 512, (void *)0, main_TASK_PRIORITY + 2, &CanTask_Handle); xTaskCreate(GpsTask, (const char *const)"GpsTask", 512, (void *)0, main_TASK_PRIORITY + 1, &GpsTask_Handle); xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 2048, (void *)0, main_TASK_PRIORITY + 0, &Uart_4G_Task_Handle); vTaskStartScheduler(); for (;;) { if (exit_code != 0) { break; } } return exit_code; } /** @} */