Added CDC functional descriptor structs to the Low Level CDC demos and CDC class...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 28 Sep 2010 13:27:19 +0000 (13:27 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 28 Sep 2010 13:27:19 +0000 (13:27 +0000)
Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev).

14 files changed:
Bootloaders/CDC/BootloaderCDC.c
Bootloaders/CDC/BootloaderCDC.h
Bootloaders/CDC/Descriptors.c
Bootloaders/CDC/Descriptors.h
Bootloaders/DFU/Descriptors.c
Bootloaders/DFU/Descriptors.h
Demos/Device/LowLevel/DualVirtualSerial/Descriptors.c
Demos/Device/LowLevel/DualVirtualSerial/Descriptors.h
Demos/Device/LowLevel/RNDISEthernet/Descriptors.c
Demos/Device/LowLevel/RNDISEthernet/Descriptors.h
Demos/Device/LowLevel/VirtualSerial/Descriptors.c
Demos/Device/LowLevel/VirtualSerial/Descriptors.h
LUFA/ManPages/ChangeLog.txt
LUFA/ManPages/LUFAPoweredProjects.txt

index cfc040f..234b5ce 100644 (file)
 #define  INCLUDE_FROM_BOOTLOADERCDC_C
 #include "BootloaderCDC.h"
 
 #define  INCLUDE_FROM_BOOTLOADERCDC_C
 #include "BootloaderCDC.h"
 
+/** Contains the current baud rate and other settings of the first virtual serial port. This must be retained as some
+ *  operating systems will not open the port unless the settings can be set successfully.
+ */
+CDC_Line_Coding_t LineEncoding = { .BaudRateBPS = 0,
+                                   .CharFormat  = OneStopBit,
+                                   .ParityType  = Parity_None,
+                                   .DataBits    = 8            };
+
 /** Current address counter. This stores the current address of the FLASH or EEPROM as set by the host,
  *  and is used when reading or writing to the AVRs memory (either FLASH or EEPROM depending on the issued
  *  command.)
 /** Current address counter. This stores the current address of the FLASH or EEPROM as set by the host,
  *  and is used when reading or writing to the AVRs memory (either FLASH or EEPROM depending on the issued
  *  command.)
@@ -113,6 +121,40 @@ void EVENT_USB_Device_ConfigurationChanged(void)
                                   ENDPOINT_BANK_SINGLE);
 }
 
                                   ENDPOINT_BANK_SINGLE);
 }
 
+/** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific
+ *  control requests that are not handled internally by the USB library (including the CDC control commands,
+ *  which are all issued via the control endpoint), so that they can be handled appropriately for the application.
+ */
+void EVENT_USB_Device_UnhandledControlRequest(void)
+{
+       /* Process CDC specific control requests */
+       switch (USB_ControlRequest.bRequest)
+       {
+               case REQ_GetLineEncoding:
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
+                       {       
+                               Endpoint_ClearSETUP();
+
+                               /* Write the line coding data to the control endpoint */
+                               Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
+                               Endpoint_ClearOUT();
+                       }
+                       
+                       break;
+               case REQ_SetLineEncoding:
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
+                       {
+                               Endpoint_ClearSETUP();
+
+                               /* Read the line coding data in from the host into the global struct */
+                               Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
+                               Endpoint_ClearIN();
+                       }
+       
+                       break;
+       }
+}
+
 /** Reads or writes a block of EEPROM or FLASH memory to or from the appropriate CDC data endpoint, depending
  *  on the AVR910 protocol command issued.
  *
 /** Reads or writes a block of EEPROM or FLASH memory to or from the appropriate CDC data endpoint, depending
  *  on the AVR910 protocol command issued.
  *
index 7aa07a2..98154c2 100644 (file)
@@ -49,7 +49,7 @@
 
                #include <LUFA/Drivers/USB/USB.h>
 
 
                #include <LUFA/Drivers/USB/USB.h>
 
-       /* Macros: */           
+       /* Macros: */
                /** Version major of the CDC bootloader. */
                #define BOOTLOADER_VERSION_MAJOR     0x01
 
                /** Version major of the CDC bootloader. */
                #define BOOTLOADER_VERSION_MAJOR     0x01
 
                /** Eight character bootloader firmware identifier reported to the host when requested */
                #define SOFTWARE_IDENTIFIER          "LUFACDC"
                
                /** Eight character bootloader firmware identifier reported to the host when requested */
                #define SOFTWARE_IDENTIFIER          "LUFACDC"
                
