flash(1202).h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef _FLASH_H_
  2. #define _FLASH_H_
  3. /* includes ----------------------------------------------------------*/
  4. #include "stm32f1xx_hal.h"
  5. #include "FreeRTOS.h"
  6. #include "task.h"
  7. /* typedef -----------------------------------------------------------*/
  8. typedef struct{
  9. uint8_t updateFlag; // 更新标志
  10. uint8_t pageNumMove; // 需要进行搬移的flash页的数量
  11. uint16_t b; // 预留
  12. uint32_t jumpAddr; // 跳转地址
  13. }param_boot;
  14. extern param_boot s_param_boot;
  15. /* define ------------------------------------------------------------*/
  16. #define APP1_ADDRESS ((unsigned int)0x8002800U) // 0x8002800-0x8040C00 250k 程序运行区
  17. #define APP2_ADDRESS ((unsigned int)0x8041000U) // 0x8040C00-0x807F000 248k 下载备份区
  18. #define PARAM_ADDRESS ((unsigned int)0x807F000U) // 0x807F000-0x80800000 4k
  19. /* macro -------------------------------------------------------------*/
  20. /* variables ---------------------------------------------------------*/
  21. /* function prototypes -----------------------------------------------*/
  22. // @brief 参数区数据读取
  23. void Read_ParamArea(void);
  24. // @brief 向量重映射
  25. void Remap_Vector_Table(void);
  26. // @brief flash按字写入
  27. HAL_StatusTypeDef FLASH_Write(uint32_t address, uint32_t *data, uint32_t length);
  28. // @brief 写参数区数据
  29. void Write_paramArea(void);
  30. // @brief flash按页擦除
  31. HAL_StatusTypeDef FLASH_Erase(uint32_t start_address, uint32_t number_of_pages);
  32. // @brief flash读数据
  33. void FLASH_Read(uint32_t address, uint32_t *read_buf, uint32_t length);
  34. #endif