flash(3910).h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #if 0 // PYJ.2019.08.30_BEGIN --
  2. /*
  3. * flash.h
  4. *
  5. * Created on: 2019. 7. 4.
  6. * Author: parkyj
  7. */
  8. #ifndef FLASH_H_
  9. #define FLASH_H_
  10. #include "main.h"
  11. #include "CRC16.h"
  12. #define FLASH_USER_START_ADDR ((uint32_t)0x08004000)
  13. #define FLASH_USER_END_ADDR FLASH_USER_START_ADDR + ((uint32_t)0x000FFFF) /* End @ of user Flash area */
  14. #define APPLICATION_ADDRESS (uint32_t)0x08004000 /* Start user code address: ADDR_FLASH_PAGE_8 */
  15. #define FirmwareUpdataAck 0x11
  16. #define FirmwareUpdataNak 0x22
  17. #define FirmwareUpdateDelay 50
  18. #endif /* FLASH_H_ */
  19. #else
  20. /**
  21. ******************************************************************************
  22. * @file STM32F2xx_IAP/inc/flash_if.h
  23. * @author MCD Application Team
  24. * @version V1.0.0
  25. * @date 02-May-2011
  26. * @brief This file provides all the headers of the flash_if functions.
  27. ******************************************************************************
  28. * @attention
  29. *
  30. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  31. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  32. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  33. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  34. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  35. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  36. *
  37. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  38. ******************************************************************************
  39. */
  40. /* Define to prevent recursive inclusion -------------------------------------*/
  41. #ifndef __FLASH_IF_H
  42. #define __FLASH_IF_H
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f2xx.h"
  45. #include "main.h"
  46. #include "CRC16.h"
  47. /* Exported types ------------------------------------------------------------*/
  48. #define FLASH_USER_START_ADDR ((uint32_t)0x08004000)
  49. #define FLASH_USER_END_ADDR FLASH_USER_START_ADDR + ((uint32_t)0x000FFFF) /* End @ of user Flash area */
  50. #define APPLICATION_ADDRESS (uint32_t)0x08004000 /* Start user code address: ADDR_FLASH_PAGE_8 */
  51. #define FirmwareUpdataAck 0x11
  52. #define FirmwareUpdataNak 0x22
  53. #define FirmwareUpdateDelay 50
  54. /* Exported constants --------------------------------------------------------*/
  55. /* Base address of the Flash sectors */
  56. #define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbyte */
  57. #define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbyte */
  58. #define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbyte */
  59. #define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbyte */
  60. #define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbyte */
  61. #define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbyte */
  62. #define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbyte */
  63. #define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbyte */
  64. #define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbyte */
  65. #define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbyte */
  66. #define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbyte */
  67. #define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbyte */
  68. /* End of the Flash address */
  69. #define USER_FLASH_END_ADDRESS 0x080FFFFF
  70. /* Define the user application size */
  71. #define USER_FLASH_SIZE (USER_FLASH_END_ADDRESS - APPLICATION_ADDRESS + 1)
  72. /* Define the address from where user application will be loaded.
  73. Note: the 1st sector 0x08000000-0x08003FFF is reserved for the IAP code */
  74. #define APPLICATION_ADDRESS (uint32_t)0x08004000
  75. /* Exported macro ------------------------------------------------------------*/
  76. /* Exported functions ------------------------------------------------------- */
  77. void FLASH_If_Init(void);
  78. uint32_t FLASH_If_Erase(uint32_t StartSector);
  79. uint32_t FLASH_If_Write(__IO uint32_t* FlashAddress, uint32_t* Data, uint16_t DataLength);
  80. uint16_t FLASH_If_GetWriteProtectionStatus(void);
  81. uint32_t FLASH_If_DisableWriteProtection(void);
  82. #endif /* __FLASH_IF_H */
  83. /*******************(C)COPYRIGHT 2011 STMicroelectronics *****END OF FILE******/
  84. #endif // PYJ.2019.08.30_END --