Trying to switch between host and device on one usb

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Trying to switch between host and device on one usb

602 次查看
danielwinsor
Contributor II

I have a device with one USB port.   I use it to create a virtual com port.  this works fine.

if I reconfigure the sw on my board as a usb device, I can connect my board to a PC and it looks like a storage device.

My question is, does anyone have an example of switch from host to device mode and back to host without a shutdown?

When I try to shut down the host stack and go to device mode I am ok. 

Then, when I try to shut down device mode and bring up host mode again, I get error C1 (USBERR_DEVICE_BUSY)

Here is how I shut down:

_int_disable();
_usb_host_bus_control(host_handle,USB_ASSERT_BUS_RESET);
_usb_host_shutdown(host_handle);
bShutdownGood = true;
_int_enable();

Any examples of switching between host and device mode without a shutdown would be appreciated!

Thanks so much!

Dan.

标记 (1)
0 项奖励
回复
1 回复

445 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi Dan:

Such capability is usually implemented by the ID pin of the mini and Micro USB connectors. When the pin is floating, device mode should be initialized. When the pin is grounded, host mode should be initialized

As far as I know, we don't support the OTG functionality with MQX USB Host/Device stack. You need to develop this feature by yourself. Maybe you can refer to usb stack in KSDK, it supports OTG.

Regards

Daniel

0 项奖励
回复