/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.h * @brief : Header for main.c file. * This file contains the common defines of the application. ****************************************************************************** * @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 __MAIN_H #define __MAIN_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include #include /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ /* USER CODE BEGIN ET */ /* USER CODE END ET */ /* Exported constants --------------------------------------------------------*/ /* USER CODE BEGIN EC */ /* USER CODE END EC */ /* Exported macro ------------------------------------------------------------*/ /* USER CODE BEGIN EM */ // 基准年份 #define XTELL_BASE_YEAR 2026 /** * 宏定义:3-4-5-4 固件版本编码 * y: Year (2026-2033) * m: Month (1-12) * d: Day (1-31) * b: Build (0-15) */ #define MAKE_XTELL_CODE(y, m, d, b) ( \ ((( (y) - XTELL_BASE_YEAR ) & 0x07) << 13) | \ (((m) & 0x0F) << 9) | \ (((d) & 0x1F) << 4) | \ (((b) & 0x0F) << 0) \ ) // 举例:2026年3月19日,第10次编译 (b=9) // 计算过程: (0 << 13) | (3 << 9) | (19 << 4) | 9 = 0x0600 | 0x0130 | 0x0009 #define XTELL_FIRMWARE_CODE MAKE_XTELL_CODE(2026, 5, 10, 1) // ---- - -- - // | | | | // | | | 编译次数 // | | 日 // | 月 // 年 #ifndef USE_W5500 #define USE_W5500 1 /* 默认启用W5500以太网模块 */ #endif #ifndef USE_RS485 #define USE_RS485 1 /* 默认启用RS485通信模块 */ #endif #ifndef USE_IO_MONITOR #define USE_IO_MONITOR 1 /* 启用IO监控与心跳上报 */ #endif /* ========================================================= 🚀 核心协议常量定义 (RF433) ========================================================= */ #define PROTO_START_BYTE 0xAA #define PROTO_TYPE_IO 0x10 #define PROTO_TYPE_NET 0x55 #define PROTO_TYPE_485 0x48 #define PROTO_TYPE_HB 0xAA /* ========================================================= 🚀 核心身份标识:烧录不同设备时,请务必修改这个数字! 比如:设备A烧录时改为 0x01,设备B烧录时改为 0x02 ========================================================= */ #define MY_DEVICE_ID 101 /* ========================================================= 🚀 开发调试开关 TEST_A701: - 1: 测试环境 (A701室/本地测试),使用 192.168.6.x 网段 - 0: 生产环境 (实船/现场部署),使用 192.168.0.x 网段 ========================================================= */ #define TEST_A701 0 /* USER CODE END EM */ /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ #define M0_Pin GPIO_PIN_7 #define M0_GPIO_Port GPIOA #define M1_Pin GPIO_PIN_0 #define M1_GPIO_Port GPIOB #define AUX_Pin GPIO_PIN_1 #define AUX_GPIO_Port GPIOB #define RESET_Pin GPIO_PIN_2 #define RESET_GPIO_Port GPIOB #define W5500_CS_Pin GPIO_PIN_12 #define W5500_CS_GPIO_Port GPIOB #define W5500_RESET_Pin GPIO_PIN_8 #define W5500_RESET_GPIO_Port GPIOA #define RL_Control_Pin GPIO_PIN_15 #define RL_Control_GPIO_Port GPIOA #define LED_RX_Pin GPIO_PIN_3 #define LED_RX_GPIO_Port GPIOB #define MCU_DI1_Pin GPIO_PIN_4 #define MCU_DI1_GPIO_Port GPIOB #define MCU_DI2_Pin GPIO_PIN_5 #define MCU_DI2_GPIO_Port GPIOB #define MCU_DI3_Pin GPIO_PIN_6 #define MCU_DI3_GPIO_Port GPIOB #define MCU_DI4_Pin GPIO_PIN_7 #define MCU_DI4_GPIO_Port GPIOB #define LED_TX_Pin GPIO_PIN_9 #define LED_TX_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ void gpio_led_tx_on(void); void gpio_led_tx_off(void); void gpio_led_rx_on(void); void gpio_led_rx_off(void); void systick_interrupt_1ms_callback(void); void systick_set_user_timeout( uint32_t time_ms ); uint32_t systick_get_user_timeout(void); void uart1_rx_timeout_1ms_callback(void); bool uart1_check_rx_done( uint8_t *buffer , uint32_t *length ); /* USER CODE END Private defines */ #ifdef __cplusplus } #endif #endif /* __MAIN_H */