diff --git a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h index 263b866..16bf6c7 100644 --- a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h +++ b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h @@ -28,9 +28,12 @@ extern "C" { /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx.h" +#include "stm32_defs.h" #include "Legacy/stm32_hal_legacy.h" #include -//#include "mcu_wrapper_conf.h" +#include "stm32f1xx_matlab_rcc.h" +#include "stm32f1xx_matlab_gpio.h" +#include "stm32f1xx_matlab_tim.h" /* Exported types ------------------------------------------------------------*/ diff --git a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_gpio.h b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_gpio.h index e694421..41a48a8 100644 --- a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_gpio.h +++ b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_gpio.h @@ -2,7 +2,8 @@ #define _MATLAB_GPIO_H_ #include "simstruc.h" -#include "mcu_wrapper_conf.h" +#include "stm32f1xx_matlab_conf.h" +//#include "mcu_wrapper_conf.h" /* GPIO) */ #define GET_GPIO_CONF(_reg_, _pos_) ((_pos_ < 8)? \ diff --git a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_rcc.h b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_rcc.h index 8767828..f6bacf5 100644 --- a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_rcc.h +++ b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_rcc.h @@ -1,7 +1,7 @@ #ifndef _MATLAB_RCC_H_ #define _MATLAB_RCC_H_ -#include "mcu_wrapper_conf.h" +#include "stm32f1xx_matlab_conf.h" diff --git a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_tim.h b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_tim.h index 889491e..91a5f48 100644 --- a/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_tim.h +++ b/MCU_STM32F1xx_Matlab/Drivers/STM32F1xx_SIMULINK/stm32f1xx_matlab_tim.h @@ -6,7 +6,8 @@ #define _MATLAB_TIM_H_ #include "stm32f1xx_it.h" -#include "mcu_wrapper_conf.h" +#include "stm32f1xx_matlab_conf.h" +//#include "mcu_wrapper_conf.h" diff --git a/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.c b/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.c index ea1927b..c204d2d 100644 --- a/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.c +++ b/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.c @@ -86,7 +86,7 @@ void Init_TIM_SIM(void) { #ifdef USE_TIM1 tim1s.tx_cnt = TIM1->CNT; - tim1s.tx_step = hmcu.SIM_Sample_Time * ABP2_TIMS_Value; + tim1s.tx_step = hmcu.sSimSampleTime * ABP2_TIMS_Value; tim1s.Channels.OC1_GPIOx = GPIOA; tim1s.Channels.OC1_PIN_SHIFT = 8; @@ -99,7 +99,7 @@ void Init_TIM_SIM(void) #endif #ifdef USE_TIM2 tim2s.tx_cnt = TIM2->CNT; - tim2s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value; + tim2s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value; tim2s.Channels.OC1_GPIOx = GPIOA; tim2s.Channels.OC1_PIN_SHIFT = 5; @@ -112,7 +112,7 @@ void Init_TIM_SIM(void) #endif #ifdef USE_TIM3 tim3s.tx_cnt = TIM3->CNT; - tim3s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value; + tim3s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value; tim3s.Channels.OC1_GPIOx = GPIOB; tim3s.Channels.OC1_PIN_SHIFT = 4; @@ -125,7 +125,7 @@ void Init_TIM_SIM(void) #endif #ifdef USE_TIM4 tim4s.tx_cnt = TIM4->CNT; - tim4s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value; + tim4s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value; tim4s.Channels.OC1_GPIOx = GPIOD; tim4s.Channels.OC1_PIN_SHIFT = 12; @@ -138,7 +138,7 @@ void Init_TIM_SIM(void) #endif #ifdef USE_TIM5 tim5s.tx_cnt = TIM5->CNT; - tim5s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value; + tim5s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value; tim5s.Channels.OC1_GPIOx = GPIOA; tim5s.Channels.OC1_PIN_SHIFT = 0; @@ -151,7 +151,7 @@ void Init_TIM_SIM(void) #endif #ifdef USE_TIMx tim6s.tx_cnt = TIMx->CNT; - tim6s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value; + tim6s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value; tim6s.Channels.OC1_GPIOx = GPIOA; tim6s.Channels.OC1_PIN_SHIFT = 0; diff --git a/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.h b/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.h index 43717cb..16c20dd 100644 --- a/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.h +++ b/MCU_STM32F1xx_Matlab/stm32f1xx_matlab_conf.h @@ -7,7 +7,6 @@ #define _MATLAB_SETUP_H_ #include "stm32_defs.h" #include "stm32f1xx_hal.h" -#include "mcu_wrapper_conf.h" // DEFINES (UNCOMMENT WHAT YOU WILL SIMULATE) // TIMS diff --git a/MCU_Wrapper/run_mex.bat b/MCU_Wrapper/run_mex.bat index e59442c..fab74e4 100644 --- a/MCU_Wrapper/run_mex.bat +++ b/MCU_Wrapper/run_mex.bat @@ -70,7 +70,7 @@ set includes_PERIPH=-I".\MCU_STM32F1xx_Matlab"^ :: ---------------------SET PARAMS FOR MEX COMPILING----------------------- :: -------------ALL------------ set includes= %includes_WRAPPER% %includes_PERIPH% %includes_USER% -set codes= %code_WRAPPER% %code_USER% %code_PERIPH% +set codes= %code_WRAPPER% %code_PERIPH% %code_USER% set defines= %defines_WRAPPER% %defines_CONFIG% %defines_USER% :: -------OUTPUT FOLDER-------- set output= -outdir "." -output %filename% diff --git a/app_wrapper/app_includes.h b/app_wrapper/app_includes.h index d58ef24..7815e34 100644 --- a/app_wrapper/app_includes.h +++ b/app_wrapper/app_includes.h @@ -10,6 +10,7 @@ // INCLUDES START // Инклюды для доступа к коду МК в коде оболочке +//#include "stm32f1xx_matlab_conf.h" #include "upp.h" #include "main.h" // INCLUDES END diff --git a/app_wrapper/app_io.c b/app_wrapper/app_io.c index d500615..7eb699f 100644 --- a/app_wrapper/app_io.c +++ b/app_wrapper/app_io.c @@ -99,11 +99,19 @@ void app_writeOutputBuffer(real_T* Buffer) { { WriteOutputArray(1, 0, i); } + else + { + WriteOutputArray(0, 0, i); + } if (GPIOB->ODR & (1 << i)) { WriteOutputArray(1, 1, i); } + else + { + WriteOutputArray(0, 1, i); + } } int var = phase_A.ctrl.angle.delay_us; diff --git a/app_wrapper/app_wrapper.c b/app_wrapper/app_wrapper.c index b682334..34b816b 100644 --- a/app_wrapper/app_wrapper.c +++ b/app_wrapper/app_wrapper.c @@ -13,7 +13,9 @@ void app_step(void) // // Вызов разных функций на шаге симуляции в случае, // если не используется отдельный поток для main(). -//upp_main(); +uwTick = hmcu.SystemClock / (MCU_CORE_CLOCK / 1000); + +upp_main(); // USER APP STEP END } diff --git a/mcu_test_r2023.slx b/mcu_test_r2023.slx index 16c4220..aa1202a 100644 Binary files a/mcu_test_r2023.slx and b/mcu_test_r2023.slx differ diff --git a/mcu_test_r2023.slx.autosave b/mcu_test_r2023.slx.autosave new file mode 100644 index 0000000..53476d2 Binary files /dev/null and b/mcu_test_r2023.slx.autosave differ