賽區(qū)-民航附件源程序_第1頁
賽區(qū)-民航附件源程序_第2頁
賽區(qū)-民航附件源程序_第3頁
賽區(qū)-民航附件源程序_第4頁
賽區(qū)-民航附件源程序_第5頁
已閱讀5頁,還剩30頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

#include<hidef.h> /*commondefinesandmacros*/#include<mc9s12dg128.h> /*derivativeinformation*/#include<math.h>voidinit_PLL(void){ //pll _LOCK==0);//waitpllclocksteadyCLKSEL=0x80;//setbusclock=pllclock/2}voidinit_AD(void)//初始化{ATD0CTL2=0xC0;AD模塊上電,快速清零,無等待模式,忽略觸發(fā),轉(zhuǎn)換完成中斷ATD0CTL3=0x08;//轉(zhuǎn)換的通道數(shù)為1,NoFIFO,Freeze模式下不停止ATD0CTL4=0x81;//8位精度,采樣2個時鐘周期ATD0DIEN=0x00;//數(shù)字輸入}/************initializationPort//PortH6void{PTH_PTH6=0; DDRH_DDRH6=0; PPSH_PPSH6=0; PIFH_PIFH6=1; PIEH_PIEH6=1; //中斷使能}/***********initializationPortJ1******************/voidinit_intPortJ1(void){PTJ_PTJ1=DDRJ_DDRJ1=PERJ_PERJ1= //PullDevice}/************initializationPortJ0*****************/voidinit_PortJ0(void){PTJ_PTJ0=DDRJ_DDRJ0=0;//PORTJDataDirection:INPUTPPSJ_PPSJ0=1;//PORTJRisingEdgePIFJ_PIFJ0=1;//ClearPORTJInterruptPIEJ_PIEJ0=1;//PORTJInterrupt//} voidinit_(void){POL=0x0F; //Polarity CLK=0x00; //PRCLK=0x04; //ClockA=BusClock/16 ClockB=BusClock CAE=0x00; //LeftAligeOutputModeCTL=0x30; //Concatenatechannel0and1 2and3PER01=50000;//50HzDTY01=3650;PER23=6000; DTY23=0;E= //Channel1andChannel3}voidinit_ECT(void){ =0x00; //inputcaptureTSCR2=0x07; TCTL4 //下降沿捕捉脈沖PBCTL=0x40; ICPAR=0X03; 10=TSCR1 //計數(shù)器使能,讀時自動}void{MCCTL=MCCTL&0Xfb;//模數(shù)計數(shù)器運MCCTL //MCCTL=MCCTL|0X04;//模數(shù)計數(shù)器使能T=2500;//(1/40M)*16*2500=MCCTLMCCTL|0X08}#defineFIELDPTIJ_PTIJ1#defineLINE39#defineDOT#defineDIV#defineTIME_INTER5chargo_ready;charbegin,t,deal;unsignedcharfield;unsignedintline;unsignedchardot;unsignedcharoddfinish,evenfinish;unsignedchari,j,k,l,m;unsignedcharleft,right,width,width0,inflag,inflag1,outflag;inttime;unsignedcharunsignedchardark0,dark,dark1,white,white0,white1,dif,dif1,ndark,nwhite;unsignedintsumwhite;unsignedcharblackarea[8],blacknum;unsignedcharmaybe[4];unsignedcharfindoutline;unsignedcharfinish;charunsignedcharfindstartline,leftoutflag=0,rightoutflag=0,outnumber;unsignedcharstartlinedally,canstop;int reaknumber;//計算曲線用charfloatturn,angle,angle0,absangle,anglechange;unsignedcharbreakpoint[20];chargetlineslope[14][2],sanjiaoout=1,sanjiaoin=0;floatlineslope[14];charturnleft,turnright,beS;intendwarp,startwarp;charroadfalse;unsignedcharintfloatkeepspeed,kp1,difu,intp0,p1,espeed,difspeed,sespeed,oldespeed=0, unsignedintnumber_count;floatwarp;floatsumwarp;floataveragewarp,a,b;floatsumx,sumy;floatsumxsumx,sumxx,sumxy;floatslope,constnum;charADDSPEED;charSLOWSPEED;#defineeclkdiv(*((volatileunsignedchar*)(0x0110)))#defineecnfg(*((volatileunsignedchar*)(0x0113)))#defineeprot(*((volatileunsignedchar*)(0x0114)))#defineestat(*((volatileunsignedchar*)(0x0115)))#defineecmd(*((volatileunsignedchar*)(0x0116)))unsignedcharrelative_addr;#defineEE_BASE((volatileunsignedint*)(0x2000))volatileunsignedint*ee_addr=EE_BASE;voidwreeprom(void)//putyourowncodehereECLKDIV=0x4b;*ee_addr=n;ECMD=0x20;ESTAT|=0x80;*ee_addr=turn;ECMD=0x20;ESTAT|=0x80;*ee_addr=count;ECMD=0x20;ESTAT|=0x80;*ee_addr=p0;ECMD=0x20;ESTAT|=0x80;}voidreadcount(void){}/************setspeed**********************/voidsetspeed(int*s1,int*s2) //speedneeddespeed{{}else{{}elseif(sespeed<=-{sespeed=-} {{}}{{}{{}}}}{}}voidgetdot(unsignedchar*c){ //現(xiàn)在為偶{} //{}{{finish--}{}{}}{{}{}}}voidmain(void){/*REFDV=3; //設(shè)置pll _LOCK==0);//waitpllclocksteadyCLKSEL=0x80;//setbusclock=pllclock/2 DDRK=0xFF;DDRA=0x00;if{ }else{}else{}else{}else{}else{}else{}else{}{findstartline=1;}elsefindstartline=0;{{}else{}{ {for(j=0;j<DOT-{{{}{}}elseif(*(q+j)+20<*(q+j+2)&&blacknum%2==1) {}{}}{}}{ {{}{}}}{ {{{if(*(q+center[i])+5>*(q-{}{}}{}}}}if(findoutline>=1)//真正找到{}}{{{}}{if(*(q+j)<=dark0)//找到{}else{}{}else{}else{}}for(i=start;i>0;i--{q+=i*DOTi{if(center[i]+1>k&&*(q-DOT+center[i]-{} { } {{{if(*(q-DOT+center[i]- dark0=*(q-DOT+center[i]-}elseif(*(q-DOT+center[i]-{dark=*(q-DOT+center[i]-}if(*(q-DOT+center[i]-{white0=*(q-DOT+center[i]-}elseif(*(q-DOT+center[i]-{white1=*(q-DOT+center[i]-}elseif(*(q-DOT+center[i]-{white=*(q-DOT+center[i]-}}}else{{{}elseif(*(q-{}if(*(q-{white0=*(q-}elseif(*(q-{white1=*(q-}elseif(*(q-{white=*(q-}}}{}{if(center[i]+1>k&&*(q-DOT+center[i]-{} if(center[i]+k<DOT&&*(q-{}}{}}for(j=root+1;j<DOT-{sumwhite=(*(q-DOT+j+1)+*(q-DOT+j+2)+*(q-if(*(q-DOT+j)>dif+dark&&sumwhite+dif/2>*(q-DOT+j)&&sumwhite<*(q-{{}}}for(j=root-1;j>3;j--{sumwhite=(*(q-DOT+j-1)+*(q-DOT+j-2)+*(q-DOT+j-if(*(q-DOT+j)>dif+dark&&sumwhite+dif/2>*(q-DOT+j)&&sumwhite<*(q-{}}width=right-{{{}}}{}}{}else{}}{}{}{{}{PORTK&=0xf0;}else}else}{{}{{if(*(q-{}elseif(*(q-2*DOT+center[i]-{}{}}} {} //3--{}{}if(center[i-1]>center[i]+5||center[i-1]<center[i]- {} for(i=start-1;i>end;i--{if(center[i-{if(center[i]==center[i-1]-1||center[i]==center[i-{}}}for(i=start-1;i>end;i--{{}}{horizontallength=(center[start]-}{} //15--{{{warp=-} {}}{{}}else}{}for(i=0;i<breaknumber-{ lineslope[i]/=getlineslope[i][1];//斜率{}else{}}if(breaknumber<=2)//直 {beS=0;}else{} {}{{{}{}}}{}{}a2=center[end]-center[end+1];{}a3=center[end+1]-center[end+2];{}a4=center[end+2]-center[end+3];{}{{}}if(start-end+horizontallength>20||((center[end]>DOT-2||center[end]<2)&&start-{}{{if(breakpoint[i]-breakpoint[i-{}}}{startlinedally--}else{{{if(*(q+center[i]-{{{{} *(q+(root-{}}{}}if(k<center[i]-2&&k>center[i]-{ //iffindstartline>1thenstop}}}{{{{{}elseif(*(q+(root-*(q+(root-{}}{}}{ //iffindstartline>1thenstop}}}}}////else}{} //roadfalse{n=start- {for(i=start+1;i>end;i--{sumxy+=i*center[i-sumxx+=(i-1)*(i-}for(i=start+1;i>end;i--{}{{}}{{}} {if(start-end<30||angle>10||angle<-{{}}}turn=((float)(endwarp-startwarp)*(start-10)/(start- {}elseif(turn<-{{} {}{}{}else{ }else{}if(angle-angle0>0.1||angle0-{{}elseif(angle<=-{}}{DTY01=(int)(3700-}if(angle<-{DTY01=(int)(3700-}if({}if( { }{{}else{slow--}}else{}{{slow--}else}{}{}else{{}///}else{}/*else{ {{{{

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論