Renamed the EVENT_USB_Device_UnhandledControlRequest() event to EVENT_USB_Device_ControlRequest() as it is now fired before the library request handlers, not afterwards.
This commit is contained in:
parent
99a9e415ef
commit
fb76acb084
88 changed files with 222 additions and 224 deletions
|
@ -48,73 +48,62 @@ 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();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(RequestHandled))
|
||||
EVENT_USB_Device_UnhandledControlRequest();
|
||||
|
||||
if (Endpoint_IsSETUPReceived())
|
||||
{
|
||||
Endpoint_StallTransaction();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue