1.1 --- a/test.c Wed Mar 13 17:11:10 2013 +0000
1.2 +++ b/test.c Wed Mar 13 23:33:39 2013 +0000
1.3 @@ -426,9 +426,9 @@
1.4 /**
1.5 * Send a control request consisting of the given setup data.
1.6 */
1.7 -uint8_t max_control(uint8_t *setup)
1.8 +bool max_control(uint8_t *setup)
1.9 {
1.10 - uint8_t status, hrsl;
1.11 + uint8_t status, hrsl, timer = 255;
1.12
1.13 max_write_fifo(0, setup, 8);
1.14
1.15 @@ -440,9 +440,9 @@
1.16 status = max_wait_transfer(status);
1.17 hrsl = max_read(MAX_REG_HRSL, &status);
1.18 }
1.19 - while (hrsl & MAX_HRSL_HRSLT);
1.20 + while ((hrsl & MAX_HRSL_HRSLT) && (--timer));
1.21
1.22 - return status;
1.23 + return !(hrsl & MAX_HRSL_HRSLT);
1.24 }
1.25
1.26 bool max_control_input(uint8_t *data, uint8_t *len, max_device *device)
1.27 @@ -618,7 +618,9 @@
1.28 setup_packet(setup, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, usb_descriptor_type(type) | value, index,
1.29 initial ? 8 : 64);
1.30
1.31 - max_control(setup);
1.32 + if (!max_control(setup))
1.33 + return NULL;
1.34 +
1.35 if (!max_control_input(data, &len, device))
1.36 {
1.37 printf("Failed.\n");
1.38 @@ -968,7 +970,10 @@
1.39 else if ((devstate == MAX_DEVSTATE_RESET) && frame_event && !(--framecount))
1.40 {
1.41 if (!max_init_device(&device))
1.42 + {
1.43 printf("FAILED: RESET -> INSPECTED\n");
1.44 + framecount = 200;
1.45 + }
1.46 else
1.47 {
1.48 devstate = MAX_DEVSTATE_INSPECTED;