#include "mcu_wrapper_conf.h" #ifndef PWM_SIM #define PWM_SIM #define ENABLE_UNITED_COUNTER_FOR_ALL_PWM #define PWM_SIMULATION_MODE_TK_LINES //#define PWM_SIMULATION_MODE_REGULAR_PWM #define PWM_PERIOD (FREQ_INTERNAL_GENERATOR_XILINX_TMS / FREQ_PWM) #define PWM_TICK_STEP (FREQ_INTERNAL_GENERATOR_XILINX_TMS * hmcu.sSimSampleTime) // Для моделирования ШИМ /** * @brief 3lvl PWM One Phase Simulation handle */ typedef struct { int ci1A; int ci1B; int ci2A; int ci2B; }PWMPhaseOutput; /** * @brief DeadTime Simulation Handle */ typedef struct { int DtPeriod; int stateDt; int dtcnt; int pre_ciA; int pre_ciB; }DeadTimeSimHandle; enum StateDeadTime { stateDtWait = 0, stateDtReady }; /** * @brief Tim Simulation Handle */ typedef struct { double TxCntPlus; double TxPeriod; double tcntAux; double tcntAuxPrev; double tcnt; double cmpA; double cmpB; DeadTimeSimHandle deadtime; void (*simulatePwm)(); }TimerSimHandle; /** * @brief PWM Phase Simulation Handle */ typedef struct { PWMPhaseOutput pwmOut; TimerSimHandle* tsim1; TimerSimHandle* tsim2; int tkLineA; int tkLineB; DeadTimeSimHandle deadtime; }PWMPhaseSimHandle; extern TimerSimHandle t1sim; extern TimerSimHandle t2sim; extern TimerSimHandle t3sim; extern TimerSimHandle t4sim; extern TimerSimHandle t5sim; extern TimerSimHandle t6sim; extern TimerSimHandle t7sim; extern TimerSimHandle t8sim; extern TimerSimHandle t9sim; extern TimerSimHandle t10sim; extern TimerSimHandle t11sim; extern TimerSimHandle t12sim; extern PWMPhaseSimHandle PWMPhaseA1; extern PWMPhaseSimHandle PWMPhaseB1; extern PWMPhaseSimHandle PWMPhaseC1; extern PWMPhaseSimHandle PWMPhaseA2; extern PWMPhaseSimHandle PWMPhaseB2; extern PWMPhaseSimHandle PWMPhaseC2; void Simulate_PWM(void); void Init_PWM_Simulation(void); void Simulate_PWMPhase(PWMPhaseSimHandle* tksim, int T1, int T0); void Simulate_MainTIM(TimerSimHandle* tsim, int compare); void Simulate_SimpleTIM(TimerSimHandle* tsim, int compare); int simulateTimAndGetCompare(TimerSimHandle* tsim, int compare); void simulateActionActionQualifierSubmodule(TimerSimHandle* tsim); void simulateDeadBendSubmodule(TimerSimHandle* tsim, int* ciA, int* ciB); void simulateTripZoneSubmodule(TimerSimHandle* tsim); void Init_TIM_Simulation(TimerSimHandle* tsim, int period, double step); void Init_PWMPhase_Simulation(PWMPhaseSimHandle* tksim, TimerSimHandle* tsim1, TimerSimHandle* tsim2, int period, double step); void convertSVGenTimesToTkLines(PWMPhaseSimHandle* tksim); void xilinxPwm3LevelSimulation(PWMPhaseSimHandle* tksim); #if defined(PWM_SIMULATION_MODE_REGULAR_PWM) && defined(PWM_SIMULATION_MODE_TK_LINES) #error Choose only one PWM simulation mode! #endif #endif //PWM_SIM