#include"reg51.h"
#include"math.h"
#include"stdio.h"
sbit out=0x90; /*out is P1_0*/
sbit in=0x91; /*in is P1_1*/
sbit clock=0x92; /*clock is P1_2*/
sbit enable=0x93; /*enable is P1_3*/
int RESET=0x0000; /*RESET = 00000000B*/
int MEASURE=0x0008; /*MEASURE = 00001000B*/
int REPORT=0x000c; /*REPORT = 00001100B*/
int bdata READY=0x000c; /*READY = 00001100B*/
int bdata MOVE_OUT,MOVE_IN; /*MOVE_OUT is command move to HM55B Din
MOVE_IN is status move to 8051
MOVE_INXY is data move to 8051*/
int x_data,y_data;
int MASK=0xf800;
sbit M_OUT=MOVE_OUT^8;
sbit M_IN=MOVE_IN^8;
sbit M_INXY=MOVE_INXY^8;
void shift_out(int);
int shift_in();
int shift_inXY();
void delay(int);
main()
{
again_me:
clock=0;
shift_out(RESET); /* move reset command to HM55B*/
enable=1;
shift_out(MEASURE); /* move measure command to HM55B*/
enable=1;
delay(40000); /* stay 40ms*/
shift_out(REPORT); /* move report command to HM55B*/
enable=1;
shift_in(); /* data move to 8051*/
if(MOVE_IN==READY) /* if the data of move to 8051 is arighy */
{
P1=0x23; /* P1 output*/
}
else
{
goto again_me;
}
}