133 lines
3.9 KiB
C
133 lines
3.9 KiB
C
/* 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 <stdbool.h>
|
||
#include <stdio.h>
|
||
/* 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 */
|
||
|
||
#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 0x02
|
||
/* 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 */
|