diff options
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/Audio.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MIDI.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorage.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/RNDIS.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c | 93 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/Events.h | 18 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/StdRequestType.h | 22 | ||||
-rw-r--r-- | LUFA/Drivers/USB/USB.h | 12 |
10 files changed, 74 insertions, 83 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h index 1657c7eb9..429b899c6 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.h +++ b/LUFA/Drivers/USB/Class/Device/Audio.h @@ -131,7 +131,7 @@ bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Processes incoming control requests from the host, that are directed to the given Audio class interface. This should be - * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. * * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. */ diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index ea014bdb9..caea6ebc7 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -157,7 +157,7 @@ bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Processes incoming control requests from the host, that are directed to the given CDC class interface. This should be - * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. */ diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index 5ce72b545..b9baf2900 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -144,7 +144,7 @@ bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Processes incoming control requests from the host, that are directed to the given HID class interface. This should be - * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. * * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. */ diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.h b/LUFA/Drivers/USB/Class/Device/MIDI.h index a8b79b75b..4f72d5c93 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.h +++ b/LUFA/Drivers/USB/Class/Device/MIDI.h @@ -168,7 +168,7 @@ /* Inline Functions: */ /** Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be - * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. * * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. */ diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.h b/LUFA/Drivers/USB/Class/Device/MassStorage.h index cf3cad967..57b145e38 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.h @@ -131,7 +131,7 @@ bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Processes incoming control requests from the host, that are directed to the given Mass Storage class interface. This should be - * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. * * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. */ diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.h b/LUFA/Drivers/USB/Class/Device/RNDIS.h index 1288a25b6..292c51b77 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDIS.h +++ b/LUFA/Drivers/USB/Class/Device/RNDIS.h @@ -140,7 +140,7 @@ bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Processes incoming control requests from the host, that are directed to the given RNDIS class interface. This should be - * linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event. + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. * * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. */ diff --git a/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c b/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c index 93b4440bc..7d7e48d9b 100644 --- a/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c +++ b/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c @@ -48,72 +48,61 @@ bool USB_RemoteWakeupEnabled; void USB_Device_ProcessControlRequest(void) { - bool RequestHandled = false; uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest; for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) *(RequestHeader++) = Endpoint_Read_Byte(); - uint8_t bmRequestType = USB_ControlRequest.bmRequestType; + EVENT_USB_Device_ControlRequest(); - switch (USB_ControlRequest.bRequest) + if (Endpoint_IsSETUPReceived()) { - case REQ_GetStatus: - if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || - (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT))) - { - USB_Device_GetStatus(); - RequestHandled = true; - } + uint8_t bmRequestType = USB_ControlRequest.bmRequestType; - break; - case REQ_ClearFeature: - case REQ_SetFeature: - if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) || - (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))) - { - USB_Device_ClearSetFeature(); - RequestHandled = true; - } + switch (USB_ControlRequest.bRequest) + { + case REQ_GetStatus: + if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT))) + { + USB_Device_GetStatus(); + } - break; - case REQ_SetAddress: - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) - { - USB_Device_SetAddress(); - RequestHandled = true; - } + break; + case REQ_ClearFeature: + case REQ_SetFeature: + if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))) + { + USB_Device_ClearSetFeature(); + } - break; - case REQ_GetDescriptor: - if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || - (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE))) - { - USB_Device_GetDescriptor(); - RequestHandled = true; - } + break; + case REQ_SetAddress: + if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_SetAddress(); - break; - case REQ_GetConfiguration: - if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) - { - USB_Device_GetConfiguration(); - RequestHandled = true; - } + break; + case REQ_GetDescriptor: + if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE))) + { + USB_Device_GetDescriptor(); + } - break; - case REQ_SetConfiguration: - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) - { - USB_Device_SetConfiguration(); - RequestHandled = true; - } + break; + case REQ_GetConfiguration: + if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_GetConfiguration(); - break; - } + break; + case REQ_SetConfiguration: + if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_SetConfiguration(); - if (!(RequestHandled)) - EVENT_USB_Device_UnhandledControlRequest(); + break; + } + } if (Endpoint_IsSETUPReceived()) { diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h index 8d58e3947..63bcab5de 100644 --- a/LUFA/Drivers/USB/HighLevel/Events.h +++ b/LUFA/Drivers/USB/HighLevel/Events.h @@ -227,18 +227,20 @@ */ void EVENT_USB_Device_Disconnect(void); - /** Event for unhandled control requests. This event fires when a the USB host issues a control - * request to the control endpoint (address 0) that the library does not handle. This may either - * be a standard request that the library has no handler code for, or a class specific request - * issued to the device which must be handled appropriately. + /** Event for control requests. This event fires when a the USB host issues a control request + * to the mandatory device control endpoint (of address 0). This may either be a standard + * request that the library may have a handler code for internally, or a class specific request + * issued to the device which must be handled appropriately. If a request is not processed in the + * user application via this event, it will be passed to the library for processing internally + * if a suitable handler exists. * * This event is time-critical; each packet within the request transaction must be acknowledged or * sent within 50ms or the host will abort the transfer. * * The library internally handles all standard control requests with the exceptions of SYNC FRAME, * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left - * for the user to process via this event if desired. If not handled in the user application, requests - * are automatically STALLed. + * for the user to process via this event if desired. If not handled in the user application or by + * the library internally, unknown requests are automatically STALLed. * * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). @@ -249,7 +251,7 @@ * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used * by the application to determine how to handle the issued request. */ - void EVENT_USB_Device_UnhandledControlRequest(void); + void EVENT_USB_Device_ControlRequest(void); /** Event for USB configuration number changed. This event fires when a the USB host changes the * selected configuration number while in device mode. This event should be hooked in device @@ -352,7 +354,7 @@ #if defined(USB_CAN_BE_DEVICE) void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_UnhandledControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_ControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); diff --git a/LUFA/Drivers/USB/HighLevel/StdRequestType.h b/LUFA/Drivers/USB/HighLevel/StdRequestType.h index 2d8c7cfab..6b984ea60 100644 --- a/LUFA/Drivers/USB/HighLevel/StdRequestType.h +++ b/LUFA/Drivers/USB/HighLevel/StdRequestType.h @@ -174,43 +174,43 @@ { REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface * recipients. Passed to the user application for other recipients - * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * via the \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface * recipients. Passed to the user application for other recipients - * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * via the \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface * recipients. Passed to the user application for other recipients - * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * via the \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed * to the user application for other recipients via the - * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_GetDescriptor = 6, /**< Implemented in the library for device and interface recipients. Passed to the * user application for other recipients via the - * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * via the \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed * to the user application for other recipients via the - * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed * to the user application for other recipients via the - * \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * via the \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * via the \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_UnhandledControlRequest() event when received in + * via the \ref EVENT_USB_Device_ControlRequest() event when received in * device mode. */ }; diff --git a/LUFA/Drivers/USB/USB.h b/LUFA/Drivers/USB/USB.h index 1e1c26e88..fcb74006f 100644 --- a/LUFA/Drivers/USB/USB.h +++ b/LUFA/Drivers/USB/USB.h @@ -214,14 +214,14 @@ * * The final standardized Device Class Driver function is the Control Request handler function * <i><b>{Class Name}</b>_Device_ProcessControlRequest()</i>, which should be called when the - * \ref EVENT_USB_Device_UnhandledControlRequest() event fires. This function should also be - * called for each class driver instance, using the address of the instance to operate on as - * the function's parameter. The request handler will abort if it is determined that the current - * request is not targeted at the given class driver instance, thus these methods can safely be - * called one-after-another in the event handler with no form of error checking: + * \ref EVENT_USB_Device_ControlRequest() event fires. This function should also be called for + * each class driver instance, using the address of the instance to operate on as the function's + * parameter. The request handler will abort if it is determined that the current request is not + * targeted at the given class driver instance, thus these methods can safely be called + * one-after-another in the event handler with no form of error checking: * * \code - * void EVENT_USB_Device_UnhandledControlRequest(void) + * void EVENT_USB_Device_ControlRequest(void) * { * Audio_Device_ProcessControlRequest(&My_Audio_Interface); * } |