32 lines
1.2 KiB
C
32 lines
1.2 KiB
C
#include "buzzer.h"
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//This program is for educational purposes only, without the author's permission, may not be used for any other purpose
|
|
//ALIENTEK STM32F407 Development Board
|
|
//Buzzer driver code
|
|
//Hot Atomic @ALIENTEK
|
|
//Forum: www.openedv.com
|
|
//Date created: 2014/6/10
|
|
//Version: V1.0
|
|
//All rights reserved pirated reserved.
|
|
//Copyright(C) Guangzhou wing electronic technology limited company 2014-2024
|
|
//All rights reserved
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//Initialize the PE2 outlet. and to enable these two clocks
|
|
//Buzzer class IO
|
|
void Buzzer_Init(void)
|
|
{
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE,ENABLE); // GPIOE clock
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; // Output
|
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // Push-pull output
|
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // Pull the output
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; // High-speed GPIO
|
|
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
|
|
|
GPIO_ResetBits(GPIOE, GPIO_Pin_2); // GPIOE line
|
|
}
|