+               /** CDC Class specific request to get the current virtual serial port configuration settings. */
+               #define REQ_GetLineEncoding          0x21
+
+               /** CDC Class specific request to set the current virtual serial port configuration settings. */
+               #define REQ_SetLineEncoding          0x20
+
        /* Type Defines: */
        /* Type Defines: */
+               /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration
+                *  as set by the host via a class specific request.
+                */
+               typedef struct
+               {
+                       uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */
+                       uint8_t  CharFormat; /**< Character format of the virtual serial port, a value from the
+                                             *   CDCDevice_CDC_LineCodingFormats_t enum
+                                             */
+                       uint8_t  ParityType; /**< Parity setting of the virtual serial port, a value from the
+                                             *   CDCDevice_LineCodingParity_t enum
+                                             */
+                       uint8_t  DataBits; /**< Bits of data per character of the virtual serial port */
+               } CDC_Line_Coding_t;
+
                /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
                typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
                
                /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
                typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
                
+       /* Enums: */
+               /** Enum for the possible line encoding formats of a virtual serial port. */
+               enum CDCDevice_CDC_LineCodingFormats_t
+               {
+                       OneStopBit          = 0, /**< Each frame contains one stop bit */
+                       OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
+                       TwoStopBits         = 2, /**< Each frame contains two stop bits */
+               };
+               
+               /** Enum for the possible line encoding parity settings of a virtual serial port. */
+               enum CDCDevice_LineCodingParity_t
+               {
+                       Parity_None         = 0, /**< No parity bit mode on each frame */
+                       Parity_Odd          = 1, /**< Odd parity bit mode on each frame */
+                       Parity_Even         = 2, /**< Even parity bit mode on each frame */
+                       Parity_Mark         = 3, /**< Mark parity bit mode on each frame */
+                       Parity_Space        = 4, /**< Space parity bit mode on each frame */
+               };
+
        /* Function Prototypes: */
                void CDC_Task(void);
                void SetupHardware(void);
        /* Function Prototypes: */
                void CDC_Task(void);
                void SetupHardware(void);
index 092ee2f..b86b213 100644 (file)
@@ -55,7 +55,7 @@ USB_Descriptor_Device_t DeviceDescriptor =
                
        .VendorID               = 0x03EB,
        .ProductID              = 0x204A,
                
        .VendorID               = 0x03EB,
        .ProductID              = 0x204A,
-       .ReleaseNumber          = 0x0000,
+       .ReleaseNumber          = 0x0002,
                
        .ManufacturerStrIndex   = NO_DESCRIPTOR,
        .ProductStrIndex        = 0x01,
                
        .ManufacturerStrIndex   = NO_DESCRIPTOR,
        .ProductStrIndex        = 0x01,
@@ -102,29 +102,30 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor =
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
-       .CDC_Functional_IntHeader = 
+       .CDC_Functional_Header = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x00,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x00,
                        
                        
-                       .Data                   = {0x10, 0x01}
+                       .CDCSpecification       = VERSION_BCD(01.10),
                },
 
                },
 
