CY8CKIT-046 PSoC® 4 L-Series Pioneer Kit Guide, Doc. #: 002-03344 Rev. *D
44
Code Examples
maximum of 48 kHz audio rate. This defines the buffer size of each endpoint as 294 (288 + 6) bytes.
The additional six bytes (or one audio sample) are for occasional asynchronous control, where the
USB host may be required to transmit one additional sample to match the audio streaming rate. The
example implements these two primary endpoints along with two control endpoints. One control end-
point communicates between the PC and PSoC 4200L, exchanging various audio controls such as
volume and mute. The other control endpoint is an Isochronous Synch Endpoint (refer to section
3.7.2.2 in the
USB Audio device class v1.0 specification
for details). This endpoint is used to syn-
chronize the audio streaming data rate to the USB transfer data rate. The basic function of this end-
point is to communicate the number of samples transferred to the audio device in an interval
synchronized with the USB host clock (typically 1 ms for Full-Speed USB). With this data, the USB
host can adjust the number of samples per packet it transfers in subsequent cycles.
The high level data flow is as follows:
1. Every 1 millisecond, transfer the entire USB data packet to a four-packet wide circular buffer with
DMA and update the circular buffer write/read pointer.
2. If the circular buffer is at least half full (two packets full), start streaming data to and from the I2S
component.
3. The I2S requests data from the circular buffer whenever space is available in the internal FIFO.
4. Every time one-eighth of the circular buffer has transferred to the I2S component, trigger an
interrupt and update the circular buffer read/write pointer.
In addition to audio streaming, a USB HID device class is also implemented. The HID device class
implements a Consumer Device interface to provide media controls and volume controls through the
CapSense Gesture Pad. Note that the audio playback controls supported by the CapSense Gesture
Pad are different from the ones supported over the audio control endpoint described earlier along
with the audio streaming endpoints. The gestures supported in this example and the respective
media control settings are listed in