GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO, ENABLE);
/**********************
1.执行端口重映射时,复用功能时钟得使能:RCC_APB2Periph_AFIO
2. &1.GPIO_Remap_SWJ_Disable: !< Full SWJ Disabled (JTAG-DP + SW-DP)
此时PA13|PA14|PA15|PB3|PB4都可作为普通IO用了
为了保存某些调试端口,GPIO_Remap_SWJ_Disable也可选择为下面两种模式:
&2.GPIO_Remap_SWJ_JTAGDisable: !< JTAG-DP Disabled and SW-DP Enabled
此时PA15|PB3|PB4可作为普通IO用了
&3.GPIO_Remap_SWJ_NoJTRST: !< Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST
此时只有PB4可作为普通IO用了
**********************/
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE); //使能禁止JTAG
//初始化GPIOB 推挽输出
GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_3|GPIO_Pin_4);
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB, GPIO_Pin_3|GPIO_Pin_4);
//初始化GPIOA 推挽输出
GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_SetBits(GPIOA, GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
|