int usb_bulk_get_max_lun(mass_dev* dev) { int ret; usb_callback_data cb_data; iop_sema_t s; char max_lun; s.initial = 0; s.max = 1; s.option = 0; s.attr = 0; cb_data.semh = CreateSema(&s); //Call Bulk only mass storage reset ret = UsbControlTransfer( dev->controlEp, //default pipe 0xA1, 0xFE, 0, dev->interfaceNumber, //interface number 1, //length &max_lun, //data usb_callback, (void*) &cb_data ); if (ret != USB_RC_OK) { printf("USBHDFSD: Error - get_max_lun %d\n", ret); max_lun = -ret; } else { WaitSema(cb_data.semh); } DeleteSema(cb_data.semh); return max_lun; }
static void ds3_set_operational(int slot) { UsbControlTransfer(ds3_list[slot].endp, INTERFACE_GET, USB_REQ_GET_REPORT, (USB_REPTYPE_FEATURE<<8) | 0xf2, 0x0, 17, opbuf, NULL, NULL); }
static void request_data(int result, int count, void *arg) { int slot = (int)arg; UsbControlTransfer(ds3_list[slot].endp, INTERFACE_GET, USB_REQ_GET_REPORT, (USB_REPTYPE_INPUT<<8) | 0x01, 0x0, DS3PS2_INPUT_LEN, &gamepad[slot], request_data_cb, arg); }
int ds3ps2_send_ledsrumble(int slot) { ledsrumble_buf[9] = led_pattern[ds3_list[slot].led]; ledsrumble_buf[1] = ds3_list[slot].rumble.time_r; ledsrumble_buf[2] = ds3_list[slot].rumble.power_r; ledsrumble_buf[3] = ds3_list[slot].rumble.time_l; ledsrumble_buf[4] = ds3_list[slot].rumble.power_l; return UsbControlTransfer(ds3_list[slot].endp, INTERFACE_SET, USB_REQ_SET_REPORT, (USB_REPTYPE_OUTPUT<<8) | 0x01, 0x0, sizeof(ledsrumble_buf), ledsrumble_buf, NULL, NULL); }
void usb_bulk_reset(mass_dev* dev, int mode) { int ret; usb_callback_data cb_data; iop_sema_t s; s.initial = 0; s.max = 1; s.option = 0; s.attr = 0; cb_data.semh = CreateSema(&s); //Call Bulk only mass storage reset ret = UsbControlTransfer( dev->controlEp, //default pipe 0x21, //bulk reset 0xFF, 0, dev->interfaceNumber, //interface number 0, //length NULL, //data usb_callback, (void*) &cb_data ); if (ret != USB_RC_OK) { printf("USBHDFSD: Error - sending reset %d\n", ret); } else { WaitSema(cb_data.semh); //clear bulk-in endpoint if (mode & 0x01) { usb_bulk_clear_halt(dev, 0); } //clear bulk-out endpoint if (mode & 0x02) { usb_bulk_clear_halt(dev, 1); } } DeleteSema(cb_data.semh); }
/** Set the value in a 8bit register */ int setReg8(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char value) { int ret; WaitSema(ps2cam_sema); ret = UsbControlTransfer(dev->controll, USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1, 0, (unsigned short)reg_id, 1, &value, PS2CamCallback, (void*)ps2cam_sema); if(ret != USB_RC_OK) { printf("UsbControlTransfer failed in 'setReg8'.\n"); ret = -1; } else { WaitSema(ps2cam_sema); } SignalSema(ps2cam_sema); return ret; }
void usb_getstring(int endp, int index, char *desc) { u8 *data; string_descriptor *str; int ret; data = (u8 *) AllocSysMemory(0, sizeof(string_descriptor), NULL); str = (string_descriptor *) data; if(data != NULL) { str->desc = desc; ret = UsbControlTransfer(endp, 0x80, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | index, 0, sizeof(string_descriptor) - 4, data, ps2kbd_getstring_set, data); if(ret != USB_RC_OK) { printf("PS2KBD: Error sending string descriptor request\n"); FreeSysMemory(data); } } }
static void usb_bulk_reset(mass_dev* dev, int mode) { int ret; usb_callback_data cb_data; cb_data.semh = dev->ioSema; //Call Bulk only mass storage reset ret = UsbControlTransfer( dev->controlEp, //default pipe 0x21, //bulk reset 0xFF, 0, dev->interfaceNumber, //interface number 0, //length NULL, //data usb_callback, (void*) &cb_data ); if (ret == USB_RC_OK) { WaitSema(cb_data.semh); ret = cb_data.returnCode; } if(ret == USB_RC_OK) { //clear bulk-in endpoint if (mode & 0x01) ret = usb_bulk_clear_halt(dev, USB_BLK_EP_IN); } if(ret == USB_RC_OK) { //clear bulk-out endpoint if (mode & 0x02) ret = usb_bulk_clear_halt(dev, USB_BLK_EP_OUT); } if(ret != USB_RC_OK){ XPRINTF("USBHDFSD: Error - sending reset %d to device %d.\n", ret, dev->devId); dev->status |= USBMASS_DEV_STAT_ERR; } }
void ps2kbd_config_set(int resultCode, int bytes, void *arg) /* Called when we have finished choosing our configuration */ { kbd_dev *dev; if(resultCode != USB_RC_OK) { printf("PS2KEYBOARD: Configuration set error res %d, bytes %d, arg %p\n", resultCode, bytes, arg); return; } //printf("PS2KEYBOARD: Configuration set res %d, bytes %d, arg %p\n", resultCode, bytes, arg); /* Do a interrupt data transfer */ dev = (kbd_dev *) arg; if(dev != NULL) { int ret; ret = UsbControlTransfer(dev->configEndp, 0x21, USB_REQ_SET_IDLE, 0, dev->interfaceNo, 0, NULL, ps2kbd_idlemode_set, arg); } }
static int usb_bulk_get_max_lun(mass_dev* dev) { int ret; usb_callback_data cb_data; char max_lun; cb_data.semh = dev->ioSema; //Call Bulk only mass storage reset ret = UsbControlTransfer( dev->controlEp, //default pipe 0xA1, 0xFE, 0, dev->interfaceNumber, //interface number 1, //length &max_lun, //data usb_callback, (void*) &cb_data ); if (ret == USB_RC_OK) { WaitSema(cb_data.semh); ret = cb_data.returnCode; } if(ret == USB_RC_OK){ ret = max_lun; } else { //Devices that do not support multiple LUNs may STALL this command. usb_bulk_clear_halt(dev, USB_BLK_EP_IN); usb_bulk_clear_halt(dev, USB_BLK_EP_OUT); ret = -ret; } return ret; }