break;\r
case REQ_ClearFeature:\r
case REQ_SetFeature:\r
- if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))\r
+ if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+ (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT)))\r
{\r
USB_Device_ClearSetFeature();\r
RequestHandled = true;\r
}\r
\r
if (!(RequestHandled))\r
- RAISE_EVENT(USB_UnhandledControlPacket);\r
+ EVENT_USB_UnhandledControlPacket();\r
\r
if (Endpoint_IsSETUPReceived())\r
{\r
{\r
Endpoint_ClearSETUP();\r
\r
- while (!(Endpoint_IsINReady()));\r
- \r
Endpoint_ClearIN();\r
\r
while (!(Endpoint_IsINReady()));\r
\r
static void USB_Device_SetConfiguration(void)\r
{\r
- bool AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
+ bool AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
\r
#if defined(USE_SINGLE_DEVICE_CONFIGURATION)\r
if ((uint8_t)USB_ControlRequest.wValue > 1)\r
#else\r
USB_Descriptor_Device_t* DevDescriptorPtr;\r
\r
- if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||\r
+ if ((CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||\r
#if defined(USE_RAM_DESCRIPTORS)\r
((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations))\r
#elif defined (USE_EEPROM_DESCRIPTORS)\r
Endpoint_ClearIN();\r
\r
if (!(AlreadyConfigured) && USB_ConfigurationNumber)\r
- RAISE_EVENT(USB_DeviceEnumerationComplete);\r
+ EVENT_USB_DeviceEnumerationComplete();\r
\r
- RAISE_EVENT(USB_ConfigurationChanged);\r
+ EVENT_USB_ConfigurationChanged();\r
}\r
\r
void USB_Device_GetConfiguration(void)\r
{\r
- Endpoint_ClearSETUP(); \r
+ Endpoint_ClearSETUP();\r
\r
Endpoint_Write_Byte(USB_ConfigurationNumber);\r
\r
void* DescriptorPointer;\r
uint16_t DescriptorSize;\r
\r
- if ((DescriptorSize = USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)\r
- return;\r
+ if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,\r
+ &DescriptorPointer)) == NO_DESCRIPTOR)\r
+ {\r
+ return;\r
+ }\r
\r
Endpoint_ClearSETUP();\r
\r
#if defined(USE_RAM_DESCRIPTORS)\r
Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);\r
#else\r
- bool SendZLP;\r
+ bool SendZLP;\r
\r
if (USB_ControlRequest.wLength > DescriptorSize)\r
USB_ControlRequest.wLength = DescriptorSize;\r
while (USB_ControlRequest.wLength && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
{\r
#if defined (USE_EEPROM_DESCRIPTORS)\r
- Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++)); \r
+ Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++)); \r
#else\r
Endpoint_Write_Byte(pgm_read_byte(DescriptorPointer++));\r
#endif\r
case REQREC_DEVICE:\r
if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)\r
USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);\r
+ else\r
+ return;\r
\r
break; \r
#if !defined(CONTROL_ONLY_DEVICE)\r
{\r
uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
\r
- if (EndpointIndex != ENDPOINT_CONTROLEP)\r
- {\r
- Endpoint_SelectEndpoint(EndpointIndex);\r
-\r
- if (Endpoint_IsEnabled())\r
- { \r
- if (USB_ControlRequest.bRequest == REQ_ClearFeature)\r
- {\r
- Endpoint_ClearStall();\r
- Endpoint_ResetFIFO(EndpointIndex);\r
- Endpoint_ResetDataToggle();\r
- }\r
- else\r
- {\r
- Endpoint_StallTransaction(); \r
- }\r
+ if (EndpointIndex == ENDPOINT_CONTROLEP)\r
+ return;\r
+\r
+ Endpoint_SelectEndpoint(EndpointIndex);\r
+\r
+ if (Endpoint_IsEnabled())\r
+ { \r
+ if (USB_ControlRequest.bRequest == REQ_ClearFeature)\r
+ {\r
+ Endpoint_ClearStall();\r
+ Endpoint_ResetFIFO(EndpointIndex);\r
+ Endpoint_ResetDataToggle();\r
+ }\r
+ else\r
+ {\r
+ Endpoint_StallTransaction();\r
}\r
-\r
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
- Endpoint_ClearSETUP();\r
- Endpoint_ClearIN();\r
}\r
}\r
\r
break;\r
#endif\r
}\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+\r
+ Endpoint_ClearSETUP();\r
+\r
+ Endpoint_ClearIN();\r
}\r
\r
#endif\r