参考stm32的库,很简单。如下:
/**
* @brief Configures Output GPIO.
* @param Led: Specifies the Led to be configured.
* This parameter can be one of following parameters:
* @arg DEBUGLED
* @arg LEDSERV
* @retval None
*/
void OutPortInit(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); //注意这个AFIO时钟一定要打开,否则JTAG REMAP无效
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); //JTAG关闭,SWD使能
//INIT DebugLed
RCC_APB2PeriphClockCmd(DebugLed_GPIO_CLK, ENABLE);
GPIO_InitStructure.GPIO_Pin = DebugLed_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(DebugLed_GPIO_PORT, &GPIO_InitStructure);
} |