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

Adding usb-cdc support into nrf mesh project

Hi all,

we would like to add usb-cdc support for our nrf mesh project. I have tried merging an usbd example project into our application but without success so far. I am having hard time to even compile. Is there a recommended way for doing this? I am using SEGGER Embedded Studio and nRF Connect to program the nRF52840 dongles.

Parents
  • Hi Bro ,

    Do you successful merge USB cdc & mesh now? I 'm working with this purpose without success yet. Can you give me some advice.

  • Yeah, well it's working mostly fine now just make sure you have the latest version of softdevice. I believe prior versions can't handle the usb and ble at the same time. Lastly, make sure you have USBD_POWER_DETECTION disabled. This is the code I used in our application (please note this may not be the best way to do that, but at least it's working):

    static void cdc_acm_event_handler(app_usbd_class_inst_t const * p_inst,
                                      app_usbd_cdc_acm_user_event_t event)
    {
      // handle incoming data
    }
    
    static void usbd_event_handler(app_usbd_event_type_t event)
    {
      // empty, we're not using this one
    }
    
    APP_USBD_CDC_ACM_GLOBAL_DEF(m_app_cdc_acm,
                                cdc_acm_event_handler,
                                CDC_ACM_COMM_INTERFACE,
                                CDC_ACM_DATA_INTERFACE,
                                CDC_ACM_COMM_EPIN,
                                CDC_ACM_DATA_EPIN,
                                CDC_ACM_DATA_EPOUT,
                                APP_USBD_CDC_COMM_PROTOCOL_AT_V250
    );
    
    static void usbd_init(void)
    {    
        static const app_usbd_config_t usbd_config = {
            .ev_state_proc = usbd_event_handler
        };
        ERROR_CHECK(nrf_drv_power_init(NULL));
        ERROR_CHECK(nrf_drv_clock_init());
    
        app_usbd_serial_num_generate();
        ERROR_CHECK(app_usbd_init(&usbd_config));
    
        app_usbd_class_inst_t const * class_cdc_acm = 
            app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm);
        ERROR_CHECK(app_usbd_class_append(class_cdc_acm));
    }
    
    static void start(void)
    {
        if (USBD_POWER_DETECTION)
        {
            ERROR_CHECK(app_usbd_power_events_enable());
        }
        else
        {
            app_usbd_enable();
            app_usbd_start();
        }
    }

  • Hello, @nrf_developer witch version of the softdevice are you using? unfortunately I had no success using your code, it runs, but the PC doesn't recognizes as a COM device

Reply Children
No Data
Related