USB CDC and MSD

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

USB CDC and MSD

Jump to solution
2,623 Views
arnogir
Senior Contributor II

Hello,

We developed a project few years ago (2015/2016) based on Kinetis K70, MQX 4.1.1 with Kds 3.0

On this Platform, we used the USB to plug an USB key (Mass storage) . This key can be need in many step in the product life:

- On first startup, when external flash is empty, we look for on the Key to copy some file needed for our application (Ressources for PEG Library)

- On product live, we could need to copy some application file from/to USB Key / external flash.

So we use also the MFS part..

Now, we need to add a Bluetooth communication to replace the current Serial port which come so obselete. Then the idea is to plug an USB/Bluetooth (https://fr.rs-online.com/web/c/informatique-et-peripheriques/reseaux-et-connectivite/adaptateurs-blu...)

Then we need to used the USB port like an Host CDC.

Currently we used the USB in Host Msd like the provided exemple.

I seen the CDC host exemple which seem no much more complicated.

The question I have is:

- Can we configure the USB to work both in CDC/MSD which is automatically detected according the object which is plugged?

- If no, can we switch from Msd to CDC and CDC to Msd? => How "un install" Usb Msd driver properly?

Thank

Labels (1)
0 Kudos
1 Solution
1,896 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Arnaud:

Theoretically, I think it is possible to configure usb host to work with cdc & msd.

Please refer to Freescale_MQX_4_x\doc\usb\MQX_USB_Host_Reference_Manual

section 2.3 Using the Freescale MQX USB Host API , there defined msd and printer in a driver capabilites table.


1. Define a table of driver capabilities that the application uses (as follows):
Example 2-1. Sample driver info table
static USB_HOST_DRIVER_INFO DriverInfoTable[ ] =
{
{
/* Vendor ID per USB-IF */
{0x00,0x00},
/* Product ID per manufacturer */
{0x00,0x00},
/* Class code */
USB_CLASS_MASS_STORAGE,
/* Sub-Class code */
USB_SUBCLASS_MASS_UFI,
/* Protocol */
USB_PROTOCOL_MASS_BULK,
/* Reserved */
0,
/* Application call back function */
usb_host_mass_device_event
},
{
/* Vendor ID per USB-IF */
{0x00,0x00},
/* Product ID per manufacturer */
{0x00,0x00},
/* Class code */
USB_CLASS_PRINTER,
/* Sub-Class code */
USB_SUBCLASS_PRINTER,
/* Protocol */
USB_PROTOCOL_PRT_BIDIR,
/* Reserved

0,
/* Application call back function */
usb_host_prt_device_event
},
{
/* All-zero entry terminates */
{0x00,0x00},
/* driver info list. */
{0x00,0x00},
0,
0,
0,
0,
NULL
}
};
2. Initialize the USB Host controller interface (_usb_host_init()).
3. The application should then register this table with the host stack by calling the
_usb_host_driver_info_register() host API function.
4. Optionally register services for types of events (_usb_host_register_service()).
5. Wait for the callback function, which is specified in the driver info table, to be called.
6. Check for the events in the callback function: One of ATTACH, DETACH, CONFIG or INTF.
ATTACH: indicates a newly attached device was just enumerated and a default configuration was
selected
DETACH: the device was detached.
CONFIG: A new configuration was selected on the device.
INTF: A new interface was selected on the device.
7. If it is an attach event, then select an interface by calling the host API function
_usb_hostdev_select_interface().
8. After the INTF event is notified in the callback function, issue class-specific commands by using
the class API.
9. Open the pipe for a connected device or devices (_usb_host_open_pipe()).
10. Get the pipe handle by calling the host API function _usb_hostdev_find_pipe_handle().
11. Transfer data by using the host API functions _usb_host_send_data() and/or
_usb_host_recv_data().
12. If required, cancel a transfer on a pipe (_usb_host_cancel_transfer()).
13. If applicable, unregister services for types of events (_usb_host_unregister_service()) and close
pipes for disconnected devices (_usb_host_close_pipe()).
14. Shut down the USB Host controller interface (_usb_host_shutdown()).

Regards

Daniel

View solution in original post

0 Kudos
7 Replies
1,896 Views
arnogir
Senior Contributor II

Then now,

Like indicated in my new post here:

https://community.nxp.com/message/996344

I'm looking for a way to get a Bluetooth dongle which work directly in USB (Host or Device) CDC serial....

This product exist in the market, but too expensive.. Maybe NXP has solution to do it with a no expensive Kinetis series...?...

0 Kudos
1,896 Views
arnogir
Senior Contributor II

Hello,

Ok, I run the USB Host AND device CDC demo with success.

Then if I add USB mass storage class in the Driver Info table it is ok.

Thank for your help.

0 Kudos
1,896 Views
danielchen
NXP TechSupport
NXP TechSupport

You are welcome, thanks for your update.

Regards

Daniel

0 Kudos
1,896 Views
arnogir
Senior Contributor II

Hello

Then first, Is somebody can help me to use the exemple USB-CDC on the tower K70 allowing to be connect the Tower USB port to the computer which emulate it in seral port and then seen byte transmited from/to Serial port to/from USB(Serial emulmated...) ???

Currently, when I plug the USB cable in the tower and to the computer, nothing append in the K70 task: No event of attach/detach appears...

0 Kudos
1,896 Views
arnogir
Senior Contributor II

Hello,

Yes I will test that, but first I must make work the Host CDC exemple on the tower K70.

I try to plug a computer on it but without success, I havn't enumeration callback (attach event...)

I think this is because both computer and Tower are in Host!..

Then I order an Bluetooth key to plug on the tower, then my computer will attach to them and try to emulate serial port with it.

0 Kudos
1,897 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Arnaud:

Theoretically, I think it is possible to configure usb host to work with cdc & msd.

Please refer to Freescale_MQX_4_x\doc\usb\MQX_USB_Host_Reference_Manual

section 2.3 Using the Freescale MQX USB Host API , there defined msd and printer in a driver capabilites table.


1. Define a table of driver capabilities that the application uses (as follows):
Example 2-1. Sample driver info table
static USB_HOST_DRIVER_INFO DriverInfoTable[ ] =
{
{
/* Vendor ID per USB-IF */
{0x00,0x00},
/* Product ID per manufacturer */
{0x00,0x00},
/* Class code */
USB_CLASS_MASS_STORAGE,
/* Sub-Class code */
USB_SUBCLASS_MASS_UFI,
/* Protocol */
USB_PROTOCOL_MASS_BULK,
/* Reserved */
0,
/* Application call back function */
usb_host_mass_device_event
},
{
/* Vendor ID per USB-IF */
{0x00,0x00},
/* Product ID per manufacturer */
{0x00,0x00},
/* Class code */
USB_CLASS_PRINTER,
/* Sub-Class code */
USB_SUBCLASS_PRINTER,
/* Protocol */
USB_PROTOCOL_PRT_BIDIR,
/* Reserved

0,
/* Application call back function */
usb_host_prt_device_event
},
{
/* All-zero entry terminates */
{0x00,0x00},
/* driver info list. */
{0x00,0x00},
0,
0,
0,
0,
NULL
}
};
2. Initialize the USB Host controller interface (_usb_host_init()).
3. The application should then register this table with the host stack by calling the
_usb_host_driver_info_register() host API function.
4. Optionally register services for types of events (_usb_host_register_service()).
5. Wait for the callback function, which is specified in the driver info table, to be called.
6. Check for the events in the callback function: One of ATTACH, DETACH, CONFIG or INTF.
ATTACH: indicates a newly attached device was just enumerated and a default configuration was
selected
DETACH: the device was detached.
CONFIG: A new configuration was selected on the device.
INTF: A new interface was selected on the device.
7. If it is an attach event, then select an interface by calling the host API function
_usb_hostdev_select_interface().
8. After the INTF event is notified in the callback function, issue class-specific commands by using
the class API.
9. Open the pipe for a connected device or devices (_usb_host_open_pipe()).
10. Get the pipe handle by calling the host API function _usb_hostdev_find_pipe_handle().
11. Transfer data by using the host API functions _usb_host_send_data() and/or
_usb_host_recv_data().
12. If required, cancel a transfer on a pipe (_usb_host_cancel_transfer()).
13. If applicable, unregister services for types of events (_usb_host_unregister_service()) and close
pipes for disconnected devices (_usb_host_close_pipe()).
14. Shut down the USB Host controller interface (_usb_host_shutdown()).

Regards

Daniel

0 Kudos
1,896 Views
arnogir
Senior Contributor II

Hello

I'm trying desperately to make the exemple Host_Cdc_serail work without success.

The serial part work (with debug mode, I got event on received data on the UART part)

But, for the USB part, it not work:

- If I plug an USB Key (with a specific added driverInfoTable), I got the call back with Attach...dettach event.

- If I plug a Bluetooth dongle (Link bellow) or directly a computer, noting call back comes..

What can we plug on the board to make the exemple call correctly the call back corresponding to a device of Class "Communication or Data"?

Thank for your help!

https://www.silabs.com/products/wireless/bluetooth/bluetooth-low-energy-modules/bled112-bluetooth-sm...

0 Kudos