找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2835|回复: 2
收起左侧

STM32F4xx官方IAP源码

[复制链接]
ID:622511 发表于 2019-10-11 20:07 | 显示全部楼层 |阅读模式
STM32F4xx官方IAP源码

单片机源程序如下:
  1. /* Includes ------------------------------------------------------------------*/
  2. #include "menu.h"
  3. #include "stm324xg_eval.h"

  4. /* Private typedef -----------------------------------------------------------*/
  5. /* Private define ------------------------------------------------------------*/
  6. /* Private macro -------------------------------------------------------------*/
  7. /* Private variables ---------------------------------------------------------*/
  8. extern pFunction Jump_To_Application;
  9. extern uint32_t JumpAddress;

  10. /* Private function prototypes -----------------------------------------------*/
  11. static void IAP_Init(void);

  12. /* Private functions ---------------------------------------------------------*/

  13. /**
  14.   * @brief  Main program.
  15.   * @param  None
  16.   * @retval None
  17.   */
  18. int main(void)
  19. {
  20.   /* Unlock the Flash Program Erase controller */
  21.   FLASH_If_Init();

  22.   /* Initialize Key Button mounted on STM324xG-EVAL board */
  23.   STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO);

  24.   /* Test if Key push-button on STM324xG-EVAL Board is pressed */
  25.   if (STM_EVAL_PBGetState(BUTTON_KEY) == 0x00)
  26.   {
  27.     /* Execute the IAP driver in order to reprogram the Flash */
  28.     IAP_Init();
  29.     /* Display main menu */
  30.     Main_Menu ();
  31.   }
  32.   /* Keep the user application running */
  33.   else
  34.   {
  35.     /* Test if user code is programmed starting from address "APPLICATION_ADDRESS" */
  36.     if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
  37.     {
  38.       /* Jump to user application */
  39.       JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
  40.       Jump_To_Application = (pFunction) JumpAddress;
  41.       /* Initialize user application's Stack Pointer */
  42.       __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
  43.       Jump_To_Application();
  44.     }
  45.   }

  46.   while (1)
  47.   {}
  48. }

  49. /**
  50.   * @brief  Initialize the IAP: Configure USART.
  51.   * @param  None
  52.   * @retval None
  53.   */
  54. void IAP_Init(void)
  55. {
  56. USART_InitTypeDef USART_InitStructure;

  57.   /* USART resources configuration (Clock, GPIO pins and USART registers) ----*/
  58.   /* USART configured as follow:
  59.         - BaudRate = 115200 baud  
  60.         - Word Length = 8 Bits
  61.         - One Stop Bit
  62.         - No parity
  63.         - Hardware flow control disabled (RTS and CTS signals)
  64.         - Receive and transmit enabled
  65.   */
  66.   USART_InitStructure.USART_BaudRate = 115200;
  67.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  68.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  69.   USART_InitStructure.USART_Parity = USART_Parity_No;
  70.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  71.   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  72.   STM_EVAL_COMInit(COM1, &USART_InitStructure);
  73. }

  74. #ifdef USE_FULL_ASSERT
  75. /**
  76.   * @brief  Reports the name of the source file and the source line number
  77.   *         where the assert_param error has occurred.
  78.   * @param  file: pointer to the source file name
  79.   * @param  line: assert_param error line source number
  80.   * @retval None
  81.   */
  82. void assert_failed(uint8_t* file, uint32_t line)
  83. {
  84.   /* User can add his own implementation to report the file name and line number,
  85.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  86.   /* Infinite loop */
  87.   while (1)
  88.   {
  89.   }
  90. }
  91. #endif

  92. /**
  93.   * @}
  94.   */

  95. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
复制代码

所有资料51hei提供下载:
STM32F4xx_AN3965_V1.0.0.7z (1.07 MB, 下载次数: 60)
回复

使用道具 举报

ID:565307 发表于 2020-7-2 15:17 | 显示全部楼层
这个实例是在官方哪儿下载的
回复

使用道具 举报

ID:606388 发表于 2020-9-11 15:00 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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