SY/USER/Led/Led.c
gituser a971ce7e43 更新 'USER/Led/Led.c'
添加系统控制指示灯时钟初始化
2020-05-27 00:37:21 +08:00

61 lines
2.1 KiB
C
Raw 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.

#include "Led.h"
/**-------------------------------------------------------
* @函数名 LED_GPIO_INIT
* @功能 LED GPIO初始化
* @返回值 无
***------------------------------------------------------*/
void LED_GPIO_INIT(void){
GPIO_InitTypeDef GPIO_InitStructure;
/* 使能LED对应GPIO的时钟 */
RCC_APB2PeriphClockCmd(LED_CLOCK|LED_SYS_CLOCK, ENABLE); //使能对应端口时钟
/* 初始化LED的GPIO管脚,配置为推挽输出 */ //设置端口
GPIO_InitStructure.GPIO_Pin = LED_Pin_ALL; //LED所有引脚
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //设置为推挽(Push-Pull)输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //最大输出速度为50MHz
GPIO_Init(LED_PORT, &GPIO_InitStructure); //调用GPIO初始化函数
GPIO_SetBits(LED_PORT,LED_Pin_ALL); //led全灭
/* 初始化LED的GPIO管脚,配置为推挽输出 */ //设置端口
GPIO_InitStructure.GPIO_Pin = LED_SYS_Pin; //LED所有引脚
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //设置为推挽(Push-Pull)输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //最大输出速度为50MHz
GPIO_Init(LED_SYS_PORT, &GPIO_InitStructure); //调用GPIO初始化函数
GPIO_ResetBits(LED_SYS_PORT,LED_SYS_Pin); //点亮系统指示灯
}
/**-------------------------------------------------------
* @函数名 LED_ON
* @功能 点亮指定LED LED0,1,2,3
* @返回值 无
***------------------------------------------------------*/
void LED_ON(u8 n){
uint16_t GPIO_PIN_LIST[]={LED2_Pin,LED3_Pin,LED4_Pin,LED5_Pin};
u8 i;
for(i=0;i<4;i++)
{
GPIO_SetBits(LED_PORT,GPIO_PIN_LIST[i]);
}
GPIO_ResetBits(LED_PORT,GPIO_PIN_LIST[n]);
}
/**-------------------------------------------------------
* @函数名 LED_OFF
* @功能 关闭所有LED
* @返回值 无
***------------------------------------------------------*/
void LED_OFF(void){
uint16_t GPIO_PIN_LIST[]={LED2_Pin,LED3_Pin,LED4_Pin,LED5_Pin};
u8 i;
for(i=0;i<4;i++)
{
GPIO_SetBits(LED_PORT,GPIO_PIN_LIST[i]);
}
}