Refactored Host mode Class Driver *_Host_ConfigurePipes() routines to be more space...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 2 Dec 2010 01:56:06 +0000 (01:56 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 2 Dec 2010 01:56:06 +0000 (01:56 +0000)
Added new *_ENUMERROR_PipeConfigurationFailed error codes for the *_Host_ConfigurePipes() routines.

19 files changed:
LUFA/Drivers/USB/Class/Device/CDC.c
LUFA/Drivers/USB/Class/Device/MIDI.c
LUFA/Drivers/USB/Class/Device/MassStorage.c
LUFA/Drivers/USB/Class/Device/RNDIS.c
LUFA/Drivers/USB/Class/Host/CDC.c
LUFA/Drivers/USB/Class/Host/CDC.h
LUFA/Drivers/USB/Class/Host/HID.c
LUFA/Drivers/USB/Class/Host/HID.h
LUFA/Drivers/USB/Class/Host/MIDI.c
LUFA/Drivers/USB/Class/Host/MIDI.h
LUFA/Drivers/USB/Class/Host/MassStorage.c
LUFA/Drivers/USB/Class/Host/MassStorage.h
LUFA/Drivers/USB/Class/Host/Printer.c
LUFA/Drivers/USB/Class/Host/Printer.h
LUFA/Drivers/USB/Class/Host/RNDIS.c
LUFA/Drivers/USB/Class/Host/RNDIS.h
LUFA/Drivers/USB/Class/Host/StillImage.c
LUFA/Drivers/USB/Class/Host/StillImage.h
LUFA/ManPages/ChangeLog.txt

index b4afac1..c830718 100644 (file)
@@ -134,7 +134,7 @@ bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfac
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
-                                                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
+                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
                {
                        return false;
                }
                {
                        return false;
                }
index 78d9043..83081be 100644 (file)
@@ -67,7 +67,7 @@ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInter
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
-                                                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
+                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
                {
                        return false;
                }
                {
                        return false;
                }
index 7f01d5e..3ee10d6 100644 (file)
@@ -102,7 +102,7 @@ bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
-                                                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
+                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
                {
                        return false;
                }
                {
                        return false;
                }
index 759e414..fa6aeae 100644 (file)
@@ -148,7 +148,7 @@ bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISIn
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
                }
 
                if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
-                                                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
+                                                DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
                {
                        return false;
                }
                {
                        return false;
                }
index e48d487..40fe3fd 100644 (file)
@@ -100,31 +100,59 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
+               uint16_t Size;
+               uint8_t  Type;
+               uint8_t  Token;
+               uint8_t  EndpointAddress;
+               uint8_t  InterruptPeriod;
+               bool     DoubleBanked;
+
                if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber)
                {
                if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
-                                          DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
-                                          CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataINEndpoint->EndpointSize;
+                       EndpointAddress = DataINEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = CDCInterfaceInfo->Config.DataINPipeDoubleBank;
+                       InterruptPeriod = 0;
 
                        CDCInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == CDCInterfaceInfo->Config.DataOUTPipeNumber)
                {
 
                        CDCInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == CDCInterfaceInfo->Config.DataOUTPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
-                                          DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
-                                          CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataOUTEndpoint->EndpointSize;
+                       EndpointAddress = DataOUTEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_OUT;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = CDCInterfaceInfo->Config.DataOUTPipeDoubleBank;
+                       InterruptPeriod = 0;
 
                        CDCInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
                else if (PipeNum == CDCInterfaceInfo->Config.NotificationPipeNumber)
                {
 
                        CDCInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
                else if (PipeNum == CDCInterfaceInfo->Config.NotificationPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
-                                          NotificationEndpoint->EndpointAddress, NotificationEndpoint->EndpointSize,
-                                          CDCInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
-                       Pipe_SetInterruptPeriod(NotificationEndpoint->PollingIntervalMS);
+                       Size            = NotificationEndpoint->EndpointSize;
+                       EndpointAddress = NotificationEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_INTERRUPT;
+                       DoubleBanked    = CDCInterfaceInfo->Config.NotificationPipeDoubleBank;
+                       InterruptPeriod = NotificationEndpoint->PollingIntervalMS;
 
                        CDCInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize;
                }
 
                        CDCInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize;
                }
+               else
+               {
+                       continue;
+               }
+               
+               if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size,
+                                        DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE)))
+               {
+                       return CDC_ENUMERROR_PipeConfigurationFailed;
+               }
+               
+               if (InterruptPeriod)
+                 Pipe_SetInterruptPeriod(InterruptPeriod);
        }
 
        CDCInterfaceInfo->State.ControlInterfaceNumber = CDCControlInterface->InterfaceNumber;
        }
 
        CDCInterfaceInfo->State.ControlInterfaceNumber = CDCControlInterface->InterfaceNumber;
