USB Audio Speaker Tutorial: Step 3

Step 3: Configure USB Library for Audio Device

1

Expand theHarmony Framework Configuration > USB Library selection tree.

2

Check theUse USB Stack? Box.

3

Make sure theInterrupt Mode box is checked.

4

Expand theSelect Host or Device Stack option.

5

The USB stack is used in Device mode. Make sure theUSB Device option is checked.

6

Next, set the Number of Endpoints Used to2. 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.

7

Endpoint 0 Buffer Size must be left to the default value of64 (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.

8

Keep the (default) checkedUSB 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).

9

SelectUSB_SPEED_FULL as the USB Speed. This is used to load the appropriate USB driver (Full Speed or High Speed).

10

Number of Functions Registered to this Device Instance must be left to the default value of1, as only Audio 1.0 device class is used.

11

Next, keep the (default) checkedFunction 1 option and expand it.

12

Since the end application is USB Audio 1.0, select the USB audio device class. Change the Device Class toAUDIO.

13

Set the configuration value to which this function driver is tied. There will be only one configuration and hence retain the default Configuration Value of1.

14

Retain the default Start Interface Number of0.

15

Next, configure the number of interfaces used by this function driver. Change the Number of Interfaces to2. 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.

16

Set the Speed toUSB_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.

17

Next, set the read and write queue size used by the function driver:

  • Keep the default value1 for Audio Write Queue Size*.
  • Change the Audio Read Queue Size to2. 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.

18

Number of Audio Streaming Interfaces must be left to the default value of1, as there is only one audio streaming interface: from USB host to device.

19

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 of2.

20

This application falls into the category of USB speaker. Set the Product ID Selection tousb_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.

21

Leave theSuspend in Sleep option unchecked.

22

Next, set theUSB interrupt priorities:

  • Change the USB Interrupt Priority toINT_PRIORITY_LEVEL1.
  • Keep the default value of USB Interrupt Sub-priority asINT_SUBPRIORITY_LEVEL0.
  • Keep the default value of USB DMA Interrupt Priority asINT_PRIORITY_LEVEL4.
  • Keep the default value of USB DMA Interrupt Sub-priority asINT_SUBPRIORITY_LEVEL0.

23

Keep the default value ofSYS_MODULE_POWER_RUN_FULL for Power State.

24

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:

image_32.png

This finishes the configuration of USB library for your application. Save the configuration.


Next Step >