Multiple different USB devices via virtual hub or switching

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

Multiple different USB devices via virtual hub or switching

2,007 次查看
aimozg
Contributor II

Hello.

 

I'm using K60F with MQX. I need to have two USB devices --- Virtual COM and Mass Storage Device. I can see two possible solutions:

1. Implement a software hub. I didn't find hub device support in MQX, so I suspect I have to implement hub class over MQX USB Framework, and modify standard CDC and MSD implementations so they will work through software hub and don't call USB Framework functions. Correct me if I'm wrong.

2. As a backup solution. Programmatically switch from one USB device to another after certain external event. So on this event I have to detach and deinitialize one device; then initialize another. MQX CDC and MSD classes don't have 'deinit' of 'detach' functions. Aside carefully freeing their memory, what is the common process of detaching device?

标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

1,116 次查看
stalisman
Contributor III

What you want to do is to create a  'composite device' that presents both the Virtual COM and the mass storage devices to the PC.  This will utilise a single physical connection.  A composite device is merely a template for you to embed your existing devices neatly.   I suppose you could consider it to be a 'wrapper' device for it is just as complex or simple as any other device only it gives access to devices you have already written. ( If I recall it is easier than hacking through HID device classes).

0 项奖励
回复

1,116 次查看
Fabi
Contributor III

I'm also interested in an implementation for composite device CDC+MST (virtual com plus mass storage) using MQX. The things to do, would be on the one hand to define proper descriptors. This could be lean on e.g. http://homepage2.nifty.com/Notus/USB_CDC_HID_IAD_10.zip which includes USB_Descriptor.c for CDC and HID. It shouldn't be difficult to replace the HID specifics by MST.

Second step could be to test if 'MQX is ready for usb composite device'. I guess, however, some changes on usb middleware in MQX would be necessary to make it working. Experience from freescale's MQX-engineers would be necessary for it.

So, a developers group could be initiated to manage it. What's your opinion? Is anybody interested in?

(Sorry for my english - my source code is better :smileywink:

0 项奖励
回复

1,116 次查看
Jarpba
Contributor II

Hello there! I'm looking for a similar solution to deinit the mass storage device and then reinit it after some data has been updated on the k60 device using mqx 3.7 (without disconnecting the usb physically in between).

 

I found that freescale medical usb stack (without mqx) has deinit functions at least for msc (also cdc) and a better documentation (USBAPIRM).

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MEDICALUSB

I have tried to port files and functions from an example project included without any success. They share similar function calls with mqx usb stack but the code is so different that it is beyond my skills. The documentation says that medical usb stack is compatible with mqx but there is no advice on how to make them talk to each others.

 

For the deinitialization procedure the documentation states the following:

 

2.4.1.2 De-initialization flow
To de-initialize the driver layer, the class layer must:
1. Call 3.1.7“_usb_device_deinit()” to de-initialize low level driver and the controller.
2. Call 3.1.17“_usb_device_unregister_service()” to unregister service callback functions for the
following:
— USB_SERVICE_BUS_RESET
— USB_SERVICE_SUSPEND
— USB_SERVICE_SOF
— USB_SERVICE_RESUME
— USB_SERVICE_SLEEP
— USB_SERVICE_ERROR
— USB_SERVICE_STALL
3. Call 3.1.17“_usb_device_unregister_service()” to unregister callback functions for control and
non-control endpoints.

 

Maybe it would be possible to spy on those functions in medical usb stack and implement only necessary parts in current mqx 3.7 usb device source?

 

edit: calling USB_Class_MSC_DeInit() will deinit not only the mass storage class but also the controller hardware so this would be what we want to port to mqx libs.

0 项奖励
回复