index fdbc7ae..016f4a5 100644 (file)
                                CDC_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                CDC_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                CDC_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible CDC interface was not found in the device's Configuration Descriptor. */
                                CDC_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                CDC_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                CDC_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible CDC interface was not found in the device's Configuration Descriptor. */
+                               CDC_ENUMERROR_PipeConfigurationFailed    = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
                        };
 
                /* Function Prototypes: */
                        };
 
                /* Function Prototypes: */
index bb10ee2..e6c575e 100644 (file)
@@ -95,25 +95,49 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
+               uint16_t Size;
+               uint8_t  Type;
+               uint8_t  Token;
+               uint8_t  EndpointAddress;
+               uint8_t  InterruptPeriod;
+               bool     DoubleBanked;
+
                if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
                {
                if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
-                                          DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
-                                          HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
-                       Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS);
-
-                       HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
+                       Size            = DataINEndpoint->EndpointSize;
+                       EndpointAddress = DataINEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_INTERRUPT;
+                       DoubleBanked    = HIDInterfaceInfo->Config.DataINPipeDoubleBank;
+                       InterruptPeriod = DataINEndpoint->PollingIntervalMS;
+
+                       HIDInterfaceInfo->State.DataINPipeSize   = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber)
                {
                }
                else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT,
-                                          DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
-                                          HIDInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
-                       Pipe_SetInterruptPeriod(DataOUTEndpoint->PollingIntervalMS);
-
-                       HIDInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
+                       Size            = DataOUTEndpoint->EndpointSize;
+                       EndpointAddress = DataOUTEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_OUT;
+                       Type            = EP_TYPE_INTERRUPT;
+                       DoubleBanked    = HIDInterfaceInfo->Config.DataOUTPipeDoubleBank;
+                       InterruptPeriod = DataOUTEndpoint->PollingIntervalMS;
+
+                       HIDInterfaceInfo->State.DataOUTPipeSize   = DataOUTEndpoint->EndpointSize;
                        HIDInterfaceInfo->State.DeviceUsesOUTPipe = true;
                }
                        HIDInterfaceInfo->State.DeviceUsesOUTPipe = true;
                }
+               else
+               {
+                       continue;
+               }
+
+               if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size,
+                                        DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE)))
+               {
+                       return HID_ENUMERROR_PipeConfigurationFailed;
+               }
+               
+               if (InterruptPeriod)
+                 Pipe_SetInterruptPeriod(InterruptPeriod);
        }
 
        HIDInterfaceInfo->State.InterfaceNumber      = HIDInterface->InterfaceNumber;
        }
 
        HIDInterfaceInfo->State.InterfaceNumber      = HIDInterface->InterfaceNumber;
index 200cbda..d1392c9 100644 (file)
                                HID_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                HID_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                HID_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor. */
                                HID_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                HID_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                HID_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor. */
+                               HID_ENUMERROR_PipeConfigurationFailed    = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
                        };
 
                /* Function Prototypes: */
                        };
 
                /* Function Prototypes: */
