64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
#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);
|
||
} |