/** ************************************************************************** * @file app_init.h * @brief Файл с функциями записи входов/выходов программы МК @ref app_init. **************************************************************************/ #include "mcu_wrapper_conf.h" #include "app_wrapper.h" #define PIN_READ(_verbname_) (_verbname_##_GPIO_Port->ODR & (_verbname_##_Pin)) ? 1 : 0 void Write_Thyristors(real_T* Buffer, int ind_port) { int pwm1_pin = PIN_READ(PWM1); int pwm2_pin = PIN_READ(PWM2); int pwm3_pin = PIN_READ(PWM3); int pwm4_pin = PIN_READ(PWM4); int pwm5_pin = PIN_READ(PWM5); int pwm6_pin = PIN_READ(PWM6); WriteOutputArray(pwm1_pin, ind_port, 0); WriteOutputArray(pwm2_pin, ind_port, 1); WriteOutputArray(pwm3_pin, ind_port, 2); WriteOutputArray(pwm4_pin, ind_port, 3); WriteOutputArray(pwm5_pin, ind_port, 4); WriteOutputArray(pwm6_pin, ind_port, 5); } void Write_PowerMonitor(real_T* Buffer, int ind_port) { int nn = 0; for (int i = 0; i < 3; i++) { WriteOutputArray(pm.U[i], ind_port, nn++); } for (int i = 0; i < 3; i++) { WriteOutputArray(pm.ZC_Detected[i], ind_port, nn++); } for (int i = 0; i < 3; i++) { WriteOutputArray(pm.F[i], ind_port, nn++); } for (int i = 0; i < 3; i++) { WriteOutputArray(pm.I[i], ind_port, nn++); } for (int i = 0; i < 2; i++) { WriteOutputArray(pm.T[i], ind_port, nn++); } } /** * @brief Функция для записи входов в приложение МК * @param u - массив входных значений */ void app_readInputs(const real_T* Buffer) { // USER APP INPUT START ADC_Set_Channel_Value(ADC3, 4, ReadInputArray(0,0)); ADC_Set_Channel_Value(ADC3, 5, ReadInputArray(0,1)); ADC_Set_Channel_Value(ADC3, 6, ReadInputArray(0,2)); ADC_Set_Channel_Value(ADC3, 7, ReadInputArray(0,3)); ADC_Set_Channel_Value(ADC3, 8, ReadInputArray(0,4)); ADC_Set_Channel_Value(ADC3, 10, ReadInputArray(0,5)); // USER APP INPUT END } /** * @brief Функция для записи выходов приложения МК * @param xD - массив буффера выходов(дискретных выходов) * @details Используте WriteOutputArray(val, arr_ind, val_ind) для записи */ void app_writeOutputBuffer(real_T* Buffer) { // USER APP OUTPUT START //ThyristorWrite(Buffer, 0); Write_PowerMonitor(Buffer, 1); WriteOutputArray(hmcu.dSFuncPeriod, 2, 12); WriteOutputArray(hmcu.dSFuncTime, 2, 13); WriteOutputArray(hmcu.dMCUStepTime, 2, 14); // USER APP OUTPUT END }