Files
2025-06-27 00:32:57 +08:00

40 lines
1.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/***
***************************************************************************
* @file led.c
* @brief LED接口相关函数
***************************************************************************
* @description
*
* 初始化LED的IO口配置为推挽输出、上拉、速度等级2M。
*
***************************************************************************
***/
#include "led.h"
// 函数LED IO口初始化
//
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //定义结构体
RCC_AHB1PeriphClockCmd ( LED1_CLK, ENABLE); //初始化GPIOG时钟
RCC_AHB1PeriphClockCmd ( LED2_CLK, ENABLE); //初始化GPIOD时钟
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //输出模式
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //推挽输出
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //上拉
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; //速度选择
//初始化 LED1 引脚
GPIO_InitStructure.GPIO_Pin = LED1_PIN;
GPIO_Init(LED1_PORT, &GPIO_InitStructure);
//初始化 LED2 引脚
GPIO_InitStructure.GPIO_Pin = LED2_PIN;
GPIO_Init(LED2_PORT, &GPIO_InitStructure);
LED1_OFF;
LED2_OFF;
}