|

楼主 |
发表于 2021-10-31 16:38:19
|
显示全部楼层
非常难 为情,硬汉哥,没成功。再次麻烦硬汉哥指正。
我的IAP跳转程序是这样的 :
typedef void (*_func)(void);
__disable_irq();
/* MCU peripherals re-initial. */
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStruct.GPIO_Pin &= ~(GPIO_Pin_13 | GPIO_Pin_14); /* SWDIO/SWCLK */
GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_All;
GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_Init(GPIOD, &GPIO_InitStruct);
GPIO_Init(GPIOE, &GPIO_InitStruct);
GPIO_Init(GPIOF, &GPIO_InitStruct);
GPIO_Init(GPIOG, &GPIO_InitStruct);
GPIO_Init(GPIOH, &GPIO_InitStruct);
GPIO_Init(GPIOI, &GPIO_InitStruct);
/* reset systick */
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
/* disable all peripherals clock. */
RCC->AHB1ENR = (1<<20); /* 20: F4 CCMDAT ARAMEN. */
RCC->AHB2ENR = 0;
RCC->AHB3ENR = 0;
RCC->APB1ENR = 0;
RCC->APB2ENR = 0;
/* Switch to default cpu clock. */
RCC->CFGR = 0;
} /* MCU peripherals re-initial. */
/* Disable MPU */
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
/* disable and clean up all interrupts. */
{
int i;
for(i = 0; i < 8; i++)
{
/* disable interrupts. */
NVIC->ICER[i] = 0xFFFFFFFF;
/* clean up interrupts flags. */
NVIC->ICPR[i] = 0xFFFFFFFF;
}
}
// /* Set new vector table pointer */
SCB->VTOR = FLASH_APP1_ADDR;
// /* reset register values */
__set_BASEPRI(0);
__set_FAULTMASK(0);
// /* set up MSP and switch to it */
__set_MSP(*(uint32_t*)FLASH_APP1_ADDR);
__set_PSP(*(uint32_t*)FLASH_APP1_ADDR);
__set_CONTROL(0);
// /* ensure what we have done could take effect */
__ISB();
__disable_irq();
//
//
RCC_AHB2PeriphResetCmd(RCC_AHB2Periph_OTG_FS, ENABLE);
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, DISABLE);
//RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS_ULPI, DISABLE);
RCC_AHB2PeriphResetCmd(RCC_AHB2Periph_OTG_FS, DISABLE);
// /* never return */
((_func)(*(uint32_t*)(FLASH_APP1_ADDR + 4)))();
APP 程序是跳转正常,就是无法检测到U盘插入。
这个写法对么?
|
|