最小的IAP程序,只执行跳转到APP程序,跳不过去。
#define APP_START_ADDRESS 0x08008000
typedef void (*pFunction)(void);
void JumpToApplication(__IO uint32_t Addr)
{
pFunction Jump_To_Application;
__IO uint32_t JumpAddress;
/* Test if user code is programmed starting from address "ApplicationAddress" */
if (((*(__IO uint32_t*)Addr) & 0x2FF00000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (Addr + 4);
Jump_To_Application = (pFunction) JumpAddress;
__set_MSP(*(__IO uint32_t*)Addr);
Jump_To_Application();
}
}
/*********************************************************************************************************
** Function name: Run_App
** Descriptions: 跳转到APP运行
** input parameters: 无
** Output parameters: 无
** Returned value: 无
*********************************************************************************************************/
void Run_App(void)
{
if((*((uint32_t *)APP_START_ADDRESS)!=0xFFFFFFFF))//运行APP
{
JumpToApplication(APP_START_ADDRESS);
}
}
int main(void)
{
while (1){
Run_App();/*跳转到APP运行*/
}
}
|