void _USB_DEVICE_EndpointWriteCallBack( USB_DEVICE_IRP * irp ) { /* An endpoint write has completed */ USB_DEVICE_EVENT_DATA_ENDPOINT_WRITE_COMPLETE eventData; SYS_MODULE_INDEX deviceInstanceNumber; USB_DEVICE_Q_SIZE_ENDPOINT* thisEndpointQueueSize; USB_DEVICE_OBJ* devClientHandle; /* Get Handle to the Device Object */ devClientHandle = (USB_DEVICE_OBJ*)irp->userData; /* Get Device instance Number */ deviceInstanceNumber = devClientHandle->usbDevLayerIndex; /* Get Handle to the Endpoint Queue Size */ thisEndpointQueueSize = &qSizeEndpoint[deviceInstanceNumber]; /* Update Queue Size. We have freed one read queue element as we have completed a Transfer */ thisEndpointQueueSize->qSizeCurrentEpWrite --; if( devClientHandle->callBackFunc != NULL ) { /* Get data size received from Host */ eventData.length = irp->size; /* Get Transfer Handle */ eventData.transferHandle = ( USB_DEVICE_TRANSFER_HANDLE )irp; /* Get transfer status */ if ((irp->status == USB_DEVICE_IRP_STATUS_COMPLETED) || (irp->status == USB_DEVICE_IRP_STATUS_COMPLETED_SHORT)) { /* Transfer completed successfully */ eventData.status = USB_DEVICE_RESULT_OK; } else if (irp->status == USB_DEVICE_IRP_STATUS_ABORTED_ENDPOINT_HALT) { /* Transfer canceled due to Endpoint Halt */ eventData.status = USB_DEVICE_RESULT_ERROR_ENDPOINT_HALTED; } else if (irp->status == USB_DEVICE_IRP_STATUS_TERMINATED_BY_HOST) { /* Transfer Canceled by Host (Host sent a Clear feature )*/ eventData.status = USB_DEVICE_RESULT_ERROR_TERMINATED_BY_HOST; } else { /* Transfer was not completed successfully */ eventData.status = USB_DEVICE_RESULT_ERROR; } /* Send an event to application letting it know that a endpoint write * has completed */ devClientHandle->callBackFunc( USB_DEVICE_EVENT_ENDPOINT_WRITE_COMPLETE, &eventData, devClientHandle->context); } }
void _USB_DEVICE_EndpointWriteCallBack( USB_DEVICE_IRP * irp ) { /* An endpoint write has completed */ USB_DEVICE_EVENT_DATA_ENDPOINT_WRITE_COMPLETE event; SYS_MODULE_INDEX deviceInstanceNumber; USB_DEVICE_Q_SIZE_ENDPOINT* thisEndpointQueueSize; USB_DEVICE_OBJ* devClientHandle; /* Get Handle to the Device Object */ devClientHandle = (USB_DEVICE_OBJ*)irp->userData; /* Get Device instance Number */ deviceInstanceNumber = devClientHandle->usbDevLayerIndex; /* Get Handle to the Endpoint Queue Size */ thisEndpointQueueSize = &qSizeEndpoint[deviceInstanceNumber]; /* Update Queue Size. We have freed one read queue element as we have completed a Transfer */ thisEndpointQueueSize->qSizeCurrentEpWrite --; if( devClientHandle->callBackFunc != NULL ) { /* Get data size received from Host */ event.length = irp->size; /* Get Transfer Handle */ event.transferHandle = ( USB_DEVICE_TRANSFER_HANDLE )irp; /* Send an event to application letting it know that a endpoint write * has completed */ devClientHandle->callBackFunc( USB_DEVICE_EVENT_ENDPOINT_WRITE_COMPLETE, &event, devClientHandle->context); } }