123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- /* 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 -----------------------------------------------------------*/
- #define adc0_Pin GPIO_PIN_0
- #define adc0_GPIO_Port GPIOC
- #define adc1_Pin GPIO_PIN_1
- #define adc1_GPIO_Port GPIOC
- #define adc2_Pin GPIO_PIN_2
- #define adc2_GPIO_Port GPIOC
- #define input0_Pin GPIO_PIN_0
- #define input0_GPIO_Port GPIOA
- #define input1_Pin GPIO_PIN_1
- #define input1_GPIO_Port GPIOA
- #define input2_Pin GPIO_PIN_2
- #define input2_GPIO_Port GPIOA
- #define input3_Pin GPIO_PIN_3
- #define input3_GPIO_Port GPIOA
- #define input4_Pin GPIO_PIN_4
- #define input4_GPIO_Port GPIOA
- #define input5_Pin GPIO_PIN_5
- #define input5_GPIO_Port GPIOA
- #define input6_Pin GPIO_PIN_6
- #define input6_GPIO_Port GPIOA
- #define input7_Pin GPIO_PIN_7
- #define input7_GPIO_Port GPIOA
- #define kmg_Pin GPIO_PIN_0
- #define kmg_GPIO_Port GPIOB
- #define usart3_tx_Pin GPIO_PIN_10
- #define usart3_tx_GPIO_Port GPIOB
- #define usart3_rx_Pin GPIO_PIN_11
- #define usart3_rx_GPIO_Port GPIOB
- #define led_Pin GPIO_PIN_12
- #define led_GPIO_Port GPIOB
- #define usart1_tx_Pin GPIO_PIN_9
- #define usart1_tx_GPIO_Port GPIOA
- #define usart1_rx_Pin GPIO_PIN_10
- #define usart1_rx_GPIO_Port GPIOA
- #define output0_Pin GPIO_PIN_3
- #define output0_GPIO_Port GPIOB
- #define output1_Pin GPIO_PIN_4
- #define output1_GPIO_Port GPIOB
- #define output2_Pin GPIO_PIN_5
- #define output2_GPIO_Port GPIOB
- #define output3_Pin GPIO_PIN_6
- #define output3_GPIO_Port GPIOB
- /* 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 */
|