GeekIMU/2.Firmware/STM32/Firmware/driver/gpio.c

57 lines
2.1 KiB
C
Raw Normal View History

2024-11-09 21:39:20 +08:00
/******************** (C) COPYRIGHT 2020 GEEKIMU *******************************
* File Name : gpio.c
* Current Version : V2.0 & ST 3.5.0
* Author : zhanli 719901725@qq.com & JustFeng.
* Date of Issued : 2017.1.11 zhanli : Create
* Comments : STM32 GPIO<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>
********************************************************************************/
#include "gpio.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "sys.h"
#include "led.h"
#define USB_ENABLE_PERIPH_CLK RCC_APB2Periph_GPIOA // USBʹ<42>ܶ˿<DCB6>ʱ<EFBFBD><CAB1>
#define USB_ENABLE_GPIO_TYPE GPIOA // USBʹ<42>ܶ˿<DCB6><CBBF><EFBFBD><EFBFBD><EFBFBD>
#define USB_ENABLE_PIN GPIO_Pin_2 // USBʹ<42>ܶ˿<DCB6>PA2
/**----------------------------------------------------------------------
* Function : Init_USB_Enable_GPIO
* Description : USBʹ<EFBFBD>ܿ<EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
* Author : zhanli&719901725@qq.com & JustFeng.
* Date : 2015/2/13 zhanli
*---------------------------------------------------------------------**/
void Init_USB_Enable_GPIO()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(USB_ENABLE_PERIPH_CLK, ENABLE); /* ʹ<><CAB9>PB<50>˿<EFBFBD>ʱ<EFBFBD><CAB1> */
GPIO_InitStructure.GPIO_Pin = USB_ENABLE_PIN; /* LED0-->PB.9 <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD> */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* IO<49><4F><EFBFBD>ٶ<EFBFBD>Ϊ50MHz */
GPIO_Init(USB_ENABLE_GPIO_TYPE, &GPIO_InitStructure); /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>GPIOB.9 */
// USB<53><42><EFBFBD><EFBFBD>ʹ<EFBFBD>ܣ<EFBFBD>Ĭ<EFBFBD><C4AC>USB<53><42><EFBFBD><EFBFBD>
GPIO_SetBits(USB_ENABLE_GPIO_TYPE, USB_ENABLE_PIN);
}
/**----------------------------------------------------------------------
* Function : GPIO_Configuration
* Description : <EFBFBD><EFBFBD>Set_System()<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD>
* Author : zhanli&719901725@qq.com & JustFeng.
* Date : 2015/9/17 zhanli
*---------------------------------------------------------------------**/
void GPIO_Configuration(void)
{
// USBʹ<42>ܶ˿ڳ<CBBF>ʼ<EFBFBD><CABC>
Init_USB_Enable_GPIO();
// LED<45><44>ʼ<EFBFBD><CABC>
LED_Init_GPIO();
}