Hi.
Can you please tell me how to detect the presence of connected (detect event) USB on microcontrollers nRF52840 and nRF52820?
Thanks.
Hi.
Can you please tell me how to detect the presence of connected (detect event) USB on microcontrollers nRF52840 and nRF52820?
Thanks.
Hello,
I can see that the callback you define when calling usb_enable(usb_dc_status_callback status_cb) can provide multiple events that may be useful, see:
/**
* @brief USB Driver Status Codes
*
* Status codes reported by the registered device status callback.
*/
enum usb_dc_status_code {
/** USB error reported by the controller */
USB_DC_ERROR,
/** USB reset */
USB_DC_RESET,
/** USB connection established, hardware enumeration is completed */
USB_DC_CONNECTED,
/** USB configuration done */
USB_DC_CONFIGURED,
/** USB connection lost */
USB_DC_DISCONNECTED,
/** USB connection suspended by the HOST */
USB_DC_SUSPEND,
/** USB connection resumed by the HOST */
USB_DC_RESUME,
/** USB interface selected */
USB_DC_INTERFACE,
/** Set Feature ENDPOINT_HALT received */
USB_DC_SET_HALT,
/** Clear Feature ENDPOINT_HALT received */
USB_DC_CLEAR_HALT,
/** Start of Frame received */
USB_DC_SOF,
/** Initial USB connection status */
USB_DC_UNKNOWN
};
Kenneth
Thank you for your reply.
Are there any code samples where these callbacks are used? What libraries do I need to include in for this?
Thanks.
Hello,
My suggestion, take the usb example that closest resemble what you want to make. Then find an example that have usb_enable("with something else than NULL"); and re-use that callback handler.
Kenneth
Hello,
My suggestion, take the usb example that closest resemble what you want to make. Then find an example that have usb_enable("with something else than NULL"); and re-use that callback handler.
Kenneth
Thank you for your recommendations.
1. Can you please tell me if the "USB_DC_CONNECTED" event is triggered when there is voltage on the VBUS or if the D+ and D- lines should be connected as well?
2. Do I need to describe the USB in the device tree file (.dts) in some way?
Hello,
It seems that currently there is no straightforward way to get USBDETECTED events in the application in Zephyr. However, there is a pull request on the Zephyr project on GitHub that aims to provide this functionality, but it's unclear when this PR will be merged. You can follow the progress of this pull request https://github.com/zephyrproject-rtos/zephyr/issues/51034.
Also see discussion on this devzone case: https://devzone.nordicsemi.com/f/nordic-q-a/104785/usb-detection-by-pin?ReplyFilter=Answers&ReplySortBy=Answers&ReplySortOrder=Descending
Kenneth
Thanks again for your responses.
I will most likely use the solution provided in the nRF52840DK schematic for USB detection.