INflash.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __INFLASH_H
  2. #define __INFLASH_H
  3. #include "CONFIG.h"
  4. #include "sys.h"
  5. //FLASH起始地址
  6. #define STM32_FLASH_BASE 0x08000000 //STM32 FLASH的起始地址
  7. #define STM32_FLASH_SIZE FLASH_SIZE //所选STM32的FLASH容量大小(单位为K)
  8. #define STM32_FLASH_WREN 1 //使能FLASH写入(0,不是能;1,使能)
  9. /* STM32F103扇区大小 */
  10. #if STM32_FLASH_SIZE < 256
  11. #define STM32_SECTOR_SIZE 1024 /* 容量小于256K的F103, 扇区大小为1K字节 */
  12. #else
  13. #define STM32_SECTOR_SIZE 2048 /* 容量大于等于256K的F103, 扇区大小为2K字节 */
  14. #endif
  15. //(现在是512页的stm32 f103ZE)
  16. #define FLASH_SAVE_ADDR SAVE_ADDR //设置FLASH 保存地址(必须为偶数,且其值要大于本代码所占用FLASH的大小+0X08000000)
  17. void store(void);
  18. void clearflash(void);
  19. void STMFLASH_Read(uint32_t ReadAddr,uint16_t *pBuffer,uint16_t NumToRead);
  20. //结构体存储数组
  21. #pragma pack(1)
  22. typedef struct{
  23. char deviceSecret[40];
  24. char productKey[20];
  25. char deviceName[20];
  26. uint8_t read_flag;//判断存flash是否成功,从flash读取值为1代表成功
  27. }Coefficient_Data;
  28. #pragma pack()
  29. #endif