запустилось... но симуляцию периферии надо переделывать, работает непойми как

This commit is contained in:
Razvalyaev 2025-06-15 02:42:02 +03:00
parent 0f3ac734bf
commit e7e0884c09
12 changed files with 28 additions and 13 deletions

View File

@ -28,9 +28,12 @@ extern "C" {
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "stm32f1xx.h" #include "stm32f1xx.h"
#include "stm32_defs.h"
#include "Legacy/stm32_hal_legacy.h" #include "Legacy/stm32_hal_legacy.h"
#include <stddef.h> #include <stddef.h>
//#include "mcu_wrapper_conf.h" #include "stm32f1xx_matlab_rcc.h"
#include "stm32f1xx_matlab_gpio.h"
#include "stm32f1xx_matlab_tim.h"
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/

View File

@ -2,7 +2,8 @@
#define _MATLAB_GPIO_H_ #define _MATLAB_GPIO_H_
#include "simstruc.h" #include "simstruc.h"
#include "mcu_wrapper_conf.h" #include "stm32f1xx_matlab_conf.h"
//#include "mcu_wrapper_conf.h"
/* äåôàéíû äëÿ ïðîâåðêè êîíôèãóðàöèè GPIO) */ /* äåôàéíû äëÿ ïðîâåðêè êîíôèãóðàöèè GPIO) */
#define GET_GPIO_CONF(_reg_, _pos_) ((_pos_ < 8)? \ #define GET_GPIO_CONF(_reg_, _pos_) ((_pos_ < 8)? \

View File

@ -1,7 +1,7 @@
#ifndef _MATLAB_RCC_H_ #ifndef _MATLAB_RCC_H_
#define _MATLAB_RCC_H_ #define _MATLAB_RCC_H_
#include "mcu_wrapper_conf.h" #include "stm32f1xx_matlab_conf.h"

View File

@ -6,7 +6,8 @@
#define _MATLAB_TIM_H_ #define _MATLAB_TIM_H_
#include "stm32f1xx_it.h" #include "stm32f1xx_it.h"
#include "mcu_wrapper_conf.h" #include "stm32f1xx_matlab_conf.h"
//#include "mcu_wrapper_conf.h"

View File

@ -86,7 +86,7 @@ void Init_TIM_SIM(void)
{ {
#ifdef USE_TIM1 #ifdef USE_TIM1
tim1s.tx_cnt = TIM1->CNT; 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_GPIOx = GPIOA;
tim1s.Channels.OC1_PIN_SHIFT = 8; tim1s.Channels.OC1_PIN_SHIFT = 8;
@ -99,7 +99,7 @@ void Init_TIM_SIM(void)
#endif #endif
#ifdef USE_TIM2 #ifdef USE_TIM2
tim2s.tx_cnt = TIM2->CNT; 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_GPIOx = GPIOA;
tim2s.Channels.OC1_PIN_SHIFT = 5; tim2s.Channels.OC1_PIN_SHIFT = 5;
@ -112,7 +112,7 @@ void Init_TIM_SIM(void)
#endif #endif
#ifdef USE_TIM3 #ifdef USE_TIM3
tim3s.tx_cnt = TIM3->CNT; 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_GPIOx = GPIOB;
tim3s.Channels.OC1_PIN_SHIFT = 4; tim3s.Channels.OC1_PIN_SHIFT = 4;
@ -125,7 +125,7 @@ void Init_TIM_SIM(void)
#endif #endif
#ifdef USE_TIM4 #ifdef USE_TIM4
tim4s.tx_cnt = TIM4->CNT; 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_GPIOx = GPIOD;
tim4s.Channels.OC1_PIN_SHIFT = 12; tim4s.Channels.OC1_PIN_SHIFT = 12;
@ -138,7 +138,7 @@ void Init_TIM_SIM(void)
#endif #endif
#ifdef USE_TIM5 #ifdef USE_TIM5
tim5s.tx_cnt = TIM5->CNT; 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_GPIOx = GPIOA;
tim5s.Channels.OC1_PIN_SHIFT = 0; tim5s.Channels.OC1_PIN_SHIFT = 0;
@ -151,7 +151,7 @@ void Init_TIM_SIM(void)
#endif #endif
#ifdef USE_TIMx #ifdef USE_TIMx
tim6s.tx_cnt = TIMx->CNT; 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_GPIOx = GPIOA;
tim6s.Channels.OC1_PIN_SHIFT = 0; tim6s.Channels.OC1_PIN_SHIFT = 0;

View File

@ -7,7 +7,6 @@
#define _MATLAB_SETUP_H_ #define _MATLAB_SETUP_H_
#include "stm32_defs.h" #include "stm32_defs.h"
#include "stm32f1xx_hal.h" #include "stm32f1xx_hal.h"
#include "mcu_wrapper_conf.h"
// DEFINES (UNCOMMENT WHAT YOU WILL SIMULATE) // DEFINES (UNCOMMENT WHAT YOU WILL SIMULATE)
// TIMS // TIMS

View File

@ -70,7 +70,7 @@ set includes_PERIPH=-I".\MCU_STM32F1xx_Matlab"^
:: ---------------------SET PARAMS FOR MEX COMPILING----------------------- :: ---------------------SET PARAMS FOR MEX COMPILING-----------------------
:: -------------ALL------------ :: -------------ALL------------
set includes= %includes_WRAPPER% %includes_PERIPH% %includes_USER% 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% set defines= %defines_WRAPPER% %defines_CONFIG% %defines_USER%
:: -------OUTPUT FOLDER-------- :: -------OUTPUT FOLDER--------
set output= -outdir "." -output %filename% set output= -outdir "." -output %filename%

View File

@ -10,6 +10,7 @@
// INCLUDES START // INCLUDES START
// Инклюды для доступа к коду МК в коде оболочке // Инклюды для доступа к коду МК в коде оболочке
//#include "stm32f1xx_matlab_conf.h"
#include "upp.h" #include "upp.h"
#include "main.h" #include "main.h"
// INCLUDES END // INCLUDES END

View File

@ -99,11 +99,19 @@ void app_writeOutputBuffer(real_T* Buffer) {
{ {
WriteOutputArray(1, 0, i); WriteOutputArray(1, 0, i);
} }
else
{
WriteOutputArray(0, 0, i);
}
if (GPIOB->ODR & (1 << i)) if (GPIOB->ODR & (1 << i))
{ {
WriteOutputArray(1, 1, i); WriteOutputArray(1, 1, i);
} }
else
{
WriteOutputArray(0, 1, i);
}
} }
int var = phase_A.ctrl.angle.delay_us; int var = phase_A.ctrl.angle.delay_us;

View File

@ -13,7 +13,9 @@ void app_step(void)
// //
// Вызов разных функций на шаге симуляции в случае, // Вызов разных функций на шаге симуляции в случае,
// если не используется отдельный поток для main(). // если не используется отдельный поток для main().
//upp_main(); uwTick = hmcu.SystemClock / (MCU_CORE_CLOCK / 1000);
upp_main();
// USER APP STEP END // USER APP STEP END
} }

Binary file not shown.

BIN
mcu_test_r2023.slx.autosave Normal file

Binary file not shown.