I am trying to modify the usbd_cdc_acm_modified example project in the SDK to do the following:
"After starting the library, the whole stack starts to work. All processing required by the standard is done in the interrupts. It means that no more processing in any main loop is required for the USB to work."
I was able to accomplish #1 easily enough. I am still stuck on #2.
I modified power_usb_event_handler to implement the following statement:
"This may be done inside USB power event handler. USBD library should be enabled on NRF_DRV_POWER_USB_EVT_DETECTED and started on NRF_DRV_POWER_USB_EVT_READY."
Here is the modified function:
static void power_usb_event_handler(nrf_drv_power_usb_evt_t event)
NRF_LOG_INFO("USB power detected");
NRF_LOG_INFO("USB power removed");
m_usb_connected = false;
m_usb_connected = true;
Notice I added app_usbd_stop() and app_usbd_start()...
This still does not work unless app_usbd_event_queue_process() is called within the while() loop in main. I tried to comment it out, and set
#define APP_USBD_EVENT_QUEUE_ENABLE 0
but I don't get any received characters.
I am using Keil, PCA10056 and the latest SDK 14.2.0
Any help would be appreciated!
Did you change usbd_config struct passed to app_usbd_init()? I tried to apply your changes to the USBD CDC ACM example, but got a hardfault in app_usbd_event_add(), most likely because ev_handler is not set in the config struct. Passing NULL to app_usbd_init() seems to fix the issue. The app_usbd library will then use the default internal event handler, but you can also provide your own in the config struct.