Advertisement

使用库函数控制流水灯(基于STM32)

阅读量:

LED.h

复制代码
 #ifndef __LED_H

    
 #define __LED_H
    
  
    
 void LED_init();
    
  
    
 #endif
    
    
    
    

led.c

复制代码
 #include "led.h"

    
 #include "stm32f10x.h"
    
  
    
 void LED_init()
    
 {
    
   GPIO_InitTypeDef GPIO_InitStructA;
    
   GPIO_InitTypeDef GPIO_InitStructD;//定义两个初始化GPIO的结构体
    
   
    
 	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
    
 	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);//使能相关时钟
    
   
    
   //设定初始化数据
    
 	GPIO_InitStructA.GPIO_Mode=GPIO_Mode_Out_PP;//设置推挽输出
    
 	GPIO_InitStructA.GPIO_Pin=GPIO_Pin_8;//引脚

全部评论 (0)

还没有任何评论哟~