/* * wrapper for usb_control_msg call */ static int usbasp_transmit(PROGRAMMER * pgm, unsigned char receive, unsigned char functionid, unsigned char send[4], unsigned char * buffer, int buffersize) { int nbytes; #ifdef USE_usb_1_0 nbytes = usb_control_transfer(PDATA(pgm)->usbhandle, (usb_REQUEST_TYPE_VENDOR | usb_RECIPIENT_DEVICE | (receive << 7)) & 0xff, functionid & 0xff, ((send[1] << 8) | send[0]) & 0xffff, ((send[3] << 8) | send[2]) & 0xffff, (char *)buffer, buffersize & 0xffff, 5000); if(nbytes < 0){ fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, strerror(usb_to_errno(nbytes))); return -1; } #else nbytes = usb_control_msg(PDATA(pgm)->usbhandle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | (receive << 7), functionid, (send[1] << 8) | send[0], (send[3] << 8) | send[2], (char *)buffer, buffersize, 5000); if(nbytes < 0){ fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror()); return -1; } #endif return nbytes; }
static void do_other_wait(void) { int rv; struct setup setup; byte configuration[18]; do { sleep_poll(); delay(1000); // get the configuration descriptor usb_setup(1, SETUP_TYPE_STANDARD, SETUP_RECIP_DEVICE, REQUEST_GET_DESCRIPTOR, (CONFIGURATION_DESCRIPTOR<<8)|0, 0, sizeof(configuration), &setup); rv = usb_control_transfer(&setup, configuration, sizeof(configuration)); } while (rv > 0); }