EZ-USB FX3 Technical Reference Manual, Document Number: 001-76074 Rev. *F 190
Low Performance Peripherals (LPP)
8.8.4.11 Initialize I2S Block
The CyU3PI2sInit API initializes the FX3 I2S block. The I2S block is initialized to operate at the default sampling rate of 8 kHz.
The CyU3PI2sInit function definition follows.
CyU3PI2sInit (void)
{
CyU3PMutexCreate (&glI2sLock, CYU3P_NO_INHERIT);
/* Set the clock frequency. This should precede the I2S power up. Setting it to stereo
fixed mode. */
status = CyU3PI2sSetClock (CY_U3P_I2S_DEFAULT_SAMPLE_RATE * 64);
/* Identify if the LPP block has been initialized. */
status = CyU3PLppInit (CY_U3P_LPP_I2S,CyU3PI2sInt_ThreadHandler);
/* Power on the I2S module */
I2S->lpp_i2s_power &= ~(1 << 31);
CyU3PBusyWait (10);
I2S->lpp_i2s_power |= 1 << 31;
while (!(I2S->lpp_i2s_power & CY_U3P_LPP_I2S_ACTIVE));
/* Mark the module active. */
glIsI2sActive = CyTrue;
}
8.8.4.12 Configure I2S Interface
The CyU3PI2sSetConfig API configures the FX3 I2S block. Following is the code for setting the I2S interface sampling
frequency of 44.1 kHz. A sample word is configured to 16 bits, and DMA transfers are enabled.
/* Configure the I2S interface. */
CyU3PMemSet ((uint8_t *)&i2sCfg, 0, sizeof (i2sCfg));
i2sCfg.isMono = CyFalse;
i2sCfg.isLsbFirst = CyFalse;
i2sCfg.isDma = CyTrue;
i2sCfg.padMode = CY_U3P_I2S_PAD_MODE_NORMAL;
i2sCfg.sampleRate = CY_U3P_I2S_SAMPLE_RATE_44_1KHz;
i2sCfg.sampleWidth = CY_U3P_I2S_WIDTH_16_BIT;
status = CyU3PI2sSetConfig (&i2sCfg, NULL);
8.8.4.13 Transfer Data from USB to I2S Interface Using DMA Transfers
The FX3 firmware source code to transfer the data from EP1 OUT to the left channel and data received on EP2 OUT to the
right channel of an I2S amplifier/speaker follows. The DMA buffer size is defined based on the USB speed: 64 for Full Speed,
512 for High Speed, and 1024 for SuperSpeed. Auto DMA channels are created between two sockets of the USB and the left
and right I2S sockets.
/* Identify the usb speed. Once that is identified, create a DMA channel and start the
transfer on this. Based on the Bus Speed configure the endpoint packet size */
switch (usbSpeed)
{
case CY_U3P_FULL_SPEED:
size = 64;
break;
case CY_U3P_HIGH_SPEED:
size = 512;