參考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);
} |