/* 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) 2023 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 "stdio.h" #include "string.h" #include "iap.h" /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ /* USER CODE BEGIN ET */ extern void __set_FAULTMASK(uint32_t faultMask); #define iap_ 1 #if 1 #define IR_ROM1 0x8000000 #else #define IR_ROM1 0x8020000 #endif /* USER CODE END ET */ /* Exported constants --------------------------------------------------------*/ /* USER CODE BEGIN EC */ /* USER CODE END EC */ /* Exported macro ------------------------------------------------------------*/ /* USER CODE BEGIN EM */ extern uint16_t initial_address; extern int nameLength; extern int sizeLength ; extern int md5Length; extern uint32_t System_version; // 定义数组大小 #define ARRAY_SIZE 1024 /* USER CODE END EM */ /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); /* USER CODE BEGIN EFP */ uint16_t read_flash_16(uint32_t addr); void read_new_address(uint32_t addr); void Write_Information(uint32_t addr, uint8_t* rx_buffer, uint8_t buffer_index); void ModBus(void); void receive_modbus_9_1(uint16_t addr, uint8_t funcode, uint16_t startaddr, uint16_t reg, uint8_t byteNum); void receive_modbus_4(uint16_t addr, uint8_t funcode); void clear_buf(void); void erase_flash(uint32_t ADDR_FLASH); uint32_t read_flash_32(uint32_t addr); /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ /* USER CODE BEGIN Private defines */ #define FILTER_LENGTH 10 #define DEBOUNCE_COUNT 10 #define Modbus 1 #define addr_FLASH_ADDR ((uint32_t)0x8070000) // address #define pbstatus_FLASH_ADDR ((uint32_t)0x8070800) // PbStatus #define baudrate_FLASH_ADDR ((uint32_t)0x8071000) // Baudrate #define ADC1_FLASH_ADDR ((uint32_t)0x8071800) // Adc2_Calibration 4-20mA #define ADC2_FLASH_ADDR ((uint32_t)0x8072000) // Adc3_Calibration 4-20mA #define SYSVERSION_ADDR ((uint32_t)0x8072800) #define CURaddr_PACKAGE_ADDR ((uint32_t)0x8073000) #define VERSION_ADDR ((uint32_t)0x8074000) #define LENGTH_ADDR ((uint32_t)0x8074800) #define MD5_ADDR ((uint32_t)0x8075000) /* USER CODE END Private defines */ #ifdef __cplusplus } #endif #endif /* __MAIN_H */