标题:
声光报警stm32f103
[打印本页]
作者:
2.31
时间:
2018-5-8 20:15
标题:
声光报警stm32f103
#include "alarm.h"
#include "stm32f10x_gpio.h"
#include "delay.h"
void Config_LED1_out(){
GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;
}
void Config_LED2_out(){
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;
}
void BEEP_Init ( void ){
GPIO_InitTypeDef GPIO_InitStructure;
SystemInit ();
RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOB, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init ( GPIOB, &GPIO_InitStructure ); //3õê¼»ˉGPIO
}
void sound1 ( void ){
unsigned int i = 1000;
while ( i-- ){
GPIO_SetBits ( GPIOB, GPIO_Pin_5 );
delay( i );
GPIO_ResetBits ( GPIOB, GPIO_Pin_5 );
delay( i-- );
}
}
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1