app_loader.c 905 B

1234567891011121314151617181920212223242526272829
  1. #include "app_loader.h"
  2. void IAP_Init(void)
  3. {
  4. #if (STM32F103 == 1)
  5. #ifdef VECT_TAB_SRAM
  6. SCB->VTOR = SRAM_BASE | NEW_VECTOR_OFFSET; /* Vector Table Relocation in Internal SRAM. */
  7. #else
  8. SCB->VTOR = FLASH_BASE | NEW_VECTOR_OFFSET; /* Vector Table Relocation in Internal FLASH. */
  9. #endif
  10. #elif (STM32F072 == 1)
  11. /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
  12. uint32_t i = 0;
  13. /* Copy the vector table from the Flash (mapped at the base of the application
  14. load address 0x08003000) to the base address of the SRAM at 0x20000000. */
  15. for(i = 0; i < 48; i++)
  16. {
  17. *((uint32_t*)(NEW_VECTOR_ADDRESS + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
  18. }
  19. /* Enable the SYSCFG peripheral clock*/
  20. __HAL_RCC_SYSCFG_CLK_ENABLE();
  21. /* Remap SRAM at 0x00000000 */
  22. __HAL_SYSCFG_REMAPMEMORY_SRAM();
  23. #endif
  24. }