By default, PB4 is a JTAG pin and placed in pull mode, so it cannot be used as a normal I/O port. You can reuse it in SWD boot method, then PB4 can”save
1 (rcc_apb2periph_gpiob | rcc_apb2periph_gpioc | rcc_apb2periph_afio, enable);
When a port is restarted, the reuse function clock must include: rcc_apb2periph_afio
2. GPIO_REMAP_SWJ_DISABLE SWJ full disabled (JTAG-DP + SW-DP) currently PA13 | PA14 | PA15 | PB3 | PB4 can be used as a normal input mode.
To reserve some debug ports, GPIO_REMAP_SWJ_DISABLE can also have the following two modes:
3. GPIO_REMAP_SWJ_JTAGDISABLE JTAG-DISALTED AND SW-DP ACCEST.
4. gpio_remap_swj_nojtrsttrstfull SWJ on (JTAG-DP + SW-DP) but with JTGRST.
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, enable);
// PB4 is used as the default test port. If it is used as a normal I/O unit, you need to add the following two sentences
RCC_APB2PeriphClockCmd (RCC_APB2Periph_AFIO, enable),
GPIO_Pin aRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE),
GPIO_InitStructure. GPIO_Pin a = GPIO_Pin a_4 | GPIO_Pin a_5;
GPIO_InitStructure. GPIO_Speed = GPIO_Speed_50MHz;
gpio_initstruction. gpio_mode = gpio_mode_out_pp; // press exit
GPIO_Init(GPIOB, & GPIO_InitStructure);