симулируется упп на stm32f103

This commit is contained in:
2025-05-10 01:20:08 +03:00
parent c6269ca448
commit 08719ffc05
397 changed files with 516 additions and 30524 deletions

65
App_Wrapper/app_io.c Normal file
View File

@@ -0,0 +1,65 @@
#include "stm32f1xx_matlab_gpio.h"
#include "upp.h"
void WriteFromSFunc(real_T* disc)
{
for (int i = 0; i < PORT_WIDTH; i++)
{
if (GPIOA->ODR & (1 << i))
{
disc[i] = 1;
}
if (GPIOB->ODR & (1 << i))
{
disc[PORT_WIDTH + i] = 1;
}
}
disc[2 * PORT_WIDTH + 0] = phase_A.ctrl.f.EnableTiristor;
disc[2 * PORT_WIDTH + 1] = phase_A.ctrl.f.TiristorIsEnable;
disc[2 * PORT_WIDTH + 2] = uwTick - phase_A.ctrl.enable_start_tick;
disc[2 * PORT_WIDTH + 3] = phase_A.ctrl.angle.start_delay_us;
disc[2 * PORT_WIDTH + 4] = (uint16_t)((uint16_t)TIMER->CNT - phase_A.ctrl.angle.start_delay_us);
}
void ReadToSFunc(real_T* in)
{
static real_T in_prev[3];
if ((in[0] > 0.5) && (in_prev[0] <= 0.5))
{
phase_A.zc_detector.f.EXTIZeroCrossDetected = 1;
}
else if ((in[0] < 0.5) && (in_prev[0] >= 0.5))
{
phase_A.zc_detector.f.EXTIZeroCrossDetected = 1;
}
if ((in[1] > 0.5) && (in_prev[1] <= 0.5))
{
phase_B.zc_detector.f.EXTIZeroCrossDetected = 1;
}
else if ((in[1] < 0.5) && (in_prev[1] >= 0.5))
{
phase_B.zc_detector.f.EXTIZeroCrossDetected = 1;
}
if ((in[2] > 0.5) && (in_prev[2] <= 0.5))
{
phase_C.zc_detector.f.EXTIZeroCrossDetected = 1;
}
else if ((in[2] < 0.5) && (in_prev[2] >= 0.5))
{
phase_C.zc_detector.f.EXTIZeroCrossDetected = 1;
}
in_prev[0] = in[0];
in_prev[1] = in[1];
in_prev[2] = in[2];
}