unsigned char key_data_hc165[2];
void HC165_Init(unsigned char *str,unsigned char n)
{
unsigned char i,j,tmp;
KEY_STB = 0; //read all the data to the latch
_nop_();
_nop_();
KEY_STB = 1;
delay_ms(1);
KEY_CLK = 0;
for(j = 0;j < n;j++)
{
tmp = 0;
for(i=0; i<8; i++)
{
tmp<<=1; //left shift 1 bit
tmp|=KEY_DATA1;
KEY_CLK=0; //CLK set zero
_nop_(); //risiing edge
_nop_();
KEY_CLK=1; //CLK set one
_nop_();
}
*str++=tmp;
}
}
|