# HG changeset patch # User Paul Boddie # Date 1362522404 0 # Node ID 05341884dd5e716c378806d971e638b743c8a7f4 # Parent 5580bf1e6c9e2e832fcdfdeff0b24711eff8c86e Removed the superfluous second reset apparently done/expected by Windows. diff -r 5580bf1e6c9e -r 05341884dd5e test.c --- a/test.c Mon Mar 04 22:26:19 2013 +0000 +++ b/test.c Tue Mar 05 22:26:44 2013 +0000 @@ -35,9 +35,7 @@ MAX_DEVSTATE_INIT = 0, MAX_DEVSTATE_CONNECTED = 1, MAX_DEVSTATE_RESET = 2, - MAX_DEVSTATE_INSPECTED = 3, - MAX_DEVSTATE_RESET_AGAIN = 4, - MAX_DEVSTATE_READY = 5 + MAX_DEVSTATE_READY = 3 } max_devstate; /* Device details. */ @@ -669,10 +667,6 @@ printf("iProduct: %d\n", device->desc.iProduct); printf("iSerialNumber: %d\n", device->desc.iSerialNumber); printf("bNumConfigurations: %d\n", device->desc.bNumConfigurations); - - /* Reset the device. */ - - max_write(MAX_REG_HCTL, MAX_HCTL_BUSRST); return true; } @@ -926,36 +920,17 @@ else if ((devstate == MAX_DEVSTATE_RESET) && frame_event && max_can_send(&status)) { - if (max_init_device(&device)) - { - devstate = MAX_DEVSTATE_INSPECTED; - printf("INSPECTED\n"); - } + if (!max_init_device(&device)) + printf("FAILED: RESET -> READY\n"); else - printf("FAILED: RESET -> INSPECTED\n"); - } - - /* Handle the second device reset initiation. This is arguably - superfluous, since the second reset is typically done because - Windows aborts the device descriptor acquisition after 8 bytes - because it was only interested in the maximum packet size. */ - - else if ((devstate == MAX_DEVSTATE_INSPECTED) && bus_event) - { - devstate = MAX_DEVSTATE_RESET_AGAIN; - printf("RESET AGAIN\n"); - } - - /* Handle the second device reset completion, initiating communications. */ - - else if ((devstate == MAX_DEVSTATE_RESET_AGAIN) && frame_event && max_can_send(&status)) - { - max_write(MAX_REG_MODE, max_read(MAX_REG_MODE, NULL) & ~MAX_MODE_SOFKAENAB); - max_set_address(&device); - devstate = MAX_DEVSTATE_READY; - usb_show_languages(max_get_descriptor(&device, USB_DT_STRING, 0, 0)); - usb_show_configuration(max_get_descriptor(&device, USB_DT_CONFIG, 0, 0)); - printf("READY\n"); + { + max_write(MAX_REG_MODE, max_read(MAX_REG_MODE, NULL) & ~MAX_MODE_SOFKAENAB); + max_set_address(&device); + usb_show_languages(max_get_descriptor(&device, USB_DT_STRING, 0, 0)); + usb_show_configuration(max_get_descriptor(&device, USB_DT_CONFIG, 0, 0)); + devstate = MAX_DEVSTATE_READY; + printf("READY\n"); + } } /* Handle device disconnection. */