四旋翼无人机从0到1的实现(十六)无人机MCU驱动→GPIO

Author:家有仙妻谢掌柜
Date:2021/2/18

今年会更新一个系列,小四轴无人机从功能设计→思维导图→原理图设计→PCBLayout→焊接PCB→程序代码的编写→整机调试一系列,以此记录自己的成长历程!
这个小四轴无人机是大学时期学习制作的,加上现在工作学习对嵌入式的理解更加深入,因此想要重新梳理一下小四轴,之后在此基础上实现大四轴的飞控设计,这些都将在工作之余完成!

//小四轴无人机设计,需要LED灯作为提示

#include "GPIO.h"
/*******************************************************************************
 * fuction	Led_gpio_init    
 * brief	gpio配置初始化
 * param	无
 * return	无
 *******************************************************************************/  
void Led_gpio_init(void)
{
    
    
	GPIO_InitTypeDef  GPIO_InitStructure;	
	/*开启引脚时钟*/
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC|RCC_AHBPeriph_GPIOB|RCC_AHBPeriph_GPIOD, ENABLE);//开的是IO口的时钟
	/*引脚的配置PPC15/PB4/PB2/PD8*/
	/*引脚的配置PC*/
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_Init(GPIOC,&GPIO_InitStructure);		
	/*引脚的配置PB*/
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_2;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_Init(GPIOB,&GPIO_InitStructure);		
  /*引脚的配置PD*/
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_Init(GPIOD,&GPIO_InitStructure);		
}
#ifndef _GPIO_H__
#define _GPIO_H__

#include "board_define.h"

//void uart1_init(void);
void Led_gpio_init(void);

#endif

猜你喜欢

转载自blog.csdn.net/FutureStudio1994/article/details/113854666