洛阳理工学院毕业设计(论文)
TIM_SelectSlaveMode(SONIC_TIMx, TIM_SlaveMode_Reset); /* Enable the Master/Slave Mode */
TIM_SelectMasterSlaveMode(SONIC_TIMx,
TIM_MasterSlaveMode_Enable);
}
//定时器中断里边的内容 void TIMx_IRQHandler(void) { }
30
/* TIM enable counter */
TIM_Cmd(SONIC_TIMx, ENABLE); /* Enable the CC2 Interrupt Request */
TIM_ITConfig(SONIC_TIMx, TIM_IT_CC2, ENABLE);
if(TIM_GetITStatus(SONIC_TIMx,TIM_IT_CC2)!=RESET) {
TIM_ClearITPendingBit(SONIC_TIMx,TIM_IT_CC2); value1=TIM_GetCapture2(SONIC_TIMx); if(value1!=0) {
value2=TIM_GetCapture1(SONIC_TIMx); } else {
value1=0; }
time=value2;
value2=0;
}
洛阳理工学院毕业设计(论文)
//12864液晶显示模块初始化
//初始化液晶,引脚初始化,发送初始化命令 void initlcd12864() { }
//液晶引脚资源初始化 void GPIO_Config(void) {
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOx|RCC_APB2PGPIO_Config(); write_com(0x30); delayms(1);
write_com(0x0c);//整体显示开 游标关 游标位置关 delayms(1); write_com(0x01); delayms(5);
eriph_GPIOy,ENABLE);
GPIO_InitStructure.GPIO_Pin
=
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOx, &GPIO_InitStructure);
GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOy, &GPIO_InitStructure);
31
洛阳理工学院毕业设计(论文)
}
//打印显示汉字程序,包括设定显示坐标,显示内容
void hanzi(unsigned char x,unsigned char y,unsigned char *z) //显示汉字 字符
{ unsigned char pos; if(x==0)
x=0x80;
if(x==1)
x=0x90;
if(x==2)
x=0x88;
if(x==3)
x=0x98;
pos=x+y; write_com(pos); while(*z!='\\0') { write_date(*z);
z++;
}
}
32
洛阳理工学院毕业设计(论文)
//主函数内容 int main(void) {
while(1) {
a=Sonic1(); b=Sonic2(); c=Sonic3(); d=Sonic4(); if(a<=100)
else
hanzi(0,0,\号车位有车\
u8 a,b,c,d; SystemInit();
GPIO_Configuration();//串口引脚初始化
USART_Configuration(9600);//串口初始化,方便系统调试 Delay_Configuration(72);//系统延时函数初始化 Sonic_Init();//超声波初始化
initlcd12864();//液晶显示模块初始化
printf(\//初始化结束 串口打印OK信息
hanzi(0,0,\号车位无车\
if(b<=100) hanzi(0,0,\号车位有车\
else
hanzi(0,0,\号车位无车\
if(c<=100) hanzi(0,0,\号车位有车\
else
hanzi(0,0,\号车位无车\
}
if(d<=100) hanzi(0,0,\号车位有车\
else
hanzi(0,0,\号车位无车\
delayms(100);
}
33