-       .CDC_Functional_AbstractControlManagement = 
+       .CDC_Functional_ACM = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24},
-                       .SubType                = 0x02,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x02,
                        
                        
-                       .Data                   = {0x06}
+                       .Capabilities           = 0x04,
                },
                
        .CDC_Functional_Union = 
                {
                },
                
        .CDC_Functional_Union = 
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x06,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x06,
                        
                        
-                       .Data                   = {0x00, 0x01}
-               },      
+                       .MasterInterfaceNumber  = 0,
+                       .SlaveInterfaceNumber   = 1,
+               },
 
        .CDC_NotificationEndpoint = 
                {
 
        .CDC_NotificationEndpoint = 
                {
index 307b323..4610888 100644 (file)
                        #error The selected AVR part is not currently supported by this bootloader.
                #endif
 
                        #error The selected AVR part is not currently supported by this bootloader.
                #endif
 
-               /** Structure for a CDC class Functional descriptor, with a given data size. This is used instead of a
-                *  type define so that the same macro can be used for functional descriptors of varying data lengths,
-                *  while allowing the sizeof() operator to return correct results.
-                *
-                *  \param[in] DataSize  Size of the functional descriptor's data payload, in bytes
-                */
-               #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize)        \
-                    struct                                        \
-                    {                                             \
-                         USB_Descriptor_Header_t Header;          \
-                             uint8_t                 SubType;         \
-                         uint8_t                 Data[DataSize];  \
-                    }
-
                /** Endpoint number for the CDC control interface event notification endpoint. */
                #define CDC_NOTIFICATION_EPNUM         3
 
                /** Endpoint number for the CDC control interface event notification endpoint. */
                #define CDC_NOTIFICATION_EPNUM         3
 
                #define CDC_TXRX_EPSIZE                16
 
        /* Type Defines: */
                #define CDC_TXRX_EPSIZE                16
 
        /* Type Defines: */
+               /** Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device
+                *  contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.
+                *  See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint16_t                CDCSpecification; /**< Version number of the CDC specification implemented by the device,
+                                                                  *   encoded in BCD format.
+                                                                  */
+               } USB_Descriptor_CDC_FunctionalHeader_t;
+
+               /** Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface
+                *  supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
+               } USB_Descriptor_CDC_FunctionalACM_t;
+               
+               /** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
+                *  CDC control and data interfaces are related. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
+                       uint8_t                 SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
+               } USB_Descriptor_CDC_FunctionalUnion_t;
+
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                {
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_t               CDC_CCI_Interface;
                {
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_t               CDC_CCI_Interface;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC_Functional_IntHeader;
-                       CDC_FUNCTIONAL_DESCRIPTOR(1)             CDC_Functional_AbstractControlManagement;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC_Functional_Union;
+                       USB_Descriptor_CDC_FunctionalHeader_t    CDC_Functional_Header;
+                       USB_Descriptor_CDC_FunctionalACM_t       CDC_Functional_ACM;
+                       USB_Descriptor_CDC_FunctionalUnion_t     CDC_Functional_Union;
                        USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint;
                        USB_Descriptor_Interface_t               CDC_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC_DataOutEndpoint;
                        USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint;
                        USB_Descriptor_Interface_t               CDC_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC_DataOutEndpoint;
index ad4e06a..8db6531 100644 (file)
@@ -104,7 +104,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor =
                
        .DFU_Functional = 
                {
                
        .DFU_Functional = 
                {
-                       .Header                 = {.Size = sizeof(USB_DFU_Functional_Descriptor_t), .Type = DTYPE_DFUFunctional},
+                       .Header                 = {.Size = sizeof(USB_Descriptor_DFU_Functional_t), .Type = DTYPE_DFUFunctional},
                        
                        .Attributes             = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD),
 
                        
                        .Attributes             = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD),
 
index 133d8fb..5b38e60 100644 (file)
                        USB_Descriptor_Header_t               Header; /**< Standard descriptor header structure */
                        
                        uint8_t                               Attributes; /**< DFU device attributes, a mask comprising of the
                        USB_Descriptor_Header_t               Header; /**< Standard descriptor header structure */
                        
                        uint8_t                               Attributes; /**< DFU device attributes, a mask comprising of the
-                                                                           *  ATTR_* macros listed in this source file
-                                                                           */
+                                                                          *  ATTR_* macros listed in this source file
+                                                                          */
                        uint16_t                              DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH
                        uint16_t                              DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH
-                                                                               *  command being issued and the device detaching
-                                                                               *  from the USB bus
-                                                                               */                                                                                                                                      
+                                                                              *  command being issued and the device detaching
+                                                                              *  from the USB bus
+                                                                              */                                                                                                                                       
                        uint16_t                              TransferSize; /**< Maximum number of bytes the DFU device can accept
                        uint16_t                              TransferSize; /**< Maximum number of bytes the DFU device can accept
-                                                                             *  from the host in a transaction
-                                                                             */                        
+                                                                            *  from the host in a transaction
+                                                                            */                 
                        uint16_t                              DFUSpecification; /**< BCD packed DFU specification number this DFU
                        uint16_t                              DFUSpecification; /**< BCD packed DFU specification number this DFU
-                                                                                 *  device complies with
-                                                                                 */
-               } USB_DFU_Functional_Descriptor_t;
+                                                                                *  device complies with
+                                                                                */
+               } USB_Descriptor_DFU_Functional_t;
        
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
        
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                {
                        USB_Descriptor_Configuration_Header_t Config;
                        USB_Descriptor_Interface_t            DFU_Interface;
                {
                        USB_Descriptor_Configuration_Header_t Config;
                        USB_Descriptor_Interface_t            DFU_Interface;
-                       USB_DFU_Functional_Descriptor_t       DFU_Functional;
+                       USB_Descriptor_DFU_Functional_t       DFU_Functional;
                } USB_Descriptor_Configuration_t;
                
        /* Function Prototypes: */
                } USB_Descriptor_Configuration_t;
                
        /* Function Prototypes: */
