main.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.h
  5. * @brief : Header for main.c file.
  6. * This file contains the common defines of the application.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2023 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __MAIN_H
  22. #define __MAIN_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32f1xx_hal.h"
  28. /* Private includes ----------------------------------------------------------*/
  29. /* USER CODE BEGIN Includes */
  30. #include "stdio.h"
  31. #include "string.h"
  32. #include "Data_deal.h"
  33. #include "iap.h"
  34. #include "md5c.h"
  35. #include "stmflash.h"
  36. /* USER CODE END Includes */
  37. /* Exported types ------------------------------------------------------------*/
  38. /* USER CODE BEGIN ET */
  39. #define iap_ 1
  40. #if 1
  41. #define IR_ROM1 0x08000000
  42. #else
  43. #define IR_ROM1 0x08020000
  44. #endif
  45. /* USER CODE END ET */
  46. /* Exported constants --------------------------------------------------------*/
  47. /* USER CODE BEGIN EC */
  48. /* USER CODE END EC */
  49. /* Exported macro ------------------------------------------------------------*/
  50. /* USER CODE BEGIN EM */
  51. #define Rx_Max 1024
  52. #define Version_sys 0x23060800
  53. extern uint16_t Adc2_CalibrationValue ;
  54. extern uint16_t Adc3_CalibrationValue ;
  55. extern uint8_t gpioaStatus ;
  56. extern uint8_t gpiobStatus ;
  57. extern uint8_t Rx_Flag;
  58. extern uint16_t Rx_Len;
  59. extern uint8_t Rx_Buf[Rx_Max];
  60. extern int data_lengthU2;
  61. extern int flagU2Rx;
  62. /* USER CODE END EM */
  63. /* Exported functions prototypes ---------------------------------------------*/
  64. void Error_Handler(void);
  65. /* USER CODE BEGIN EFP */
  66. uint16_t read_flash_16(uint32_t addr);
  67. void read_new_address(uint32_t addr);
  68. void Write_Information(uint32_t addr, uint8_t* rx_buffer, uint8_t buffer_index);
  69. void delay_sys_us(uint32_t Delay);
  70. void ModBus(void);
  71. /* USER CODE END EFP */
  72. /* Private defines -----------------------------------------------------------*/
  73. /* USER CODE BEGIN Private defines */
  74. #define FILTER_LENGTH 10
  75. #define DEBOUNCE_COUNT 10
  76. #define Modbus 1
  77. #define ADDR_FLASH_PAGE_94 ((uint32_t)0x802F000) // Flash扇区94页的起始地址 address
  78. #define ADDR_FLASH_PAGE_104 ((uint32_t)0x8034000) // Flash扇区104页的起始地址 PbStatus
  79. #define ADDR_FLASH_PAGE_114 ((uint32_t)0x8039000) // Flash扇区114页的起始地址 Baudrate
  80. #define ADDR_FLASH_PAGE_124 ((uint32_t)0x803E000) // Flash扇区124页的起始地址 Adc2_Calibration 4-20mA
  81. #define ADDR_FLASH_PAGE_134 ((uint32_t)0x8043000) // Flash扇区134页的起始地址 Adc3_Calibration 4-20mA
  82. #define ADDR_FLASH_PAGE_144 ((uint32_t)0x8048000) // Flash扇区144页的起始地址
  83. #define ADDR_UPDATE_FLAG 0x0807F078
  84. #define StartMode_Addr 0x0807F07A
  85. #define Application_Buffer_Addr 0x08040000
  86. #define ADD_UPDATE_PROG 0x08020000
  87. #define ADD_UPDATE_PROG1 0x08000000
  88. /* USER CODE END Private defines */
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif /* __MAIN_H */