XMega: CDC on USB composite controller does not function properly

1k views Asked by At

For a project I am making a USB keyboard, it has a few buttons and the keys should be programmable. I have chosen the ATXMega32C4, since it has USB support and well as a handy ASF library in Atmel Studio 6.

I've created some Atmel Studio projects to let it function as a keyboard as well as a CDC controller, separately they work successfully. To combine these 2 functionalities, I had to change my project USB to a composite device.

But here is the problem: The CDC controller does not detect properly in Windows, while the composite device and the keyboard controller does.

I've fiddled with the end-points addresses to try and fix the problem, but that din't work and I am out of ideas what the problem might be.(Ofcourse, I do change the PID at each test)

What I tried to do to fix the problem

Change max endpoint/Interface addresses, change endpoint/Interface addresses of the CDC configuration, set different baud rate for the CDC, try to replicate the USB examples for the Xplained.

conf_usb.h:

//! Control endpoint size
#define  USB_DEVICE_EP_CTRL_SIZE       64
//! Number of interfaces for this device
// 1 or more
#define  USB_DEVICE_NB_INTERFACE       3 
//! Total endpoint used by all interfaces
// 0 to max endpoint requested by interfaces
#define  USB_DEVICE_MAX_EP             4 
//! Endpoint numbers definition
#define  UDI_HID_KBD_EP_IN           (1 | USB_EP_DIR_IN)

//! Interface number
#define  UDI_HID_KBD_IFACE_NUMBER    0

//! Endpoints' numbers used by single or first CDC port
#define  UDI_CDC_DATA_EP_IN_0          (2 | USB_EP_DIR_IN)  // TX
#define  UDI_CDC_DATA_EP_OUT_0         (3 | USB_EP_DIR_OUT) // RX
#define  UDI_CDC_COMM_EP_0             (4 | USB_EP_DIR_IN)  // Notify endpoint

//! Interface numbers used by single or first CDC port
#define  UDI_CDC_COMM_IFACE_NUMBER_0   1
#define  UDI_CDC_DATA_IFACE_NUMBER_0   2

//! USB Interfaces descriptor structure
#define UDI_COMPOSITE_DESC_T \
udi_hid_kbd_desc_t udi_hid_kbd; \
usb_iad_desc_t udi_cdc_iad; \
udi_cdc_comm_desc_t udi_cdc_comm; \
udi_cdc_data_desc_t udi_cdc_data
//! USB Interfaces descriptor value for Full Speed
#define UDI_COMPOSITE_DESC_FS \
.udi_hid_kbd = UDI_HID_KBD_DESC, \
.udi_cdc_iad   = UDI_CDC_IAD_DESC_0, \
.udi_cdc_comm  = UDI_CDC_COMM_DESC_0, \
.udi_cdc_data  = UDI_CDC_DATA_DESC_0_FS

//! USB Interfaces descriptor value for High Speed
#define UDI_COMPOSITE_DESC_HS \
.udi_cdc_iad               = UDI_CDC_IAD_DESC_0, \
.udi_cdc_comm              = UDI_CDC_COMM_DESC_0, \
.udi_cdc_data              = UDI_CDC_DATA_DESC_0_HS
//! USB Interface APIs
#define UDI_COMPOSITE_API \
&udi_api_hid_kbd, \
&udi_api_cdc_comm, \
&udi_api_cdc_data

For further inspection I've uploaded some files that might help:

conf_usb.h: http://puu.sh/iwdQi/1551aa928a.h

main.c: http://puu.sh/iwdQ7/df8fc8728a.c

Any help will be greatly appreciated!

2

There are 2 answers

0
Mike Myhre On BEST ANSWER

I don't think you can change the .inf file without deleting the parsed file (same name as the inf, but different extension (.pnf)). I have always had luck in deleting this file before making changes to the .inf, then next plug in of the USB and a new .pnf file will be created.

0
Chinny On

The solution was to install the CDC driver manually. I thought it should automatically detect the CDC port, like the other examples, but it din't.