void HID_CtrlSetupSetReport(void * pVoid) { S_DRVUSB_DEVICE *psDevice = (S_DRVUSB_DEVICE *)((S_HID_DEVICE *)pVoid)->device; if(psDevice->au8Setup[3] == 1) { /* Report Type = input */ // Trigger next Control Out DATA1 Transaction. _DRVUSB_SET_EP_TOG_BIT(1, FALSE); _DRVUSB_TRIG_EP(1, 0); } else if (psDevice->au8Setup[3] == 2) { _DRVUSB_SET_EP_TOG_BIT(1, FALSE); _DRVUSB_TRIG_EP(1, 0x00); } else if (psDevice->au8Setup[3] == 3) { /* Request Type = Feature */ _DRVUSB_SET_EP_TOG_BIT(1, FALSE); _DRVUSB_TRIG_EP(1, 0x00); } else { // Not support. Reply STALL. _HID_CLR_CTRL_READY_AND_TRIG_STALL(); } }
void HID_CtrlSetupSetIdle(void * pVoid) { _DRVUSB_SET_EP_TOG_BIT(0, 0); _DRVUSB_TRIG_EP(0,0x00); //DBG_PRINTF("Set idle\n"); }
void HID_CtrlGetDescriptorIn(void * pVoid) { uint32_t u32Len; // S_DRVUSB_DEVICE *psDevice = &gsUsbDevice; // uint32_t u32EpId; DBG_PRINTF(" >>> 0x%08x %d size.\n", gpu8UsbBuf, gu32BytesInUsbBuf); if(gpu8UsbBuf) { if(gu32BytesInUsbBuf == 0) { /* Zero packet */ DrvUSB_DataIn(0, gpu8UsbBuf, 0); gpu8UsbBuf = 0; //u32Len = 10000; //while(u32Len--); //_DRVUSB_TRIG_EP(1,0x00); } else { u32Len = Minimum(gu32BytesInUsbBuf, HID_MAX_PACKET_SIZE_CTRL); DrvUSB_DataIn(0, gpu8UsbBuf, u32Len); gpu8UsbBuf += u32Len; gu32BytesInUsbBuf -= u32Len; if(gu32BytesInUsbBuf == 0) { if(u32Len < HID_MAX_PACKET_SIZE_CTRL) { /* This should be last IN packet due to it is less than HID_MAX_PACKET_SIZE_EP0 */ gpu8UsbBuf = 0; //u32Len = 10000; //while(u32Len--); //_DRVUSB_TRIG_EP(1,0x00); } else { if(!gIsOverRequest) { gpu8UsbBuf = 0; //u32Len = 10000; //while(u32Len--); //_DRVUSB_TRIG_EP(1,0x00); } } } } } else { /* The EP id 1 should always be used as control (OUT) endpoint */ _DRVUSB_TRIG_EP(1,0x00); } }
void HID_CtrlSetupSetProtocol(void * pVoid) { _DRVUSB_SET_EP_TOG_BIT(0, FALSE); _DRVUSB_TRIG_EP(0, 0x00); DBG_PRINTF("Set protocol"); }
void HID_CtrlSetupSetProtocol(void * pVoid) { S_HID_DEVICE *psDevice = (S_HID_DEVICE *) pVoid; S_DRVUSB_DEVICE *pUsbDevice = (S_DRVUSB_DEVICE *)psDevice->device; psDevice->isReportProtocol = pUsbDevice->au8Setup[2]; _DRVUSB_SET_EP_TOG_BIT(0,0); _DRVUSB_TRIG_EP(0,0x00); }
void HID_CtrlGetDescriptorIn(void * pVoid) { uint32_t u32Len; DBG_PRINTF(" >>> 0x%08x %d size.\n", gpu8UsbBuf, gu32BytesInUsbBuf); if (gpu8UsbBuf) { if (gu32BytesInUsbBuf == 0) { /* Zero packet */ DrvUSB_DataIn(0, gpu8UsbBuf, 0); gpu8UsbBuf = 0; } else { u32Len = Minimum(gu32BytesInUsbBuf, HID_MAX_PACKET_SIZE_EP0); DrvUSB_DataIn(0, gpu8UsbBuf, u32Len); gpu8UsbBuf += u32Len; gu32BytesInUsbBuf -= u32Len; if (gu32BytesInUsbBuf == 0) { if (u32Len < HID_MAX_PACKET_SIZE_EP0) { /* This should be last IN packet due to it is less than UAC_MAX_PACKET_SIZE_EP0 */ gpu8UsbBuf = 0; } else { if (!gIsOverRequest) { /* This should be the last IN packet because there is no more data to transfer and it is not over request transfer */ gpu8UsbBuf = 0; } } } } } else { /* The EP id 1 should always be used as control (OUT) endpoint */ _DRVUSB_TRIG_EP(1, 0x00); } }
void HID_CtrlSetupGetDescriptor(void * pVoid) { S_HID_DEVICE *psDevice = (S_HID_DEVICE *) pVoid; S_DRVUSB_DEVICE *pUsbDevice = (S_DRVUSB_DEVICE *)psDevice->device; uint16_t u16Len; u16Len = 0; u16Len = pUsbDevice->au8Setup[7]; u16Len <<= 8; u16Len += pUsbDevice->au8Setup[6]; gIsOverRequest = 0; gu32BytesInUsbBuf = 0; gpu8UsbBuf = 0; switch (pUsbDevice->au8Setup[3]) { // Get Device Descriptor case DESC_DEVICE: { HID_PrepareDescriptors(g_HID_sDevice.au8DeviceDescriptor, LEN_DEVICE, u16Len, HID_MAX_PACKET_SIZE_EP0); /* Prepare the OUT to avoid HOST stop data phase without all data transfered. */ _DRVUSB_TRIG_EP(1, 0x00); // GR_DBG_PRINTF("DESC_DEVICE .\n"); break; } // Get Configuration Descriptor case DESC_CONFIG: { HID_PrepareDescriptors(g_HID_sDevice.au8ConfigDescriptor, gau8ConfigDescriptor[2], u16Len, HID_MAX_PACKET_SIZE_EP0); // GR_DBG_PRINTF("DESC_CONFIG .\n"); break; } // Get HID Descriptor case DESC_HID: { HID_PrepareDescriptors(g_HID_sDevice.pu8HIDDescriptor, LEN_HID, u16Len, HID_MAX_PACKET_SIZE_EP0); // GR_DBG_PRINTF("DESC_HID .\n"); break; } // Get Report Descriptor case DESC_HID_RPT: { HID_PrepareDescriptors(g_HID_sDevice.pu8ReportDescriptor, g_HID_sDevice.u32ReportDescriptorSize, u16Len, HID_MAX_PACKET_SIZE_EP0); // GR_DBG_PRINTF("DESC_HID_RPT .\n"); break; } // Get String Descriptor case DESC_STRING: { // Get Language if (pUsbDevice->au8Setup[2] == 0) { HID_PrepareDescriptors(gau8StringLang, 4, u16Len, HID_MAX_PACKET_SIZE_EP0); } else { // Get String Descriptor switch (pUsbDevice->au8Setup[2]) { case 1: HID_PrepareDescriptors((const uint8_t *)gau8VendorStringDescriptor, gau8VendorStringDescriptor[0], u16Len, HID_MAX_PACKET_SIZE_EP0); break; case 2: HID_PrepareDescriptors((const uint8_t *)gau8ProductStringDescriptor, gau8ProductStringDescriptor[0], u16Len, HID_MAX_PACKET_SIZE_EP0); break; case 3: HID_PrepareDescriptors(gau8StringSerial, gau8StringSerial[0], u16Len, HID_MAX_PACKET_SIZE_EP0); break; default: /* Not support. Reply STALL. */ DrvUSB_ClrCtrlReadyAndTrigStall(); } } // GR_DBG_PRINTF("DESC_STRING .\n"); break; } default: /* Not support. Reply STALL. */ DrvUSB_ClrCtrlReadyAndTrigStall(); } }
void HID_CtrlSetupSetIdle(void * pVoid) { _DRVUSB_SET_EP_TOG_BIT(0, FALSE); _DRVUSB_TRIG_EP(0, 0x00); }