main.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /* USER CODE END Includes */
  33. /* Exported types ------------------------------------------------------------*/
  34. /* USER CODE BEGIN ET */
  35. /* USER CODE END ET */
  36. /* Exported constants --------------------------------------------------------*/
  37. /* USER CODE BEGIN EC */
  38. /* USER CODE END EC */
  39. /* Exported macro ------------------------------------------------------------*/
  40. /* USER CODE BEGIN EM */
  41. extern uint8_t receive_buffer[300]; // 定义接收缓存,这里假设最多可以接收100个字节
  42. extern uint8_t flag ;
  43. extern uint16_t Adc2_CalibrationValue ;
  44. extern uint16_t Adc3_CalibrationValue ;
  45. extern uint8_t gpioaStatus ;
  46. extern uint8_t gpiobStatus ;
  47. /* USER CODE END EM */
  48. /* Exported functions prototypes ---------------------------------------------*/
  49. void Error_Handler(void);
  50. /* USER CODE BEGIN EFP */
  51. uint16_t read_flash_16(uint32_t flash_address);
  52. void read_new_address_from_flash(uint32_t flash_address);
  53. void erase_flash(uint32_t ADDR_FLASH);
  54. void write_flash_address(uint8_t* rx_buffer);
  55. void write_flash_PbStatus(uint8_t* rx_buffer);
  56. void write_flash_autoAdc(uint32_t ADDR_FLASH);
  57. void CoverADC(uint32_t ADDR);
  58. void write_flash_Baudrate(uint8_t* rx_buffer);
  59. /* USER CODE END EFP */
  60. /* Private defines -----------------------------------------------------------*/
  61. /* USER CODE BEGIN Private defines */
  62. #define FILTER_LENGTH 20
  63. #define Modbus 1
  64. #define ADDR_FLASH_PAGE_61 ((uint32_t)0x0800A000) // Flash扇区61的起始地址 address
  65. #define ADDR_FLASH_PAGE_62 ((uint32_t)0x0800C000) // Flash扇区62的起始地址 PbStatus
  66. #define ADDR_FLASH_PAGE_63 ((uint32_t)0x0800E000) // Flash扇区63的起始地址 Baudrate
  67. #define ADDR_FLASH_PAGE_64 ((uint32_t)0x0800EC00) // Flash扇区64的起始地址 Adc2_Calibration 4-20mA
  68. #define ADDR_FLASH_PAGE_65 ((uint32_t)0x0800F000) // Flash扇区65的起始地址 Adc3_Calibration 4-20mA
  69. #define ADDR_FLASH_PAGE_66 ((uint32_t)0x0800FC00) // Flash扇区66的起始地址
  70. /* USER CODE END Private defines */
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif /* __MAIN_H */