Dual CDC with SAMG55 (ASF3)

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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 ?

 

 

Last Edited: Wed. Mar 25, 2020 - 09:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems that the SAMG55 has only 6 USB end points, not enough to run two CDC instances (3 EP's per instance) as EP0 is always used for device configuration.

 

Is there any way to use single EP as notification for two CDC’s? (probably by modifying USB drivers...?)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems that the SAMG55 has only 6 USB end points

That's pretty depressing.  The lesser SAMD21 has 16...

 

PJRC recently added multiple CDC ports for their bigger "Teensy" USB boards (Not Atmel based); a thing that caused me a double take: "oh, you can do that?!  More things should do that!"

https://github.com/PaulStoffrege...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did anyone find the working way..

Please paste it here..