STM32 HAL库禁用调试

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); //开启AFIO时钟
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);//使能JTAGDisable,即禁用JTAG接口

常见的禁用选项:
  *     @arg GPIO_Remap_SWJ_NoJTRST      : Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST
  *     @arg GPIO_Remap_SWJ_JTAGDisable  : JTAG-DP Disabled and SW-DP Enabled
  *     @arg GPIO_Remap_SWJ_Disable      : Full SWJ Disabled (JTAG-DP + SW-DP)
//stm32f1 HAL库禁用调试
    	__HAL_RCC_GPIOA_CLK_ENABLE();
        __HAL_RCC_GPIOB_CLK_ENABLE();  //可能要有
        __HAL_RCC_GPIOF_CLK_ENABLE();  //可能要有
        __HAL_RCC_AFIO_CLK_ENABLE();

        __HAL_AFIO_REMAP_SWJ_DISABLE();
        __HAL_AFIO_REMAP_SWJ_NOJTAG();

        GPIO_Initure.Pin   = GPIO_PIN_15;
        GPIO_Initure.Mode  = GPIO_MODE_OUTPUT_PP;
        GPIO_Initure.Pull  = GPIO_PULLUP;
        GPIO_Initure.Speed = GPIO_SPEED_FREQ_HIGH;
        HAL_GPIO_Init(GPIOA, &GPIO_Initure);

你可能感兴趣的:(STM32)