main.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 "iap.h"
  33. /* USER CODE END Includes */
  34. /* Exported types ------------------------------------------------------------*/
  35. /* USER CODE BEGIN ET */
  36. extern void __set_FAULTMASK(uint32_t faultMask);
  37. #define iap_ 1
  38. #if 1
  39. #define IR_ROM1 0x8000000
  40. #else
  41. #define IR_ROM1 0x8020000
  42. #endif
  43. /* USER CODE END ET */
  44. /* Exported constants --------------------------------------------------------*/
  45. /* USER CODE BEGIN EC */
  46. /* USER CODE END EC */
  47. /* Exported macro ------------------------------------------------------------*/
  48. /* USER CODE BEGIN EM */
  49. extern uint16_t initial_address;
  50. extern int nameLength;
  51. extern int sizeLength ;
  52. extern int md5Length;
  53. extern uint32_t System_version;
  54. // ¶¨ÒåÊý×é´óС
  55. #define ARRAY_SIZE 1024
  56. /* USER CODE END EM */
  57. /* Exported functions prototypes ---------------------------------------------*/
  58. void Error_Handler(void);
  59. /* USER CODE BEGIN EFP */
  60. uint16_t read_flash_16(uint32_t addr);
  61. void read_new_address(uint32_t addr);
  62. void Write_Information(uint32_t addr, uint8_t* rx_buffer, uint8_t buffer_index);
  63. void ModBus(void);
  64. void receive_modbus_9_1(uint16_t addr, uint8_t funcode, uint16_t startaddr, uint16_t reg, uint8_t byteNum);
  65. void receive_modbus_4(uint16_t addr, uint8_t funcode);
  66. void clear_buf(void);
  67. void erase_flash(uint32_t ADDR_FLASH);
  68. uint32_t read_flash_32(uint32_t addr);
  69. /* USER CODE END EFP */
  70. /* Private defines -----------------------------------------------------------*/
  71. /* USER CODE BEGIN Private defines */
  72. #define FILTER_LENGTH 10
  73. #define DEBOUNCE_COUNT 10
  74. #define Modbus 1
  75. #define addr_FLASH_ADDR ((uint32_t)0x8070000) // address
  76. #define pbstatus_FLASH_ADDR ((uint32_t)0x8070800) // PbStatus
  77. #define baudrate_FLASH_ADDR ((uint32_t)0x8071000) // Baudrate
  78. #define ADC1_FLASH_ADDR ((uint32_t)0x8071800) // Adc2_Calibration 4-20mA
  79. #define ADC2_FLASH_ADDR ((uint32_t)0x8072000) // Adc3_Calibration 4-20mA
  80. #define SYSVERSION_ADDR ((uint32_t)0x8072800)
  81. #define CURPACKAGE_ADDR ((uint32_t)0x8073000)
  82. #define CURADDRESS_ADDR ((uint32_t)0x8073800)
  83. #define VERSION_ADDR ((uint32_t)0x8074000)
  84. #define LENGTH_ADDR ((uint32_t)0x8074800)
  85. #define MD5_ADDR ((uint32_t)0x8075000)
  86. /* USER CODE END Private defines */
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif /* __MAIN_H */