| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 | 
							- #include "at32f403a_407.h"
 
- #include "at32f403a_407_board.h"
 
- #include "at32f403a_407_clock.h"
 
- #include "common_config.h"
 
- #include "FreeRTOS.h"
 
- #include "task.h"
 
- #include "queue.h"
 
- #include "semphr.h"
 
- #include "usb_eth.h"
 
- #include "mux.h"
 
- #include "misc.h"
 
- #include "spi_common.h"
 
- #include "extended_sram.h"
 
- #include "modbus.h"
 
- #include "common_gpio.h"
 
- #include "io.h"
 
- #include "input.h"
 
- #include "wdt.h"
 
- #include <stdio.h>
 
- #include <stdbool.h>
 
- #include <string.h>
 
- // 
 
- void jump_to_app(uint32_t address);
 
- void (*pftarget)(void);
 
- int main()
 
- {
 
-     nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
 
-   
 
-     system_clock_config();
 
-     delay_init();
 
-     
 
-     uart_print_init(115200);
 
-     
 
-     printf("IAP starting...\r\n");
 
-     
 
-     printf("Go to main FW\r\n");
 
-     
 
-     jump_to_app(0x08021000);
 
-     
 
- #if 0    
 
-     // Check if valid stack address (RAM address) then jump to user application
 
-     if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFD0000) == 0x20000000) {
 
-         jump_to_app(0x08021000); 
 
-     } else {
 
-         // Флеш пустая, нечего загружать, висим в аварийном режиме 
 
-         printf("\n\rFW empty. Started bootloader\n\r");
 
-     }
 
- #endif    
 
-     
 
-     while (1) {}
 
- }
 
- // 
 
- void jump_to_app(uint32_t address)
 
- {
 
-     uint32_t stkptr, jumpaddr;
 
-     stkptr = *(uint32_t *)address;
 
-     jumpaddr = *(uint32_t *)(address + sizeof(uint32_t));
 
-     
 
-     __set_MSP(stkptr);
 
-     pftarget = (void (*) (void))jumpaddr;
 
-     pftarget();
 
- }
 
 
  |