2025-05-26 17:39:58 +08:00

64 lines
1.4 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 "stm32f10x.h"
#include "led.h"
#include "Delay.h"
/*****************************
*函 数LED初始化
*时 间2024-05-14
*输 入:无
*返 回:无
*引 脚PA4,PA5
*Dragon-H
*****************************/
void LED_Init(void){
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_OD;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4|GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
LEDGreen_OFF();
LEDRed_OFF();
}
/*****************************
*函 数LED功能函数
*时 间2024-05-14
*输 入:无
*返 回:无
*引 脚PA4,PA5
*Dragon-H
*****************************/
void LEDGreen_OFF(void){
GPIO_SetBits(GPIOA,GPIO_Pin_4);//绿灯
}
void LEDGreen_ON(void){
GPIO_ResetBits(GPIOA,GPIO_Pin_4);//绿灯
}
void LEDRed_OFF(void){
GPIO_SetBits(GPIOA,GPIO_Pin_5);//红灯
}
void LEDRed_ON(void){
GPIO_ResetBits(GPIOA,GPIO_Pin_5);//红灯
}
void LEDGreen_Flash(void){ //绿灯闪
GPIO_SetBits(GPIOA,GPIO_Pin_4);
Delay_ms(300);
GPIO_SetBits(GPIOA,GPIO_Pin_4);
Delay_ms(300);
}
void LEDRed_Flash(void){ //红灯闪
GPIO_SetBits(GPIOA,GPIO_Pin_5);
Delay_ms(50);
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
Delay_ms(50);
GPIO_SetBits(GPIOA,GPIO_Pin_5);
Delay_ms(50);
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
Delay_ms(50);
}