app_loader.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. }
  25. MCU_Manufacturter_Struct_t IdentifyMCUManufacturer( void )
  26. {
  27. MCU_Manufacturter_Struct_t manufacturer = STM32F103RBT6;
  28. if( (*(uint8_t *)0xE00FFFD0 == 0x05)&&(*(uint8_t *)0xE00FFFE0 == 0x9B)&&(*(uint8_t *)0xE00FFFE4 == 0x52)&&(*(uint8_t *)0xE00FFFE8 == 0x05) ) //2̨ÑéÖ¤ÕýÈ·
  29. {
  30. manufacturer = HK32F103RBT6;
  31. }
  32. else if( (*(uint8_t *)0xE00FFFD0 == 0x04)&&(*(uint8_t *)0xE00FFFE0 == 0xC3)&&(*(uint8_t *)0xE00FFFE4 == 0xB4)&&(*(uint8_t *)0xE00FFFE8 == 0x0B) ) //4̨ÑéÖ¤ÕýÈ·
  33. {
  34. manufacturer = APM32F103RBT6;
  35. }
  36. else if( (*(uint8_t *)0xE00FFFD0 == 0x00)&&(*(uint8_t *)0xE00FFFE0 == 0x10)&&(*(uint8_t *)0xE00FFFE4 == 0x04)&&(*(uint8_t *)0xE00FFFE8 == 0x0A) ) //4̨ÑéÖ¤ÕýÈ·
  37. {
  38. manufacturer = STM32F103RBT6;
  39. }
  40. else if( (*(uint32_t *)0xE0042000) == 0x13030410 ) //2̨ÑéÖ¤ÕýÈ·
  41. {
  42. manufacturer = GD32F103RBT6;
  43. }
  44. else
  45. {
  46. manufacturer = NoName;
  47. }
  48. return manufacturer;
  49. }