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