index cce7270..45f1d4e 100644 (file)
@@ -128,28 +128,29 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
-       .CDC1_Functional_IntHeader = 
+       .CDC1_Functional_Header = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x00,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x00,
                        
                        
-                       .Data                   = {0x01, 0x10}
+                       .CDCSpecification       = VERSION_BCD(01.10),
                },
 
                },
 
-       .CDC1_Functional_AbstractControlManagement = 
+       .CDC1_Functional_ACM = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24},
-                       .SubType                = 0x02,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x02,
                        
                        
-                       .Data                   = {0x06}
+                       .Capabilities           = 0x06,
                },
                
        .CDC1_Functional_Union = 
                {
                },
                
        .CDC1_Functional_Union = 
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x06,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x06,
                        
                        
-                       .Data                   = {0x00, 0x01}
+                       .MasterInterfaceNumber  = 0,
+                       .SlaveInterfaceNumber   = 1,
                },
 
        .CDC1_ManagementEndpoint = 
                },
 
        .CDC1_ManagementEndpoint = 
@@ -228,28 +229,29 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
-       .CDC2_Functional_IntHeader = 
+       .CDC2_Functional_Header = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x00,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x00,
                        
                        
-                       .Data                   = {0x01, 0x10}
+                       .CDCSpecification       = VERSION_BCD(01.10),
                },
 
                },
 
-       .CDC2_Functional_AbstractControlManagement = 
+       .CDC2_Functional_ACM = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24},
-                       .SubType                = 0x02,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x02,
                        
                        
-                       .Data                   = {0x06}
+                       .Capabilities           = 0x06,
                },
                
        .CDC2_Functional_Union = 
                {
                },
                
        .CDC2_Functional_Union = 
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x06,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x06,
                        
                        
-                       .Data                   = {0x02, 0x03}
+                       .MasterInterfaceNumber  = 2,
+                       .SlaveInterfaceNumber   = 3,
                },
 
        .CDC2_ManagementEndpoint = 
                },
 
        .CDC2_ManagementEndpoint = 
index 64c44a0..aa1a8be 100644 (file)
                #include <avr/pgmspace.h>
                
        /* Macros: */
                #include <avr/pgmspace.h>
                
        /* Macros: */
-               /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a
-                *  uniform structure but variable sized data payloads, thus cannot be represented accurately by
-                *  a single typedef struct. A macro is used instead so that functional descriptors can be created
-                *  easily by specifying the size of the payload. This allows sizeof() to work correctly.
-                *
-                *  \param[in] DataSize  Size in bytes of the CDC functional descriptor's data payload
-                */
-               #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize)        \
-                    struct                                        \
-                    {                                             \
-                         USB_Descriptor_Header_t Header;          \
-                             uint8_t                 SubType;         \
-                         uint8_t                 Data[DataSize];  \
-                    }
-
                /** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */
                #define CDC1_NOTIFICATION_EPNUM        3
 
                /** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */
                #define CDC1_NOTIFICATION_EPNUM        3
 
                #define CDC_TXRX_EPSIZE                16       
 
        /* Type Defines: */
                #define CDC_TXRX_EPSIZE                16       
 
        /* Type Defines: */
