Extract UsbReceiveData()

This commit is contained in:
László Monda
2016-02-29 16:00:00 +01:00
parent 9585c2c8cb
commit ce056ed2ca

View File

@@ -13,6 +13,12 @@
static usb_device_generic_hid_struct_t UsbGenericHidDevice;
static usb_status_t UsbReceiveData() {
return USB_DeviceHidRecv(UsbCompositeDevice.genericHidHandle, USB_GENERIC_HID_ENDPOINT_OUT_ID,
(uint8_t *)&UsbGenericHidDevice.buffer[UsbGenericHidDevice.bufferIndex][0],
USB_GENERIC_HID_OUT_BUFFER_LENGTH);
}
usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void *param)
{
usb_status_t error = kStatus_USB_Error;
@@ -42,9 +48,7 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void *
(uint8_t *)&UsbGenericHidDevice.buffer[UsbGenericHidDevice.bufferIndex][0],
USB_GENERIC_HID_OUT_BUFFER_LENGTH);
UsbGenericHidDevice.bufferIndex ^= 1U;
return USB_DeviceHidRecv(UsbCompositeDevice.genericHidHandle, USB_GENERIC_HID_ENDPOINT_OUT_ID,
(uint8_t *)&UsbGenericHidDevice.buffer[UsbGenericHidDevice.bufferIndex][0],
USB_GENERIC_HID_OUT_BUFFER_LENGTH);
return UsbReceiveData();
break;
case kUSB_DeviceHidEventGetReport:
case kUSB_DeviceHidEventSetReport:
@@ -66,10 +70,7 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void *
usb_status_t UsbGenericHidSetConfiguration(class_handle_t handle, uint8_t configuration)
{
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
return USB_DeviceHidRecv(
UsbCompositeDevice.genericHidHandle, USB_GENERIC_HID_ENDPOINT_OUT_ID,
(uint8_t *)&UsbGenericHidDevice.buffer[UsbGenericHidDevice.bufferIndex][0],
USB_GENERIC_HID_OUT_BUFFER_LENGTH);
return UsbReceiveData();
}
return kStatus_USB_Error;
}
@@ -78,10 +79,7 @@ usb_status_t UsbGenericHidSetInterface(class_handle_t handle, uint8_t interface,
{
if (USB_KEYBOARD_INTERFACE_INDEX == interface) {
UsbCompositeDevice.currentInterfaceAlternateSetting[interface] = alternateSetting;
return USB_DeviceHidRecv(
UsbCompositeDevice.genericHidHandle, USB_GENERIC_HID_ENDPOINT_OUT_ID,
(uint8_t *)&UsbGenericHidDevice.buffer[UsbGenericHidDevice.bufferIndex][0],
USB_GENERIC_HID_OUT_BUFFER_LENGTH);
return UsbReceiveData();
}
return kStatus_USB_Error;
}