drv_chipFlash.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef _CHIPFLASH_H_
  2. #define _CHIPFLASH_H_
  3. #include "stdint.h"
  4. //#include "drv_ec800k.h"
  5. #include "stm32l4xx_hal.h"
  6. //芯片大小 256kb
  7. #define CHIPFLASH_SIZE 256
  8. //#define FLASH_BASE ((uint32_t)0x08000000)
  9. #if CHIPFLASH_SIZE < 256
  10. #define SECTOR_SIZE 1024 //byte
  11. #else
  12. #define SECTOR_SIZE 2048 //byte
  13. #endif
  14. extern uint32_t cur_address;
  15. //应用程序起始地址
  16. #define APPLICATION_ADDRESS (uint32_t)0x08008000
  17. //固件标志位信息地址
  18. #define SET_ADDRESS (APPLICATION_ADDRESS - SECTOR_SIZE)
  19. #define SET_RESET_ADDRESS (APPLICATION_ADDRESS - 2*SECTOR_SIZE)
  20. //设备CONFIG地址
  21. //#define BASE_CONFIG_ADDR (0x0801FC00 - SECTOR_SIZE)
  22. #define USER_FLASH_END_ADDR 0x0803FFFF
  23. //有效验证位
  24. #define AVAILABLE_FLAG (unsigned int)0xA88A
  25. //extern BASE_CONFIG base_config;
  26. //extern unsigned short ipaFlag;
  27. uint16_t FLASH_ReadHalfWord(uint32_t address);
  28. uint64_t FLASH_ReadDoubleWord(uint32_t address);
  29. int FLASH_ReadMoreData(uint32_t startAddress, uint64_t *readData, uint32_t countToRead);
  30. int FLASH_ErasePage(uint32_t StartPage, uint32_t PageNumber);
  31. void erasure_bin_flash(void);
  32. int FLASH_Write_DoubleWord(volatile uint32_t FlashAddress, uint64_t *WriteData, uint16_t DataLength);
  33. #endif