1.1 --- a/test.c Sat Feb 23 19:10:59 2013 +0000
1.2 +++ b/test.c Sat Feb 23 19:34:47 2013 +0000
1.3 @@ -487,13 +487,16 @@
1.4 return timeout;
1.5 }
1.6
1.7 +/**
1.8 + * Return whether the bus is ready to be sampled. The application note claims
1.9 + * that the SAMPLEBUS bit is cleared, but this does not seem to be the case.
1.10 + */
1.11 uint8_t samplebusready()
1.12 {
1.13 uint8_t result;
1.14
1.15 result = max_read(MAX_REG_HCTL, NULL);
1.16 -
1.17 - return !(result & MAX_HCTL_SAMPLEBUS);
1.18 + return result & MAX_HCTL_SAMPLEBUS;
1.19 }
1.20
1.21 void samplebus()
1.22 @@ -677,6 +680,17 @@
1.23 revision = max_read(MAX_REG_REVISION, &status);
1.24 printf("Revision = %x\n", revision);
1.25
1.26 + /* Sample the bus for any devices that are already connected. */
1.27 +
1.28 + samplebus();
1.29 +
1.30 + if (devicechanged())
1.31 + {
1.32 + devstate = MAX_DEVSTATE_CONNECTED;
1.33 + }
1.34 +
1.35 + /* Enter the main processing loop. */
1.36 +
1.37 for (count = 0; count <= 65535; count++)
1.38 {
1.39 if (!PIN(MAX_INT))