index 87e4290..3dd98be 100644 (file)
@@ -79,22 +79,42 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
+               uint16_t Size;
+               uint8_t  Type;
+               uint8_t  Token;
+               uint8_t  EndpointAddress;
+               bool     DoubleBanked;
+
                if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber)
                {
                if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
-                                          DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
-                                          MIDIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataINEndpoint->EndpointSize;
+                       EndpointAddress = DataINEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = MIDIInterfaceInfo->Config.DataINPipeDoubleBank;
 
                        MIDIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber)
                {
 
                        MIDIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
-                                          DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
-                                          MIDIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataOUTEndpoint->EndpointSize;
+                       EndpointAddress = DataOUTEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_OUT;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = MIDIInterfaceInfo->Config.DataOUTPipeDoubleBank;
 
                        MIDIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
 
                        MIDIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
+               else
+               {
+                       continue;
+               }
+
+               if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size,
+                                        DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE)))
+               {
+                       return MIDI_ENUMERROR_PipeConfigurationFailed;
+               }
        }
 
        MIDIInterfaceInfo->State.InterfaceNumber = MIDIInterface->InterfaceNumber;
        }
 
        MIDIInterfaceInfo->State.InterfaceNumber = MIDIInterface->InterfaceNumber;
index 83b08d1..7ac4ab7 100644 (file)
                                MIDI_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                MIDI_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                MIDI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible MIDI interface was not found in the device's Configuration Descriptor. */
                                MIDI_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                MIDI_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                MIDI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible MIDI interface was not found in the device's Configuration Descriptor. */
+                               MIDI_ENUMERROR_PipeConfigurationFailed    = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
                        };
 
                /* Function Prototypes: */
                        };
 
                /* Function Prototypes: */
index ef8053b..682a696 100644 (file)
@@ -79,22 +79,42 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
+               uint16_t Size;
+               uint8_t  Type;
+               uint8_t  Token;
+               uint8_t  EndpointAddress;
+               bool     DoubleBanked;
+
                if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber)
                {
                if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
-                                          DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
-                                          MSInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataINEndpoint->EndpointSize;
+                       EndpointAddress = DataINEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = MSInterfaceInfo->Config.DataINPipeDoubleBank;
 
                        MSInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber)
                {
 
                        MSInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
-                                          DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
-                                          MSInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
-
+                       Size            = DataOUTEndpoint->EndpointSize;
+                       EndpointAddress = DataOUTEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_OUT;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = MSInterfaceInfo->Config.DataOUTPipeDoubleBank;
+                       
                        MSInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
                        MSInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
+               else
+               {
+                       continue;
+               }
+
+               if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size,
+                                        DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE)))
+               {
+                       return MS_ENUMERROR_PipeConfigurationFailed;
+               }
        }
 
        MSInterfaceInfo->State.InterfaceNumber = MassStorageInterface->InterfaceNumber;
        }
 
        MSInterfaceInfo->State.InterfaceNumber = MassStorageInterface->InterfaceNumber;
index bef26fd..5779a47 100644 (file)
                                MS_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                MS_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                MS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Mass Storage interface was not found in the device's Configuration Descriptor. */
                                MS_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                MS_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                MS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Mass Storage interface was not found in the device's Configuration Descriptor. */
+                               MS_ENUMERROR_PipeConfigurationFailed    = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
                        };
 
                /* Function Prototypes: */
                        };
 
                /* Function Prototypes: */
index f08ee5b..9229922 100644 (file)
@@ -79,22 +79,42 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
+               uint16_t Size;
+               uint8_t  Type;
+               uint8_t  Token;
+               uint8_t  EndpointAddress;
+               bool     DoubleBanked;
+
                if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber)
                {
                if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
-                                          DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
-                                          PRNTInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataINEndpoint->EndpointSize;
+                       EndpointAddress = DataINEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = PRNTInterfaceInfo->Config.DataINPipeDoubleBank;
 
                        PRNTInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber)
                {
 
                        PRNTInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
-                                          DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
-                                          PRNTInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataOUTEndpoint->EndpointSize;
+                       EndpointAddress = DataOUTEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_OUT;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = PRNTInterfaceInfo->Config.DataOUTPipeDoubleBank;
 
                        PRNTInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
 
                        PRNTInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
+               else
+               {
+                       continue;
+               }
+
+               if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size,
+                                        DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE)))
+               {
+                       return PRNT_ENUMERROR_PipeConfigurationFailed;
+               }
        }
 
        PRNTInterfaceInfo->State.InterfaceNumber  = PrinterInterface->InterfaceNumber;
        }
 
        PRNTInterfaceInfo->State.InterfaceNumber  = PrinterInterface->InterfaceNumber;
