Добавлена простенькая симуляция АЦП в сканирующем режиме.
Но надо отлаживать и сравнивать с работой реального (в плане разных режимов работы, доделать прерывания/дма, флаги и так далее)
This commit is contained in:
@@ -16,11 +16,21 @@ MCU_CortexMemoryTypeDef MCU_CORTEX_MEM;
|
||||
void Initialize_Periph_Sim(void)
|
||||
{
|
||||
Init_TIM_SIM();
|
||||
Init_ADC_SIM();
|
||||
}
|
||||
|
||||
// MCU PERIPH SIM
|
||||
void Simulate_Periph_Sim(void)
|
||||
{
|
||||
Simulate_TIMs();
|
||||
Simulate_ADCs();
|
||||
}
|
||||
|
||||
// MCU PERIPH DEINIT
|
||||
void deInitialize_Periph_Sim(void)
|
||||
{
|
||||
TIM_SIM_DEINIT();
|
||||
ADC_SIM_DEINIT();
|
||||
}
|
||||
// MCU DEINIT
|
||||
void deInitialize_MCU(void)
|
||||
@@ -85,6 +95,7 @@ struct TIM_Sim tim14s;
|
||||
void Init_TIM_SIM(void)
|
||||
{
|
||||
#ifdef USE_TIM1
|
||||
memset(&tim1s, 0, sizeof(tim1s));
|
||||
tim1s.tx_cnt = TIM1->CNT;
|
||||
tim1s.tx_step = hmcu.sSimSampleTime * ABP2_TIMS_Value;
|
||||
|
||||
@@ -98,6 +109,7 @@ void Init_TIM_SIM(void)
|
||||
tim1s.Channels.OC4_PIN_SHIFT = 11;
|
||||
#endif
|
||||
#ifdef USE_TIM2
|
||||
memset(&tim2s, 0, sizeof(tim2s));
|
||||
tim2s.tx_cnt = TIM2->CNT;
|
||||
tim2s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value;
|
||||
|
||||
@@ -111,6 +123,7 @@ void Init_TIM_SIM(void)
|
||||
tim2s.Channels.OC4_PIN_SHIFT = 3;
|
||||
#endif
|
||||
#ifdef USE_TIM3
|
||||
memset(&tim3s, 0, sizeof(tim3s));
|
||||
tim3s.tx_cnt = TIM3->CNT;
|
||||
tim3s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value;
|
||||
|
||||
@@ -124,6 +137,7 @@ void Init_TIM_SIM(void)
|
||||
tim3s.Channels.OC4_PIN_SHIFT = 9;
|
||||
#endif
|
||||
#ifdef USE_TIM4
|
||||
memset(&tim4s, 0, sizeof(tim4s));
|
||||
tim4s.tx_cnt = TIM4->CNT;
|
||||
tim4s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value;
|
||||
|
||||
@@ -137,6 +151,7 @@ void Init_TIM_SIM(void)
|
||||
tim4s.Channels.OC4_PIN_SHIFT = 9;
|
||||
#endif
|
||||
#ifdef USE_TIM5
|
||||
memset(&tim5s, 0, sizeof(tim5s));
|
||||
tim5s.tx_cnt = TIM5->CNT;
|
||||
tim5s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value;
|
||||
|
||||
@@ -150,6 +165,7 @@ void Init_TIM_SIM(void)
|
||||
tim5s.Channels.OC4_PIN_SHIFT = 3;
|
||||
#endif
|
||||
#ifdef USE_TIMx
|
||||
memset(&tim6s, 0, sizeof(tim6s));
|
||||
tim6s.tx_cnt = TIMx->CNT;
|
||||
tim6s.tx_step = hmcu.sSimSampleTime * ABP1_TIMS_Value;
|
||||
|
||||
@@ -165,3 +181,39 @@ void Init_TIM_SIM(void)
|
||||
}
|
||||
/*-------------------------------TIMERS----------------------------------*/
|
||||
//-----------------------------------------------------------------------//
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------//
|
||||
/*---------------------------------ADC-----------------------------------*/
|
||||
#ifdef USE_ADC1
|
||||
struct ADC_Sim adc1s;
|
||||
#endif
|
||||
#ifdef USE_ADC2
|
||||
struct ADC_Sim adc2s;
|
||||
#endif
|
||||
#ifdef USE_ADC3
|
||||
struct ADC_Sim adc3s;
|
||||
#endif
|
||||
void Init_ADC_SIM(void)
|
||||
{
|
||||
#ifdef USE_ADC1
|
||||
memset(&adc1s, 0, sizeof(adc1s));
|
||||
adc1s.simulation_step = hmcu.sSimSampleTime;
|
||||
adc1s.adc_clock_freq = ABP2_Value; // Частота APB2
|
||||
#endif
|
||||
|
||||
#ifdef USE_ADC2
|
||||
memset(&adc2s, 0, sizeof(adc2s));
|
||||
adc2s.simulation_step = hmcu.sSimSampleTime;
|
||||
adc2s.adc_clock_freq = ABP2_Value; // Частота APB2
|
||||
#endif
|
||||
|
||||
#ifdef USE_ADC3
|
||||
memset(&adc3s, 0, sizeof(adc3s));
|
||||
adc3s.simulation_step = hmcu.sSimSampleTime;
|
||||
adc3s.adc_clock_freq = ABP2_Value; // Частота APB2
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------ADC-----------------------------------*/
|
||||
//-----------------------------------------------------------------------//
|
||||
|
||||
Reference in New Issue
Block a user