leaf_ota.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __LEAF_OTA_H_
  2. #define __LEAF_OTA_H_
  3. #include "main.h"
  4. /* 开关全局中断的宏 */
  5. #define ENABLE_INT() __set_PRIMASK(0) /* 使能全局中断 */
  6. #define DISABLE_INT() __set_PRIMASK(1) /* 禁止全局中断 */
  7. #define PageSize 1024 //1K
  8. #define Appear_si 128
  9. /*=====用户配置(根据自己的分区进行配置)=====*/
  10. #define BootLoader_Size 0xA000 ///< BootLoader的大小 40K
  11. #define Appear_Size 0x6000 ///< BootLoader的大小 40K
  12. #define Application_Size 0x20000 ///< 应用程序的大小 128K
  13. //#define Application_1_Addr 0x08010000 ///< 应用程序1的首地址
  14. //#define Application_2_Addr 0x08030000 ///< 应用程序2的首地址
  15. //#define Application_2_Addr 0x08017FFF ///< 应用程序2的首地址
  16. #define Application_1_Addr ADDR_FLASH_SECTOR_0 ///< 应用程序1的首地址
  17. #define Application_2_Addr ADDR_FLASH_SECTOR_6 ///< 应用程序2的首地址
  18. #define Application_Buffer_Addr ADDR_FLASH_SECTOR_7 ///< 接收到的文件存储区
  19. /*==========================================*/
  20. #define StartMode_Addr ADDR_FLASH_SECTOR_4 ///< 应用程序2的首地址
  21. /* 启动选项 */
  22. #define Startup_Normal 0xFFFFFFFF ///< 正常启动 跳转到APP1
  23. #define Startup_Update 0xAAAAAAAA ///< 升级再启动
  24. #define Startup_Reset 0x5555AAAA ///< ***恢复出厂 目前没使用***
  25. #define Startup_APP2 0x5555BBBB ///< ***跳转到APP2***
  26. /* Base address of the Flash sectors */
  27. #define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base address of Sector 0, 32 Kbytes */
  28. #define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08008000) /* Base address of Sector 1, 32 Kbytes */
  29. #define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08010000) /* Base address of Sector 2, 32 Kbytes */
  30. #define ADDR_FLASH_SECTOR_3 ((uint32_t)0x08018000) /* Base address of Sector 3, 32 Kbytes */
  31. #define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08020000) /* Base address of Sector 4, 128 Kbytes */
  32. #define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08040000) /* Base address of Sector 5, 256 Kbytes */
  33. #define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08080000) /* Base address of Sector 6, 256 Kbytes */
  34. #define ADDR_FLASH_SECTOR_7 ((uint32_t)0x080C0000) /* Base address of Sector 7, 256 Kbytes */
  35. void Start_BootLoader(void);
  36. uint8_t Erase_page(uint32_t pageaddr, uint32_t num);
  37. void WriteFlash2(uint32_t addr, uint32_t *buff, int word_size);
  38. #endif