stmflash.h 1.1 KB

123456789101112131415161718192021222324252627
  1. #ifndef __STMFLASH_H__
  2. #define __STMFLASH_H__
  3. #include "sys.h"
  4. #include "stdint.h"
  5. //////////////////////////////////////////////////////////////////////////////////////////////////////
  6. //用户根据自己的需要设置
  7. #define STM32_FLASH_SIZE 256 //所选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. u16 STMFLASH_ReadHalfWord(u32 faddr); //读出半字
  14. void STMFLASH_WriteLenByte(u32 WriteAddr,u32 DataToWrite,u16 Len); //指定地址开始写入指定长度的数据
  15. u32 STMFLASH_ReadLenByte(u32 ReadAddr,u16 Len); //指定地址开始读取指定长度数据
  16. void STMFLASH_Write(u32 WriteAddr,u16 *pBuffer,u16 NumToWrite); //从指定地址开始写入指定长度的数据
  17. void STMFLASH_Read(u32 ReadAddr,u16 *pBuffer,u16 NumToRead); //从指定地址开始读出指定长度的数据
  18. //测试写入
  19. void Test_Write(u32 WriteAddr,u16 WriteData);
  20. #endif