First publishment of Shimabara Audio Codec Controller library. Including code for ADAU1361 and UMB-ADAU1361A. Working pretty fine. Checked with LPCXpresso 4337 and Unzen_lpc4337

Dependents:   unzen_sample_LPC4088_quickstart unzen_sample_lpcxpresso_4337_callbacks unzen_sample_nucleo_f746 unzen_delay_sample_nucleo_f746 ... more

Embed: (wiki syntax)

« Back to documentation index

UMB_ADAU1361A Class Reference

UMB_ADAU1361A Class Reference

UMB-ADAU1361-A audio codec board controller. More...

#include <umb_adau1361a.h>

Inherits shimabara::Adau1361.

Public Member Functions

 UMB_ADAU1361A (Fs_Type Fs, I2C &controler, unsigned int Addr)
 constructor.
virtual void start (void)
 Set up the ADAU1361 codec, and then, start the codec.
virtual void set_line_input_gain (float left_gain, float right_gain, bool mute=false)
 Set the line input gain and enable the relevant mixer.
virtual void set_aux_input_gain (float left_gain, float right_gain, bool mute=false)
 Set the aux input gain and enable the relevant mixer.
virtual void set_line_output_gain (float left_gain, float right_gain, bool mute=false)
 Set the line output gain and enable the relevant mixer.
virtual void set_hp_output_gain (float left_gain, float right_gain, bool mute=false)
 Set the headphone output gain and enable the relevant mixer.
virtual void set_mic_input_gain (float left_gain, float right_gain, bool mute=false)
 Set the mic input gain and enable the relevant mixer.

Protected Member Functions

virtual void configure_pll (void)
 configuration of the PLL for the desired Fs.
virtual void configure_board (void)
 configuration of the the codec for UMB-ADAU1361-A
virtual void send_command (const char command[], int size)
 Service function for the ADAu1361 board implementer.
virtual void send_command_table (const char table[][3], int rows)
 send one command to ADAU1361.
virtual void wait_pll_lock (void)
 wait until PLL locks.

Detailed Description

UMB-ADAU1361-A audio codec board controller.

This class send a set of command to control an UMB-ADAU1361-A codec board.

The hardware desription is here. http://dsps.shop-pro.jp/?pid=82798273

example :

#include "unzen.h"          // audio framework include file
#include "umb_adau1361a.h"     // audio codec contoler include file
#include "mbed.h"

#define CODEC_I2C_ADDR 0x38

DigitalOut myled1(LED1);


    // customer signal processing initialization call back.
void init_callback(
            unsigned int block_size     // block size [sample]
            )
{
        // place initialization code here
}


    // customer signal processing call back.
void process_callback(
            float rx_left_buffer[],     // array of the left input samples
            float rx_right_buffer[],    // array of the right input samples
            float tx_left_buffer[],     // place to write the left output samples
            float tx_right_buffer[],    // place to write the left output samples
            unsigned int block_size     // block size [sample]
            )
{
        // Sample processing
    for ( int i=0; i<block_size; i++)   // for all sample
    {
        tx_left_buffer[i] = rx_left_buffer[i];      // copy from input to output
        tx_right_buffer[i] = rx_right_buffer[i];
        
    }
}



int main() 
{    
        // I2C is essential to talk with ADAU1361
    I2C i2c(SDA, SCL);

        // create an audio codec contoler
    shimabara::UMB_ADAU1361A codec(shimabara::Fs_32, i2c, CODEC_I2C_ADDR ); 
//    shimabara::UMB_ADAU1361A codec(shimabara::Fs_441, i2c, CODEC_I2C_ADDR ); 
//    shimabara::UMB_ADAU1361A codec(shimabara::Fs_48, i2c, CODEC_I2C_ADDR ); 
//    shimabara::UMB_ADAU1361A codec(shimabara::Fs_96, i2c, CODEC_I2C_ADDR ); 

       // create an audio framework by singlton pattern
    unzen::Framework audio;
 
         // Set I3C clock to 10kHz
    i2c.frequency( 10000 );


        // Configure the optional block size of signal processing. By default, it is 1[Sample] 
//    audio.set_block_size(16);

    
        // Start the ADAU1361. Audio codec starts to generate the I2C signals 
    codec.start();

        // Start the audio framework on ARM processor.  
    audio.start( init_callback, process_callback);     // path the initializaiton and process call back to framework 


        // periodically changing gain for test
    while(1)     
    {
        for ( int i=-15; i<4; i++ )
        {
            codec.set_hp_output_gain( i, i );
            codec.set_line_output_gain( i, i );
            myled1 = 1;
            wait(0.2);
            myled1 = 0;
            wait(0.2);
        }
    }
}

Definition at line 114 of file umb_adau1361a.h.


Constructor & Destructor Documentation

UMB_ADAU1361A ( Fs_Type  Fs,
I2C &  controler,
unsigned int  Addr 
)

constructor.

Parameters:
controlerPass the I2C controler object.
FsSampling frequency.
AddrI2C device address. value range is from 0 to 127

initialize the internal variables.

Definition at line 125 of file umb_adau1361a.h.


