Hi,
I'm working with MCB4300 eval board using MDK 4 and trying to operate the OTG supplement on USB0. Is there a specific support for OTG in case I'm using the USB library given by keil ( V4.60 )? Does anyone have a good code example demonstrating the use of OTG?
Thanks in advance, Idan
There is documentation regarding OTG on usb.org (www.usb.org/.../) and this is main source of OTG information.
What type of device do you want to develop so that you need OTG support?
I'd like to develop a device which using OTG will recognize if I'm a host or a device. If I'm a host, depending the device just enumerated, I'll decide to be a CDC or a mass storage host. If I'm a device, I'd like to be a CDC device.
You could do it manually at the moment meaning you look at the ID pin on the OTG connector and if it is pulled down then you initialize your device as Host otherwise it as Peripheral, that way it would allow you to change roles by connecting different micro plug, micro-A plug internally has ID pin connected to GND so plugging in a micro-A plug would make your device Host and micro-B plug would make your device Peripheral.
Additional capability of the OTG is to switch roles by software but this you would have to implement yourself if necessary.
Yes. I'm familiar with this ID pin but don't know exactly when do I need to check it out during enumeration process...?
Is this not a must to support the HNP & SRP protocols using software?
Do you maybe have a code example for switching the roles?
Do you know if OTG is supported in a newer keil version say MDK5 ( USB Component V6.0 and above ) ?
Thanks for all the help!
Idan
Well, for ID pin you could initialize device as Peripheral when it is powered on, ID pin should have a pull-up enabled and when micro-A plug is connected it will pull ID pin low and that should generate an interrupt preferably and at that time you would uninitialize Peripheral and initialize Host until disconnect is signaled on port your device is Host unless you implement HNP and enable your Host to become Peripheral.
> Is this not a must to support the HNP & SRP protocols using software? This is really not clear to me, aren't most of microcontroller actions determined by software?
I do not have sample code but generally if you want to use Host you would call something like: usbh_init or USBH_Initialize
if you want to use Peripheral you would call something like: usbd_init or USBD_Initialize followed by usbd_connect(true) or USBD_Connect
if you want to switch to Peripheral from Host you would do something like: usbh_uninit or USBH_Uninitialize followed by usbd_init or USBD_Initialize followed by usbd_connect(true) or USBD_Connect
if you want to switch to Host from Peripheral you would do something like: usbd_connect(false) or USBD_Disconnect usbd_uninit or USBD_Uninitialize followed by usbh_init or USBH_Initialize followed by
> Do you know if OTG is supported in a newer keil version say MDK5 ( USB Component V6.0 and > above ) ? You should ask Keil support for that.
Thanks! you've helped a lot clearing some things up.
BTW, I meant example code for SRP & HNP.