INflash.h 1.0 KB

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