Step 5: Configure USB Library and File System
Step 5.1: Configure USB Library (Mass Storage Host)
Expand the Harmony Framework Configuration > USB Library tree.
1
Check the Use USB Stack? box.
The USB library is dependent on the Timer System Service for maintaining internal timing requirements. MHC knows this, so it enables the Timer System Service for you. Note the Use Timer System Service? option has been selected under the System Services > Timer selection tree.
MHC also knows the Timer System Service needs a Timer driver to function, so it enables this for you too. Note the Use Timer Driver? option has been selected under the Harmony Framework > Configuration > Drivers > Timer selection tree. Observe that MHC has configured Timer Instance 0 to use the Timer1 peripheral (TMR_ID_1).
2
The Interrupt Mode is checked by default. Keep this selection.
3
Expand the Select Host or Device Stack option. Uncheck the USB Device option and check the USB Host (Recommended) option.
4
Keep the Host Speed as USB_SPEED_HIGH. The PIC32MZ Host supports both Full Speed and High-Speed operations. Selecting High Speed allows the device to work at both Full Speed and High Speed.
5
Keep the Number of Devices to the default value of 1.
6
Keep the Number of Targeted Peripheral List (TPL) Entries to 1. The TPL allows the USB host to focus on specific USB devices. For Mass Storage Class, the Host Layer attaches the MSD Host Client Driver to a device when the class, subclass, and protocol fields in the Interface Descriptor matches the entry in the TPL table. The following code shows a TPL table design for matching MSD Devices.
This shows that the Host Layer attaches the USB_HOST_MSD_INTERFACE driver whenever the class code, subclass code, and protocol code in the USB interface descriptor of the device matches 0x08 (Class code: Mass Storage), 0x06 (Sub-class code: SCSI transparent command) and 0x50 (Protocol code: Bulk-only Transfer).
7
Keep the Host Max Interface per Device at 5. This defines the maximum number of interfaces the host can support.
If the attached device's configuration descriptor indicates 4 interfaces, then the Host Max Interface per Device value should be a minimum of 4 or the device will not be processed by the USB host layer. The mass storage device descriptors define only one interface, so the Host Max Interface per Device may be changed to 1.
8
Since this is a USB MSD Host application, check the Use MSD Host Client Driver box.
9
Keep the Number of MSD Host Driver Instances at 1. This defines the maximum number of MSD Host Driver instances. If you wanted to support two flash drives, then you would set this value to 2.
Step 5.2: Configure the File System Service For USB MSD Media
A file system is needed to access the files on the flash drive.
1
Expand the Harmony Framework Configuration > System Services > File System selection tree. Note that you have already selected the Use File System Service? option when you configured the file system for SD Card.
2
Expand the Use File System Service?. Change the Total Number Of Media to 2. One media is the SD Card and the other is the USB Mass Storage Device.
The Use File System Auto Mount Feature? is already enabled. This causes the USB MSD Host client driver to automatically mount the file system on the drive, and then notify the application through SYS_FS_MOUNT_EVENT in the file system event handler registered by the application. Note that in previous MHC versions, mounting of the file system was handled by the application when the application received a USB_HOST_MSD_EVENT_ATTACH in the USB Host MSD event handler registered by the application.
3
Expand Media 1. (Note: Media 0 is already configured for the SD Card media).
4
Next, you need to configure the media. Expand Media Configuration (1).
5
Change the Media Type to SYS_FS_MEDIA_TYPE_MSD. This causes the media driver functions to use the USB Mass Storage SCSI functions in order to access the media.
6
Retain File System Type as FAT.
7
Retain Number Of Volumes as 1. This reflects the number of valid partitions available on the media. Make sure Volume 1 is selected and that the Device Name and Media Mount Name are set to*/dev/sda1** and /mnt/myDrive2 respectively.
8
Keep the File System Types value at 1 and verify that FAT File System is selected.