Hi, I am trying to get two CDC working on SAMG55.
The CDC device example from ASF3 works fine with single CDC, but when I change UDI_CDC_PORT_NB to 2 not even one CDC works.
I modified CDC callbacks to "multi" type, and added a simple echo (working fine when UDI_CDC_PORT_NB = 2).
BTW, I don't need a to a physical UART
void uart_rx_notify(uint8_t port) { UNUSED(port); LED_Toggle(LED0); if (udi_cdc_multi_is_rx_ready(port)) { int c = udi_cdc_multi_getc(port); if (udi_cdc_multi_is_tx_ready(port)){ udi_cdc_multi_putc(port, c); } } // If UART is open // if (usart_get_interrupt_mask(USART_BASE) // & US_IMR_RXRDY) { // // Enable UART TX interrupt to send a new value // usart_enable_tx(USART_BASE); // usart_enable_interrupt(USART_BASE, US_IER_TXRDY); // } }
USB configuration from udi_cdc_conf.h:
/** * \name Default endpoint configuration * The USBB, UDP, UDPHS and UOTGHS interfaces can support up to 2 CDC interfaces. */ //@{ # if UDI_CDC_PORT_NB > 2 # error USBB, UDP, UDPHS and UOTGHS interfaces have not enought endpoints. # endif #define UDI_CDC_DATA_EP_IN_0 (1 | USB_EP_DIR_IN) // TX #define UDI_CDC_DATA_EP_OUT_0 (2 | USB_EP_DIR_OUT) // RX #define UDI_CDC_COMM_EP_0 (3 | USB_EP_DIR_IN) // Notify endpoint # if SAM3U /* For 3U max endpoint size of 4 is 64, use 5 and 6 as bulk tx and rx */ # define UDI_CDC_DATA_EP_IN_1 (6 | USB_EP_DIR_IN) // TX # define UDI_CDC_DATA_EP_OUT_1 (5 | USB_EP_DIR_OUT) // RX # define UDI_CDC_COMM_EP_1 (4 | USB_EP_DIR_IN) // Notify # else # define UDI_CDC_DATA_EP_IN_1 (4 | USB_EP_DIR_IN) // TX # define UDI_CDC_DATA_EP_OUT_1 (5 | USB_EP_DIR_OUT) // RX # define UDI_CDC_COMM_EP_1 (6 | USB_EP_DIR_IN) // Notify # endif //! 3 endpoints used per CDC interface #undef USB_DEVICE_MAX_EP // undefine this definition in header file #define USB_DEVICE_MAX_EP (3*UDI_CDC_PORT_NB) //@}
I found that the udi_cdc_comm_enable() is called only once, so only one CDC instance is initialized, but can't trace it back.
Can anyone help and point me in the right direction ?