flash.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. ******************************************************************************
  3. * @file FLASH.h
  4. * @author
  5. * @brief Header for flash.c module
  6. ******************************************************************************
  7. *
  8. ******************************************************************************
  9. */
  10. /* Define to prevent recursive inclusion -------------------------------------*/
  11. #ifndef __FLASH_H
  12. #define __FLASH_H
  13. /* Includes ------------------------------------------------------------------*/
  14. #include "bsp.h"
  15. /* Exported types ------------------------------------------------------------*/
  16. /* Exported macro ------------------------------------------------------------*/
  17. /* Base address of the Flash sectors */
  18. #define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
  19. #define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
  20. #define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
  21. #define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */
  22. #define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */
  23. #define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
  24. #define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
  25. #define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */
  26. #define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbytes */
  27. #define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbytes */
  28. #define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbytes */
  29. #define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbytes */
  30. /* Exported constants --------------------------------------------------------*/
  31. #define FLASH_USER_START_ADDR ADDR_FLASH_SECTOR_11 /* Start @ of user Flash area */
  32. #define FLASH_USER_PAGE_SIZE 0x20000
  33. #define FLASH_USER_END_ADDR ADDR_FLASH_SECTOR_11 + FLASH_USER_PAGE_SIZE -1 /* End @ of user Flash area : sector start address + sector size -1 */
  34. #define FLASH_BUFFER_SIZE 0x0800
  35. #define DATA1_32 ((uint32_t)0x12345678)
  36. #define DATA2_32 ((uint32_t)0x87654321)
  37. #define FLASH_SETTING_ADDRESS(x) ((x)+FLASH_USER_START_ADDR)
  38. /* Exported functions ------------------------------------------------------- */
  39. //int ProgramFlashPage(uint32_t startaddress, uint32_t endaddress, uint32_t data);
  40. int ProgramFlashPage(uint32_t startAddress, const uint8_t* data, uint32_t len);
  41. int EraseFlashProgram(uint32_t startaddress, uint32_t length);
  42. int WriteData2FlashProgram(uint32_t startaddress, const uint8_t* data, uint32_t length);
  43. int FinishFlashProgram(uint32_t startaddress, uint32_t length);
  44. void SetFlashWriteProtect(void);
  45. void ClearFlashWriteProtect(void);
  46. void SetFlashReadProtect(void);
  47. void SetBORLevel(void);
  48. #endif /* __FLASH_H */
  49. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/