Step 3: Configure USB Library for Audio Device
Expand the Harmony Framework Configuration > USB Library selection tree.
Check the Use USB Stack? Box.
Make sure the Interrupt Mode box is checked.
Expand the Select Host or Device Stack option.
The USB stack is used in Device mode. Make sure the USB Device option is checked.
Next, set the Number of Endpoints Used to 2. This includes the default control endpoint 0 which will be used for USB device control transfers and USB audio control transfers. The other endpoint will be used for streaming USB audio data.
Endpoint 0 Buffer Size must be left to the default value of 64 (Maximum buffer size). For full speed devices, the USB specification allows the Endpoint 0 buffer to be of size 8, 16, 32 or 64 bytes.
Keep the (default) checked USB Device Instance 0 option and expand it.
Since there is only one USB peripheral on the device, there is only one USB instance (selected by default).
Select the USB Speed to USB_SPEED_FULL. This is used to load the appropriate USB driver (Full Speed or High Speed).
Number of Functions Registered to this Device Instance must be left to the default value of 1, as only Audio 1.0 device class is used.
Next, keep the (default) checked Function 1 option and expand it.
Since the end application is USB Audio 1.0, select the USB audio device class. Change the Device Class to AUDIO
Set the configuration value to which this function driver is tied. There will be only one configuration and hence retain the default Configuration Value of 1.
Retain the default Start Interface Number of 0.
Next, configure the number of interfaces used by this function driver. Change the Number of Interfaces to 2. One interface will be used for the transfer of audio controls (volume and mute), and the other will be used for transfer of the audio data stream.
Set the Speed to USB_SPEED_FULL. This is used to populate the device descriptors for USB full speed operation.
Stereo audio files with 48 KHz sampling rate and 16-bit resolution will be played. USB high speed may be used to play high resolution audio files.
Next, set the read and write queue size used by the function driver.
- Keep the default value 1 for Audio Write Queue Size
- Change the Audio Read Queue Size to 2. For a continuous reception of audio stream, and to avoid the loss of audio data, the read queue size must be at least 2 to allow for ping-pong buffer operation.
Number of Audio Streaming Interfaces must be left to the default value of 1, as there is only one audio streaming interface: from USB host to device.
Two alternate settings will be used: one to reclaim the bandwidth when the audio functionality is not being used, and the other when the audio functionality is used. Keep the Maximum Number of Interface Alternate Settings to the default value of 2.
This application falls into the category of USB speaker. Set the Product ID Selection to "usb_speaker_demo" from the drop-down box. Notice that when the "usb_speaker_demo" is selected, these fields are populated as follows:
- Enter Vendor ID: 0x04D8
- Enter Product ID: 0x0064
- Manufacturer String: “Microchip Technology Inc.”
- Product String: “Harmony USB Speaker Example”
You can rename the Product String to “Harmony USB Speaker" if you want to.
Leave the Suspend in Sleep option unchecked.
Next, set the USB interrupt priorities:
- Change the USB Interrupt Priority to INT_PRIORITY_LEVEL1
- Keep the default value of USB Interrupt Sub-priority as INT_SUBPRIORITY_LEVEL0
- Keep the default value of USB DMA Interrupt Priority as INT_PRIORITY_LEVEL4
- Keep the default value of USB DMA Interrupt Sub-priority as INT_SUBPRIORITY_LEVEL0
Keep the default value of SYS_MODULE_POWER_RUN_FULL for Power State
The other options must be left unchecked:
- Enable SOF Events
- Enable Set Descriptor Events
- Enable Sync Frame Events
- Use Remote Wakeup Feature
- Enable BOS Descriptor Support
- Enable advanced String Descriptor Table
See the following screen shot of the USB library configuration:
This finishes the configuration of USB library for your application. Save the configuration.