#ifndef __BEEP_H
#define __BEEP_H
void BEEP_Init(void);
#endif
#include "stm32f4xx.h"
#include "beep.h"
void BEEP_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOF,&GPIO_InitStructure);
GPIO_ResetBits(GPIOF,GPIO_Pin_8);
}
#include "stm32f4xx.h"
#include "beep.h"
#include "delay.h"
int main(void)
{
delay_init(168); //168MHz
BEEP_Init();
while(1)
{
GPIO_SetBits(GPIOF,GPIO_Pin_8);
delay_ms(500);
GPIO_ResetBits(GPIOF,GPIO_Pin_8);
delay_ms(500);
}
}