+               /** Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device
+                *  contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.
+                *  See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint16_t                CDCSpecification; /**< Version number of the CDC specification implemented by the device,
+                                                                  *   encoded in BCD format.
+                                                                  */
+               } USB_Descriptor_CDC_FunctionalHeader_t;
+
+               /** Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface
+                *  supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
+               } USB_Descriptor_CDC_FunctionalACM_t;
+               
+               /** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
+                *  CDC control and data interfaces are related. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
+                       uint8_t                 SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
+               } USB_Descriptor_CDC_FunctionalUnion_t;
+
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_Association_t   CDC1_IAD;
                        USB_Descriptor_Interface_t               CDC1_CCI_Interface;
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_Association_t   CDC1_IAD;
                        USB_Descriptor_Interface_t               CDC1_CCI_Interface;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC1_Functional_IntHeader;
-                       CDC_FUNCTIONAL_DESCRIPTOR(1)             CDC1_Functional_AbstractControlManagement;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC1_Functional_Union;
+                       USB_Descriptor_CDC_FunctionalHeader_t    CDC1_Functional_Header;
+                       USB_Descriptor_CDC_FunctionalACM_t       CDC1_Functional_ACM;
+                       USB_Descriptor_CDC_FunctionalUnion_t     CDC1_Functional_Union;
                        USB_Descriptor_Endpoint_t                CDC1_ManagementEndpoint;
                        USB_Descriptor_Interface_t               CDC1_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC1_DataOutEndpoint;
                        USB_Descriptor_Endpoint_t                CDC1_DataInEndpoint;
                        USB_Descriptor_Interface_Association_t   CDC2_IAD;
                        USB_Descriptor_Interface_t               CDC2_CCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC1_ManagementEndpoint;
                        USB_Descriptor_Interface_t               CDC1_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC1_DataOutEndpoint;
                        USB_Descriptor_Endpoint_t                CDC1_DataInEndpoint;
                        USB_Descriptor_Interface_Association_t   CDC2_IAD;
                        USB_Descriptor_Interface_t               CDC2_CCI_Interface;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC2_Functional_IntHeader;
-                       CDC_FUNCTIONAL_DESCRIPTOR(1)             CDC2_Functional_AbstractControlManagement;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC2_Functional_Union;
+                       USB_Descriptor_CDC_FunctionalHeader_t    CDC2_Functional_Header;
+                       USB_Descriptor_CDC_FunctionalACM_t       CDC2_Functional_ACM;
+                       USB_Descriptor_CDC_FunctionalUnion_t     CDC2_Functional_Union;
                        USB_Descriptor_Endpoint_t                CDC2_ManagementEndpoint;
                        USB_Descriptor_Interface_t               CDC2_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC2_DataOutEndpoint;
                        USB_Descriptor_Endpoint_t                CDC2_ManagementEndpoint;
                        USB_Descriptor_Interface_t               CDC2_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC2_DataOutEndpoint;
index e50c2f7..d6e79e1 100644 (file)
@@ -104,26 +104,27 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
        .CDC_Functional_Header = 
                {
 
        .CDC_Functional_Header = 
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x00,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x00,
                        
                        
-                       .Data                   = {0x01, 0x10}
+                       .CDCSpecification       = VERSION_BCD(01.10),
                },
 
                },
 
-       .CDC_Functional_AbstractControlManagement = 
+       .CDC_Functional_ACM = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24},
-                       .SubType                = 0x02,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x02,
                        
                        
-                       .Data                   = {0x00}
+                       .Capabilities           = 0x00,
                },
                },
-       
+               
        .CDC_Functional_Union = 
                {
        .CDC_Functional_Union = 
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x06,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x06,
                        
                        
-                       .Data                   = {0x00, 0x01}
+                       .MasterInterfaceNumber  = 0,
+                       .SlaveInterfaceNumber   = 1,
                },
 
        .CDC_NotificationEndpoint = 
                },
 
        .CDC_NotificationEndpoint = 
index 74ecd46..0d651c5 100644 (file)
                #include <avr/pgmspace.h>
 
        /* Macros: */
                #include <avr/pgmspace.h>
 
        /* Macros: */
