找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4006|回复: 4
打印 上一主题 下一主题
收起左侧

HC32F460的IAP例程与资料

  [复制链接]
跳转到指定楼层
楼主
这是华大的HC32F460的IAP例程,供大家参考。


以上资料下载: hc32f460_iap资料.7z (3.11 MB, 下载次数: 203)
  1. /*******************************************************************************
  2. * Include files
  3. ******************************************************************************/
  4. #include "iap.h"
  5. #include "basic.h"
  6. #include "flash.h"
  7. #include "uart.h"
  8. #include "modem.h"
  9. #include "User_Timer.h"

  10. /*******************************************************************************
  11. * Local type definitions ('typedef')
  12. ******************************************************************************/

  13. /*******************************************************************************
  14. * Local pre-processor symbols/macros ('#define')
  15. ******************************************************************************/

  16. /*******************************************************************************
  17. * Global variable definitions (declared in header file with 'extern')
  18. ******************************************************************************/
  19. uint32_t JumpAddress;
  20. func_ptr_t JumpToApplication;

  21. /*******************************************************************************
  22. * Local function prototypes ('static')
  23. ******************************************************************************/
  24. static en_result_t IAP_JumpToApp(uint32_t u32Addr);
  25. static void IAP_ResetConfig(void);

  26. /*******************************************************************************
  27. * Local variable definitions ('static')
  28. ******************************************************************************/

  29. /*******************************************************************************
  30. * Function implementation - global ('extern') and local ('static')
  31. ******************************************************************************/
  32. /**
  33. *******************************************************************************
  34. ** \brief Initialize IAP
  35. **
  36. ** \param [in] None
  37. **
  38. ** \retval None
  39. **
  40. ******************************************************************************/
  41. void IAP_Init(void)
  42. {
  43.     SystemClock_Init();
  44.     LED_Init();
  45.     UART_Init();
  46. }

  47. /**
  48. *******************************************************************************
  49. ** \brief UART receive byte.
  50. **
  51. ** \param [out] u8RxData                   Pointer to Rx data.
  52. **
  53. ** \retval Ok                              Receive data finished.
  54. ** \retval Error                           Don't receive data.
  55. **
  56. ******************************************************************************/
  57. void IAP_Main(void)
  58. {
  59.     uint32_t u32AppFlag;
  60.     en_result_t enRet;

  61.     while (1)
  62.     {
  63.         enRet = Modem_Process(BOOT_WAIT_TIME);
  64.         if ((enRet == Ok) || (enRet == ErrorTimeout))
  65.         {
  66.             u32AppFlag = *(__IO uint32_t *)BOOT_PARA_ADDRESS;
  67.             if ((0xFFFF != u32AppFlag))
  68.             {
  69.                 if (Error == IAP_JumpToApp(APP_ADDRESS))
  70.                 {
  71.                     LED0_OFF();
  72.                     LED1_ON();   
  73.                 }
  74.             }
  75.             else
  76.             {
  77.                 LED0_ON();
  78.                 LED1_ON();
  79.             }
  80.         }
  81.         else
  82.         {
  83.             LED1_OFF();
  84.             LED0_ON();
  85.         }
  86.     }
  87. }

  88. /**
  89. *******************************************************************************
  90. ** \brief IAP main function
  91. **
  92. ** \param [in] u32Addr                     APP address
  93. **
  94. ** \retval Error                           APP address error
  95. **
  96. ******************************************************************************/
  97. static en_result_t IAP_JumpToApp(uint32_t u32Addr)
  98. {
  99.     uint32_t u32StackTop = *((__IO uint32_t *)u32Addr);

  100.     /* Check if user code is programmed starting from address "u32Addr" */
  101.     /* Check stack top pointer. */
  102.     if ((u32StackTop > SRAM_BASE) && (u32StackTop <= (SRAM_BASE + RAM_SIZE)))
  103.     {
  104.         IAP_ResetConfig();
  105.         /* Jump to user application */
  106.         JumpAddress = *(__IO uint32_t *)(u32Addr + 4);
  107.         JumpToApplication = (func_ptr_t)JumpAddress;
  108.         /* Initialize user application's Stack Pointer */
  109.         __set_MSP(*(__IO uint32_t *)u32Addr);
  110.         JumpToApplication();
  111.     }

  112.     return Error;
  113. }

  114. /**
  115. *******************************************************************************
  116. ** \brief Boot reset configure
  117. **
  118. ** \param [in] None
  119. **
  120. ** \retval None
  121. **
  122. ******************************************************************************/
  123. static void IAP_ResetConfig(void)
  124. {
  125.     LED_DeInit();
  126.     UART_DeInit();
  127.     Timer_DeInit();
  128.     SystemClock_DeInit();
  129. }

  130. /******************************************************************************
  131. * EOF (not truncated)
  132. *****************************************************************************/
复制代码


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏4 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:94968 发表于 2021-9-2 16:49 | 只看该作者
好资料,51黑有你更精彩!!!
回复

使用道具 举报

板凳
ID:7861 发表于 2022-3-31 16:28 | 只看该作者
感谢感谢,找了很久终于找到了
回复

使用道具 举报

地板
ID:1021750 发表于 2022-4-26 09:53 | 只看该作者
这个资料在哪里找的啊?我去官网都没找到
回复

使用道具 举报

5#
ID:398504 发表于 2023-3-13 22:01 | 只看该作者
感谢,,,,马上下载来研究研究
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表