47 lines
1.0 KiB
C
47 lines
1.0 KiB
C
#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);
|
||
}
|