Using OTG2 for USB CDC host

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using OTG2 for USB CDC host

Jump to solution
1,186 Views
jeffthompson
Contributor V

I want to be able to switch from OTG1 to OTG2 (and back) for use as a USB CDC host. How is this possible?

Labels (1)
0 Kudos
1 Solution
1,017 Views
dmarks_ls
Senior Contributor I

Hi Jeff,

Turns out I'm also trying to get a USB CDC host running on OTG2 on an RT1052, though I'm not looking to switch back and forth.  So far, I'm not having success... the USB ISR never fires.  I'm not convinced that the MCUX configurator is creating the correct settings for which EHCI controller is associated with OTG2, I'm still debugging and will probably create my own post.  I'll update here if/when I do.

Frankly, I'm not impressed with the CDC host middleware that's provided; it's badly cobbled together from the USB CDC bare-metal SDK example, and doesn't do anything useful as provided.  It should provide a clean API for applications to get USB in data and send USB out data, but instead you have to hack apart the CIC functions they give you.  There shouldn't be any reference to a "UART" in the CIC code, but there's dozens still there because they just ported the SDK example and left all the confusing variable names in place.

To your original question... I don't think it should be that big a deal to switch back and forth.  There are USB_HostInit() and USB_HostDeinit() calls in the API, so I would think you should be able to simply shut down the one interface and then start the other.  You would just need to make sure you're passing the correct instances to your event handlers and ISR.

David R.

View solution in original post

0 Kudos
5 Replies
1,018 Views
dmarks_ls
Senior Contributor I

Hi Jeff,

Turns out I'm also trying to get a USB CDC host running on OTG2 on an RT1052, though I'm not looking to switch back and forth.  So far, I'm not having success... the USB ISR never fires.  I'm not convinced that the MCUX configurator is creating the correct settings for which EHCI controller is associated with OTG2, I'm still debugging and will probably create my own post.  I'll update here if/when I do.

Frankly, I'm not impressed with the CDC host middleware that's provided; it's badly cobbled together from the USB CDC bare-metal SDK example, and doesn't do anything useful as provided.  It should provide a clean API for applications to get USB in data and send USB out data, but instead you have to hack apart the CIC functions they give you.  There shouldn't be any reference to a "UART" in the CIC code, but there's dozens still there because they just ported the SDK example and left all the confusing variable names in place.

To your original question... I don't think it should be that big a deal to switch back and forth.  There are USB_HostInit() and USB_HostDeinit() calls in the API, so I would think you should be able to simply shut down the one interface and then start the other.  You would just need to make sure you're passing the correct instances to your event handlers and ISR.

David R.

0 Kudos
1,017 Views
dmarks_ls
Senior Contributor I

For what it's worth, I did eventually get USB2 working as an OTG host (it was mostly issues with the connected Kinetis slave device).  I also plan to make a post regarding the rather poor state of the USB host CDC middleware that's provided, with some suggestions for optimization.

So yes, there shouldn't be any issue switching USB functions as long as you cleanly bring your USB stacks up and down each time.

David R.

0 Kudos
1,017 Views
jeffthompson
Contributor V

I also got separate hosts going, just a few days ago, by changing CONTROLLER_ID and rebuilding. Turns out my hardware had a separate enable for the second USB Vbus that I wasn't aware of and I had to turn it on. My application should never both the regular host and OTG host at the same time, so tearing down one stack and starting another will be acceptable.

1,017 Views
jeffthompson
Contributor V

My bad, I should have specified that I'm using MCUXpresso 11.01 for the MIMXRT1062DVJ6A, and MCUXpresso SDK USB Stack, Rev. 10, 06/2019.

0 Kudos
1,017 Views
Pavel
NXP Employee
NXP Employee

NXP offers LSDK 1909 for the Layerscape processors.

See the Section 7.2.16 in LSDK 1909 User Guide:

https://www.nxp.com/docs/en/user-guide/LSDKUG_Rev19.09.pdf

 

Have a great day,
Pavel Chubakov

 

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

0 Kudos