Member Function Documentation

void configure_board ( void   ) [protected, virtual]

configuration of the the codec for UMB-ADAU1361-A

Configure Internal signal pass and parameters for UMB-ADAU1361. The all pass-through signals are shut off. All cross channel signals are shut off. Monoral output is disabled.

Implements Adau1361.

Definition at line 84 of file umb_adau1361a.cpp.

void configure_pll ( void   ) [protected, virtual]

configuration of the PLL for the desired Fs.

Configure the PLL based on the given Fs and hardware clock configuration. Fs is stored in fs member variable already. Hadrware clock have to be given from the circuit designer. For the UMB-ADAU1361-A, the clock is external 12MHz oscillator from the clock input.

Implements Adau1361.

Definition at line 54 of file umb_adau1361a.cpp.

void send_command ( const char  command[],
int  size 
) [protected, virtual, inherited]

Service function for the ADAu1361 board implementer.

send one command to ADAU1361.

Parameters:
commandcommand data array. It have to have register addess of ADAU1361 in first two bytes.
sizenumber of bytes in the command, including the regsiter address.

Send one complete command to ADAU3161 by I2C.

Definition at line 83 of file adau1361.cpp.

void send_command_table ( const char  table[][3],
int  rows 
) [protected, virtual, inherited]

send one command to ADAU1361.

Parameters:
tablecommand table. All commands are stored in one row. Each row has only 1 byte data after reg address.
rowsnumber of the rows in the table.

Service function for the ADAu1361 board implementer.

Send a list of command to ADAU1361. All commands has 3 bytes length. That mean, after two byte register address, only 1 byte data payload is allowed. Commadns are sent by I2C

Definition at line 90 of file adau1361.cpp.

void set_aux_input_gain ( float  left_gain,
float  right_gain,
bool  mute = false 
) [virtual, inherited]

Set the aux input gain and enable the relevant mixer.

Parameters:
left_gainGain by dB. The gain value outside of the acceptable range will be saturated.
right_gainGain by dB. The gain value outside of the acceptable range will be saturated.
muteset true to mute

Other input lines are not killed. To kill it, user have to mute them explicitly.

Reimplemented from BaseAudioCodec.

Definition at line 171 of file adau1361.cpp.

void set_hp_output_gain ( float  left_gain,
float  right_gain,
bool  mute = false 
) [virtual, inherited]

Set the headphone output gain and enable the relevant mixer.

Parameters:
left_gainGain by dB. The gain value outside of the acceptable range will be saturated.
right_gainGain by dB. The gain value outside of the acceptable range will be saturated.
muteset true to mute

Other out line like line in are not killed. To kill it, user have to mute them explicitly.

Reimplemented from BaseAudioCodec.

Definition at line 239 of file adau1361.cpp.

void set_line_input_gain ( float  left_gain,
float  right_gain,
bool  mute = false 
) [virtual, inherited]

Set the line input gain and enable the relevant mixer.

Parameters:
left_gainGain by dB. The gain value outside of the acceptable range will be saturated.
right_gainGain by dB. The gain value outside of the acceptable range will be saturated.
muteset true to mute

As same as start(), this gain control function uses the single-end negative input only. Other input signal of the line in like positive signal or diff signal are killed.

Other input line like aux are not killed. To kill it, user have to mute them explicitly.

Reimplemented from BaseAudioCodec.

Definition at line 135 of file adau1361.cpp.

void set_line_output_gain ( float  left_gain,
float  right_gain,
bool  mute = false 
) [virtual, inherited]

Set the line output gain and enable the relevant mixer.

Parameters:
left_gainGain by dB. The gain value outside of the acceptable range will be saturated.
right_gainGain by dB. The gain value outside of the acceptable range will be saturated.
muteset true to mute

Other output lines are not killed. To kill it, user have to mute them explicitly.

Reimplemented from BaseAudioCodec.

Definition at line 209 of file adau1361.cpp.

void set_mic_input_gain ( float  left_gain,
float  right_gain,
bool  mute = false 
) [virtual, inherited]

Set the mic input gain and enable the relevant mixer.

Parameters:
left_gainGain by dB. The gain value outside of the acceptable range will be saturated.
right_gainGain by dB. The gain value outside of the acceptable range will be saturated.
muteset true to mute

Definition at line 20 of file baseaudiocodec.cpp.

void start ( void   ) [virtual, inherited]

Set up the ADAU1361 codec, and then, start the codec.

This method starts the ADAU1361 AD/DA conversion and I2S communication.

The line in is configured to use the Single-End negative input. This is funny but ADAU1361 datasheet specifies to do it. The positive in and diff in are killed. All biases are set as "normal".

The CODEC is configured as master mode. That mean, bclk and WS are given from ADAU1361 to the micro processor.

Implements BaseAudioCodec.

Definition at line 111 of file adau1361.cpp.

void wait_pll_lock ( void   ) [protected, virtual, inherited]

wait until PLL locks.

Service function for the ADAu1361 board implementer.

Read the PLL status and repeat it until the PLL locks.

Definition at line 100 of file adau1361.cpp.