симулируется упп на stm32f103
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
@details
|
||||
Данный файл содержит функции S-Function, который вызывает MATLAB.
|
||||
**************************************************************************
|
||||
@note
|
||||
@note
|
||||
Описание функций по большей части сгенерировано MATLAB'ом, поэтому на английском
|
||||
**************************************************************************/
|
||||
|
||||
@@ -25,18 +25,18 @@
|
||||
#include "mcu_wrapper_conf.h"
|
||||
|
||||
#define MDL_UPDATE ///< для подключения mdlUpdate()
|
||||
/**
|
||||
* @brief Update S-Function at every step of simulation
|
||||
* @param S - pointer to S-Function (library struct from "simstruc.h")
|
||||
* @details Abstract:
|
||||
* This function is called once for every major integration time step.
|
||||
* Discrete states are typically updated here, but this function is useful
|
||||
* for performing any tasks that should only take place once per
|
||||
* integration step.
|
||||
*/
|
||||
static void mdlUpdate(SimStruct *S)
|
||||
{
|
||||
// get time of simulation
|
||||
/**
|
||||
* @brief Update S-Function at every step of simulation
|
||||
* @param S - pointer to S-Function (library struct from "simstruc.h")
|
||||
* @details Abstract:
|
||||
* This function is called once for every major integration time step.
|
||||
* Discrete states are typically updated here, but this function is useful
|
||||
* for performing any tasks that should only take place once per
|
||||
* integration step.
|
||||
*/
|
||||
static void mdlUpdate(SimStruct* S, int_T tid)
|
||||
{
|
||||
// get time of simulation
|
||||
time_T TIME = ssGetT(S);
|
||||
|
||||
//---------------SIMULATE MCU---------------
|
||||
@@ -44,46 +44,46 @@ static void mdlUpdate(SimStruct *S)
|
||||
//------------------------------------------
|
||||
}//end mdlUpdate
|
||||
|
||||
/**
|
||||
* @brief Writting outputs of S-Function
|
||||
/**
|
||||
* @brief Writting outputs of S-Function
|
||||
* @param S - pointer to S-Function (library struct from "simstruc.h")
|
||||
* @details Abstract:
|
||||
* In this function, you compute the outputs of your S-function
|
||||
* block. Generally outputs are placed in the output vector(s),
|
||||
* ssGetOutputPortSignal.
|
||||
*/
|
||||
static void mdlOutputs(SimStruct *S)
|
||||
static void mdlOutputs(SimStruct* S, int_T tid)
|
||||
{
|
||||
SIM_writeOutputs(S);
|
||||
}//end mdlOutputs
|
||||
|
||||
#define MDL_CHECK_PARAMETERS /* Change to #undef to remove function */
|
||||
#if defined(MDL_CHECK_PARAMETERS) && defined(MATLAB_MEX_FILE)
|
||||
static void mdlCheckParameters(SimStruct *S)
|
||||
static void mdlCheckParameters(SimStruct* S)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Проверяем и принимаем параметры и разрешаем или запрещаем их менять
|
||||
// в процессе моделирования
|
||||
for (i=0; i<1; i++)
|
||||
for (i = 0; i < 1; i++)
|
||||
{
|
||||
// Input parameter must be scalar or vector of type double
|
||||
if (!mxIsDouble(ssGetSFcnParam(S,i)) || mxIsComplex(ssGetSFcnParam(S,i)) ||
|
||||
mxIsEmpty(ssGetSFcnParam(S,i)))
|
||||
if (!mxIsDouble(ssGetSFcnParam(S, i)) || mxIsComplex(ssGetSFcnParam(S, i)) ||
|
||||
mxIsEmpty(ssGetSFcnParam(S, i)))
|
||||
{
|
||||
ssSetErrorStatus(S,"Input parameter must be of type double");
|
||||
ssSetErrorStatus(S, "Input parameter must be of type double");
|
||||
return;
|
||||
}
|
||||
// Параметр м.б. только скаляром, вектором или матрицей
|
||||
if (mxGetNumberOfDimensions(ssGetSFcnParam(S,i)) > 2)
|
||||
if (mxGetNumberOfDimensions(ssGetSFcnParam(S, i)) > 2)
|
||||
{
|
||||
ssSetErrorStatus(S,"Параметр м.б. только скаляром, вектором или матрицей");
|
||||
ssSetErrorStatus(S, "Параметр м.б. только скаляром, вектором или матрицей");
|
||||
return;
|
||||
}
|
||||
// sim_dt = mxGetPr(ssGetSFcnParam(S,0))[0];
|
||||
// Parameter not tunable
|
||||
// ssSetSFcnParamTunable(S, i, SS_PRM_NOT_TUNABLE);
|
||||
// Parameter tunable (we must create a corresponding run-time parameter)
|
||||
// sim_dt = mxGetPr(ssGetSFcnParam(S,0))[0];
|
||||
// Parameter not tunable
|
||||
// ssSetSFcnParamTunable(S, i, SS_PRM_NOT_TUNABLE);
|
||||
// Parameter tunable (we must create a corresponding run-time parameter)
|
||||
ssSetSFcnParamTunable(S, i, SS_PRM_TUNABLE);
|
||||
// Parameter tunable only during simulation
|
||||
// ssSetSFcnParamTunable(S, i, SS_PRM_SIM_ONLY_TUNABLE);
|
||||
@@ -92,57 +92,57 @@ static void mdlCheckParameters(SimStruct *S)
|
||||
|
||||
}//end mdlCheckParameters
|
||||
#endif //MDL_CHECK_PARAMETERS
|
||||
static void mdlInitializeSizes(SimStruct *S)
|
||||
{
|
||||
ssSetNumSFcnParams(S, 1);
|
||||
// Кол-во ожидаемых и фактических параметров должно совпадать
|
||||
if(ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S))
|
||||
{
|
||||
// Проверяем и принимаем параметры
|
||||
mdlCheckParameters(S);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;// Parameter mismatch will be reported by Simulink
|
||||
}
|
||||
static void mdlInitializeSizes(SimStruct* S)
|
||||
{
|
||||
ssSetNumSFcnParams(S, 1);
|
||||
// Кол-во ожидаемых и фактических параметров должно совпадать
|
||||
if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S))
|
||||
{
|
||||
// Проверяем и принимаем параметры
|
||||
mdlCheckParameters(S);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;// Parameter mismatch will be reported by Simulink
|
||||
}
|
||||
|
||||
// set up discrete states
|
||||
ssSetNumContStates(S, 0); // number of continuous states
|
||||
ssSetNumDiscStates(S, DISC_STATES_WIDTH); // number of discrete states
|
||||
|
||||
// set up input port
|
||||
if (!ssSetNumInputPorts(S, 1)) return;
|
||||
if (!ssSetNumInputPorts(S, 1)) return;
|
||||
for (int i = 0; i < IN_PORT_NUMB; i++)
|
||||
ssSetInputPortWidth(S, i, IN_PORT_WIDTH);
|
||||
ssSetInputPortDirectFeedThrough(S, 0, 0);
|
||||
ssSetInputPortRequiredContiguous(S, 0, 1); // direct input signal access
|
||||
ssSetInputPortDirectFeedThrough(S, 0, 0);
|
||||
ssSetInputPortRequiredContiguous(S, 0, 1); // direct input signal access
|
||||
|
||||
// set up output port
|
||||
if (!ssSetNumOutputPorts(S, OUT_PORT_NUMB)) return;
|
||||
if (!ssSetNumOutputPorts(S, OUT_PORT_NUMB)) return;
|
||||
for (int i = 0; i < OUT_PORT_NUMB; i++)
|
||||
ssSetOutputPortWidth(S, i, OUT_PORT_WIDTH);
|
||||
|
||||
|
||||
ssSetNumSampleTimes(S, 1);
|
||||
ssSetNumSampleTimes(S, 1);
|
||||
|
||||
|
||||
ssSetNumRWork( S, 5); // number of real work vector elements
|
||||
ssSetNumIWork( S, 5); // number of integer work vector elements
|
||||
ssSetNumPWork( S, 0); // number of pointer work vector elements
|
||||
ssSetNumModes( S, 0); // number of mode work vector elements
|
||||
ssSetNumNonsampledZCs( S, 0); // number of nonsampled zero crossings
|
||||
ssSetNumRWork(S, 5); // number of real work vector elements
|
||||
ssSetNumIWork(S, 5); // number of integer work vector elements
|
||||
ssSetNumPWork(S, 0); // number of pointer work vector elements
|
||||
ssSetNumModes(S, 0); // number of mode work vector elements
|
||||
ssSetNumNonsampledZCs(S, 0); // number of nonsampled zero crossings
|
||||
|
||||
|
||||
ssSetRuntimeThreadSafetyCompliance(S, RUNTIME_THREAD_SAFETY_COMPLIANCE_TRUE);
|
||||
/* Take care when specifying exception free code - see sfuntmpl.doc */
|
||||
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
|
||||
/* Take care when specifying exception free code - see sfuntmpl.doc */
|
||||
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#define MDL_START /* Change to #undef to remove function */
|
||||
#if defined(MDL_START)
|
||||
/**
|
||||
/**
|
||||
* @brief Initialize S-Function at start of simulation
|
||||
* @param S - pointer to S-Function (library struct from "simstruc.h")
|
||||
* @details Abstract:
|
||||
@@ -150,13 +150,13 @@ static void mdlInitializeSizes(SimStruct *S)
|
||||
* have states that should be initialized once, this is the place
|
||||
* to do it.
|
||||
*/
|
||||
static void mdlStart(SimStruct *S)
|
||||
static void mdlStart(SimStruct* S)
|
||||
{
|
||||
SIM_Initialize_Simulation();
|
||||
SIM_Initialize_Simulation();
|
||||
}
|
||||
#endif // MDL_START
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Initialize Sample Time of Simulation
|
||||
* @param S - pointer to S-Function (library struct from "simstruc.h")
|
||||
* @details Abstract:
|
||||
@@ -164,17 +164,17 @@ static void mdlStart(SimStruct *S)
|
||||
* S-function. You must register the same number of sample times as
|
||||
* specified in ssSetNumSampleTimes.
|
||||
*/
|
||||
static void mdlInitializeSampleTimes(SimStruct *S)
|
||||
{
|
||||
static void mdlInitializeSampleTimes(SimStruct* S)
|
||||
{
|
||||
// Шаг дискретизации
|
||||
hmcu.SIM_Sample_Time = mxGetPr(ssGetSFcnParam(S,NPARAMS-1))[0];
|
||||
hmcu.SIM_Sample_Time = mxGetPr(ssGetSFcnParam(S, NPARAMS - 1))[0];
|
||||
|
||||
// Register one pair for each sample time
|
||||
ssSetSampleTime(S, 0, hmcu.SIM_Sample_Time);
|
||||
ssSetOffsetTime(S, 0, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Terminate S-Function at the end of simulation
|
||||
* @param S - pointer to S-Function (library struct from "simstruc.h")
|
||||
* @details Abstract:
|
||||
@@ -182,7 +182,7 @@ static void mdlInitializeSampleTimes(SimStruct *S)
|
||||
* at the termination of a simulation. For example, if memory was
|
||||
* allocated in mdlStart, this is the place to free it.
|
||||
*/
|
||||
static void mdlTerminate(SimStruct *S)
|
||||
static void mdlTerminate(SimStruct* S)
|
||||
{
|
||||
hmcu.fMCU_Stop = 1;
|
||||
ResumeThread(hmcu.hMCUThread);
|
||||
@@ -197,9 +197,9 @@ static void mdlTerminate(SimStruct *S)
|
||||
*/
|
||||
|
||||
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a
|
||||
MEX-file? */
|
||||
MEX-file? */
|
||||
#include "simulink.c" /* MEX-file interface mechanism */
|
||||
#else
|
||||
#include "cg_sfun.h" /* Code generation registration
|
||||
function */
|
||||
function */
|
||||
#endif
|
||||
|
||||
@@ -18,9 +18,10 @@ SIM__MCUHandleTypeDef hmcu; ///< Хендл для управления
|
||||
/** MCU_WRAPPER
|
||||
* @}
|
||||
*/
|
||||
//-------------------------------------------------------------//
|
||||
//-----------------CONTROLLER SIMULATE FUNCTIONS---------------//
|
||||
/* THREAD FOR MCU APP */
|
||||
//-------------------------------------------------------------//
|
||||
//-----------------CONTROLLER SIMULATE FUNCTIONS---------------//
|
||||
/* THREAD FOR MCU APP */
|
||||
#ifdef RUN_APP_MAIN_FUNC_THREAD
|
||||
/**
|
||||
* @brief Главная функция приложения МК.
|
||||
* @details Функция с которой начинается выполнение кода МК. Выход из данной функции происходит только в конце симуляции @ref mdlTerminate
|
||||
@@ -35,6 +36,7 @@ unsigned __stdcall MCU_App_Thread(void) {
|
||||
return 0; // end thread
|
||||
// note: this return will reached only at the end of simulation, when all whiles will be skipped due to @ref sim_while
|
||||
}
|
||||
#endif //RUN_APP_MAIN_FUNC_THREAD
|
||||
/* SIMULATE MCU FOR ONE SIMULATION STEP */
|
||||
/**
|
||||
* @brief Симуляция МК на один такт симуляции.
|
||||
@@ -43,7 +45,7 @@ unsigned __stdcall MCU_App_Thread(void) {
|
||||
* @details Запускает поток, который выполняет код МК и управляет ходом потока:
|
||||
* Если прошел таймаут, поток прерывается, симулируется периферия
|
||||
* и на следующем шаге поток возобнавляется.
|
||||
*
|
||||
*
|
||||
* Вызывается из mdlUpdate()
|
||||
*/
|
||||
void MCU_Step_Simulation(SimStruct* S, time_T time)
|
||||
@@ -56,11 +58,15 @@ void MCU_Step_Simulation(SimStruct* S, time_T time)
|
||||
|
||||
MCU_Periph_Simulation(); // simulate peripheral
|
||||
|
||||
extern void upp_main(void);
|
||||
upp_main();
|
||||
#ifdef RUN_APP_MAIN_FUNC_THREAD
|
||||
ResumeThread(hmcu.hMCUThread);
|
||||
for (int i = DEKSTOP_CYCLES_FOR_MCU_APP; i > 0; i--)
|
||||
{
|
||||
}
|
||||
SuspendThread(hmcu.hMCUThread);
|
||||
#endif //RUN_APP_MAIN_FUNC_THREAD
|
||||
|
||||
MCU_writeOutputs(S); // запись портов (по факту запись в буфер. запись в порты в mdlOutputs)
|
||||
}
|
||||
@@ -74,7 +80,7 @@ void MCU_Periph_Simulation(void)
|
||||
{
|
||||
uwTick = hmcu.SystemClock / (MCU_CORE_CLOCK / 1000);
|
||||
|
||||
Simulate_TIMs();
|
||||
Simulate_TIMs();
|
||||
}
|
||||
|
||||
/* READ INPUTS S-FUNCTION TO MCU REGS */
|
||||
@@ -88,7 +94,7 @@ void MCU_readInputs(SimStruct* S)
|
||||
/* Get S-Function inputs */
|
||||
real_T* IN = ssGetInputPortRealSignal(S, 0);
|
||||
|
||||
SFUNC_to_GPIO(IN);
|
||||
ReadToSFunc(IN);
|
||||
}
|
||||
|
||||
/* WRITE OUTPUTS BUFFER S-FUNCTION FROM MCU REGS*/
|
||||
@@ -102,7 +108,8 @@ void MCU_writeOutputs(SimStruct* S)
|
||||
/* Get S-Function descrete array */
|
||||
real_T* Out_Buff = ssGetDiscStates(S);
|
||||
|
||||
GPIO_to_SFUNC(Out_Buff);
|
||||
//Simulate_GPIO_BSRR();
|
||||
WriteFromSFunc(Out_Buff);
|
||||
}
|
||||
//-----------------CONTROLLER SIMULATE FUNCTIONS---------------//
|
||||
//-------------------------------------------------------------//
|
||||
@@ -137,18 +144,21 @@ void SIM_writeOutputs(SimStruct* S)
|
||||
/* MCU WRAPPER DEINITIALIZATION */
|
||||
/**
|
||||
* @brief Инициализация симуляции МК.
|
||||
* @details Пользовательский код, который создает поток для приложения МК
|
||||
* @details Пользовательский код, который создает поток для приложения МК
|
||||
и настраивает симулятор МК для симуляции.
|
||||
*/
|
||||
void SIM_Initialize_Simulation(void)
|
||||
{
|
||||
#ifdef RUN_APP_MAIN_FUNC_THREAD
|
||||
// инициализация потока, который будет выполнять код МК
|
||||
hmcu.hMCUThread = (HANDLE)CreateThread(NULL, 0, MCU_App_Thread, 0, CREATE_SUSPENDED, &hmcu.idMCUThread);
|
||||
|
||||
#endif //RUN_APP_MAIN_FUNC_THREAD
|
||||
|
||||
/* user initialization */
|
||||
Initialize_Periph_Sim();
|
||||
|
||||
extern int main_init(void);
|
||||
main_init();
|
||||
/* wrapper initialization */
|
||||
hmcu.SystemClock_step = MCU_CORE_CLOCK * hmcu.SIM_Sample_Time; // set system clock step
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
**************************************************************************
|
||||
* @dir ../MCU_Wrapper
|
||||
* @brief <b> Папка с исходным кодом оболочки МК. </b>
|
||||
* @details
|
||||
В этой папке содержаться оболочка(англ. wrapper) для запуска и контроля
|
||||
эмуляции микроконтроллеров в MATLAB (любого МК, не только STM).
|
||||
Оболочка представляет собой S-Function - блок в Simulink, который работает
|
||||
по скомпилированому коду. Компиляция происходит с помощью MSVC-компилятора.
|
||||
* @details
|
||||
В этой папке содержаться оболочка(англ. wrapper) для запуска и контроля
|
||||
эмуляции микроконтроллеров в MATLAB (любого МК, не только STM).
|
||||
Оболочка представляет собой S-Function - блок в Simulink, который работает
|
||||
по скомпилированому коду. Компиляция происходит с помощью MSVC-компилятора.
|
||||
**************************************************************************/
|
||||
|
||||
/**
|
||||
@@ -21,8 +21,8 @@
|
||||
- для S-Function "simstruc.h"
|
||||
- для потоков <process.h>
|
||||
**************************************************************************/
|
||||
#ifndef _CONTROLLER_H_
|
||||
#define _CONTROLLER_H_
|
||||
#ifndef _WRAPPER_CONF_H_
|
||||
#define _WRAPPER_CONF_H_
|
||||
|
||||
// Includes
|
||||
#include "stm32f1xx_matlab_conf.h" // For stm simulate functions
|
||||
@@ -35,44 +35,52 @@
|
||||
* @brief Всякое для оболочки МК
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup WRAPPER_CONF Wrapper Configuration
|
||||
* @ingroup MCU_WRAPPER
|
||||
* @brief Параметры конфигурации для оболочки МК
|
||||
* @details Здесь дефайнами задается параметры оболочки, которые определяют как она будет работать
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @addtogroup WRAPPER_CONF Wrapper Configuration
|
||||
* @ingroup MCU_WRAPPER
|
||||
* @brief Параметры конфигурации для оболочки МК
|
||||
* @details Здесь дефайнами задается параметры оболочки, которые определяют как она будет работать
|
||||
* @{
|
||||
*/
|
||||
|
||||
// Parametrs of MCU simulator
|
||||
//#define RUN_APP_MAIN_FUNC_THREAD ///< Enable using thread for MCU main() func
|
||||
#define DEKSTOP_CYCLES_FOR_MCU_APP 0xFF ///< number of for() cycles after which MCU thread would be suspended
|
||||
#define MCU_CORE_CLOCK 72000000
|
||||
|
||||
// Parametrs of MCU simulator
|
||||
#define CREATE_SUSPENDED 0x00000004 ///< define from WinBase.h. We dont wanna include "Windows.h" or smth like this, because of HAL there are a lot of redefine errors.
|
||||
|
||||
#define DEKSTOP_CYCLES_FOR_MCU_APP 0xFFFF ///< number of for() cycles after which MCU thread would be suspended
|
||||
#define PORT_WIDTH 16 ///< width of one port
|
||||
#define PORT_NUMB 3 ///< amount of ports
|
||||
|
||||
// Parameters of S_Function
|
||||
#define NPARAMS 1 ///< number of input parametrs (only Ts)
|
||||
#define IN_PORT_WIDTH (8) ///< width of input ports
|
||||
#define IN_PORT_WIDTH (3) ///< width of input ports
|
||||
#define IN_PORT_NUMB 1 ///< number of input ports
|
||||
#define OUT_PORT_WIDTH PORT_WIDTH ///< width of output ports
|
||||
#define OUT_PORT_NUMB PORT_NUMB ///< number of output ports
|
||||
#define DISC_STATES_WIDTH PORT_WIDTH*PORT_NUMB ///< width of discrete states array
|
||||
|
||||
#define MCU_CORE_CLOCK SystemCoreClock
|
||||
/** WRAPPER_CONF
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup MCU_WRAPPER
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @addtogroup MCU_WRAPPER
|
||||
* @{
|
||||
*/
|
||||
|
||||
// Fixed parameters(?) of S_Function
|
||||
#define NPARAMS 1 ///< number of input parametrs (only Ts)
|
||||
#define DISC_STATES_WIDTH OUT_PORT_WIDTH*OUT_PORT_NUMB ///< width of discrete states array (outbup buffer)
|
||||
/**
|
||||
* @brief Define for creating thread in suspended state.
|
||||
* @details Define from WinBase.h. We dont wanna include "Windows.h" or smth like this, because of HAL there are a lot of redefine errors.
|
||||
*/
|
||||
#define CREATE_SUSPENDED 0x00000004
|
||||
typedef void* HANDLE; ///< MCU handle typedef
|
||||
|
||||
/**
|
||||
* @brief MCU handle Structure definition.
|
||||
* @brief MCU handle Structure definition.
|
||||
* @note Prefixes: h - handle, s - settings, f - flag
|
||||
*/
|
||||
typedef struct {
|
||||
@@ -92,6 +100,7 @@ extern SIM__MCUHandleTypeDef hmcu; // extern для видимос
|
||||
|
||||
//-------------------------------------------------------------//
|
||||
//------------------ SIMULINK WHILE DEFINES -----------------//
|
||||
#ifdef RUN_APP_MAIN_FUNC_THREAD
|
||||
/* DEFINE TO WHILE WITH SIMULINK WHILE */
|
||||
/**
|
||||
* @brief Redefine C while statement with sim_while() macro.
|
||||
@@ -99,44 +108,44 @@ extern SIM__MCUHandleTypeDef hmcu; // extern для видимос
|
||||
* @details Это while который будет использоваться в симулинке @ref sim_while для подробностей.
|
||||
*/
|
||||
#define while(_expression_) sim_while(_expression_)
|
||||
|
||||
/* SIMULINK WHILE */
|
||||
/**
|
||||
* @brief While statement for emulate MCU code in Simulink.
|
||||
* @param _expression_ - expression for while.
|
||||
* @details Данный while необходим, чтобы в конце симуляции, завершить поток МК:
|
||||
* При выставлении флага окончания симуляции, все while будут пропускаться
|
||||
* и поток сможет дойти до конца функции main и завершить себя.
|
||||
*/
|
||||
#endif
|
||||
/* SIMULINK WHILE */
|
||||
/**
|
||||
* @brief While statement for emulate MCU code in Simulink.
|
||||
* @param _expression_ - expression for while.
|
||||
* @details Данный while необходим, чтобы в конце симуляции, завершить поток МК:
|
||||
* При выставлении флага окончания симуляции, все while будут пропускаться
|
||||
* и поток сможет дойти до конца функции main и завершить себя.
|
||||
*/
|
||||
#define sim_while(_expression_) while((_expression_)&&(hmcu.fMCU_Stop == 0))
|
||||
|
||||
/* DEFAULT WHILE */
|
||||
/**
|
||||
* @brief Default/Native C while statement.
|
||||
* @param _expression_ - expression for while.
|
||||
* @details Данный while - аналог обычного while, без дополнительного функционала.
|
||||
*/
|
||||
/* DEFAULT WHILE */
|
||||
/**
|
||||
* @brief Default/Native C while statement.
|
||||
* @param _expression_ - expression for while.
|
||||
* @details Данный while - аналог обычного while, без дополнительного функционала.
|
||||
*/
|
||||
#define native_while(_expression_) for(; (_expression_); )
|
||||
/***************************************************************/
|
||||
/***************************************************************/
|
||||
|
||||
//------------------ SIMULINK WHILE DEFINES -----------------//
|
||||
//-------------------------------------------------------------//
|
||||
//------------------ SIMULINK WHILE DEFINES -----------------//
|
||||
//-------------------------------------------------------------//
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------//
|
||||
//---------------- SIMULATE FUNCTIONS PROTOTYPES -------------//
|
||||
/* Step simulation */
|
||||
void MCU_Step_Simulation(SimStruct *S, time_T time);
|
||||
//-------------------------------------------------------------//
|
||||
//---------------- SIMULATE FUNCTIONS PROTOTYPES -------------//
|
||||
/* Step simulation */
|
||||
void MCU_Step_Simulation(SimStruct* S, time_T time);
|
||||
|
||||
/* MCU peripheral simulation */
|
||||
void MCU_Periph_Simulation(void);
|
||||
void MCU_Periph_Simulation(void);
|
||||
|
||||
/* Initialize MCU simulation */
|
||||
void SIM_Initialize_Simulation(void);
|
||||
void SIM_Initialize_Simulation(void);
|
||||
|
||||
/* Deinitialize MCU simulation */
|
||||
void SIM_deInitialize_Simulation(void);
|
||||
void SIM_deInitialize_Simulation(void);
|
||||
|
||||
/* Read inputs S-function */
|
||||
void MCU_readInputs(SimStruct* S);
|
||||
@@ -152,17 +161,17 @@ void SIM_writeOutput(SimStruct* S);
|
||||
/** MCU_WRAPPER
|
||||
* @}
|
||||
*/
|
||||
#endif // _CONTROLLER_H_
|
||||
#endif // _WRAPPER_CONF_H_
|
||||
|
||||
|
||||
//-------------------------------------------------------------//
|
||||
//---------------------BAT FILE DESCRIBTION--------------------//
|
||||
/**
|
||||
* @file run_mex.bat
|
||||
* @brief Батник для компиляции оболочки МК.
|
||||
* @details
|
||||
* Вызывается в матлабе из mexing.m.
|
||||
*
|
||||
* Исходный код батника:
|
||||
* @include F:\Work\Projects\MATLAB\matlab_stm_emulate\MCU_Wrapper\run_mex.bat
|
||||
*/
|
||||
//-------------------------------------------------------------//
|
||||
//---------------------BAT FILE DESCRIBTION--------------------//
|
||||
/**
|
||||
* @file run_mex.bat
|
||||
* @brief Батник для компиляции оболочки МК.
|
||||
* @details
|
||||
* Вызывается в матлабе из mexing.m.
|
||||
*
|
||||
* Исходный код батника:
|
||||
* @include F:\Work\Projects\MATLAB\matlab_stm_emulate\MCU_Wrapper\run_mex.bat
|
||||
*/
|
||||
@@ -1,70 +1,60 @@
|
||||
@echo off
|
||||
|
||||
set defines=-D"STM32F407xx" -D"USE_HAL_DRIVER"^
|
||||
set defines=-D"STM32F103xB" -D"USE_HAL_DRIVER"^
|
||||
-D"MATLAB"^
|
||||
-D"__sizeof_ptr=8"
|
||||
:: -------------------------USERS PATHS AND CODE---------------------------
|
||||
:: заголовочные файлы (не добавлять CMSIS и HAL, они добавлены ниже)
|
||||
set includes_USER= -I".\Code\Core\Inc" -I".\Code\GENERAL"^
|
||||
-I".\Code\Modbus" -I".\Code\PWM"
|
||||
set includes_USER= -I"..\mcu_project\upp\Core\Inc" -I"..\mcu_project\upp\Core\upp"
|
||||
|
||||
:: для добавления в переменую новых файлов. иначе будет перезапись
|
||||
setlocal enabledelayedexpansion
|
||||
:: исходный код
|
||||
set code_USER=
|
||||
|
||||
for %%f in (.\Code\Core\Src\*.c) do (
|
||||
set code_USER=!code_USER! %%f
|
||||
)
|
||||
|
||||
for %%f in (.\Code\GENERAL\*.c) do (
|
||||
set code_USER=!code_USER! %%f
|
||||
)
|
||||
|
||||
for %%f in (.\Code\Modbus\*.c) do (
|
||||
set code_USER=!code_USER! %%f
|
||||
)
|
||||
|
||||
for %%f in (.\Code\PWM\*.c) do (
|
||||
set code_USER=!code_USER! %%f
|
||||
)
|
||||
set code_USER=.\App_Wrapper\main.c^
|
||||
.\App_Wrapper\app_io.c^
|
||||
..\mcu_project\upp\Core\Src\gpio.c^
|
||||
..\mcu_project\upp\Core\Src\adc.c^
|
||||
..\mcu_project\upp\Core\Src\tim.c^
|
||||
..\mcu_project\upp\Core\Src\stm32f1xx_hal_msp.c^
|
||||
..\mcu_project\upp\Core\Src\stm32f1xx_it.c^
|
||||
..\mcu_project\upp\Core\Src\system_stm32f1xx.c^
|
||||
..\mcu_project\upp\Core\upp\upp.c^
|
||||
..\mcu_project\upp\Core\upp\zero_cross.c^
|
||||
..\mcu_project\upp\Core\upp\adc_filter.c^
|
||||
..\mcu_project\upp\Core\upp\tiristor.c
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
:: -----------------------MCU LIBRARIES & SIMULATOR------------------------
|
||||
:: -----MCU LIBRARIES STUFF----
|
||||
:: заголовочные файлы
|
||||
set includes_MCU= -I".\MCU_STM32F4xx_Matlab"^
|
||||
-I".\MCU_STM32F4xx_Matlab\STM32F4xx_SIMULINK"^
|
||||
-I".\MCU_STM32F4xx_Matlab\Drivers\CMSIS"^
|
||||
-I".\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Inc"^
|
||||
-I".\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy"
|
||||
set includes_MCU= -I".\MCU_STM32F1xx_Matlab"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\CMSIS"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\CMSIS\Device\STM32F1xx"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Inc"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy"
|
||||
|
||||
:: код библиотек МК, переделанный для матлаб
|
||||
set code_MCU=.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_usart.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c
|
||||
set code_MCU= .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc_ex.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c
|
||||
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c^
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c^
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c^
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c^
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ramfunc.c^
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c^
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c^
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c^
|
||||
|
||||
:: --------MCU SIMULATOR-------
|
||||
:: код, которая будет симулировать перефирию МК в симулинке
|
||||
set code_MCU_Sim= .\MCU_STM32F4xx_Matlab\stm32f4xx_matlab_conf.c^
|
||||
.\MCU_STM32F4xx_Matlab\STM32F4xx_SIMULINK\stm32f4xx_matlab_gpio.c^
|
||||
.\MCU_STM32F4xx_Matlab\STM32F4xx_SIMULINK\stm32f4xx_matlab_tim.c^
|
||||
.\MCU_STM32F4xx_Matlab\STM32F4xx_SIMULINK\stm32f4xx_periph_registers.c
|
||||
set code_MCU_Sim= .\MCU_STM32F1xx_Matlab\stm32f1xx_matlab_conf.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK\stm32f1xx_matlab_gpio.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK\stm32f1xx_matlab_tim.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK\stm32f1xx_periph_registers.c
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
@echo off
|
||||
|
||||
set defines=-D"STM32F103xB" -D"USE_HAL_DRIVER"^
|
||||
-D"MATLAB"^
|
||||
-D"__sizeof_ptr=8"
|
||||
:: -------------------------USERS PATHS AND CODE---------------------------
|
||||
:: заголовочные файлы (не добавлять CMSIS и HAL, они добавлены ниже)
|
||||
set includes_USER= -I".\Core\Inc"
|
||||
|
||||
:: исходный код
|
||||
setlocal enabledelayedexpansion
|
||||
set code_USER=
|
||||
for %%f in (.\Core\Src\*.c) do (
|
||||
set code_USER=!code_USER! %%f
|
||||
)
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
:: -----------------------MCU LIBRARIES & SIMULATOR------------------------
|
||||
:: -----MCU LIBRARIES STUFF----
|
||||
:: заголовочные файлы
|
||||
set includes_MCU= -I".\MCU_STM32F1xx_Matlab"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\CMSIS"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\CMSIS\Device\STM32F1xx"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Inc"^
|
||||
-I".\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy"
|
||||
|
||||
:: код библиотек МК, переделанный для матлаб
|
||||
set code_MCU= .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c
|
||||
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ramfunc.c^
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c^
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c^
|
||||
:: .\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c^
|
||||
|
||||
:: --------MCU SIMULATOR-------
|
||||
:: код, которая будет симулировать перефирию МК в симулинке
|
||||
set code_MCU_Sim= .\MCU_STM32F1xx_Matlab\stm32f1xx_matlab_conf.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK\stm32f1xx_matlab_gpio.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK\stm32f1xx_matlab_tim.c^
|
||||
.\MCU_STM32F1xx_Matlab\Drivers\STM32F1xx_SIMULINK\stm32f1xx_periph_registers.c
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
:: -------------------------WRAPPER PATHS AND CODE---------------------------
|
||||
:: оболочка, которая будет моделировать работу МК в симулинке
|
||||
set includes_WRAPPER= -I".\MCU_Wrapper"
|
||||
set code_WRAPPER= .\MCU_Wrapper\MCU.c^
|
||||
.\MCU_Wrapper\mcu_wrapper.c
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
:: ---------------------SET PARAMS FOR MEX COMPILING-----------------------
|
||||
:: --------ALL INCLUDES--------
|
||||
set includes= %includes_USER% %includes_MCU% %includes_WRAPPER%
|
||||
set codes= %code_WRAPPER% %code_USER% %code_MCU% %code_MCU_Sim%
|
||||
:: -------OUTPUT FOLDER--------
|
||||
set output= -outdir "."
|
||||
|
||||
:: если нужен дебаг, до запускаем run mex с припиской debug
|
||||
IF [%1]==[debug] (set debug= -g)
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
::------START COMPILING-------
|
||||
echo Compiling...
|
||||
mex %output% %defines% %includes% %codes% %debug%
|
||||
@@ -1,90 +0,0 @@
|
||||
@echo off
|
||||
|
||||
set defines=-D"STM32F407xx" -D"USE_HAL_DRIVER"^
|
||||
-D"MATLAB"^
|
||||
-D"__sizeof_ptr=8"
|
||||
:: -------------------------USERS PATHS AND CODE---------------------------
|
||||
:: заголовочные файлы (не добавлять CMSIS и HAL, они добавлены ниже)
|
||||
set includes_USER= -I".\Core\Inc"
|
||||
|
||||
:: исходный код
|
||||
set code_USER=.\Core\Src\main.c^
|
||||
.\Core\Src\tim.c^
|
||||
.\Core\Src\gpio.c^
|
||||
.\Core\Src\stm32f4xx_it.c^
|
||||
.\Core\Src\system_stm32f4xx.c
|
||||
|
||||
:: .\Core\Src\stm32f4xx_hal_msp.c^
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
:: -----------------------MCU LIBRARIES & SIMULATOR------------------------
|
||||
:: -----MCU LIBRARIES STUFF----
|
||||
:: заголовочные файлы
|
||||
set includes_MCU= -I".\MCU_STM32F4xx_Matlab"^
|
||||
-I".\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_SIMULINK"^
|
||||
-I".\MCU_STM32F4xx_Matlab\Drivers\CMSIS"^
|
||||
-I".\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Inc"^
|
||||
-I".\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy"
|
||||
|
||||
:: код библиотек МК, переделанный для матлаб
|
||||
set code_MCU=.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c
|
||||
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c^
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c^
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c^
|
||||
:: .\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c^
|
||||
|
||||
:: --------MCU SIMULATOR-------
|
||||
:: код, которая будет симулировать перефирию МК в симулинке
|
||||
set code_MCU_Sim= .\MCU_STM32F4xx_Matlab\stm32f4xx_matlab_conf.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_SIMULINK\stm32f4xx_matlab_gpio.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_SIMULINK\stm32f4xx_matlab_tim.c^
|
||||
.\MCU_STM32F4xx_Matlab\Drivers\STM32F4xx_SIMULINK\stm32f4xx_periph_registers.c
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
:: -------------------------WRAPPER PATHS AND CODE---------------------------
|
||||
:: оболочка, которая будет моделировать работу МК в симулинке
|
||||
set includes_WRAPPER= -I".\MCU_Wrapper"
|
||||
set code_WRAPPER= .\MCU_Wrapper\Outputs\asmjmp.obj^
|
||||
.\MCU_Wrapper\MCU.c^
|
||||
.\MCU_Wrapper\controller.c
|
||||
|
||||
:: оболочка, которая будет моделировать работу МК в симулинке
|
||||
set asm_WRAPPER=asmjmp
|
||||
set output_folder=.\MCU_Wrapper\Outputs\
|
||||
set asm_source=.\MCU_Wrapper\%asm_WRAPPER%.asm
|
||||
set asm_obj=%output_folder%%asm_WRAPPER%.obj
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
:: ---------------------SET PARAMS FOR MEX COMPILING-----------------------
|
||||
:: --------ALL INCLUDES--------
|
||||
set includes= %includes_USER% %includes_MCU% %includes_WRAPPER%
|
||||
set codes= %code_WRAPPER% %code_USER% %code_MCU% %code_MCU_Sim%
|
||||
:: -------OUTPUT FOLDER--------
|
||||
set output= -outdir "."
|
||||
|
||||
:: если нужен дебаг, до запускаем run mex с припиской debug
|
||||
IF [%1]==[debug] (set debug= -g)
|
||||
::-------------------------------------------------------------------------
|
||||
|
||||
|
||||
::------START COMPILING-------
|
||||
set asm_exe= "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\ml64.exe"
|
||||
set asm_command= /c /Zi /Fo %asm_obj% %asm_source%
|
||||
%asm_exe% %asm_command%
|
||||
|
||||
echo.
|
||||
echo Compiling...
|
||||
mex %output% %defines% %includes% %codes% %debug%
|
||||
Reference in New Issue
Block a user