|
|
@ -1,4 +1,4 @@
|
|
|
|
O/*
|
|
|
|
/*
|
|
|
|
*i2ctest.c
|
|
|
|
*i2ctest.c
|
|
|
|
* Raspberry Pi I2C test using wiringPi library.
|
|
|
|
* Raspberry Pi I2C test using wiringPi library.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -35,28 +35,24 @@ int main (int argc, char *argv[])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while(data != 6) {
|
|
|
|
delay(1);
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
wiringPiI2CWrite(fd, send);
|
|
|
|
wiringPiI2CWrite(fd, send);
|
|
|
|
data=wiringPiI2CRead(fd);
|
|
|
|
data=wiringPiI2CRead(fd);
|
|
|
|
|
|
|
|
printf(" Received data=%d\n", data);
|
|
|
|
if(data==-1)
|
|
|
|
if(data==-1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("No data\n");
|
|
|
|
printf("No data\n");
|
|
|
|
//return -1;
|
|
|
|
//return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(data == send*3) {
|
|
|
|
else if(data == 17) {
|
|
|
|
printf("Sending challenge");
|
|
|
|
printf("Exit code received \n");
|
|
|
|
wiringPiI2CWrite(fd, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(data == 6) {
|
|
|
|
|
|
|
|
printf("Read proper response \n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else if(data != 0) {
|
|
|
|
{
|
|
|
|
printf("Sending response %d\n", data+3 );
|
|
|
|
//print data
|
|
|
|
wiringPiI2CWrite(fd, data+3);
|
|
|
|
printf("Waiting to send challenge");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf(" data=%d\n", data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|