diff --git a/MATLAB/upp_r2023.slx b/MATLAB/upp_r2023.slx index 0af3141..21d410d 100644 Binary files a/MATLAB/upp_r2023.slx and b/MATLAB/upp_r2023.slx differ diff --git a/UPP/Core/Configs/upp_defs.h b/UPP/Core/Configs/upp_defs.h index dad89f5..8e8669b 100644 --- a/UPP/Core/Configs/upp_defs.h +++ b/UPP/Core/Configs/upp_defs.h @@ -14,6 +14,7 @@ #define _UPP_DEFS_H_ #include "upp_config.h" + /** * @addtogroup UPP_HIGHLEVEL Defines for high-level * @ingroup UPP_DEFS diff --git a/UPP/Core/Inc/main.h b/UPP/Core/Inc/main.h index ad65e1f..885ffc6 100644 --- a/UPP/Core/Inc/main.h +++ b/UPP/Core/Inc/main.h @@ -81,8 +81,8 @@ void Error_Handler(void); #define angletim htim2 #define UM_LED_GREEN2_Pin GPIO_PIN_2 #define UM_LED_GREEN2_GPIO_Port GPIOE -#define CEN_O_Pin GPIO_PIN_3 -#define CEN_O_GPIO_Port GPIOE +#define CEN_Pin GPIO_PIN_3 +#define CEN_GPIO_Port GPIOE #define UM_ERR_5VD_Pin GPIO_PIN_4 #define UM_ERR_5VD_GPIO_Port GPIOE #define DO2_Pin GPIO_PIN_5 diff --git a/UPP/Core/Src/gpio.c b/UPP/Core/Src/gpio.c index dc31934..6746ace 100644 --- a/UPP/Core/Src/gpio.c +++ b/UPP/Core/Src/gpio.c @@ -55,7 +55,7 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOD_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOE, UM_LED_GREEN2_Pin|CEN_O_Pin|RDO3_Pin|UM_LED_RED_Pin + HAL_GPIO_WritePin(GPIOE, UM_LED_GREEN2_Pin|CEN_Pin|RDO3_Pin|UM_LED_RED_Pin |UM_LED_GREEN1_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ @@ -86,7 +86,7 @@ void MX_GPIO_Init(void) /*Configure GPIO pins : PEPin PEPin PEPin PEPin PEPin */ - GPIO_InitStruct.Pin = CEN_O_Pin|DO2_Pin|RDO3_Pin|UM_LED_RED_Pin + GPIO_InitStruct.Pin = CEN_Pin|DO2_Pin|RDO3_Pin|UM_LED_RED_Pin |UM_LED_GREEN1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; diff --git a/UPP/Core/UPP/upp_io.c b/UPP/Core/UPP/upp_io.c new file mode 100644 index 0000000..a8e4607 --- /dev/null +++ b/UPP/Core/UPP/upp_io.c @@ -0,0 +1,68 @@ +/** +****************************************************************************** +* @file upp_io.c +* @brief Входы/выходы УПП +****************************************************************************** +* @details +******************************************************************************/ +#include "upp_io.h" +#include "main.h" +UPP_DiscreteInputs_t UPP_DIN; +UPP_DiscreteOutputs_t UPP_DO; + + +void UPP_CEN_Write(int state) +{ + HAL_GPIO_WritePin(CEN_GPIO_Port, CEN_Pin, state); +} +void UPP_RDO1_Write(int state) +{ + HAL_GPIO_WritePin(RDO1_GPIO_Port, RDO1_Pin, state); +} +void UPP_RDO2_Write(int state) +{ + HAL_GPIO_WritePin(RDO2_GPIO_Port, RDO2_Pin, state); +} +void UPP_RDO3_Write(int state) +{ + HAL_GPIO_WritePin(RDO3_GPIO_Port, RDO3_Pin, state); +} +void UPP_RDO4_Write(int state) +{ + HAL_GPIO_WritePin(RDO4_GPIO_Port, RDO4_Pin, state); +} +void UPP_DO1_Write(int state) +{ + HAL_GPIO_WritePin(DO1_GPIO_Port, DO1_Pin, state); +} +void UPP_DO2_Write(int state) +{ + HAL_GPIO_WritePin(DO2_GPIO_Port, DO2_Pin, state); +} +void UPP_DO3_Write(int state) +{ + HAL_GPIO_WritePin(DO3_GPIO_Port, DO3_Pin, state); +} +void UPP_DO4_Write(int state) +{ + HAL_GPIO_WritePin(DO4_GPIO_Port, DO4_Pin, state); +} +void UPP_DO5_Write(int state) +{ + HAL_GPIO_WritePin(DO5_GPIO_Port, DO5_Pin, state); +} + + +void UPP_Connect_Discrete(void) +{ + UPP_DO.CEN = &UPP_CEN_Write; + UPP_DO.RDO_Error = &UPP_RDO1_Write; + UPP_DO.RDO_Work = &UPP_RDO2_Write; + UPP_DO.RDO_Ready = &UPP_RDO3_Write; + UPP_DO.RDO4_Reserved = &UPP_RDO4_Write; + UPP_DO.DO1_Reserved = &UPP_DO1_Write; + UPP_DO.DO2_Reserved = &UPP_DO2_Write; + UPP_DO.DO3_Reserved = &UPP_DO3_Write; + UPP_DO.DO4_Reserved = &UPP_DO4_Write; + UPP_DO.DO5_Reserved = &UPP_DO5_Write; +} diff --git a/UPP/Core/UPP/upp_io.h b/UPP/Core/UPP/upp_io.h new file mode 100644 index 0000000..cec4a15 --- /dev/null +++ b/UPP/Core/UPP/upp_io.h @@ -0,0 +1,51 @@ +/** +****************************************************************************** +* @file upp_io.h +* @brief Входы/выходы УПП +****************************************************************************** +* @details +******************************************************************************/ + +#ifndef _UPP_ERRORS_H +#define _UPP_ERRORS_H +#include "mylibs_include.h" + +typedef struct +{ + /* Отладочные светодиоды */ + GPIO_LEDTypeDef green1; + GPIO_LEDTypeDef green2; + GPIO_LEDTypeDef red; +}UPP_LEDs_t; +extern UPP_LEDs_t UPP_LEDS; + +typedef struct +{ + GPIO_SwitchTypeDef in1; + GPIO_SwitchTypeDef in2; + GPIO_SwitchTypeDef in3; + + GPIO_SwitchTypeDef err_24V; + GPIO_SwitchTypeDef err_5Vd; + GPIO_SwitchTypeDef err_5Vsi; +}UPP_DiscreteInputs_t; +extern UPP_DiscreteInputs_t UPP_DIN; + +typedef struct +{ + void (*CEN)(int state); + + void (*RDO_Error)(int state); + void (*RDO_Work)(int state); + void (*RDO_Ready)(int state); + void (*RDO4_Reserved)(int state); + + + void (*DO1_Reserved)(int state); + void (*DO2_Reserved)(int state); + void (*DO3_Reserved)(int state); + void (*DO4_Reserved)(int state); + void (*DO5_Reserved)(int state); +}UPP_DiscreteOutputs_t; +extern UPP_DiscreteOutputs_t UPP_DO; +#endif //_UPP_ERRORS_H \ No newline at end of file diff --git a/UPP/MDK-ARM/UPP.uvoptx b/UPP/MDK-ARM/UPP.uvoptx index a772821..e1d7eaf 100644 --- a/UPP/MDK-ARM/UPP.uvoptx +++ b/UPP/MDK-ARM/UPP.uvoptx @@ -476,6 +476,30 @@ 0 0 + + 2 + 23 + 1 + 0 + 0 + 0 + ..\Core\UPP\upp_io.c + upp_io.c + 0 + 0 + + + 2 + 24 + 5 + 0 + 0 + 0 + ..\Core\UPP\upp_io.h + upp_io.h + 0 + 0 + @@ -486,7 +510,7 @@ 0 3 - 23 + 25 1 0 0 @@ -498,7 +522,7 @@ 3 - 24 + 26 5 0 0 @@ -510,7 +534,7 @@ 3 - 25 + 27 1 0 0 @@ -522,7 +546,7 @@ 3 - 26 + 28 5 0 0 @@ -534,7 +558,7 @@ 3 - 27 + 29 1 0 0 @@ -546,7 +570,7 @@ 3 - 28 + 30 5 0 0 @@ -558,7 +582,7 @@ 3 - 29 + 31 1 0 0 @@ -570,7 +594,7 @@ 3 - 30 + 32 5 0 0 @@ -582,7 +606,7 @@ 3 - 31 + 33 1 0 0 @@ -594,7 +618,7 @@ 3 - 32 + 34 5 0 0 @@ -614,7 +638,7 @@ 0 4 - 33 + 35 1 0 0 @@ -626,7 +650,7 @@ 4 - 34 + 36 1 0 0 @@ -638,7 +662,7 @@ 4 - 35 + 37 1 0 0 @@ -650,7 +674,7 @@ 4 - 36 + 38 1 0 0 @@ -662,7 +686,7 @@ 4 - 37 + 39 1 0 0 @@ -674,7 +698,7 @@ 4 - 38 + 40 1 0 0 @@ -686,7 +710,7 @@ 4 - 39 + 41 1 0 0 @@ -698,7 +722,7 @@ 4 - 40 + 42 1 0 0 @@ -710,7 +734,7 @@ 4 - 41 + 43 1 0 0 @@ -722,7 +746,7 @@ 4 - 42 + 44 1 0 0 @@ -734,7 +758,7 @@ 4 - 43 + 45 1 0 0 @@ -746,7 +770,7 @@ 4 - 44 + 46 1 0 0 @@ -758,7 +782,7 @@ 4 - 45 + 47 1 0 0 @@ -778,7 +802,7 @@ 0 5 - 46 + 48 5 0 0 @@ -790,7 +814,7 @@ 5 - 47 + 49 5 0 0 @@ -802,7 +826,7 @@ 5 - 48 + 50 5 0 0 @@ -814,7 +838,7 @@ 5 - 49 + 51 5 0 0 @@ -826,7 +850,7 @@ 5 - 50 + 52 5 0 0 @@ -838,7 +862,7 @@ 5 - 51 + 53 5 0 0 @@ -850,7 +874,7 @@ 5 - 52 + 54 1 0 0 @@ -862,7 +886,7 @@ 5 - 53 + 55 5 0 0 @@ -882,7 +906,7 @@ 0 6 - 54 + 56 1 0 0 @@ -894,7 +918,7 @@ 6 - 55 + 57 1 0 0 @@ -906,7 +930,7 @@ 6 - 56 + 58 1 0 0 @@ -918,7 +942,7 @@ 6 - 57 + 59 1 0 0 @@ -930,7 +954,7 @@ 6 - 58 + 60 1 0 0 @@ -942,7 +966,7 @@ 6 - 59 + 61 1 0 0 @@ -954,7 +978,7 @@ 6 - 60 + 62 1 0 0 @@ -966,7 +990,7 @@ 6 - 61 + 63 1 0 0 @@ -978,7 +1002,7 @@ 6 - 62 + 64 1 0 0 @@ -990,7 +1014,7 @@ 6 - 63 + 65 1 0 0 @@ -1002,7 +1026,7 @@ 6 - 64 + 66 1 0 0 @@ -1014,7 +1038,7 @@ 6 - 65 + 67 1 0 0 @@ -1034,7 +1058,7 @@ 0 7 - 66 + 68 1 0 0 @@ -1046,7 +1070,7 @@ 7 - 67 + 69 1 0 0 @@ -1066,7 +1090,7 @@ 0 8 - 68 + 70 1 0 0 @@ -1078,7 +1102,7 @@ 8 - 69 + 71 1 0 0 @@ -1090,7 +1114,7 @@ 8 - 70 + 72 1 0 0 @@ -1102,7 +1126,7 @@ 8 - 71 + 73 1 0 0 @@ -1114,7 +1138,7 @@ 8 - 72 + 74 1 0 0 @@ -1134,7 +1158,7 @@ 0 9 - 73 + 75 1 0 0 @@ -1146,7 +1170,7 @@ 9 - 74 + 76 1 0 0 @@ -1158,7 +1182,7 @@ 9 - 75 + 77 1 0 0 @@ -1170,7 +1194,7 @@ 9 - 76 + 78 1 0 0 @@ -1182,7 +1206,7 @@ 9 - 77 + 79 1 0 0 @@ -1194,7 +1218,7 @@ 9 - 78 + 80 1 0 0 @@ -1206,7 +1230,7 @@ 9 - 79 + 81 1 0 0 @@ -1218,7 +1242,7 @@ 9 - 80 + 82 1 0 0 @@ -1230,7 +1254,7 @@ 9 - 81 + 83 1 0 0 @@ -1242,7 +1266,7 @@ 9 - 82 + 84 1 0 0 @@ -1254,7 +1278,7 @@ 9 - 83 + 85 1 0 0 @@ -1266,7 +1290,7 @@ 9 - 84 + 86 1 0 0 @@ -1278,7 +1302,7 @@ 9 - 85 + 87 1 0 0 @@ -1290,7 +1314,7 @@ 9 - 86 + 88 1 0 0 @@ -1302,7 +1326,7 @@ 9 - 87 + 89 1 0 0 @@ -1314,7 +1338,7 @@ 9 - 88 + 90 1 0 0 @@ -1326,7 +1350,7 @@ 9 - 89 + 91 1 0 0 @@ -1338,7 +1362,7 @@ 9 - 90 + 92 1 0 0 @@ -1350,7 +1374,7 @@ 9 - 91 + 93 1 0 0 @@ -1362,7 +1386,7 @@ 9 - 92 + 94 1 0 0 @@ -1374,7 +1398,7 @@ 9 - 93 + 95 1 0 0 @@ -1386,7 +1410,7 @@ 9 - 94 + 96 1 0 0 @@ -1398,7 +1422,7 @@ 9 - 95 + 97 1 0 0 @@ -1410,7 +1434,7 @@ 9 - 96 + 98 1 0 0 @@ -1430,7 +1454,7 @@ 0 10 - 97 + 99 1 0 0 @@ -1450,7 +1474,7 @@ 0 11 - 98 + 100 2 0 0 diff --git a/UPP/MDK-ARM/UPP.uvprojx b/UPP/MDK-ARM/UPP.uvprojx index 3da23b5..6f05408 100644 --- a/UPP/MDK-ARM/UPP.uvprojx +++ b/UPP/MDK-ARM/UPP.uvprojx @@ -500,6 +500,16 @@ 5 ..\Core\UPP\upp_params.h + + upp_io.c + 1 + ..\Core\UPP\upp_io.c + + + upp_io.h + 5 + ..\Core\UPP\upp_io.h + diff --git a/UPP/UPP.ioc b/UPP/UPP.ioc index 5ed5897..7006a63 100644 --- a/UPP/UPP.ioc +++ b/UPP/UPP.ioc @@ -317,7 +317,7 @@ PE2.Locked=true PE2.PinState=GPIO_PIN_SET PE2.Signal=GPIO_Output PE3.GPIOParameters=PinState,GPIO_Label -PE3.GPIO_Label=CEN_O +PE3.GPIO_Label=CEN PE3.Locked=true PE3.PinState=GPIO_PIN_SET PE3.Signal=GPIO_Output