Audio on the Edi-Sound

Edi-Sound R02

Overview

There are two fundamental ways the Intel Edison handles audio:

  • Edison connects to a USB Audio device
  • Edison utilises it’s I2S bus stream audio to/from compatible devices

USB Audio

The general flow of audio over USB on the Edi-Sound R02 is as follows:

Intel Edison sends audio (USB format) to USB i2s Audio Bridge (CP2114), which converts USB audio to i2s audio format and sends to Audio Codec (UDA1380). (Audio Codec performs required A/D conversions for peripheral audio I/O).

Audio Codec – UDA1380

Before any audio can be piped in/out from the Edison, the UDA1380 codec must first be configured. Configuration of the UDA1380 internal registers is performed via an I2C connection directly between the Edison and the UDA1380.

The ‘uda1380.h’ header contains the appropriate register addresses, #defines etc.

The following code will initialise an I2C context for the UDA1380 using MRAA:

mraa_init();

/* Initialise i2c on Intel Edison */
fprintf(stdout, "Initialising I2C on Intel Edison...\n");

mraa_i2c_context uda_i2c;
uda_i2c = mraa_i2c_init(I2C_BUS1);
mraa_i2c_frequency(uda_i2c, MRAA_I2C_STD);
mraa_set_priority(15000);

mraa_result_t uda_i2c_connect;
uda_i2c_connect = mraa_i2c_address(uda_i2c, UDA1380_I2C_ADDR);

//Abort if i2c connection failed
if (uda_i2c_connect != MRAA_SUCCESS) {
        fprintf(stderr, "UDA1380 and Edison I2C connection failed\n");
        return EXIT_FAILURE;
}

The function (located in ‘uda1380.h’) can then be used to set the register values for the UDA1380:

uda1380_init(uda_i2c, SETTING);

Where SETTING = OUTPUT_ONLY or INPUT_AND_OUTPUT.

When using the setting INPUT_AND_OUTPUT, after the code is run the onboard electret mic will be actively audible at the output (pass-through the UDA1380). Gently rubbing the electret mic with your finger is a good test to see if the UDA1380 received the configuration settings correctly.

USB I2S Audio Bridge - CP2114

Verifying that the USB I2S Bridge is detected by the Intel Edison can be done by running either commands

lsusb           // Checks if the CP2114 enumerates as a USB module on the Edison
aplay -l        // Checks if the CP2114 is detected as a USB Audio device within ALSA

Provided the CP2114 is successfully connected to the Edison as a USB Audio device, it can be referenced via the card name = “Bridge”. For example, a simple command to verify audio works is:

This command pipes the [audio_file].wav data as USB data from the Intel Edison to the CP2114, and the CP2114 will then convert this data to standard I2S and output it on P7.

UDA1380 Registers - low level details

A clock signal must be supplied to the UDA1380 whilst configuring the Interpolator and Decimator registers. For this reason, SYSCLK should be selected as the ADC and DAC clock as it is not guaranteed a clock is always present at the WSI pin (which can render the Interpolator and Decimator registers unable to be configured).

Once these registers have been set, the ADC and DAC clock can be reconfigured to utilise the WSI clock (required if the sampling rate of the audio differs from the SYSCLK).

i2c specifications: UDA1380 is on Edison i2c Bus 1 General UDA1380 i2c address: 00110-A1-R/W’ A1 header (P8) left open/unjumpered: A1 = 0 UDA1380 Addr input for Edison: 0b00011000 = 0x18

Tables of the registers summary etc is found in ‘Edi-Sound Documentation.docx’ in the Edi-Sound dropbox folder - Winston 7/10/2015

I2S Audio

The current official Intel Edison Yocto Linux image supports digital audio streams on the I2S pins, however the output format is not standard I2s. Instead, the audio is streamed in the DSP/PCM format.

(For this reason, a digital audio link directly between the Edison and the UDA1380 is not possible, as the UDA1380 does not support DSP/PCM mode.)

The Edison streams out audio in the DSP/PCM format via the ‘dummyaudio’ card,

A simple command such as:

aplay -D hw:1,0 [audio_file].wav

Can be used to verify DSP/PCM stream being output on the Raspberry-Pi header.