flash.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef __FLASH_H__
  2. #define __FLASH_H__
  3. #include "stm32f10x.h"
  4. #include "stm32f10x_flash.h"
  5. //////////////////////////////////////////////////////////////////////////////////////////////////////
  6. //用户根据自己的需要设置
  7. #define STM32_FLASH_SIZE 128 //所选STM32的FLASH容量大小(单位为K)
  8. #define STM32_FLASH_WREN 1 //使能FLASH写入(0,不是能;1,使能)
  9. //////////////////////////////////////////////////////////////////////////////////////////////////////
  10. //FLASH起始地址
  11. #define STM32_FLASH_BASE 0x08000000 //STM32 FLASH的起始地址
  12. //FLASH解锁键值
  13. //#define RDP_Key ((uint16_t)0x00A5)
  14. //#define FLASH_KEY1 ((uint32_t)0x45670123)
  15. //#define FLASH_KEY2 ((uint32_t)0xCDEF89AB)
  16. u16 STMFLASH_ReadHalfWord(u32 faddr); //读出半字
  17. //void STMFLASH_WriteLenByte(u32 WriteAddr,u32 DataToWrite,u16 Len); //指定地址开始写入指定长度的数据
  18. //u32 STMFLASH_ReadLenByte(u32 ReadAddr,u16 Len); //指定地址开始读取指定长度数据
  19. //void STMFLASH_Write(u32 WriteAddr,u16 *pBuffer,u16 NumToWrite); //从指定地址开始写入指定长度的数据
  20. void STMFLASH_Read(u32 ReadAddr,u16 *pBuffer,u16 NumToRead); //从指定地址开始读出指定长度的数据
  21. void WritePageData(unsigned long WriteAddr,unsigned char *pData,unsigned short DataLen);
  22. void ReadFlashData(unsigned long ReadAddr,unsigned char *pData,unsigned short DataLen);
  23. //测试写入
  24. //void Test_Write(u32 WriteAddr,u16 WriteData);
  25. #endif