思路:1.时钟使能(开启GPIOA端口时钟使能) 2.GPIO配置(推挽输出模式,频率,速度等) 3.GPIO输出高电平(输出置位)
STM32F4:
推挽输出,输出低电平灯亮,输出高电平灯灭.
#include <stm32f4xx.h>
void Delay(__IO uint32_t nCount){
while(nCount--);
}
void GPIO_Con(){
GPIO_InitTypeDef GPIO_Struct;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE);
GPIO_Struct.GPIO_Pin=GPIO_Pin_9;
GPIO_Struct.GPIO_Mode=GPIO_Mode_OUT;
GPIO_Struct.GPIO_Speed=GPIO_Speed_100MHz;
GPIO_Struct.GPIO_OType=GPIO_OType_PP;
GPIO_Struct.GPIO_PuPd=GPIO_PuPd_UP;
GPIO_Init(GPIOF,&GPIO_Struct);
}
int main(void){
GPIO_Con();
while(1){
GPIO_