index b44ea56..99df01f 100644 (file)
                                PRNT_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                PRNT_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                PRNT_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Printer interface was not found in the device's Configuration Descriptor. */
                                PRNT_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                PRNT_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                PRNT_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Printer interface was not found in the device's Configuration Descriptor. */
+                               PRNT_ENUMERROR_PipeConfigurationFailed    = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
                        };
 
                /* Function Prototypes: */
                        };
 
                /* Function Prototypes: */
index e3948ec..aae445a 100644 (file)
@@ -102,31 +102,59 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
+               uint16_t Size;
+               uint8_t  Type;
+               uint8_t  Token;
+               uint8_t  EndpointAddress;
+               uint8_t  InterruptPeriod;
+               bool     DoubleBanked;
+
                if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber)
                {
                if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
-                                          DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
-                                          RNDISInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataINEndpoint->EndpointSize;
+                       EndpointAddress = DataINEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = RNDISInterfaceInfo->Config.DataINPipeDoubleBank;
+                       InterruptPeriod = 0;
 
                        RNDISInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == RNDISInterfaceInfo->Config.DataOUTPipeNumber)
                {
 
                        RNDISInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == RNDISInterfaceInfo->Config.DataOUTPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
-                                          DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
-                                          RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataOUTEndpoint->EndpointSize;
+                       EndpointAddress = DataOUTEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_OUT;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank;
+                       InterruptPeriod = 0;
 
                        RNDISInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
                else if (PipeNum == RNDISInterfaceInfo->Config.NotificationPipeNumber)
                {
 
                        RNDISInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
                else if (PipeNum == RNDISInterfaceInfo->Config.NotificationPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
-                                          NotificationEndpoint->EndpointAddress, NotificationEndpoint->EndpointSize,
-                                          RNDISInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
-                       Pipe_SetInterruptPeriod(NotificationEndpoint->PollingIntervalMS);
+                       Size            = NotificationEndpoint->EndpointSize;
+                       EndpointAddress = NotificationEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_INTERRUPT;
+                       DoubleBanked    = RNDISInterfaceInfo->Config.NotificationPipeDoubleBank;
+                       InterruptPeriod = NotificationEndpoint->PollingIntervalMS;
 
                        RNDISInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize;
                }
 
                        RNDISInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize;
                }
+               else
+               {
+                       continue;
+               }
+               
+               if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size,
+                                        DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE)))
+               {
+                       return CDC_ENUMERROR_PipeConfigurationFailed;
+               }
+               
+               if (InterruptPeriod)
+                 Pipe_SetInterruptPeriod(InterruptPeriod);
        }
 
        RNDISInterfaceInfo->State.ControlInterfaceNumber = RNDISControlInterface->InterfaceNumber;
        }
 
        RNDISInterfaceInfo->State.ControlInterfaceNumber = RNDISControlInterface->InterfaceNumber;
index b7f844e..6eaf131 100644 (file)
                                RNDIS_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                RNDIS_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                RNDIS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible RNDIS interface was not found in the device's Configuration Descriptor. */
                                RNDIS_ENUMERROR_NoError                    = 0, /**< Configuration Descriptor was processed successfully. */
                                RNDIS_ENUMERROR_InvalidConfigDescriptor    = 1, /**< The device returned an invalid Configuration Descriptor. */
                                RNDIS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible RNDIS interface was not found in the device's Configuration Descriptor. */
+                               RNDIS_ENUMERROR_PipeConfigurationFailed    = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
                        };
 
                /* Macros: */
                        };
 
                /* Macros: */
