以下代码配置GPIOA的第0号引脚为推挽输出模式 使用低电平进行点亮LED
#include "stm32f10x.h" // Device header
int main(void)
{
//启动APB时钟控制 这里配置的是GPIOA
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
//初始化参数
GPIO_InitTypeDef GPIO_InitStructure;
//设置结构体参数
//设置输出模式 这里是推挽输出
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//设置引脚 这里设置的是0号引脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
//设置输出速度
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//传入参数
GPIO_Init(GPIOA, &GPIO_InitStructure);
while(1)
{
//输出低电平
GPIO_ResetBits(GPIOA,GPIO_Pin_0);
}
}
//最后一行一一定要留空行
评论 (0)