Detect USB on nRF52840 and nRF52820

Hi.

Can you please tell me how to detect the presence of connected (detect event) USB on microcontrollers nRF52840 and nRF52820?

Thanks.

Parents
  • 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

Reply Children
Related