91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類(lèi)型: .c
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-02
  • 語(yǔ)言: 其他
  • 標(biāo)簽: STM32??

資源簡(jiǎn)介

STM32超聲波測(cè)距程序 本人自編的STM32程序測(cè)距 聲波HC-SR04

資源截圖

代碼片段和文件信息

#include?“HC-SR04.h“
#include?“sys.h“
#include?“delay.h“

#define?Trig?PBout(3)
#define?Echo?PBin(4)

u16?msHcCount=0;

void?HcsrInit()
{
GPIO_InitTypeDef?GPIO_InitStructure;
TIM_TimebaseInitTypeDef?TIM_TimebaseInitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOBENABLE);

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOB&GPIO_InitStructure);


GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB&GPIO_InitStructure);


RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3ENABLE);


TIM_TimebaseInitStructure.TIM_Period=(1000-1);
TIM_TimebaseInitStructure.TIM_Prescaler=(72-1);
TIM_TimebaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimebaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimebaseInit(TIM3&TIM_TimebaseInitStructure);

TIM_ClearFlag(TIM3TIM_CounterMode_Up);
TIM_ITConfig(TIM3TIM_IT_UpdateENABLE);
hcsr04_NVIC();
TIM_Cmd(TIM3ENABLE);
}
void?hcsr04_NVIC()
{
NVIC_InitTyp

評(píng)論

共有 條評(píng)論