index d3dda8f..45c3872 100644 (file)
@@ -88,31 +88,59 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
 
        for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
        {
+               uint16_t Size;
+               uint8_t  Type;
+               uint8_t  Token;
+               uint8_t  EndpointAddress;
+               uint8_t  InterruptPeriod;
+               bool     DoubleBanked;
+
                if (PipeNum == SIInterfaceInfo->Config.DataINPipeNumber)
                {
                if (PipeNum == SIInterfaceInfo->Config.DataINPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
-                                          DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
-                                          SIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataINEndpoint->EndpointSize;
+                       EndpointAddress = DataINEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = SIInterfaceInfo->Config.DataINPipeDoubleBank;
+                       InterruptPeriod = 0;
 
                        SIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == SIInterfaceInfo->Config.DataOUTPipeNumber)
                {
 
                        SIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
                }
                else if (PipeNum == SIInterfaceInfo->Config.DataOUTPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
-                                          DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
-                                          SIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+                       Size            = DataOUTEndpoint->EndpointSize;
+                       EndpointAddress = DataOUTEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_OUT;
+                       Type            = EP_TYPE_BULK;
+                       DoubleBanked    = SIInterfaceInfo->Config.DataOUTPipeDoubleBank;
+                       InterruptPeriod = 0;
 
                        SIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
                else if (PipeNum == SIInterfaceInfo->Config.EventsPipeNumber)
                {
 
                        SIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
                }
                else if (PipeNum == SIInterfaceInfo->Config.EventsPipeNumber)
                {
-                       Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
-                                          EventsEndpoint->EndpointAddress, EventsEndpoint->EndpointSize,
-                                          SIInterfaceInfo->Config.EventsPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
-                       Pipe_SetInterruptPeriod(EventsEndpoint->PollingIntervalMS);
+                       Size            = EventsEndpoint->EndpointSize;
+                       EndpointAddress = EventsEndpoint->EndpointAddress;
+                       Token           = PIPE_TOKEN_IN;
+                       Type            = EP_TYPE_INTERRUPT;
+                       DoubleBanked    = SIInterfaceInfo->Config.EventsPipeDoubleBank;
+                       InterruptPeriod = EventsEndpoint->PollingIntervalMS;
 
                        SIInterfaceInfo->State.EventsPipeSize = EventsEndpoint->EndpointSize;
                }
 
                        SIInterfaceInfo->State.EventsPipeSize = EventsEndpoint->EndpointSize;
                }
+               else
+               {
+                       continue;
+               }
+               
+               if (!(Pipe_ConfigurePipe(PipeNum, Type, Token, EndpointAddress, Size,
+                                        DoubleBanked ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE)))
+               {
+                       return SI_ENUMERROR_PipeConfigurationFailed;
+               }
+               
+               if (InterruptPeriod)
+                 Pipe_SetInterruptPeriod(InterruptPeriod);
        }
 
        SIInterfaceInfo->State.InterfaceNumber = StillImageInterface->InterfaceNumber;
        }
 
        SIInterfaceInfo->State.InterfaceNumber = StillImageInterface->InterfaceNumber;
index 2d1b41e..39ab65d 100644 (file)
                                SI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Still Image interface was not found in the device's
                                                                              *   Configuration Descriptor.
                                                                              */
                                SI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Still Image interface was not found in the device's
                                                                              *   Configuration Descriptor.
                                                                              */
+                               SI_ENUMERROR_PipeConfigurationFailed    = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
                        };
 
                /* Function Prototypes: */
                        };
 
                /* Function Prototypes: */
index 8be0c9c..494f179 100644 (file)
@@ -16,7 +16,8 @@
   *
   *  <b>Changed:</b>
   *  - Core:
   *
   *  <b>Changed:</b>
   *  - Core:
-  *   - None
+  *   - Refactored Host mode Class Driver *_Host_ConfigurePipes() routines to be more space efficient when compiled
+  *   - Added new *_ENUMERROR_PipeConfigurationFailed error codes for the *_Host_ConfigurePipes() routines
   *  - Library Applications:
   *   - Changed the XPLAINBridge software UART to use the regular CTC mode instead of the alternative CTC mode
   *     via the Input Capture register, to reduce user confusion
   *  - Library Applications:
   *   - Changed the XPLAINBridge software UART to use the regular CTC mode instead of the alternative CTC mode
   *     via the Input Capture register, to reduce user confusion