case TOKEN_NAK: /* device is not ready */ MKDBG_TRACE(ev_got_nak, ep); if (my_device.eps[ep].type == EPTYPE_INT) { return(0); } /* retry */ break;
hcc_u8 retry=3;
/* After the setup we shall send/receive DATA1 packets. */
my_device.eps[ep].tgl_tx=1;
my_device.eps[ep].tgl_rx=1;
/* After the setup we shall send/receive DATA1 packets. */
my_device.eps[ep].tgl_tx=BDT_CTL_DATA;
my_device.eps[ep].tgl_rx=BDT_CTL_DATA;
// set interface usb_setup(0, SETUP_TYPE_STANDARD, SETUP_RECIP_INTERFACE, 0x0b, 0, 0, 0, &setup); rv = usb_control_transfer(&setup, NULL, 0); assert(rv == 0); // get max lun usb_setup(1, SETUP_TYPE_CLASS, SETUP_RECIP_INTERFACE, 0xfe, 0, 0, sizeof(max), &setup); rv = usb_control_transfer(&setup, &max, sizeof(max)); assert(rv == 1 && max == 0); // inquiry memset(cdb, 0, sizeof(cdb)); cdb[0] = 0x12; // inquiry cdb[4] = 36; rv = scsi_bulk_transfer(1, cdb, 6, inq, sizeof(inq)); if (rv < 0) { return rv; } assert(rv == sizeof(inq)); led_happy(); // test unit ready memset(cdb, 0, sizeof(cdb)); cdb[0] = 0x00; // test unit ready (void)scsi_bulk_transfer(0, cdb, 6, NULL, 0); // request sense memset(cdb, 0, sizeof(cdb)); cdb[0] = 0x03; // request sense cdb[3] = sizeof(sense); rv = scsi_bulk_transfer(1, cdb, 10, sense, sizeof(sense)); if (rv < 0) { return rv; } assert(rv); led_happy(); // test unit ready memset(cdb, 0, sizeof(cdb)); cdb[0] = 0x00; // test unit ready rv = scsi_bulk_transfer(0, cdb, 6, NULL, 0); if (rv < 0) { return rv; } assert(rv == 0); led_happy(); // read format capacities memset(cdb, 0, sizeof(cdb)); cdb[0] = 0x23; // read format capacities cdb[8] = sizeof(caps); rv = scsi_bulk_transfer(1, cdb, 12, caps, sizeof(caps)); if (rv < 0) { return rv; } assert(rv); led_happy(); // read capacity memset(cdb, 0, sizeof(cdb)); cdb[0] = 0x25; // read capacity rv = scsi_bulk_transfer(1, cdb, 10, cap, sizeof(cap)); if (rv < 0) { return rv; } assert(rv == sizeof(cap)); led_happy(); // read block memset(cdb, 0, sizeof(cdb)); cdb[0] = 0x28; // read10 cdb[2] = sector>>24; cdb[3] = sector>>16; cdb[4] = sector>>8; cdb[5] = sector>>0; assert(count < 256); cdb[8] = count; rv = scsi_bulk_transfer(1, cdb, 10, buffer, count*512); if (rv < 0) { return rv; } assert(rv == count*512); led_happy();