Project :
Version :
Date : 2000/11/10
Author : eiman
Company : arya-elecomp
Comments:
Chip type : ATmega16
Program type : Application
Clock frequency : 1.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
************************************************** ***/
};
}
unsigned char mouse_r (void)
{
unsigned char c,a,i=0;
DDRB=0x00;
while (PINB.0==0 & PINB.1==0);
while (PINB.0==1 & PINB.1==1);
while (PINB.0==0);
while (PINB.0==1);
for (i=0;i<8;i++)
{
c=PINB;
c=c<<6;
c=c & 0x80;
a=a>>1;
a=a^c;
while (PINB.0==0);
while (PINB.0==1);
};
while (PINB.0==0 & PINB.1==0);
return a ;
}
void mouse_w (unsigned char x)
{
unsigned char i,c,p=0;
PORTB=0x03;
DDRB=0x03;
while (PINB.0==0 & PINB.1==0);
PORTB.0=0;
delay_us(100);
PORTB.1=0;
PORTB.0=1;
DDRB=0x02;
while (PINB.0==1);
for (i=0;i<8;i++)
{
c=x;
c=c & 0x01;
x=x>>1;
PORTB.1=c;
if (c==1) p+=1;
while (PINB.0==0);
while (PINB.0==1);
};
p=p%2;
if (p==0)PORTB.1=1; else
PORTB.1=0;
while (PINB.0==0);
while (PINB.0==1);
PORTB.1=1;
DDRB=0x00;
while (PINB.0==1 & PINB.1==1);
while (PINB.0==0 & PINB.1==0);
}
void mouse_on ( )
{
unsigned char y;
mouse_w(0xFF);
y=mouse_r( );
y=mouse_r( );
mouse_w(0xEA);
y=mouse_r( );
mouse_w(0xE8);
y=mouse_r( );
mouse_w(0x01);
y=mouse_r( );
mouse_w(0xF3);
y=mouse_r( );
mouse_w(0x0A);
y=mouse_r( );
mouse_w(0xF4);
y=mouse_r( );
}
دیدگاه