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

47 lines
1.0 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.

#include "stm32f10x.h"
#include "buzzer.h"
#include "Delay.h"
/*****************************
*函 数:有源蜂鸣器初始化
*时 间2024-05-14
*输 入:无
*返 回:无
*Dragon-H
*****************************/
void buzzer_Init(void){
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_1);
}
/*****************************
*函 数:有源蜂鸣器开
*时 间2024-05-14
*输 入:无
*返 回:无
*Dragon-H
*****************************/
void buzzer_on(void){
GPIO_ResetBits(GPIOA,GPIO_Pin_1);
Delay_ms(100);
GPIO_SetBits(GPIOA,GPIO_Pin_1);
Delay_ms(5);
}
/*****************************
*函 数:有源蜂鸣器关
*时 间2024-05-14
*输 入:无
*返 回:无
*Dragon-H
*****************************/
void buzzer_off(void){
GPIO_SetBits(GPIOA,GPIO_Pin_1);
}