USB stack and hardware de-initialization

cancel
Showing results for 
Search instead for 
Did you mean: 

USB stack and hardware de-initialization

184 Views
Senior Contributor I

I've been through all of the docs on the SDK's USB stack and I can't find anything useful about the deinit functions or what sequence they should be used in, and I can't find any demos that make use of them.

I need to shut down a composite device and reset the SIE, including a bus reset.  This is so the device can switch between composite mode and MSD only.  I'm moving my code from the v5 beta stack, and the hardware deinit was handled by my own code, but I'm trying to keep this version cleaner and avoid duplication of anything that's already there.

There's USB_DeviceStop, USB_DeviceDeinit, and USB_DeviceClassDeinit.  It's not clear if any of these call each other or if any of them shut down the SIE hardware - presumably USB_DeviceStop, but it doesn't say so explicitly. Can someone tell me what the expected sequence is to shut everything down?

Thanks,

Scott

Labels (1)
0 Kudos
3 Replies

41 Views
NXP TechSupport
NXP TechSupport

Hi Scott,

 

The function you need to call is USB_DeviceStop, this function disables the device functionality and detach the device from the host.

 

Referring the other functions, USB_DeviceDeinit is called inside USB_DeviceClassDeinit. This will discard all the parameters registered as USB devices. Please keep in mind that this function should be called after USB_DeviceStop.

 

I hope this helps.


Have a great day,
Felipe

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

41 Views
Senior Contributor I

Hi Felipe,

The process that's worked for me so far is calling USB_DeviceClassDeinit() followed by setting the USBTRC0_USBRESET bit - and also deleting the USB device task so as to not complicate the restart logic.

It looks like USB_DeviceStop just clears the DP pull-up bit.  Any reason I shouldn't use USBRESET instead to reset the module state?

My concern is for making sure the stack restarts in a consistent way.  The default mode is MSD-only since it doesn't prompt for a driver on any modern OS, and the user can select a composite MSD + CDC serial mode when needed.  I'm not sure this is a use case foreseen by the API, but it's been working OK so far.

Thanks,

Scott

0 Kudos

41 Views
NXP TechSupport
NXP TechSupport

Hi Scott,

 

Thanks for sharing your implementation. From my perspective you shouldn’t have issues by resetting the module your way. If you have any questions please don’t hesitate to ask me.

 

Regards,

Felipe

0 Kudos