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?
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.
I am happy to report that this worked well and turned out to be much easier than I thought it would be. Thanks.
I did notice that the usbd_cdc_acm example seems to use a mixture of p_cdc_acm and &m_app_cdc_acm in the cdc_acm_user_ev_handler function.
For a single CDC_ACM instance these wind up being the same, but when you have multuple instances p_cdc_acm winds up pointing to the CDC_ACM that the event was for.
Sorry for the late reply, I forgot to check my verified cases...
It is good to hear you were able to get the example running
I will mention the p_cdc_acm/m_app_cdc_acm inconsistency to the developers. This seems like an oversight.