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

  • 大小: 41KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-20
  • 語言: 其他
  • 標簽: tdc-gp2??激光測距??

資源簡介

基于tdc-gp2的c8051單片機的激光測距測試程序,可以用,歡迎下載

資源截圖

代碼片段和文件信息

#include
#include
#define?uchar unsigned?char
#define?uint unsigned?int
#define?sled_dm_port?P0
unsigned?long?int?M;
sbit LED =P1^3;
sbit SSN =P1^4;
sbit SCK =P1^7;
sbit SI =P1^5;
sbit SO =P1^6;
sbit INT =P2^3;//中斷標志
sbit EN_START=P2^0;
sbit EN_STOP1=P2^1;
sbit EN_STOP2=P2^2;
sbit RST =P2^7;
sbit START =P3^4;
sbit STOP =P2^6;
uchar?data0;data1;data2;data3;
uchar?code?smg[]={0x3f0x060x5b0x4f0x660x6d0x7d0x070x7f0x6f0xff};????/*數碼管0~9*/
uchar?code?sw[]={0x000x200x400x60};?//位選數組
void?delay(void)?//延時子函數
{
uchar?ab;
????for(b=1;b>0;b--)
for(a=97;a>0;a--);
}
void?display()??//數碼管顯示
{
P0=smg[data0];P3=sw[0];delay();
P0=smg[data1];P3=sw[1];delay();
P0=smg[data2];P3=sw[2];delay();
P0=smg[data3];P3=sw[3];delay();
}??????
void?spi_enable(void)?//開啟spi?通信將ssn?置低
{
SSN=0;//ssn?置低
_nop_();
}
void?spi_disable(void)?//關閉spi?通信將ssn?置高
{
SSN=1;//ssn?置高
_nop_();
}
void?send_zero(void)?//發送0
{
SCK=1;//SCK?高電平
_nop_();
SI=0;//SI-輸出一個低平
_nop_();
SCK=0;//SCK?低平
_nop_();
}
void?send_one(void)?//發送1
{
SCK=1;//SCK?高電平
_nop_();
SI=1;//SI-輸出一個高平
_nop_();
SCK=0;//SCK?低平
_nop_();
}
//=====================SPI?寫數據=====================//
void?spi_write8(uchar?wbuf8)?//?spi?寫入8?位數據
{
uchar?cnttmp=0x80;
spi_enable();
for(cnt=8;cnt>0;cnt--)
{
if((wbuf8&tmp)!=0)
send_one();//發送1
else
send_zero();//發送0
tmp?/=2;?//tmp?右移一位
}?//沒有spi?關閉命令,測試程序中代碼關閉!
}
//void?spi_write16(uint?wbuf16)?//?spi?寫16?位數據
//{
//uchar?cnt;
//uint?tmp=0x8000;
//spi_enable();
//for(cnt=16;cnt>0;cnt--)
//{
//if((wbuf16&tmp)>0)
//send_one();//發送1
//else
//send_zero();//發送0
//tmp?/=2;?//tmp?右移一位
//}
//_nop_();
//spi_disable();
//}
void?spi_write32(unsigned?long?wbuf32)?//?spi?寫32?位數據
{
uchar?cnt;
unsigned?long?tmp=0x80000000;
spi_enable();
for(cnt=32;cnt>0;cnt--)
{
if((wbuf32&tmp)!=0)
send_one();//送1
else
send_zero();//發送0
tmp?/=2;?//tmp?右移一位
}
_nop_();
spi_disable();
}
//=====================SPI?讀數據=====================//
unsigned?long?spi_read32()
{
uchar?cnt;
unsigned?long?tmp=0x80000000;
unsigned?long?int?rbuf32=0x00000000;
spi_enable();
for(cnt=32;cnt>0;cnt--)
{
SCK=0;//SCK
_nop_();
if(SO==1)//P6.2?SO
rbuf32?|=tmp;
tmp?/=2;
SCK=1;//?SCK
_nop_();
}
_nop_();
spi_disable();
return(rbuf32);
}
//===========GP2?上電復位程序==================//
void?GP2_RESET(void)
{
RST=1;?//輸出高平
_nop_();
RST=0;?//輸出低平
_nop_();
RST=1;?//輸出高平
_nop_();
}//給gp2RSTN?管腳一個Reset?的方波
//===========GP2?寄存器配置程序====================//
void?GP2_init(void)
{
unsigned?long?REG0REG1REG2?REG3?REG4REG5;
uchar?PU=0x50;
uchar?init=0x70;
REG0=0x800c3000;//校準陶瓷晶振時間為8?個32k?周期244.14us. ???0x80008420
//設置高速晶振上電后一直起振.設置測量范圍1自動校準上升沿敏感
REG1=0x81014100;//預期stop1?脈沖數1?個.計算第一個stop1-start
REG2=0x82E00000;//開啟所有中斷源
REG3=0x83080000;// ?????
REG4=0x84200000;//
REG5=0x85080000;//
spi_write8(PU);//上電復位
_nop_();
spi_disable();
spi_write32(REG0);
_nop_();
spi_write

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-01-27?20:09??TDC\
?????文件????????6376??2005-03-22?15:22??TDC\STARTUP.A51
?????文件???????14048??2014-10-23?17:49??TDC\STARTUP.LST
?????文件?????????749??2014-10-23?17:49??TDC\STARTUP.OBJ
?????文件???????15302??2015-01-07?20:30??TDC\tdc
?????文件???????11522??2015-01-07?20:30??TDC\tdc.LST
?????文件???????20605??2015-01-07?20:30??TDC\tdc.M51
?????文件???????17528??2015-01-07?20:30??TDC\tdc.OBJ
?????文件????????2196??2011-10-09?11:04??TDC\tdc.Uv2.bak
?????文件??????????33??2015-01-07?20:30??TDC\tdc.__i
?????文件????????5571??2011-11-07?17:05??TDC\tdc.c
?????文件????????3007??2015-01-07?20:30??TDC\tdc.hex
?????文件??????????54??2015-01-07?20:30??TDC\tdc.lnp
?????文件????????1295??2011-11-08?10:49??TDC\tdc.opt.bak
?????文件?????????430??2015-01-07?20:30??TDC\tdc.plg
?????文件???????56522??2015-01-07?20:55??TDC\tdc.uvopt
?????文件???????13411??2014-10-23?17:51??TDC\tdc.uvproj
?????文件????????1297??2011-11-07?17:17??TDC\tdc_Opt.Bak
?????文件????????2192??2011-10-08?11:34??TDC\tdc_Uv2.Bak
?????文件???????57065??2015-01-05?16:29??TDC\tdc_uvopt.bak

評論

共有 條評論