-               /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a
-                *  uniform structure but variable sized data payloads, thus cannot be represented accurately by
-                *  a single typedef struct. A macro is used instead so that functional descriptors can be created
-                *  easily by specifying the size of the payload. This allows sizeof() to work correctly.
-                *
-                *  \param[in] DataSize  Size in bytes of the CDC functional descriptor's data payload
-                */             
-               #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize)        \
-                    struct                                        \
-                    {                                             \
-                         USB_Descriptor_Header_t Header;          \
-                             uint8_t                 SubType;         \
-                         uint8_t                 Data[DataSize];  \
-                    }
-
                /** Endpoint number of the CDC device-to-host notification IN endpoint. */
                #define CDC_NOTIFICATION_EPNUM         3
 
                /** Endpoint number of the CDC device-to-host notification IN endpoint. */
                #define CDC_NOTIFICATION_EPNUM         3
 
                #define CDC_TXRX_EPSIZE                64
 
        /* Type Defines: */
                #define CDC_TXRX_EPSIZE                64
 
        /* Type Defines: */
+               /** Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device
+                *  contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.
+                *  See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint16_t                CDCSpecification; /**< Version number of the CDC specification implemented by the device,
+                                                                  *   encoded in BCD format.
+                                                                  */
+               } USB_Descriptor_CDC_FunctionalHeader_t;
+
+               /** Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface
+                *  supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
+               } USB_Descriptor_CDC_FunctionalACM_t;
+               
+               /** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
+                *  CDC control and data interfaces are related. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
+                       uint8_t                 SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
+               } USB_Descriptor_CDC_FunctionalUnion_t;
+
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                {
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_t               CDC_CCI_Interface;
                {
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_t               CDC_CCI_Interface;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC_Functional_Header;
-                       CDC_FUNCTIONAL_DESCRIPTOR(1)             CDC_Functional_AbstractControlManagement;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC_Functional_Union;
+                       USB_Descriptor_CDC_FunctionalHeader_t    CDC_Functional_Header;
+                       USB_Descriptor_CDC_FunctionalACM_t       CDC_Functional_ACM;
+                       USB_Descriptor_CDC_FunctionalUnion_t     CDC_Functional_Union;
                        USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint;
                        USB_Descriptor_Interface_t               CDC_DCI_Interface;
                        USB_Descriptor_Endpoint_t                RNDIS_DataOutEndpoint;
                        USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint;
                        USB_Descriptor_Interface_t               CDC_DCI_Interface;
                        USB_Descriptor_Endpoint_t                RNDIS_DataOutEndpoint;
index f7e4540..f0066d9 100644 (file)
@@ -114,28 +114,29 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
 
-       .CDC_Functional_IntHeader = 
+       .CDC_Functional_Header = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x00,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x00,
                        
                        
-                       .Data                   = {0x01, 0x10}
+                       .CDCSpecification       = VERSION_BCD(01.10),
                },
 
                },
 
-       .CDC_Functional_AbstractControlManagement = 
+       .CDC_Functional_ACM = 
                {
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24},
-                       .SubType                = 0x02,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x02,
                        
                        
-                       .Data                   = {0x06}
+                       .Capabilities           = 0x06,
                },
                
        .CDC_Functional_Union = 
                {
                },
                
        .CDC_Functional_Union = 
                {
-                       .Header                 = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
-                       .SubType                = 0x06,
+                       .Header                 = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+                       .Subtype                = 0x06,
                        
                        
-                       .Data                   = {0x00, 0x01}
+                       .MasterInterfaceNumber  = 0,
+                       .SlaveInterfaceNumber   = 1,
                },
 
        .CDC_NotificationEndpoint = 
                },
 
        .CDC_NotificationEndpoint = 
index 850fc6a..44cf084 100644 (file)
                #include <avr/pgmspace.h>
                
        /* Macros: */
                #include <avr/pgmspace.h>
                
        /* Macros: */
