diff options
Diffstat (limited to 'LUFA/Drivers/USB')
19 files changed, 101 insertions, 56 deletions
diff --git a/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h b/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h index f1e1d070d..9d701fbeb 100644 --- a/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h +++ b/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h @@ -147,7 +147,7 @@ #define HID_KEYBOARD_SC_4_AND_DOLLAR 0x21 #define HID_KEYBOARD_SC_5_AND_PERCENTAGE 0x22 #define HID_KEYBOARD_SC_6_AND_CARET 0x23 - #define HID_KEYBOARD_SC_7_AND_AND_AMPERSAND 0x24 + #define HID_KEYBOARD_SC_7_AND_AMPERSAND 0x24 #define HID_KEYBOARD_SC_8_AND_ASTERISK 0x25 #define HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS 0x26 #define HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS 0x27 @@ -229,7 +229,7 @@ #define HID_KEYBOARD_SC_F24 0x73 #define HID_KEYBOARD_SC_EXECUTE 0x74 #define HID_KEYBOARD_SC_HELP 0x75 - #define HID_KEYBOARD_SC_MANU 0x76 + #define HID_KEYBOARD_SC_MENU 0x76 #define HID_KEYBOARD_SC_SELECT 0x77 #define HID_KEYBOARD_SC_STOP 0x78 #define HID_KEYBOARD_SC_AGAIN 0x79 @@ -265,7 +265,7 @@ #define HID_KEYBOARD_SC_LANG8 0x97 #define HID_KEYBOARD_SC_LANG9 0x98 #define HID_KEYBOARD_SC_ALTERNATE_ERASE 0x99 - #define HID_KEYBOARD_SC_SISREQ 0x9A + #define HID_KEYBOARD_SC_SYSREQ 0x9A #define HID_KEYBOARD_SC_CANCEL 0x9B #define HID_KEYBOARD_SC_CLEAR 0x9C #define HID_KEYBOARD_SC_PRIOR 0x9D @@ -274,7 +274,7 @@ #define HID_KEYBOARD_SC_OUT 0xA0 #define HID_KEYBOARD_SC_OPER 0xA1 #define HID_KEYBOARD_SC_CLEAR_AND_AGAIN 0xA2 - #define HID_KEYBOARD_SC_CRSEL_ANDPROPS 0xA3 + #define HID_KEYBOARD_SC_CRSEL_AND_PROPS 0xA3 #define HID_KEYBOARD_SC_EXSEL 0xA4 #define HID_KEYBOARD_SC_KEYPAD_00 0xB0 #define HID_KEYBOARD_SC_KEYPAD_000 0xB1 @@ -330,6 +330,23 @@ #define HID_KEYBOARD_SC_RIGHT_SHIFT 0xE5 #define HID_KEYBOARD_SC_RIGHT_ALT 0xE6 #define HID_KEYBOARD_SC_RIGHT_GUI 0xE7 + #define HID_KEYBOARD_SC_MEDIA_PLAY 0xE8 + #define HID_KEYBOARD_SC_MEDIA_STOP 0xE9 + #define HID_KEYBOARD_SC_MEDIA_PREVIOUS_TRACK 0xEA + #define HID_KEYBOARD_SC_MEDIA_NEXT_TRACK 0xEB + #define HID_KEYBOARD_SC_MEDIA_EJECT 0xEC + #define HID_KEYBOARD_SC_MEDIA_VOLUME_UP 0xED + #define HID_KEYBOARD_SC_MEDIA_VOLUME_DOWN 0xEE + #define HID_KEYBOARD_SC_MEDIA_MUTE 0xEF + #define HID_KEYBOARD_SC_MEDIA_WWW 0xF0 + #define HID_KEYBOARD_SC_MEDIA_BACKWARD 0xF1 + #define HID_KEYBOARD_SC_MEDIA_FORWARD 0xF2 + #define HID_KEYBOARD_SC_MEDIA_CANCEL 0xF3 + #define HID_KEYBOARD_SC_MEDIA_SEARCH 0xF4 + #define HID_KEYBOARD_SC_MEDIA_SLEEP 0xF8 + #define HID_KEYBOARD_SC_MEDIA_LOCK 0xF9 + #define HID_KEYBOARD_SC_MEDIA_RELOAD 0xFA + #define HID_KEYBOARD_SC_MEDIA_CALCULATOR 0xFB //@} /** \name Common HID Device Report Descriptors */ diff --git a/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h b/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h index 3e601ea5e..f52013cc9 100644 --- a/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h +++ b/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h @@ -345,7 +345,7 @@ */ typedef struct { - uint8_t Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */ + uint8_t Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */ uint8_t Data1; /**< First byte of data in the MIDI event. */ uint8_t Data2; /**< Second byte of data in the MIDI event. */ diff --git a/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h b/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h index 5c6d3fdcc..640745efe 100644 --- a/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h +++ b/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h @@ -172,9 +172,6 @@ #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL //@} - /** Maximum size in bytes of a RNDIS control message which can be sent or received. */ - #define RNDIS_MESSAGE_BUFFER_SIZE 128 - /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */ #define ETHERNET_FRAME_SIZE_MAX 1500 diff --git a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c index e46330f94..03a745c1a 100644 --- a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c @@ -68,6 +68,10 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_ClearSETUP(); + + if (ReportID) + Endpoint_Write_8(ReportID); + Endpoint_Write_Control_Stream_LE(ReportData, ReportSize); Endpoint_ClearOUT(); } diff --git a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c index 061f1b249..6ee73c5bb 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c @@ -82,7 +82,7 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); - Endpoint_Read_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, USB_ControlRequest.wLength); + Endpoint_Read_Control_Stream_LE(RNDISInterfaceInfo->Config.MessageBuffer, USB_ControlRequest.wLength); Endpoint_ClearIN(); RNDIS_Device_ProcessRNDISControlMessage(RNDISInterfaceInfo); @@ -92,16 +92,16 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI case RNDIS_REQ_GetEncapsulatedResponse: if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { - RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)RNDISInterfaceInfo->Config.MessageBuffer; if (!(MessageHeader->MessageLength)) { - RNDISInterfaceInfo->State.RNDISMessageBuffer[0] = 0; - MessageHeader->MessageLength = CPU_TO_LE32(1); + RNDISInterfaceInfo->Config.MessageBuffer[0] = 0; + MessageHeader->MessageLength = CPU_TO_LE32(1); } Endpoint_ClearSETUP(); - Endpoint_Write_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, le32_to_cpu(MessageHeader->MessageLength)); + Endpoint_Write_Control_Stream_LE(RNDISInterfaceInfo->Config.MessageBuffer, le32_to_cpu(MessageHeader->MessageLength)); Endpoint_ClearOUT(); MessageHeader->MessageLength = CPU_TO_LE32(0); @@ -119,6 +119,12 @@ bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISIn RNDISInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; RNDISInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT; + if (RNDISInterfaceInfo->Config.MessageBuffer == NULL) + return false; + + if (RNDISInterfaceInfo->Config.MessageBufferLength < RNDIS_DEVICE_MIN_MESSAGE_BUFFER_LENGTH) + return false; + if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataINEndpoint, 1))) return false; @@ -162,7 +168,7 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const /* Note: Only a single buffer is used for both the received message and its response to save SRAM. Because of this, response bytes should be filled in order so that they do not clobber unread data in the buffer. */ - RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)RNDISInterfaceInfo->Config.MessageBuffer; switch (le32_to_cpu(MessageHeader->MessageType)) { @@ -170,9 +176,9 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo->State.ResponseReady = true; RNDIS_Initialize_Message_t* INITIALIZE_Message = - (RNDIS_Initialize_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + (RNDIS_Initialize_Message_t*)RNDISInterfaceInfo->Config.MessageBuffer; RNDIS_Initialize_Complete_t* INITIALIZE_Response = - (RNDIS_Initialize_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + (RNDIS_Initialize_Complete_t*)RNDISInterfaceInfo->Config.MessageBuffer; INITIALIZE_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_INITIALIZE_CMPLT); INITIALIZE_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Initialize_Complete_t)); @@ -201,13 +207,13 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const case REMOTE_NDIS_QUERY_MSG: RNDISInterfaceInfo->State.ResponseReady = true; - RNDIS_Query_Message_t* QUERY_Message = (RNDIS_Query_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; - RNDIS_Query_Complete_t* QUERY_Response = (RNDIS_Query_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Query_Message_t* QUERY_Message = (RNDIS_Query_Message_t*)RNDISInterfaceInfo->Config.MessageBuffer; + RNDIS_Query_Complete_t* QUERY_Response = (RNDIS_Query_Complete_t*)RNDISInterfaceInfo->Config.MessageBuffer; uint32_t Query_Oid = CPU_TO_LE32(QUERY_Message->Oid); - void* QueryData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + - le32_to_cpu(QUERY_Message->InformationBufferOffset)]; - void* ResponseData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Query_Complete_t)]; + void* QueryData = &RNDISInterfaceInfo->Config.MessageBuffer[sizeof(RNDIS_Message_Header_t) + + le32_to_cpu(QUERY_Message->InformationBufferOffset)]; + void* ResponseData = &RNDISInterfaceInfo->Config.MessageBuffer[sizeof(RNDIS_Query_Complete_t)]; uint16_t ResponseSize; QUERY_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_QUERY_CMPLT); @@ -234,15 +240,15 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const case REMOTE_NDIS_SET_MSG: RNDISInterfaceInfo->State.ResponseReady = true; - RNDIS_Set_Message_t* SET_Message = (RNDIS_Set_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; - RNDIS_Set_Complete_t* SET_Response = (RNDIS_Set_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Set_Message_t* SET_Message = (RNDIS_Set_Message_t*)RNDISInterfaceInfo->Config.MessageBuffer; + RNDIS_Set_Complete_t* SET_Response = (RNDIS_Set_Complete_t*)RNDISInterfaceInfo->Config.MessageBuffer; uint32_t SET_Oid = le32_to_cpu(SET_Message->Oid); SET_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_SET_CMPLT); SET_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Set_Complete_t)); SET_Response->RequestId = SET_Message->RequestId; - void* SetData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + + void* SetData = &RNDISInterfaceInfo->Config.MessageBuffer[sizeof(RNDIS_Message_Header_t) + le32_to_cpu(SET_Message->InformationBufferOffset)]; SET_Response->Status = RNDIS_Device_ProcessNDISSet(RNDISInterfaceInfo, SET_Oid, SetData, @@ -252,7 +258,7 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const case REMOTE_NDIS_RESET_MSG: RNDISInterfaceInfo->State.ResponseReady = true; - RNDIS_Reset_Complete_t* RESET_Response = (RNDIS_Reset_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Reset_Complete_t* RESET_Response = (RNDIS_Reset_Complete_t*)RNDISInterfaceInfo->Config.MessageBuffer; RESET_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_RESET_CMPLT); RESET_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Reset_Complete_t)); @@ -264,9 +270,9 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo->State.ResponseReady = true; RNDIS_KeepAlive_Message_t* KEEPALIVE_Message = - (RNDIS_KeepAlive_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + (RNDIS_KeepAlive_Message_t*)RNDISInterfaceInfo->Config.MessageBuffer; RNDIS_KeepAlive_Complete_t* KEEPALIVE_Response = - (RNDIS_KeepAlive_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + (RNDIS_KeepAlive_Complete_t*)RNDISInterfaceInfo->Config.MessageBuffer; KEEPALIVE_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_KEEPALIVE_CMPLT); KEEPALIVE_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_KeepAlive_Complete_t)); @@ -387,7 +393,7 @@ static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RN *ResponseSize = sizeof(uint32_t); /* Indicate maximum overall buffer (Ethernet frame and RNDIS header) the adapter can handle */ - *((uint32_t*)ResponseData) = CPU_TO_LE32(RNDIS_MESSAGE_BUFFER_SIZE + ETHERNET_FRAME_SIZE_MAX); + *((uint32_t*)ResponseData) = CPU_TO_LE32(RNDISInterfaceInfo->Config.MessageBufferLength + ETHERNET_FRAME_SIZE_MAX); return true; default: diff --git a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h index 4ba729a7e..2821d7deb 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h @@ -87,14 +87,15 @@ char* AdapterVendorDescription; /**< String description of the adapter vendor. */ MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter. */ + + uint8_t* MessageBuffer; /**< Buffer where RNDIS messages can be stored by the internal driver. This + * should be at least 132 bytes in length for minimal functionality. */ + uint16_t MessageBufferLength; /**< Length in bytes of the \ref MessageBuffer RNDIS buffer. */ } Config; /**< Config data for the USB class interface within the device. All elements in this section * <b>must</b> be set or the interface will fail to enumerate and operate correctly. */ struct { - uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host, - * managed by the class driver. - */ bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host. */ uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the \ref RNDIS_States_t enum. */ uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver. */ @@ -172,6 +173,9 @@ /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) + /* Macros: */ + #define RNDIS_DEVICE_MIN_MESSAGE_BUFFER_LENGTH sizeof(AdapterSupportedOIDList) + sizeof(RNDIS_Query_Complete_t) + /* Function Prototypes: */ #if defined(__INCLUDE_FROM_RNDIS_DEVICE_C) static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) diff --git a/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c b/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c index 57a619ff4..ac8d5dc5c 100644 --- a/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c @@ -98,10 +98,10 @@ uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo AOAInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataINPipe, 1))) - return false; + return AOA_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return AOA_ENUMERROR_PipeConfigurationFailed; AOAInterfaceInfo->State.IsActive = true; AOAInterfaceInfo->State.InterfaceNumber = AOAInterface->InterfaceNumber; diff --git a/LUFA/Drivers/USB/Class/Host/AudioClassHost.c b/LUFA/Drivers/USB/Class/Host/AudioClassHost.c index c437654b6..3b5bceb6a 100644 --- a/LUFA/Drivers/USB/Class/Host/AudioClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/AudioClassHost.c @@ -104,10 +104,10 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa AudioInterfaceInfo->Config.DataOUTPipe.Banks = 2; if (!(Pipe_ConfigurePipeTable(&AudioInterfaceInfo->Config.DataINPipe, 1))) - return false; + return AUDIO_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&AudioInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return AUDIO_ENUMERROR_PipeConfigurationFailed; AudioInterfaceInfo->State.ControlInterfaceNumber = AudioControlInterface->InterfaceNumber; AudioInterfaceInfo->State.StreamingInterfaceNumber = AudioStreamingInterface->InterfaceNumber; diff --git a/LUFA/Drivers/USB/Class/Host/CDCClassHost.c b/LUFA/Drivers/USB/Class/Host/CDCClassHost.c index a575c1bbf..b32a237cc 100644 --- a/LUFA/Drivers/USB/Class/Host/CDCClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/CDCClassHost.c @@ -112,13 +112,13 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo CDCInterfaceInfo->Config.NotificationPipe.Type = EP_TYPE_INTERRUPT; if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataINPipe, 1))) - return false; + return CDC_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return CDC_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.NotificationPipe, 1))) - return false; + return CDC_ENUMERROR_PipeConfigurationFailed; CDCInterfaceInfo->State.ControlInterfaceNumber = CDCControlInterface->InterfaceNumber; CDCInterfaceInfo->State.ControlLineStates.HostToDevice = (CDC_CONTROL_LINE_OUT_RTS | CDC_CONTROL_LINE_OUT_DTR); diff --git a/LUFA/Drivers/USB/Class/Host/HIDClassHost.c b/LUFA/Drivers/USB/Class/Host/HIDClassHost.c index c3375e67e..b43435dcb 100644 --- a/LUFA/Drivers/USB/Class/Host/HIDClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/HIDClassHost.c @@ -99,7 +99,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo HIDInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_INTERRUPT; if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataINPipe, 1))) - return false; + return HID_ENUMERROR_PipeConfigurationFailed; if (DataOUTEndpoint) { @@ -108,7 +108,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo HIDInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_INTERRUPT; if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return HID_ENUMERROR_PipeConfigurationFailed; } HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber; @@ -238,7 +238,7 @@ uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo { #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) - return false; + return PIPE_RWSTREAM_NoError; if (HIDInterfaceInfo->State.DeviceUsesOUTPipe && (ReportType == HID_REPORT_ITEM_Out)) { diff --git a/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c b/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c index 7ec26549d..8b898cba5 100644 --- a/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c @@ -87,10 +87,10 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI MIDIInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; if (!(Pipe_ConfigurePipeTable(&MIDIInterfaceInfo->Config.DataINPipe, 1))) - return false; + return MIDI_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&MIDIInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return MIDI_ENUMERROR_PipeConfigurationFailed; MIDIInterfaceInfo->State.InterfaceNumber = MIDIInterface->InterfaceNumber; MIDIInterfaceInfo->State.IsActive = true; diff --git a/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c b/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c index d5bace70e..ac448a55b 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c @@ -87,10 +87,10 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, MSInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; if (!(Pipe_ConfigurePipeTable(&MSInterfaceInfo->Config.DataINPipe, 1))) - return false; + return MS_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&MSInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return MS_ENUMERROR_PipeConfigurationFailed; MSInterfaceInfo->State.InterfaceNumber = MassStorageInterface->InterfaceNumber; MSInterfaceInfo->State.IsActive = true; diff --git a/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c b/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c index 7eda9f605..fd32e1c28 100644 --- a/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c @@ -87,10 +87,10 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI PRNTInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; if (!(Pipe_ConfigurePipeTable(&PRNTInterfaceInfo->Config.DataINPipe, 1))) - return false; + return PRNT_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&PRNTInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return PRNT_ENUMERROR_PipeConfigurationFailed; PRNTInterfaceInfo->State.InterfaceNumber = PrinterInterface->InterfaceNumber; PRNTInterfaceInfo->State.AlternateSetting = PrinterInterface->AlternateSetting; diff --git a/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c b/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c index 9072d3aa6..3ed51c8d9 100644 --- a/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c @@ -114,13 +114,13 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa RNDISInterfaceInfo->Config.NotificationPipe.Type = EP_TYPE_INTERRUPT; if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.DataINPipe, 1))) - return false; + return RNDIS_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return RNDIS_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.NotificationPipe, 1))) - return false; + return RNDIS_ENUMERROR_PipeConfigurationFailed; RNDISInterfaceInfo->State.ControlInterfaceNumber = RNDISControlInterface->InterfaceNumber; RNDISInterfaceInfo->State.IsActive = true; diff --git a/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c b/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c index b3d74bc1e..24a6308f5 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c @@ -100,13 +100,13 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, SIInterfaceInfo->Config.EventsPipe.Type = EP_TYPE_INTERRUPT; if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataINPipe, 1))) - return false; + return SI_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + return SI_ENUMERROR_PipeConfigurationFailed; if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.EventsPipe, 1))) - return false; + return SI_ENUMERROR_PipeConfigurationFailed; SIInterfaceInfo->State.InterfaceNumber = StillImageInterface->InterfaceNumber; SIInterfaceInfo->State.IsActive = true; diff --git a/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c index 4fc242f34..98887009c 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c +++ b/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c @@ -79,6 +79,8 @@ uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, return ENDPOINT_RWCSTREAM_DeviceDisconnected; else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; } return ENDPOINT_RWCSTREAM_NoError; diff --git a/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c index 4fc242f34..98887009c 100644 --- a/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c +++ b/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c @@ -79,6 +79,8 @@ uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, return ENDPOINT_RWCSTREAM_DeviceDisconnected; else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; } return ENDPOINT_RWCSTREAM_NoError; diff --git a/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c index 5bd4092e4..703f253c0 100644 --- a/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c +++ b/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c @@ -81,6 +81,8 @@ uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, return ENDPOINT_RWCSTREAM_DeviceDisconnected; else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; } return ENDPOINT_RWCSTREAM_NoError; diff --git a/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c b/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c index f8b0fc6af..99589809e 100644 --- a/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c +++ b/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c @@ -109,15 +109,26 @@ void USB_Disable(void) void USB_ResetInterface(void) { + uint8_t PrescalerNeeded; + #if defined(USB_DEVICE_OPT_FULLSPEED) if (USB_Options & USB_DEVICE_OPT_LOWSPEED) - CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp); + PrescalerNeeded = F_USB / 6000000; else - CLK.USBCTRL = (((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp); + PrescalerNeeded = F_USB / 48000000; #else - CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp); + PrescalerNeeded = F_USB / 6000000; #endif + uint8_t DividerIndex = 0; + while (PrescalerNeeded > 0) + { + DividerIndex++; + PrescalerNeeded >>= 1; + } + + CLK.USBCTRL = (DividerIndex - 1) << CLK_USBPSDIV_gp; + if (USB_Options & USB_OPT_PLLCLKSRC) CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm); else |