首页 STM32F103——声音
文章
取消

STM32F103——声音

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "stm32f10x.h"                
#include "voice.h"
void VoiceSensor_Init(void)
{
		GPIO_InitTypeDef GPIO_InitStructure;
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
	
 
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
}
//使能PA11口
 
unsigned char VoiceSensor_Get(void)     //读取PA11口的电平
{
	return GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_11);
}
 


#ifndef __VOICE_H
#define __VOICE_H
 
 
void VoiceSensor_Init(void);
 
unsigned char VoiceSensor_Get(void);
 
#endif
 

本文由作者按照 CC BY 4.0 进行授权