This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it possible to have 2 CDC ACM serial ports?

I've got the USB CDC ACM example up and running. I'd like to do something similar on the nrf52840 Dongle but rather than using a UART for the CLI, I'd like to use a second virtual comm port.

My end goal is to use one VCP for data comms, and the second VCP for debug/logging.

Is this possible with the existing software? Are there any examples around that show what's needed?

Parents
  • Hi Dave

    We don't have any examples showing how to set up 2 com ports, no, but in principle you just have to set up a second cdc_acm_class in the example. 

    To do this you have to set up a second CDC_ACM class instance using the APP_USBD_CDC_ACM_GLOBAL_DEF macro, and make sure to provide unique interface and endpoint numbers (so there is no conflict between them). 

    Then you have to initialize the second class and append it to the USB driver:

    app_usbd_class_inst_t const * class_cdc_acm_2 = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm_2);
    ret = app_usbd_class_append(class_cdc_acm_2);
    APP_ERROR_CHECK(ret);

    Once that is done you should be able to access the second com ports by referencing m_app_cdc_acm_2 rather than m_app_cdc_acm. 

    Finally you might want to extend the cdc_acm_user_ev_handler function to distinguish between the two com ports.

    Best regards
    Torbjørn

Reply
  • Hi Dave

    We don't have any examples showing how to set up 2 com ports, no, but in principle you just have to set up a second cdc_acm_class in the example. 

    To do this you have to set up a second CDC_ACM class instance using the APP_USBD_CDC_ACM_GLOBAL_DEF macro, and make sure to provide unique interface and endpoint numbers (so there is no conflict between them). 

    Then you have to initialize the second class and append it to the USB driver:

    app_usbd_class_inst_t const * class_cdc_acm_2 = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm_2);
    ret = app_usbd_class_append(class_cdc_acm_2);
    APP_ERROR_CHECK(ret);

    Once that is done you should be able to access the second com ports by referencing m_app_cdc_acm_2 rather than m_app_cdc_acm. 

    Finally you might want to extend the cdc_acm_user_ev_handler function to distinguish between the two com ports.

    Best regards
    Torbjørn

Children
Related