中级会员
- 积分
- 394
- 威望
- 226
- 贡献
- 20
- 兑换币
- 0
- 注册时间
- 2012-3-20
- 在线时间
- 74 小时
- 毕业学校
- 后吕小学
|
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "main.h"
int set__speed=0;
char flag=0;
int laser1=0,laser2=0,laser3=0,laser4=0,laser5=0,i;
unsigned int a;
unsigned int temp;
int state1;
unsigned char shuzu[12]={ 0
};
int zuo,you;
const static byte jiguang[6]=
{
0x01,0x02,0x04,0x08,0x10,0x20
};
const static byte duoji[13]=
{
130,140,150,160,170,180,190,120,110,100,90,80,70
};
//*******1ms延时*******//
void delay_ms(unsigned int m)
{
unsigned int a,b;
for(a=m;a>0;a--)
for(b=5340;b>0;b--);
}
//*******1us延时*******//
void delay_us(unsigned int m)
{
unsigned int a,b;
for(a=m;a>0;a--)
for(b=5;b>0;b--);
}
unsigned int laser(void)
{
delay_us(1300);
PORTA=0x15;
laser1=PTIT_PTIT3;
laser1= ((laser1<<2)|PTIT_PTIT2);
laser1=((laser1<<2)|PTIT_PTIT1);
delay_us(1300);
PORTA=0x2a;
laser2=PTIT_PTIT3;
laser2= ((laser2<<2)|PTIT_PTIT2);
laser2=((laser2<<2)|PTIT_PTIT1);
laser2=(laser2<<1);
//PORTA=0x00;
delay_us(1300);
PORTB=0x15;
laser3=PTIT_PTIT4;
laser3= ((laser3<<2)|PTIT_PTIT5);
laser3=((laser3<<2)|PTIT_PTIT6);
laser3=(laser3<<6);
delay_us(1300);
PORTB=0x2a;
laser4=PTIT_PTIT4;
laser4= ((laser4<<2)|PTIT_PTIT5);
laser4=((laser4<<2)|PTIT_PTIT6);
laser4=(laser4<<7);
//PORTB=0x00;
laser5=laser1|laser2|laser3|laser4;
return laser5;
}
//
//图像处理
void Laser_process(void)
{
temp=laser();
switch(temp)
{
case 0x0fff:state1=0; break;
case 0x0ffe:state1=1; break;
case 0x0ffc:state1=2; break;
case 0x0ff8:state1=3; break;
case 0x0ff0:state1=4; break;
case 0x0fe0:state1=5; break;
case 0x0fc0:state1=6; break;
case 0x07ff:state1=7; break;
case 0x03ff:state1=8; break;
case 0x01ff:state1=9; break;
case 0x00ff:state1=10; break;
case 0x007f:state1=11; break;
case 0x003f:state1=12; break;
}
}
//const static byte sudu1[7]=
//{150,150,120,120,110,100,0};
static byte sudu[17]={0};
void main(void)
{
SetBusCLK_64M();
Pwm_DuoJi_B();
//PIT_init(); //定时中断初始化函数 10MS定时中断设置
//dir_qianlun(130);
Pwm_DianJi_A();
io();
EnableInterrupts;
PWMDTY67=130;
flag=0;
for(;;)
{
Laser_process();
PWMDTY67=duoji[state1];
}
|
|