/**************************************************************************************************/ /** * @file : main.c * @brief : Dio example source file * - Platform: Z20K14xM * - Autosar Version: 4.6.0 * @version : 1.1.0 * @author : Zhixin Semiconductor * * @note : This example contains sample code for customer evaluation purpose only. It is not * part of the production code deliverables. The example code is only tested under defined * environment with related context of the whole example project. Therefore, it is not guaranteed * that the example always works under user environment due to the diversity of hardware and * software environment. Do not use pieces copy of the example code without prior and separate * verification and validation in user environment. * * @copyright : Copyright (c) 2021-2023 Zhixin Semiconductor Ltd. All rights reserved. **************************************************************************************************/ /** @addtogroup Dio_Example * @brief Dio Example * @{ */ #ifdef __cplusplus extern "C" { #endif #include "main.h" //#include "task.h" #include "can_func.h" #define EN_PWM 1 #define EN_CAN 1 #define EN_UART 1 #define CAN_START_SEC_VAR_INIT_BOOLEAN #include "Can_MemMap.h" static boolean Ex_Can_TxFlag = FALSE; static boolean Ex_Can_RxFlagCase2 = FALSE; static boolean Ex_Can_RxFlagCase3 = FALSE; #define CAN_STOP_SEC_VAR_INIT_BOOLEAN #include "Can_MemMap.h" #define CAN_START_SEC_VAR_INIT_8 #include "Can_MemMap.h" #include "SchM_Dio.h" #define HARDWARE_VERSION "V1.0.0" #define SOFTWARE_VERSION "V0.1.0" #ifdef GCC #pragma GCC diagnostic ignored "-Wext" #endif #ifdef __ghs__ #pragma ghs nowarning 14 #endif Std_VersionInfoType Ex_Pwm_VersionInfo; #ifndef __ghs__ void fault_test_by_div0(void) { volatile int * SCB_CCR = (volatile int *) 0xE000ED14; // SCB->CCR int x, y, z; *SCB_CCR |= (1 << 4); /* bit4: DIV_0_TRP. */ x = 10; y = 0; z = x / y; //printf("z:%d\n", z); Ex_Pwm_VersionInfo.moduleID = z; } #endif #include "Wdog_Drv.h" void Startup_Init(void) { } void Watchdog_Disable(void) { } static int bssj ; static int datai = 4; int main(void) { int Delay = 0 ; McalLib_Init(); #if (MCU_PRECOMPILE_SUPPORT == STD_OFF) Mcu_Init(&Mcu_Config); #else Mcu_Init(NULL_PTR); #endif // (MCU_PRECOMPILE_SUPPORT == STD_OFF) Mcu_InitClock(0); #if (MCU_NO_PLL == STD_OFF) while(MCU_PLL_LOCKED != Mcu_GetPllStatus()); Mcu_DistributePllClock(); #endif // MCU_NO_PLL == STD_OFF Mcu_SetMode(0); Platform_Init(NULL_PTR); #if (CAN_PRECOMPILE_SUPPORT == STD_ON) Can_Init(NULL_PTR); #else Can_Init(&Can_Config); #endif /* (CAN_PRECOMPILE_SUPPORT == STD_ON) */ #if (WDG_PRECOMPILE_SUPPORT == STD_OFF) Wdg_Init(&Wdg_Config); #else Wdg_Init(NULL_PTR); #endif // (WDG_PRECOMPILE_SUPPORT == STD_OFF) #if (PORT_PRECOMPILE_SUPPORT == STD_OFF) Port_Init(&Port_Config); #else Port_Init(NULL_PTR); #endif // (PORT_PRECOMPILE_SUPPORT == STD_OFF) #if (GPT_PRECOMPILE_SUPPORT == STD_ON) Gpt_Init(NULL_PTR); #else Gpt_Init(&Gpt_Config); #endif /* (GPT_PRECOMPILE_SUPPORT == STD_ON) */ Gpt_EnableNotification(0); #if (GPT_PRECOMPILE_SUPPORT == STD_ON) Dma_Init(NULL_PTR); #else Dma_Init(&Dma_Config); #endif /* (GPT_PRECOMPILE_SUPPORT == STD_ON) */ Dma_EnableChannelHwRequest(0U, TRUE); #ifdef EN_PWM Pwm_Init(NULL_PTR); Pwm_GetVersionInfo(&Ex_Pwm_VersionInfo); /* Set Channel Dead Time // Pwm_SetChannelDeadTimeTicks(0, 10); // Pwm_SetChannelDeadTimeTicks(6, 5); */ int duty = 31000; /* Pwm_SetPeriodAndDuty(0, 0x2000U,duty); Pwm_SetPeriodAndDuty(1, 0x2000U,duty); Pwm_SetPeriodAndDuty(2, 0x2000U,duty); */ Pwm_SetDutyCycle(0,duty); Pwm_SetDutyCycle(1,duty); Pwm_SetDutyCycle(2,duty); #endif while(1) { #ifdef EN_CAN Ex_Can_UseCase_01(); Ex_Can_UseCase_02(); Ex_Can_UseCase_03(); Ex_Can_UseCase_04(); #endif Wdg_Service(); Delay = 10000; while (Delay--) { MCALLIB_NOP(); } } //InitSysTick(); //TaskProc(); } #ifdef __cplusplus } #endif