@echo off

set defines=-D"ML" -D"__IQMATHLIB_H_INCLUDED__" -D"_MATLAB_SIMULATOR"^
 -D"_MATLAB_FAST_SIMULATOR" -D"PROJECT_SHIP=1"
 
:: -------------------------USERS PATHS AND CODE---------------------------
set includes_USER=-I".\Inu\main_matlab\device_support\include"^
 -I".\"^
 -I".\Inu"^
 -I".\Inu\tms_matlab\"^
 -I".\Inu\main_matlab"^
 -I".\Inu\Src\main"^
 -I".\Inu\Src\N12_VectorControl"^
 -I".\Inu\Src\N12_Libs"^
 -I".\Inu\Src\N12_Xilinx"

:: исходный код
set params_main_c=^
 .\Inu\Src\main\adc_tools.c^
 .\Inu\Src\main\v_pwm24_v2.c^
 .\Inu\Src\main\limit_power.c^
 .\Inu\Src\main\limit_lib.c^
 .\Inu\Src\main\pll_tools.c^
 .\Inu\Src\main\calc_rms_vals.c^
 .\Inu\Src\main\alg_simple_scalar.c^
 .\Inu\Src\main\control_station_project.c^
 .\Inu\Src\main\ramp_zadanie_tools.c
 
set params_vectorcontorl_c=.\Inu\Src\N12_VectorControl\vector_control.c^
 .\Inu\Src\N12_VectorControl\teta_calc.c^
 .\Inu\Src\N12_VectorControl\regul_power.c^
 .\Inu\Src\N12_VectorControl\regul_turns.c^
 .\Inu\Src\N12_VectorControl\abc_to_dq.c^
 .\Inu\Src\N12_VectorControl\dq_to_alphabeta_cos.c^
 .\Inu\Src\N12_VectorControl\alphabeta_to_dq.c^
 .\Inu\Src\N12_VectorControl\abc_to_alphabeta.c^
 .\Inu\Src\N12_VectorControl\alg_pll.c
 
set params_libs_c=.\Inu\Src\N12_Libs\mathlib.c^
 .\Inu\Src\N12_Libs\pid_reg3.c^
 .\Inu\Src\N12_Libs\rmp_cntl_v1.c^
 .\Inu\Src\N12_Libs\rmp_cntl_v2.c^
 .\Inu\Src\N12_Libs\filter_v1.c^
 .\Inu\Src\N12_Libs\uf_alg_ing.c^
 .\Inu\Src\N12_Libs\svgen_mf.c^
 .\Inu\Src\N12_Libs\svgen_dq_v2.c^
 .\Inu\Src\N12_Libs\control_station.c^
 .\Inu\Src\N12_Libs\global_time.c^
 .\Inu\Src\N12_Xilinx\xp_write_xpwm_time.c
 
 
set params_device_support=.\Inu\main_matlab\device_support\source\C28x_FPU_FastRTS.obj^
 .\Inu\main_matlab\device_support\source\DSP281x_GlobalVariableDefs.c^
 .\Inu\main_matlab\device_support\source\IQmathLib_matlab.c

 
set code_USER=%params_main_c% %params_vectorcontorl_c% %params_libs_c% %params_device_support%

::-------------------------------------------------------------------------


:: -------------------------WRAPPER PATHS AND CODE---------------------------
:: оболочка, которая будет моделировать работу МК в симулинке
set includes_WRAPPER= -I".\Inu"
set code_WRAPPER= .\Inu\MCU.c^
 .\Inu\mcu_wrapper.c^
 .\Inu\main_matlab\pwm_sim.c^
 .\Inu\main_matlab\init28335.c^
 .\Inu\main_matlab\param.c^
 .\Inu\main_matlab\main_matlab.c
::-------------------------------------------------------------------------


:: ---------------------SET PARAMS FOR MEX COMPILING-----------------------
:: --------ALL INCLUDES--------
set includes= %includes_USER% %includes_WRAPPER%
set codes= %code_WRAPPER% %code_USER%
:: -------OUTPUT FOLDER--------
set output= -outdir "." -output wrapper_inu

:: если нужен дебаг, до запускаем run_mex с припиской debug
IF [%1]==[debug] (set debug= -g)
::-------------------------------------------------------------------------


::------START COMPILING-------    
echo mex %output% %defines% %includes% %codes% %debug%
echo Compiling...
mex %output% %defines% %includes% %codes% %debug%
