Hello Nordic Support,
I am working on an application that logs data to SD card when disconnected from USB and appears as USB Mass Storage Class on host PC when connected to USB. Currently, this is how I am testing the application. During logging phase, the DK is powered from the JLink port. To check the SD card content, I disconnect the cable from JLink port and connect it to the USB port. Thjs approach is working fine.
Note that, my application is based on the example 'usb_msc_pca10056' example
What I would like to do is to power DK from the JLink port and also connect the USB cable to the host PC and control the USB connect/disconnect by changing the pull down of USB data lines. To achieve this, I changed USBD_POWER_DETECTION from true to false
#define USBD_POWER_DETECTION false
However, the application kept restarting. Can you please let me know how I can control the USB connect/disconnection from the host PC without physically disconnecting the USB cable?
I assume what you need is to disable the USBD driver so that you can freely access the SD card again?
I should have an old example somewhere showing how to do this, but I need some more time to find it. With some luck I can provide some code for you later in the week.
Thanks, Torbjørn. Looking forward to your suggestion.
I finally found the example, but realized it was written for a really old version of the SDK (v12.2.0).
This was a training that showed how you could dynamically disable and enable the USB connection without requiring you to remove the USB cable.
I will attach it anyway in case you can find it useful.
Let me know if you can figure out the example, if not I will do my best to help next week.
Thanks for the example. I was able to dynamically enable/disable the USB using this example as a reference. One issue that I'm facing though is related to initializing SD card and writing to it after USB is disabled. I will try to debug this and if needed, will raise another question.
Thanks for the update.
Yes, just open a new ticket if the issue is a bit on the side of the previous one. These cases get a bit hard to navigate if they cover multiple topics.