****************************************************************************/
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit CS = 0x80; //P0.0
sbit CLK = 0x81; //P0.1
sbit DIO = 0x82; //P0.2
sbit KEY = 0x83; //P0.3
void delay(uint times);
void initialize(void);
void display(void);
void Key_Scan(void);
void Send(int number);
bit flag;
void Count_int0() interrupt 0 using 2
{
flag = 1;
delay(10);
}
void Send(int number)
{
int i;
for(i=0;i <=7;i++)
{ delay(3);
` CLK = 1;
if((number&0x80)==0x80)
DIO = 1;
else
DIO = 0;
_nop_();
// CLK = 1;
number = number < <1;
_nop_();
_nop_();
CLK = 0;
_nop_();
}
}
void initialize(void)
{
Motor = 0;
Elect = 0;
CS = 1;
DIO = 1;
KEY = 1;
CLK = 0;
CS = 0;
Send(0xA4);
CS = 1;
CS = 0;
Send(0xBF);
CS = 1;
delay(500);
CS = 0;
Send(0xC8);
delay(5);
Send(0x00);
CS = 1;
}
void delay(uint times)
{
uint i,j;
for(i=times;i> 0;i--)
for(j=times;j> 0;j--){}
}
void main(void)
{
initialize();
delay(1000);
CS = 0;
Send(0xC8);
delay(4);
Send(0x01);
CS = 1;
_nop_();
_nop_();
CS = 0;
delay(500);
Send(0xA1);
CS = 1;
delay(4);
CS = 0;
Send(0xA1);
delay(4);
Send(0x03);
CS = 1;
}