diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-10 19:24:58 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-10 19:24:58 +0000 |
commit | 359fbfe14d00ab378f85a36664820ea9ba538c3f (patch) | |
tree | 0929d5663a3be4dc078dda0aba5ba798ebb627ab /LUFA/Drivers/USB/Class/Device | |
parent | e8570c4a37e41117e3fd1e989e0b41f1e9608f3c (diff) | |
download | lufa-359fbfe14d00ab378f85a36664820ea9ba538c3f.tar.gz lufa-359fbfe14d00ab378f85a36664820ea9ba538c3f.tar.bz2 lufa-359fbfe14d00ab378f85a36664820ea9ba538c3f.zip |
Add branch for the conversion of demos to use standard C header files for configuration, rather than makefile defined macros.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/AudioClassDevice.c | 57 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/AudioClassDevice.h | 25 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDCClassDevice.c | 69 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDCClassDevice.h | 18 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HIDClassDevice.c | 14 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HIDClassDevice.h | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c | 46 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h | 9 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c | 62 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h | 9 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c | 59 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h | 14 |
12 files changed, 112 insertions, 274 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c index 15fcd588d..ad79e9b2b 100644 --- a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c @@ -48,15 +48,16 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi if ((InterfaceIndex != AudioInterfaceInfo->Config.ControlInterfaceNumber) && (InterfaceIndex != AudioInterfaceInfo->Config.StreamingInterfaceNumber)) - - return; + { + return; + } } else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT) { - uint8_t EndpointIndex = (USB_ControlRequest.wIndex & 0xFF); + uint8_t EndpointAddress = (USB_ControlRequest.wIndex & 0xFF); - if ((EndpointIndex != (ENDPOINT_DIR_IN | AudioInterfaceInfo->Config.DataINEndpointNumber)) && - (EndpointIndex != (ENDPOINT_DIR_OUT | AudioInterfaceInfo->Config.DataOUTEndpointNumber))) + if ((EndpointAddress != AudioInterfaceInfo->Config.DataINEndpoint.Address) && + (EndpointAddress != AudioInterfaceInfo->Config.DataOUTEndpoint.Address)) { return; } @@ -88,7 +89,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi case AUDIO_REQ_SetMinimum: case AUDIO_REQ_SetMaximum: case AUDIO_REQ_SetResolution: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_ENDPOINT)) + if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT) { uint8_t EndpointProperty = USB_ControlRequest.bRequest; uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex; @@ -108,7 +109,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi EndpointControl, &ValueLength, Value); } } - else if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) { uint8_t Property = USB_ControlRequest.bRequest; uint8_t Entity = (USB_ControlRequest.wIndex >> 8); @@ -134,7 +135,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi case AUDIO_REQ_GetMinimum: case AUDIO_REQ_GetMaximum: case AUDIO_REQ_GetResolution: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT)) + if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT) { uint8_t EndpointProperty = USB_ControlRequest.bRequest; uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex; @@ -150,7 +151,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi Endpoint_ClearOUT(); } } - else if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) { uint8_t Property = USB_ControlRequest.bRequest; uint8_t Entity = (USB_ControlRequest.wIndex >> 8); @@ -174,39 +175,15 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) { memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State)); + + AudioInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_ISOCHRONOUS; + AudioInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_ISOCHRONOUS; - for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) - { - uint16_t Size; - uint8_t Type; - uint8_t Direction; - bool DoubleBanked; + if (!(Endpoint_ConfigureEndpointTable(&AudioInterfaceInfo->Config.DataINEndpoint, 1))) + return false; - if (EndpointNum == AudioInterfaceInfo->Config.DataINEndpointNumber) - { - Size = AudioInterfaceInfo->Config.DataINEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_ISOCHRONOUS; - DoubleBanked = true; - } - else if (EndpointNum == AudioInterfaceInfo->Config.DataOUTEndpointNumber) - { - Size = AudioInterfaceInfo->Config.DataOUTEndpointSize; - Direction = ENDPOINT_DIR_OUT; - Type = EP_TYPE_ISOCHRONOUS; - DoubleBanked = true; - } - else - { - continue; - } - - if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, - DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) - { - return false; - } - } + if (!(Endpoint_ConfigureEndpointTable(&AudioInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; return true; } diff --git a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h index 239126607..a8bfc7833 100644 --- a/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h @@ -86,19 +86,8 @@ * structure controls. */ - uint8_t DataINEndpointNumber; /**< Endpoint number of the incoming Audio Streaming data, if available - * (zero if unused). - */ - uint16_t DataINEndpointSize; /**< Size in bytes of the incoming Audio Streaming data endpoint, if available - * (zero if unused). - */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing Audio Streaming data, if available - * (zero if unused). - */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing Audio Streaming data endpoint, if available - * (zero if unused). - */ + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ } 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. */ @@ -226,7 +215,7 @@ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled)) return false; - Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpoint.Address); return Endpoint_IsOUTReceived(); } @@ -247,7 +236,7 @@ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled)) return false; - Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataINEndpoint.Address); return Endpoint_IsINReady(); } @@ -341,7 +330,7 @@ { Endpoint_Write_8(Sample); - if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size) Endpoint_ClearIN(); } @@ -360,7 +349,7 @@ { Endpoint_Write_16_LE(Sample); - if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size) Endpoint_ClearIN(); } @@ -380,7 +369,7 @@ Endpoint_Write_16_LE(Sample); Endpoint_Write_8(Sample >> 16); - if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size) Endpoint_ClearIN(); } diff --git a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c index 5b5343860..ff0f9bb55 100644 --- a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c @@ -69,8 +69,12 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter { Endpoint_ClearSETUP(); - while (!(Endpoint_IsOUTReceived())); - + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8(); CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8(); @@ -112,45 +116,18 @@ bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfac { memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State)); - for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) - { - uint16_t Size; - uint8_t Type; - uint8_t Direction; - bool DoubleBanked; + CDCInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + CDCInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; + CDCInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT; - if (EndpointNum == CDCInterfaceInfo->Config.DataINEndpointNumber) - { - Size = CDCInterfaceInfo->Config.DataINEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_BULK; - DoubleBanked = CDCInterfaceInfo->Config.DataINEndpointDoubleBank; - } - else if (EndpointNum == CDCInterfaceInfo->Config.DataOUTEndpointNumber) - { - Size = CDCInterfaceInfo->Config.DataOUTEndpointSize; - Direction = ENDPOINT_DIR_OUT; - Type = EP_TYPE_BULK; - DoubleBanked = CDCInterfaceInfo->Config.DataOUTEndpointDoubleBank; - } - else if (EndpointNum == CDCInterfaceInfo->Config.NotificationEndpointNumber) - { - Size = CDCInterfaceInfo->Config.NotificationEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_INTERRUPT; - DoubleBanked = CDCInterfaceInfo->Config.NotificationEndpointDoubleBank; - } - else - { - continue; - } + if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.DataINEndpoint, 1))) + return false; - if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, - DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) - { - return false; - } - } + if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.NotificationEndpoint, 1))) + return false; return true; } @@ -171,7 +148,7 @@ uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) return ENDPOINT_RWSTREAM_DeviceDisconnected; - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); return Endpoint_Write_Stream_LE(String, strlen(String), NULL); } @@ -182,7 +159,7 @@ uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) return ENDPOINT_RWSTREAM_DeviceDisconnected; - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); return Endpoint_Write_Stream_LE(Buffer, Length, NULL); } @@ -192,7 +169,7 @@ uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) return ENDPOINT_RWSTREAM_DeviceDisconnected; - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); if (!(Endpoint_IsReadWriteAllowed())) { @@ -215,7 +192,7 @@ uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) uint8_t ErrorCode; - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); if (!(Endpoint_BytesInEndpoint())) return ENDPOINT_READYWAIT_NoError; @@ -240,7 +217,7 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) return 0; - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpoint.Address); if (Endpoint_IsOUTReceived()) { @@ -267,7 +244,7 @@ int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInf int16_t ReceivedByte = -1; - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpoint.Address); if (Endpoint_IsOUTReceived()) { @@ -286,7 +263,7 @@ void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDC if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) return; - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber); + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpoint.Address); USB_Request_Header_t Notification = (USB_Request_Header_t) { diff --git a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h index cc0dd1b15..508c234d7 100644 --- a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h @@ -99,19 +99,11 @@ { struct { - uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device. */ - - uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint. */ - uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint. */ - bool DataINEndpointDoubleBank; /**< Indicates if the CDC interface's IN data endpoint should use double banking. */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint. */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint. */ - bool DataOUTEndpointDoubleBank; /**< Indicates if the CDC interface's OUT data endpoint should use double banking. */ - - uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used. */ - uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used. */ - bool NotificationEndpointDoubleBank; /**< Indicates if the CDC interface's notification endpoint should use double banking. */ + uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device. */ + + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ + USB_Endpoint_Table_t NotificationEndpoint; /**< Notification IN Endpoint configuration table. */ } 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. */ diff --git a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c index 5c8d878e7..e4b565327 100644 --- a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c @@ -141,13 +141,11 @@ bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfac HIDInterfaceInfo->State.UsingReportProtocol = true; HIDInterfaceInfo->State.IdleCount = 500; - if (!(Endpoint_ConfigureEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber, EP_TYPE_INTERRUPT, - ENDPOINT_DIR_IN, HIDInterfaceInfo->Config.ReportINEndpointSize, - HIDInterfaceInfo->Config.ReportINEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) - { - return false; - } + HIDInterfaceInfo->Config.ReportINEndpoint.Type = EP_TYPE_INTERRUPT; + if (!(Endpoint_ConfigureEndpointTable(&HIDInterfaceInfo->Config.ReportINEndpoint, 1))) + return false; + return true; } @@ -159,7 +157,7 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) if (HIDInterfaceInfo->State.PrevFrameNum == USB_Device_GetFrameNumber()) return; - Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber); + Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpoint.Address); if (Endpoint_IsReadWriteAllowed()) { @@ -184,7 +182,7 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) { HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount; - Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber); + Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpoint.Address); if (ReportID) Endpoint_Write_8(ReportID); diff --git a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h index a6361c6b0..e358dec75 100644 --- a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h @@ -85,9 +85,7 @@ { uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device. */ - uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint. */ - uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint. */ - bool ReportINEndpointDoubleBank; /**< Indicates if the HID interface's IN report endpoint should use double banking. */ + USB_Endpoint_Table_t ReportINEndpoint; /**< Data IN HID report endpoint configuration table. */ void* PrevReportINBuffer; /**< Pointer to a buffer where the previously created HID input report can be * stored by the driver, for comparison purposes to detect report changes that diff --git a/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c b/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c index 9f0506e56..c9553a413 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c @@ -41,38 +41,14 @@ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInter { memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State)); - for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) - { - uint16_t Size; - uint8_t Type; - uint8_t Direction; - bool DoubleBanked; - - if (EndpointNum == MIDIInterfaceInfo->Config.DataINEndpointNumber) - { - Size = MIDIInterfaceInfo->Config.DataINEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_BULK; - DoubleBanked = MIDIInterfaceInfo->Config.DataINEndpointDoubleBank; - } - else if (EndpointNum == MIDIInterfaceInfo->Config.DataOUTEndpointNumber) - { - Size = MIDIInterfaceInfo->Config.DataOUTEndpointSize; - Direction = ENDPOINT_DIR_OUT; - Type = EP_TYPE_BULK; - DoubleBanked = MIDIInterfaceInfo->Config.DataOUTEndpointDoubleBank; - } - else - { - continue; - } - - if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, - DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) - { - return false; - } - } + MIDIInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + MIDIInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; + + if (!(Endpoint_ConfigureEndpointTable(&MIDIInterfaceInfo->Config.DataINEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&MIDIInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; return true; } @@ -95,7 +71,7 @@ uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInter uint8_t ErrorCode; - Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpoint.Address); if ((ErrorCode = Endpoint_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL)) != ENDPOINT_RWSTREAM_NoError) return ErrorCode; @@ -113,7 +89,7 @@ uint8_t MIDI_Device_Flush(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) uint8_t ErrorCode; - Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpoint.Address); if (Endpoint_BytesInEndpoint()) { @@ -132,7 +108,7 @@ bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInter if (USB_DeviceState != DEVICE_STATE_Configured) return false; - Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataOUTEndpoint.Address); if (!(Endpoint_IsReadWriteAllowed())) return false; diff --git a/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h b/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h index 4fe49af1f..2703600ea 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h @@ -81,13 +81,8 @@ { uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls. */ - uint8_t DataINEndpointNumber; /**< Endpoint number of the incoming MIDI IN data, if available (zero if unused). */ - uint16_t DataINEndpointSize; /**< Size in bytes of the incoming MIDI IN data endpoint, if available (zero if unused). */ - bool DataINEndpointDoubleBank; /**< Indicates if the MIDI interface's IN data endpoint should use double banking. */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing MIDI OUT data, if available (zero if unused). */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing MIDI OUT data endpoint, if available (zero if unused). */ - bool DataOUTEndpointDoubleBank; /**< Indicates if the MIDI interface's OUT data endpoint should use double banking. */ + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ } 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. */ diff --git a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c index 6294a0a94..153ebbc89 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c @@ -75,38 +75,14 @@ bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceIn { memset(&MSInterfaceInfo->State, 0x00, sizeof(MSInterfaceInfo->State)); - for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) - { - uint16_t Size; - uint8_t Type; - uint8_t Direction; - bool DoubleBanked; + MSInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + MSInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; - if (EndpointNum == MSInterfaceInfo->Config.DataINEndpointNumber) - { - Size = MSInterfaceInfo->Config.DataINEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_BULK; - DoubleBanked = MSInterfaceInfo->Config.DataINEndpointDoubleBank; - } - else if (EndpointNum == MSInterfaceInfo->Config.DataOUTEndpointNumber) - { - Size = MSInterfaceInfo->Config.DataOUTEndpointSize; - Direction = ENDPOINT_DIR_OUT; - Type = EP_TYPE_BULK; - DoubleBanked = MSInterfaceInfo->Config.DataOUTEndpointDoubleBank; - } - else - { - continue; - } + if (!(Endpoint_ConfigureEndpointTable(&MSInterfaceInfo->Config.DataINEndpoint, 1))) + return false; - if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, - DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) - { - return false; - } - } + if (!(Endpoint_ConfigureEndpointTable(&MSInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; return true; } @@ -116,14 +92,14 @@ void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) if (USB_DeviceState != DEVICE_STATE_Configured) return; - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); - if (Endpoint_IsReadWriteAllowed()) + if (Endpoint_IsOUTReceived()) { if (MS_Device_ReadInCommandBlock(MSInterfaceInfo)) { if (MSInterfaceInfo->State.CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN) - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); bool SCSICommandResult = CALLBACK_MS_Device_SCSICommandReceived(MSInterfaceInfo); @@ -141,13 +117,13 @@ void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) if (MSInterfaceInfo->State.IsMassStoreReset) { - Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); - Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); + Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); Endpoint_ClearStall(); Endpoint_ResetDataToggle(); - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); Endpoint_ClearStall(); Endpoint_ResetDataToggle(); @@ -159,8 +135,8 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte { uint16_t BytesProcessed; - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); - + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); + BytesProcessed = 0; while (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock, (sizeof(MS_CommandBlockWrapper_t) - 16), &BytesProcessed) == @@ -175,9 +151,9 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte (MSInterfaceInfo->State.CommandBlock.Flags & 0x1F) || (MSInterfaceInfo->State.CommandBlock.SCSICommandLength == 0) || (MSInterfaceInfo->State.CommandBlock.SCSICommandLength > 16)) - { + { Endpoint_StallTransaction(); - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); Endpoint_StallTransaction(); return false; @@ -199,7 +175,7 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) { - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); while (Endpoint_IsStalled()) { @@ -211,7 +187,7 @@ static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInt return; } - Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); while (Endpoint_IsStalled()) { diff --git a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h index c2d536ce2..6b490eca1 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h @@ -81,13 +81,8 @@ { uint8_t InterfaceNumber; /**< Interface number of the Mass Storage interface within the device. */ - uint8_t DataINEndpointNumber; /**< Endpoint number of the Mass Storage interface's IN data endpoint. */ - uint16_t DataINEndpointSize; /**< Size in bytes of the Mass Storage interface's IN data endpoint. */ - bool DataINEndpointDoubleBank; /**< Indicates if the Mass Storage interface's IN data endpoint should use double banking. */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the Mass Storage interface's OUT data endpoint. */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the Mass Storage interface's OUT data endpoint. */ - bool DataOUTEndpointDoubleBank; /**< Indicates if the Mass Storage interface's OUT data endpoint should use double banking. */ + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ uint8_t TotalLUNs; /**< Total number of logical drives in the Mass Storage interface. */ } Config; /**< Config data for the USB class interface within the device. All elements in this section diff --git a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c index f78a5abf2..e5aa40cd0 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c @@ -115,45 +115,18 @@ bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISIn { memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State)); - for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) - { - uint16_t Size; - uint8_t Type; - uint8_t Direction; - bool DoubleBanked; - - if (EndpointNum == RNDISInterfaceInfo->Config.DataINEndpointNumber) - { - Size = RNDISInterfaceInfo->Config.DataINEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_BULK; - DoubleBanked = RNDISInterfaceInfo->Config.DataINEndpointDoubleBank; - } - else if (EndpointNum == RNDISInterfaceInfo->Config.DataOUTEndpointNumber) - { - Size = RNDISInterfaceInfo->Config.DataOUTEndpointSize; - Direction = ENDPOINT_DIR_OUT; - Type = EP_TYPE_BULK; - DoubleBanked = RNDISInterfaceInfo->Config.DataOUTEndpointDoubleBank; - } - else if (EndpointNum == RNDISInterfaceInfo->Config.NotificationEndpointNumber) - { - Size = RNDISInterfaceInfo->Config.NotificationEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_INTERRUPT; - DoubleBanked = RNDISInterfaceInfo->Config.NotificationEndpointDoubleBank; - } - else - { - continue; - } - - if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, - DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) - { - return false; - } - } + RNDISInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + RNDISInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; + RNDISInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT; + + if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataINEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.NotificationEndpoint, 1))) + return false; return true; } @@ -163,7 +136,7 @@ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo if (USB_DeviceState != DEVICE_STATE_Configured) return; - Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpointNumber); + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpoint.Address); if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.ResponseReady) { @@ -454,7 +427,7 @@ bool RNDIS_Device_IsPacketReceived(USB_ClassInfo_RNDIS_Device_t* const RNDISInte return false; } - Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address); return Endpoint_IsOUTReceived(); } @@ -468,7 +441,7 @@ uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfa return ENDPOINT_RWSTREAM_DeviceDisconnected; } - Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address); *PacketLength = 0; @@ -505,7 +478,7 @@ uint8_t RNDIS_Device_SendPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfa return ENDPOINT_RWSTREAM_DeviceDisconnected; } - Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpoint.Address); if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) return ErrorCode; diff --git a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h index ccd20e38e..33b807da9 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h @@ -81,17 +81,9 @@ { uint8_t ControlInterfaceNumber; /**< Interface number of the RNDIS control interface within the device. */ - uint8_t DataINEndpointNumber; /**< Endpoint number of the RNDIS interface's IN data endpoint. */ - uint16_t DataINEndpointSize; /**< Size in bytes of the RNDIS interface's IN data endpoint. */ - bool DataINEndpointDoubleBank; /**< Indicates if the RNDIS interface's IN data endpoint should use double banking. */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the RNDIS interface's OUT data endpoint. */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the RNDIS interface's OUT data endpoint. */ - bool DataOUTEndpointDoubleBank; /**< Indicates if the RNDIS interface's OUT data endpoint should use double banking. */ - - uint8_t NotificationEndpointNumber; /**< Endpoint number of the RNDIS interface's IN notification endpoint, if used. */ - uint16_t NotificationEndpointSize; /**< Size in bytes of the RNDIS interface's IN notification endpoint, if used. */ - bool NotificationEndpointDoubleBank; /**< Indicates if the RNDIS interface's notification endpoint should use double banking. */ + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ + USB_Endpoint_Table_t NotificationEndpoint; /**< Notification IN Endpoint configuration table. */ char* AdapterVendorDescription; /**< String description of the adapter vendor. */ MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter. */ |