-               /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a
-                *  uniform structure but variable sized data payloads, thus cannot be represented accurately by
-                *  a single typedef struct. A macro is used instead so that functional descriptors can be created
-                *  easily by specifying the size of the payload. This allows sizeof() to work correctly.
-                *
-                *  \param[in] DataSize  Size in bytes of the CDC functional descriptor's data payload
-                */
-               #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize)        \
-                    struct                                        \
-                    {                                             \
-                         USB_Descriptor_Header_t Header;          \
-                             uint8_t                 SubType;         \
-                         uint8_t                 Data[DataSize];  \
-                    }
-                        
                /** Endpoint number of the CDC device-to-host notification IN endpoint. */
                #define CDC_NOTIFICATION_EPNUM         2
 
                /** Endpoint number of the CDC device-to-host notification IN endpoint. */
                #define CDC_NOTIFICATION_EPNUM         2
 
                #define CDC_TXRX_EPSIZE                16       
 
        /* Type Defines: */
                #define CDC_TXRX_EPSIZE                16       
 
        /* Type Defines: */
+               /** Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device
+                *  contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.
+                *  See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint16_t                CDCSpecification; /**< Version number of the CDC specification implemented by the device,
+                                                                  *   encoded in BCD format.
+                                                                  */
+               } USB_Descriptor_CDC_FunctionalHeader_t;
+
+               /** Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface
+                *  supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
+               } USB_Descriptor_CDC_FunctionalACM_t;
+               
+               /** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
+                *  CDC control and data interfaces are related. See the CDC class specification for more details.
+                */
+               typedef struct
+               {
+                       USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
+                       uint8_t                 Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
+                       uint8_t                 MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
+                       uint8_t                 SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
+               } USB_Descriptor_CDC_FunctionalUnion_t;
+
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                /** Type define for the device configuration descriptor structure. This must be defined in the
                 *  application code, as the configuration descriptor contains several sub-descriptors which
                 *  vary between devices, and which describe the device's usage to the host.
                {
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_t               CDC_CCI_Interface;
                {
                        USB_Descriptor_Configuration_Header_t    Config;
                        USB_Descriptor_Interface_t               CDC_CCI_Interface;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC_Functional_IntHeader;
-                       CDC_FUNCTIONAL_DESCRIPTOR(1)             CDC_Functional_AbstractControlManagement;
-                       CDC_FUNCTIONAL_DESCRIPTOR(2)             CDC_Functional_Union;
+                       USB_Descriptor_CDC_FunctionalHeader_t    CDC_Functional_Header;
+                       USB_Descriptor_CDC_FunctionalACM_t       CDC_Functional_ACM;
+                       USB_Descriptor_CDC_FunctionalUnion_t     CDC_Functional_Union;
                        USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint;
                        USB_Descriptor_Interface_t               CDC_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC_DataOutEndpoint;
                        USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint;
                        USB_Descriptor_Interface_t               CDC_DCI_Interface;
                        USB_Descriptor_Endpoint_t                CDC_DataOutEndpoint;
index b826830..c7b5fde 100644 (file)
@@ -61,6 +61,7 @@
   *  - Fixed JTAG_DEBUG_POINT() and JTAG_DEBUG_BREAK() macros not compiling under pure C99 standards mode
   *  - Fixed endpoint selection within the CALLBACK_HID_Device_CreateHIDReport() callback function causing broken GET REPORT requests
   *  - Fixed incorrect command name for EEPROM memory programming in the makefile dfu-ee target
   *  - Fixed JTAG_DEBUG_POINT() and JTAG_DEBUG_BREAK() macros not compiling under pure C99 standards mode
   *  - Fixed endpoint selection within the CALLBACK_HID_Device_CreateHIDReport() callback function causing broken GET REPORT requests
   *  - Fixed incorrect command name for EEPROM memory programming in the makefile dfu-ee target
+  *  - Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev)
   *
   *  \section Sec_ChangeLog100807 Version 100807
   *  <b>New:</b>
   *
   *  \section Sec_ChangeLog100807 Version 100807
   *  <b>New:</b>
index 2d2c7da..ba68f5e 100644 (file)
@@ -76,6 +76,7 @@
  *  The following is a list of known commercial products using LUFA. Some of these are open source, although many are "black-box"
  *  solutions with no source code given.
  *
  *  The following is a list of known commercial products using LUFA. Some of these are open source, although many are "black-box"
  *  solutions with no source code given.
  *
+ *  - Arduino Uno, the official Arduino board: www.arduino.cc
  *  - ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en
  *  - Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/
  *  - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR
  *  - ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en
  *  - Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/
  *  - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR