燕建军 8 mēneši atpakaļ
vecāks
revīzija
ac503a6070

+ 11 - 0
Core/Inc/led.h

@@ -0,0 +1,11 @@
+/*
+date:2024
+*/
+//
+// Created by DELL on 2024/10/22.
+//
+
+#ifndef GMV_GATEWAY_BOARD_LED_H
+#define GMV_GATEWAY_BOARD_LED_H
+
+#endif //GMV_GATEWAY_BOARD_LED_H

+ 52 - 0
Core/Inc/tim.h

@@ -0,0 +1,52 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    tim.h
+  * @brief   This file contains all the function prototypes for
+  *          the tim.c file
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2024 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __TIM_H__
+#define __TIM_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+extern TIM_HandleTypeDef htim2;
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_TIM2_Init(void);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIM_H__ */
+

+ 1 - 1
Core/Src/ffx_master.c

@@ -97,7 +97,7 @@ _Noreturn void ffx_mater_task(void *pv) {
                         osDelay(300);
                         sync_ac_status(&ffxStatus);
                         is_error_ffx[i] = 0;
-                        error_count ++;
+                        error_count = 0;
                     } else{
                         error_count++;
                         if(error_count >= 10){

+ 6 - 0
Core/Src/led.c

@@ -0,0 +1,6 @@
+/*
+date:2024
+*/
+//
+// Created by DELL on 2024/10/22.
+//

+ 111 - 0
Core/Src/tim.c

@@ -0,0 +1,111 @@
+/* USER CODE BEGIN Header */
+/**
+  ******************************************************************************
+  * @file    tim.c
+  * @brief   This file provides code for the configuration
+  *          of the TIM instances.
+  ******************************************************************************
+  * @attention
+  *
+  * Copyright (c) 2024 STMicroelectronics.
+  * All rights reserved.
+  *
+  * This software is licensed under terms that can be found in the LICENSE file
+  * in the root directory of this software component.
+  * If no LICENSE file comes with this software, it is provided AS-IS.
+  *
+  ******************************************************************************
+  */
+/* USER CODE END Header */
+/* Includes ------------------------------------------------------------------*/
+#include "tim.h"
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+TIM_HandleTypeDef htim2;
+
+/* TIM2 init function */
+void MX_TIM2_Init(void)
+{
+
+  /* USER CODE BEGIN TIM2_Init 0 */
+
+  /* USER CODE END TIM2_Init 0 */
+
+  TIM_ClockConfigTypeDef sClockSourceConfig = {0};
+  TIM_MasterConfigTypeDef sMasterConfig = {0};
+
+  /* USER CODE BEGIN TIM2_Init 1 */
+
+  /* USER CODE END TIM2_Init 1 */
+  htim2.Instance = TIM2;
+  htim2.Init.Prescaler = 71;
+  htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
+  htim2.Init.Period = 3360-1;
+  htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+  htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+  if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
+  if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
+  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+  if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
+  {
+    Error_Handler();
+  }
+  /* USER CODE BEGIN TIM2_Init 2 */
+
+  /* USER CODE END TIM2_Init 2 */
+
+}
+
+void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
+{
+
+  if(tim_baseHandle->Instance==TIM2)
+  {
+  /* USER CODE BEGIN TIM2_MspInit 0 */
+
+  /* USER CODE END TIM2_MspInit 0 */
+    /* TIM2 clock enable */
+    __HAL_RCC_TIM2_CLK_ENABLE();
+
+    /* TIM2 interrupt Init */
+    HAL_NVIC_SetPriority(TIM2_IRQn, 5, 0);
+    HAL_NVIC_EnableIRQ(TIM2_IRQn);
+  /* USER CODE BEGIN TIM2_MspInit 1 */
+
+  /* USER CODE END TIM2_MspInit 1 */
+  }
+}
+
+void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
+{
+
+  if(tim_baseHandle->Instance==TIM2)
+  {
+  /* USER CODE BEGIN TIM2_MspDeInit 0 */
+
+  /* USER CODE END TIM2_MspDeInit 0 */
+    /* Peripheral clock disable */
+    __HAL_RCC_TIM2_CLK_DISABLE();
+
+    /* TIM2 interrupt Deinit */
+    HAL_NVIC_DisableIRQ(TIM2_IRQn);
+  /* USER CODE BEGIN TIM2_MspDeInit 1 */
+
+  /* USER CODE END TIM2_MspDeInit 1 */
+  }
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */

BIN
cmake-build-debug-mingw/.ninja_deps


+ 4 - 0
cmake-build-debug-mingw/.ninja_log

@@ -177,3 +177,7 @@
 330	932	7525813112903170	gmv-gateway-board.elf	96c62e9a0ba4e015
 7	358	7525813690756953	CMakeFiles/gmv-gateway-board.elf.dir/Core/Src/modbus_slave.c.obj	28c1ac30baf35eca
 359	930	7525813694277687	gmv-gateway-board.elf	96c62e9a0ba4e015
+4	341	7525822280420163	CMakeFiles/gmv-gateway-board.elf.dir/Core/Src/ffx_master.c.obj	bb3f9e6aaffc9871
+342	925	7525822283792773	gmv-gateway-board.elf	96c62e9a0ba4e015
+5	400	7525823261687892	CMakeFiles/gmv-gateway-board.elf.dir/Core/Src/ffx_master.c.obj	bb3f9e6aaffc9871
+400	1029	7525823265639536	gmv-gateway-board.elf	96c62e9a0ba4e015

BIN
cmake-build-debug-mingw/CMakeFiles/gmv-gateway-board.elf.dir/Core/Src/ffx_master.c.obj


+ 67 - 0
readme.md

@@ -0,0 +1,67 @@
+## 网关通信主控板
+
+### 脑图
+
+![](doc/gateway.png)
+
+### 外设说明
+
+* 分风箱主板通讯:uart2
+* 五恒主板通讯:uart3
+* mini_gateway_board:uart4
+* 调试串口:uart1
+
+### 通讯从站配置
+
+| 模块名称               | 从站地址 | 通讯口   |
+|--------------------|------|-------|
+| 分风箱主板              | 1~15 | uart2 |
+| mini_gateway_board | 1    | uart4 |         | 10   | uart3 |
+
+### 运行逻辑
+
+主板上电后,首先搜索各内机是否存在,如果存在,则读取各内机从站站号,并写入寄存器中;
+读取内机信息包括:开关机状态、模式、风速、内机编码、故障码。
+轮询mini_gateway_board,读出对应故障码,用于维护和调试;湿度下限:40018,湿度上限:40019。
+
+> 当有任意一台内机开机时,向五恒模块同步开机
+
+### 故障码逻辑
+
+1、读取mini_gateway_board故障码,如果故障码为0,则认为无故障,否则认为有故障,并记录故障码,并写入寄存器40020,40021,40022,40023,40024,40025,40026,40027,40028,40029,40030,40031,40032,40033,40034,40035,40036,40037,40038,40039,40040,40041,40042,40043,40044,40045,40046,40047,40048,40049,40050,40051,40052,40053,40054,对应故障码为0,则表示无故障,对应故障码为1,则表示有故障
+
+### 485通讯协议
+
+| 寄存器地址 | 数据含义        | 访问类型 | 范围值                                                |
+|-------|-------------|------|----------------------------------------------------|
+| 40001 | 电源状态        | RW   | 0x01: 开;0x00:关                                     |
+| 40002 | 当前运行模式      | RW   | 0x00:制冷模式;0x01:制热模式;0x02:除湿模式;0x03:送风模式;0x04:加湿模式; |
+| 40003 | 预留          | RW   | 预留                                                 |
+| 40004 | 预留          | RW   | 预留                                                 |
+| 40005 | 风速档位          | RW   | 1-5:代表一至五档;0x00:停止                                                 |
+| 40006 | 预留        | RW    | 预留                                 |
+| 40007 | 预留          | R    | 预留                                                 |
+| 40008 | 预留          | R    | 预留                                                 |
+| 40009 | 预留          | R    | 预留                                                 |
+| 40010 | 预留          | R    | 预留                                                 |
+| 40011 | 内机1~8状态     | RW   | 右到左按位,1为有,0为无;                                     |
+| 40012 | 内机9~16状态    | RW   | 右到左按位,1为有,0为无;                                     |
+| 40013 | 预留          | RW   | 预留                                                 |
+| 40014 | 预留          | RW   | 预留                                                 |
+| 40015 | 预留          | RW   | 预留                                                 |
+| 40016 | 设定温度        | R    | 16-30℃                                             |
+| 40017 | 预留          | R    | 预留                                                 |
+| 40018 | 加湿湿度下限      | R    | 0~100%                                             |
+| 40019 | 加湿湿度上限      | R    | 0~100%                                             |
+| 40020 | 预留          | R    | 预留                                                 |
+| 40021 | 网关485/CAN故障 | R    | 0:无故障;1:有故障;                                       |  
+| 40022 | 分风箱485故障    | R    | 0:无故障; 1111 1111:对应内机1~8有故障;                       |
+| 40023 | 内机组总故障      | R    | 0:无故障;1:有故障;                                       |
+| 40024 | 故障信息        | R    | 0:无故障;1:有故障;                                       |
+| 40025 | 故障信息        | R    | 0:无故障;1:有故障;                                       |
+| 40026 | 故障信息        | R    | 0:无故障;1:有故障;                                       |
+| 40027 | 故障信息        | R    | 0:无故障;1:有故障;                                       |
+| 40028 | 故障信息        | R    | 0:无故障;1:有故障;                                       |
+| 40029 | 故障信息        | R    | 0:无故障;1:有故障;                                       |
+
+