st_flash.h 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef __ST_FLASH_H__
  2. #define __ST_FLASH_H__
  3. #include <stm32f10x.h>
  4. //FLASH起始地址
  5. #define STM32_FLASH_BASE 0x08000000 //STM32 FLASH的起始地址
  6. //FLASH解锁键值
  7. #define FLASH_KEY1 0X45670123
  8. #define FLASH_KEY2 0XCDEF89AB
  9. #define __ST_FLASH_SIZE *((vu16*)(0x1FFFF7E0))
  10. //FLASH 扇区的起始地址
  11. #define ST_FLASH_SECTOR_0 ((u32)0x08000000) //扇区0起始地址, 24 Kbytes
  12. #define ST_FLASH_SECTOR_2 ((u32)0x08006000) //扇区1起始地址, 16 Kbytes
  13. #define ST_FLASH_SECTOR_3 ((u32)0x0800A000) //扇区2起始地址, 4 Kbytes
  14. #define ST_FLASH_SECTOR_5 ((u32)0x0800B000) //扇区3起始地址, 16 Kbytes
  15. void st_flash_unlock(void);
  16. void st_flash_lock(void);
  17. int st_flash_error_no(void);
  18. int st_flash_wait_done(int time);
  19. int st_flash_erase_secotr(uint8_t sector_no);
  20. int st_flash_write_flash_word(uint32_t faddr, uint32_t pdata);
  21. uint32_t st_flash_read_word(uint32_t faddr);
  22. uint8_t st_flash_addr_to_sector_no(uint32_t addr);
  23. void st_flash_read(uint32_t addr,uint32_t *buffer,uint32_t length);
  24. int st_flash_write(uint32_t addr,uint32_t *buffer,uint32_t length);
  25. #endif