Loading...
Searching...
No Matches
stm32f4xx_matlab_conf.c
Go to the documentation of this file.
/**
**************************************************************************
* @file stm32f4xx_matlab_conf.c
* @brief Исходный код для конфигурации симулятора МК.
**************************************************************************
@details
Данный файл настраивает структуры для симуляции периферий, которые выбраны
дефайнами в stm32f4xx_matlab_conf.h.
**************************************************************************/
#include "mcu_wrapper_conf.h"
MCU_MemoryTypeDef MCU_MEM;
MCU_CortexMemoryTypeDef MCU_CORTEX_MEM;
DBGMCU_TypeDef DEBUG_MCU;
//-----------------------------------------------------------------------//
/*------------------------------FUNCTIONS--------------------------------*/
/**
* @brief Инициализация периферии симулятора МК.
* @details Эта функция вызывает функции инициализации периферии для симуляции
*/
void Initialize_Periph_Sim(void)
{
Init_TIM_SIM();
}
/**
* @brief Деинициализация периферии симулятора МК.
* @details Эта функция вызывает функции деинициализации периферии для последующей симуляции
*/
void deInitialize_Periph_Sim(void)
{
TIM_SIM_DEINIT();
}
/**
* @brief Деинициализация симулятора МК.
* @details Эта функция очищает память симулятора МК, чтобы в
следующей симуляции он запускался как в первый раз.
*/
void deInitialize_MCU(void)
{
// обнуление структуры, управляющей программой МК
memset(&hmcu, 0, sizeof(hmcu));
// обнуление структур, симулирующих память МК
memset(&MCU_MEM, 0, sizeof(MCU_MEM));
memset(&MCU_CORTEX_MEM, 0, sizeof(MCU_CORTEX_MEM));
memset(&DEBUG_MCU, 0, sizeof(DEBUG_MCU));
}
/*------------------------------FUNCTIONS--------------------------------*/
//-----------------------------------------------------------------------//
//-----------------------------------------------------------------------//
/*-------------------------------TIMERS----------------------------------*/
// defines structure for simulate
#ifdef USE_TIM1
struct TIM_Sim tim1s;
#endif
#ifdef USE_TIM2
struct TIM_Sim tim2s;
#endif
#ifdef USE_TIM3
struct TIM_Sim tim3s;
#endif
#ifdef USE_TIM4
struct TIM_Sim tim4s;
#endif
#ifdef USE_TIM5
struct TIM_Sim tim5s;
#endif
#ifdef USE_TIM6
struct TIM_Sim tim6s;
#endif
#ifdef USE_TIM7
struct TIM_Sim tim7s;
#endif
#ifdef USE_TIM8
struct TIM_Sim tim8s;
#endif
#ifdef USE_TIM9
struct TIM_Sim tim9s;
#endif
#ifdef USE_TIM10
struct TIM_Sim tim10s;
#endif
#ifdef USE_TIM11
struct TIM_Sim tim11s;
#endif
#ifdef USE_TIM12
struct TIM_Sim tim12s;
#endif
#ifdef USE_TIM13
struct TIM_Sim tim13s;
#endif
#ifdef USE_TIM14
struct TIM_Sim tim14s;
#endif
/**
* @brief Инициализация таймеров симулятора МК.
* @details Эта функция инициализирует структуры для симуляции таймеров.
* Таймеры для симуляции выбираются дефайнами в stm32f4xx_matlab_conf.h.
*/
void Init_TIM_SIM(void)
{
#ifdef USE_TIM1
tim1s.tx_cnt = TIM1->CNT;
tim1s.tx_step = hmcu.SIM_Sample_Time * ABP2_TIMS_Value;
tim1s.Channels.OC1_GPIOx = GPIOE;
tim1s.Channels.OC1_PIN_SHIFT = 9;
tim1s.Channels.OC2_GPIOx = GPIOE;
tim1s.Channels.OC2_PIN_SHIFT = 11;
tim1s.Channels.OC3_GPIOx = GPIOE;
tim1s.Channels.OC3_PIN_SHIFT = 13;
tim1s.Channels.OC4_GPIOx = GPIOE;
tim1s.Channels.OC4_PIN_SHIFT = 14;
tim1s.Channels.OC1REF = 0;
tim1s.Channels.OC2REF = 0;
tim1s.Channels.OC3REF = 0;
tim1s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM2
tim2s.tx_cnt = TIM2->CNT;
tim2s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim2s.Channels.OC1_GPIOx = GPIOA;
tim2s.Channels.OC1_PIN_SHIFT = 5;
tim2s.Channels.OC2_GPIOx = GPIOA;
tim2s.Channels.OC2_PIN_SHIFT = 1;
tim2s.Channels.OC3_GPIOx = GPIOA;
tim2s.Channels.OC3_PIN_SHIFT = 2;
tim2s.Channels.OC4_GPIOx = GPIOA;
tim2s.Channels.OC4_PIN_SHIFT = 3;
tim2s.Channels.OC1REF = 0;
tim2s.Channels.OC2REF = 0;
tim2s.Channels.OC3REF = 0;
tim2s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM3
tim3s.tx_cnt = TIM3->CNT;
tim3s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim3s.Channels.OC1_GPIOx = GPIOA;
tim3s.Channels.OC1_PIN_SHIFT = 6;
tim3s.Channels.OC2_GPIOx = GPIOA;
tim3s.Channels.OC2_PIN_SHIFT = 7;
tim3s.Channels.OC3_GPIOx = GPIOB;
tim3s.Channels.OC3_PIN_SHIFT = 0;
tim3s.Channels.OC4_GPIOx = GPIOB;
tim3s.Channels.OC4_PIN_SHIFT = 1;
tim3s.Channels.OC1REF = 0;
tim3s.Channels.OC2REF = 0;
tim3s.Channels.OC3REF = 0;
tim3s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM4
tim4s.tx_cnt = TIM4->CNT;
tim4s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim4s.Channels.OC1_GPIOx = GPIOD;
tim4s.Channels.OC1_PIN_SHIFT = 12;
tim4s.Channels.OC2_GPIOx = GPIOD;
tim4s.Channels.OC2_PIN_SHIFT = 13;
tim4s.Channels.OC3_GPIOx = GPIOD;
tim4s.Channels.OC3_PIN_SHIFT = 14;
tim4s.Channels.OC4_GPIOx = GPIOD;
tim4s.Channels.OC4_PIN_SHIFT = 15;
tim4s.Channels.OC1REF = 0;
tim4s.Channels.OC2REF = 0;
tim4s.Channels.OC3REF = 0;
tim4s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM5
tim5s.tx_cnt = TIM5->CNT;
tim5s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim5s.Channels.OC1_GPIOx = GPIOA;
tim5s.Channels.OC1_PIN_SHIFT = 0;
tim5s.Channels.OC2_GPIOx = GPIOA;
tim5s.Channels.OC2_PIN_SHIFT = 1;
tim5s.Channels.OC3_GPIOx = GPIOA;
tim5s.Channels.OC3_PIN_SHIFT = 2;
tim5s.Channels.OC4_GPIOx = GPIOA;
tim5s.Channels.OC4_PIN_SHIFT = 3;
tim5s.Channels.OC1REF = 0;
tim5s.Channels.OC2REF = 0;
tim5s.Channels.OC3REF = 0;
tim5s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM6
tim6s.tx_cnt = TIM6->CNT;
tim6s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim6s.Channels.OC1_GPIOx = GPIOA;
tim6s.Channels.OC1_PIN_SHIFT = 6;
tim6s.Channels.OC2_GPIOx = GPIOA;
tim6s.Channels.OC2_PIN_SHIFT = 0;
tim6s.Channels.OC3_GPIOx = GPIOA;
tim6s.Channels.OC3_PIN_SHIFT = 0;
tim6s.Channels.OC4_GPIOx = GPIOA;
tim6s.Channels.OC4_PIN_SHIFT = 0;
tim6s.Channels.OC1REF = 0;
tim6s.Channels.OC2REF = 0;
tim6s.Channels.OC3REF = 0;
tim6s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM7
tim7s.tx_cnt = TIM7->CNT;
tim7s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim7s.Channels.OC1_GPIOx = GPIOA;
tim7s.Channels.OC1_PIN_SHIFT = 6;
tim7s.Channels.OC2_GPIOx = GPIOA;
tim7s.Channels.OC2_PIN_SHIFT = 0;
tim7s.Channels.OC3_GPIOx = GPIOA;
tim7s.Channels.OC3_PIN_SHIFT = 0;
tim7s.Channels.OC4_GPIOx = GPIOA;
tim7s.Channels.OC4_PIN_SHIFT = 0;
tim7s.Channels.OC1REF = 0;
tim7s.Channels.OC2REF = 0;
tim7s.Channels.OC3REF = 0;
tim7s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM8
tim8s.tx_cnt = TIM8->CNT;
tim8s.tx_step = hmcu.SIM_Sample_Time * ABP2_TIMS_Value;
tim8s.Channels.OC1_GPIOx = GPIOA;
tim8s.Channels.OC1_PIN_SHIFT = 6;
tim8s.Channels.OC2_GPIOx = GPIOA;
tim8s.Channels.OC2_PIN_SHIFT = 0;
tim8s.Channels.OC3_GPIOx = GPIOA;
tim8s.Channels.OC3_PIN_SHIFT = 0;
tim8s.Channels.OC4_GPIOx = GPIOA;
tim8s.Channels.OC4_PIN_SHIFT = 0;
tim8s.Channels.OC1REF = 0;
tim8s.Channels.OC2REF = 0;
tim8s.Channels.OC3REF = 0;
tim8s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM9
tim9s.tx_cnt = TIM9->CNT;
tim9s.tx_step = hmcu.SIM_Sample_Time * ABP2_TIMS_Value;
tim9s.Channels.OC1_GPIOx = GPIOA;
tim9s.Channels.OC1_PIN_SHIFT = 6;
tim9s.Channels.OC2_GPIOx = GPIOA;
tim9s.Channels.OC2_PIN_SHIFT = 0;
tim9s.Channels.OC3_GPIOx = GPIOA;
tim9s.Channels.OC3_PIN_SHIFT = 0;
tim9s.Channels.OC4_GPIOx = GPIOA;
tim9s.Channels.OC4_PIN_SHIFT = 0;
tim9s.Channels.OC1REF = 0;
tim9s.Channels.OC2REF = 0;
tim9s.Channels.OC3REF = 0;
tim9s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM10
tim10s.tx_cnt = TIM10->CNT;
tim10s.tx_step = hmcu.SIM_Sample_Time * ABP2_TIMS_Value;
tim10s.Channels.OC1_GPIOx = GPIOA;
tim10s.Channels.OC1_PIN_SHIFT = 6;
tim10s.Channels.OC2_GPIOx = GPIOA;
tim10s.Channels.OC2_PIN_SHIFT = 0;
tim10s.Channels.OC3_GPIOx = GPIOA;
tim10s.Channels.OC3_PIN_SHIFT = 0;
tim10s.Channels.OC4_GPIOx = GPIOA;
tim10s.Channels.OC4_PIN_SHIFT = 0;
tim10s.Channels.OC1REF = 0;
tim10s.Channels.OC2REF = 0;
tim10s.Channels.OC3REF = 0;
tim10s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM11
tim11s.tx_cnt = TIM11->CNT;
tim11s.tx_step = hmcu.SIM_Sample_Time * ABP2_TIMS_Value;
tim11s.Channels.OC1_GPIOx = GPIOA;
tim11s.Channels.OC1_PIN_SHIFT = 6;
tim11s.Channels.OC2_GPIOx = GPIOA;
tim11s.Channels.OC2_PIN_SHIFT = 0;
tim11s.Channels.OC3_GPIOx = GPIOA;
tim11s.Channels.OC3_PIN_SHIFT = 0;
tim11s.Channels.OC4_GPIOx = GPIOA;
tim11s.Channels.OC4_PIN_SHIFT = 0;
tim11s.Channels.OC1REF = 0;
tim11s.Channels.OC2REF = 0;
tim11s.Channels.OC3REF = 0;
tim11s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM12
tim12s.tx_cnt = TIM12->CNT;
tim12s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim12s.Channels.OC1_GPIOx = GPIOA;
tim12s.Channels.OC1_PIN_SHIFT = 6;
tim12s.Channels.OC2_GPIOx = GPIOA;
tim12s.Channels.OC2_PIN_SHIFT = 0;
tim12s.Channels.OC3_GPIOx = GPIOA;
tim12s.Channels.OC3_PIN_SHIFT = 0;
tim12s.Channels.OC4_GPIOx = GPIOA;
tim12s.Channels.OC4_PIN_SHIFT = 0;
tim12s.Channels.OC1REF = 0;
tim12s.Channels.OC2REF = 0;
tim12s.Channels.OC3REF = 0;
tim12s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM13
tim13s.tx_cnt = TIM13->CNT;
tim13s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim13s.Channels.OC1_GPIOx = GPIOA;
tim13s.Channels.OC1_PIN_SHIFT = 6;
tim13s.Channels.OC2_GPIOx = GPIOA;
tim13s.Channels.OC2_PIN_SHIFT = 0;
tim13s.Channels.OC3_GPIOx = GPIOA;
tim13s.Channels.OC3_PIN_SHIFT = 0;
tim13s.Channels.OC4_GPIOx = GPIOA;
tim13s.Channels.OC4_PIN_SHIFT = 0;
tim13s.Channels.OC1REF = 0;
tim13s.Channels.OC2REF = 0;
tim13s.Channels.OC3REF = 0;
tim13s.Channels.OC4REF = 0;
#endif
#ifdef USE_TIM14
tim14s.tx_cnt = TIM14->CNT;
tim14s.tx_step = hmcu.SIM_Sample_Time * ABP1_TIMS_Value;
tim14s.Channels.OC1_GPIOx = GPIOA;
tim14s.Channels.OC1_PIN_SHIFT = 6;
tim14s.Channels.OC2_GPIOx = GPIOA;
tim14s.Channels.OC2_PIN_SHIFT = 0;
tim14s.Channels.OC3_GPIOx = GPIOA;
tim14s.Channels.OC3_PIN_SHIFT = 0;
tim14s.Channels.OC4_GPIOx = GPIOA;
tim14s.Channels.OC4_PIN_SHIFT = 0;
tim14s.Channels.OC1REF = 0;
tim14s.Channels.OC2REF = 0;
tim14s.Channels.OC3REF = 0;
tim14s.Channels.OC4REF = 0;
#endif
}
/*-------------------------------TIMERS----------------------------------*/
//-----------------------------------------------------------------------//
MCU_CORTEX_MEM
MCU_CortexMemoryTypeDef MCU_CORTEX_MEM
Definition stm32f4xx_matlab_conf.c:14
Initialize_Periph_Sim
void Initialize_Periph_Sim(void)
Инициализация периферии симулятора МК.
Definition stm32f4xx_matlab_conf.c:23
MCU_MEM
MCU_MemoryTypeDef MCU_MEM
Definition stm32f4xx_matlab_conf.c:13
ABP1_TIMS_Value
#define ABP1_TIMS_Value
Definition stm32f4xx_matlab_rcc.h:30
ABP2_TIMS_Value
#define ABP2_TIMS_Value
Definition stm32f4xx_matlab_rcc.h:32
TIM_SIM_DEINIT
void TIM_SIM_DEINIT(void)
Деинициализирование выбранных таймеров.
Definition stm32f4xx_matlab_tim.c:571
hmcu
SIM__MCUHandleTypeDef hmcu
Хендл для управления потоком программы МК
Definition mcu_wrapper.c:16
mcu_wrapper_conf.h
Заголовочный файл для оболочки МК.
Init_TIM_SIM
void Init_TIM_SIM(void)
Инициализация таймеров симулятора МК.
Definition stm32f4xx_matlab_conf.c:105
DEBUG_MCU
DBGMCU_TypeDef DEBUG_MCU
Definition stm32f4xx_matlab_conf.c:15
deInitialize_MCU
void deInitialize_MCU(void)
Деинициализация симулятора МК.
Definition stm32f4xx_matlab_conf.c:40
deInitialize_Periph_Sim
void deInitialize_Periph_Sim(void)
Деинициализация периферии симулятора МК.
Definition stm32f4xx_matlab_conf.c:31
tim1s
struct TIM_Sim tim1s
tim4s
struct TIM_Sim tim4s
tim12s
struct TIM_Sim tim12s
tim3s
struct TIM_Sim tim3s
tim7s
struct TIM_Sim tim7s
_cortex_memory
Definition stm32f407xx_matlab_memory.h:27
_memory
Definition stm32f407xx_matlab_memory.h:107
Channels_Sim::OC2_GPIOx
GPIO_TypeDef * OC2_GPIOx
Порт второго канала
Definition stm32f4xx_matlab_tim.h:88
Channels_Sim::OC4REF
unsigned OC4REF
Четвертый канал
Definition stm32f4xx_matlab_tim.h:82
Channels_Sim::OC1_PIN_SHIFT
uint32_t OC1_PIN_SHIFT
Пин первого канала
Definition stm32f4xx_matlab_tim.h:86
Channels_Sim::OC1_GPIOx
GPIO_TypeDef * OC1_GPIOx
Порт первого канала
Definition stm32f4xx_matlab_tim.h:85
Channels_Sim::OC3_GPIOx
GPIO_TypeDef * OC3_GPIOx
Порт третьего канала
Definition stm32f4xx_matlab_tim.h:91
Channels_Sim::OC4_GPIOx
GPIO_TypeDef * OC4_GPIOx
Порт четвертого канала
Definition stm32f4xx_matlab_tim.h:94
Channels_Sim::OC2REF
unsigned OC2REF
Второй канал
Definition stm32f4xx_matlab_tim.h:80
Channels_Sim::OC4_PIN_SHIFT
uint32_t OC4_PIN_SHIFT
Пин четвертого канала
Definition stm32f4xx_matlab_tim.h:95
Channels_Sim::OC1REF
unsigned OC1REF
Первый канал
Definition stm32f4xx_matlab_tim.h:79
Channels_Sim::OC3REF
unsigned OC3REF
Третьий канал
Definition stm32f4xx_matlab_tim.h:81
Channels_Sim::OC3_PIN_SHIFT
uint32_t OC3_PIN_SHIFT
Пин третьего канала
Definition stm32f4xx_matlab_tim.h:92
Channels_Sim::OC2_PIN_SHIFT
uint32_t OC2_PIN_SHIFT
Пин второго канала
Definition stm32f4xx_matlab_tim.h:89
SIM__MCUHandleTypeDef::SIM_Sample_Time
double SIM_Sample_Time
sample time of simulation
Definition mcu_wrapper_conf.h:83
TIM_Sim
Структура для моделирования таймера
Definition stm32f4xx_matlab_tim.h:103
TIM_Sim::tx_cnt
double tx_cnt
Счетчик таймера (double, т.к. кол-во тактов за шаг симуляции может быть дробным)
Definition stm32f4xx_matlab_tim.h:104
TIM_Sim::Channels
struct Channels_Sim Channels
Структура для симуляции каналов
Definition stm32f4xx_matlab_tim.h:107
TIM_Sim::tx_step
double tx_step
Шаг счета за один шаг симуляции (double, т.к. кол-во тактов за шаг симуляции может быть дробным)
Definition stm32f4xx_matlab_tim.h:105