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

Show/hide line numbers adau1361.h Source File

adau1361.h

00001 /*
00002 * \file adau1361.h
00003 * \brief header file for the ADAU1361 codec controler abstract class
00004 */
00005 
00006 #ifndef _Adau1361_h_
00007 #define _Adau1361_h_
00008 
00009 #include "baseaudiocodec.h"
00010 #include "mbed.h"
00011 
00012 /**
00013  \brief audio framework name space. 
00014 */
00015 namespace shimabara 
00016 {
00017 
00018 
00019 
00020 /**
00021 * \brief ADAU1361 audio codec controller.
00022 * \details
00023 *   This class sends a set of commands to control an ADAU1361 codec. This class is template for all ADAU1361 based codec board.
00024 *  
00025 *   To implement the real board, you must override the configure_pll() method and configure_board method.
00026 */
00027     class Adau1361:public BaseAudioCodec
00028     {
00029     public:
00030             /**
00031             * \brief constructor.
00032             * \param controler Pass the I2C controler object.
00033             * \param Fs Sampling frequency.
00034             * \param Addr I2C device address. value range is from 0 to 127
00035             * \details
00036             *   initialize the internal variables.
00037             */
00038         Adau1361( Fs_Type Fs, I2C & controler, unsigned int Addr  );
00039 
00040             /**
00041             * \brief Set up the ADAU1361 codec,  and then, start the codec. 
00042             * \details
00043             *   This method starts the ADAU1361 AD/DA conversion and I2S communication. 
00044             *
00045             *   The line in is configured to use the Single-End negative input. This is funny but ADAU1361 datasheet
00046             *   specifies to do it. The positive in and diff in are killed. All biases are set as "normal". 
00047             *   
00048             *   The CODEC is configured as master mode. That mean, bclk and WS are given from ADAU1361 to the micro processor.
00049             */
00050         virtual void start(void);
00051 
00052             /**
00053             * \brief Set the line input gain and enable the relevant mixer.
00054             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00055             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00056             * \param mute set true to mute
00057             * \details
00058             *   As same as start(), this gain control function uses the single-end negative input only. Other
00059             *   input signal of the line in like positive signal or diff signal are killed.
00060             *
00061             *   Other input line like aux are not killed. To kill it, user have to mute them explicitly.
00062             */
00063         virtual void set_line_input_gain(float left_gain, float right_gain, bool mute=false);
00064 
00065             /**
00066             * \brief Set the aux input gain and enable the relevant mixer.
00067             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00068             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00069             * \param mute set true to mute
00070             * \details
00071             *   Other input lines are not killed. To kill it, user have to mute them explicitly.
00072             */
00073         virtual void set_aux_input_gain(float left_gain, float right_gain, bool mute=false);
00074 
00075             /**
00076             * \brief Set the line output gain and enable the relevant mixer.
00077             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00078             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00079             * \param mute set true to mute
00080             * \details
00081             *   Other output lines are not killed. To kill it, user have to mute them explicitly.
00082             *
00083             */
00084         virtual void set_line_output_gain(float left_gain, float right_gain, bool mute=false);
00085 
00086             /**
00087             * \brief Set the headphone output gain and enable the relevant mixer.
00088             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00089             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
00090             * \param mute set true to mute
00091             * \details
00092             *   Other out line like line in are not killed. To kill it, user have to mute them explicitly.
00093             */
00094         virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false);
00095         
00096     protected:
00097             I2C *i2c;
00098             unsigned int addr;
00099 
00100             /**
00101             * \brief configuration of PLL for the desired core clock
00102             * \details
00103             * A pure virutal function. 
00104             *
00105             * This member function must be overriden by inherited class. Before the call of this function,
00106             * R0 is initialized as 0 and then, set the clock source is PLL.
00107             *
00108             * This member funciton must configure the PLL correctly, confirm the PLL lock status. And then
00109             * set the SRC. 
00110             *
00111             * Note that the setting SRC before PLL lock may fail. 
00112             */
00113         virtual void configure_pll(void)=0;
00114         
00115             /**
00116             * \brief configuration of the ADAU1361 for the codec board
00117             * \details
00118             * A pure virutal function. 
00119             *
00120             * This member function must be overriden by inherited class. Before the calling of this function,
00121             * the codec is initialized as default state except PLL. PLL is set by configure_pll() method 
00122             * before calling this function.
00123             *
00124             * This member funciton must configure the ADAU1361 registered based on the board circuit. For example,
00125             * internal signal pass or bias. 
00126             *
00127             */
00128         virtual void configure_board(void)=0;
00129             /**
00130             *  Service function for the ADAu1361 board implementer.
00131             *
00132             * \brief send one command to ADAU1361.
00133             * \param command command data array. It have to have register addess of ADAU1361 in first two bytes. 
00134             * \param size number of bytes in the command, including the regsiter address. 
00135             * \details
00136             *   Send one complete command to ADAU3161 by I2C.
00137             */
00138         virtual void send_command( const char command[], int size );
00139             /**
00140             * \brief send one command to ADAU1361.
00141             * \param table command table. All commands are stored in one row. Each row has only 1 byte data after reg address.
00142             * \param rows number of the rows in the table.
00143             * \details
00144             *   Service function for the ADAu1361 board implementer.
00145             *
00146             *   Send a list of command to ADAU1361. All commands has 3 bytes length. That mean, after two byte register
00147             *   address, only 1 byte data payload is allowed. Commadns are sent by I2C
00148             */
00149         virtual void send_command_table( const char table[][3], int rows);
00150         
00151             /**
00152             * \brief wait until PLL locks.
00153             * \details
00154             *   Service function for the ADAu1361 board implementer.
00155             *
00156             *   Read the PLL status and repeat it until the PLL locks. 
00157             */
00158         virtual void wait_pll_lock(void);
00159     };
00160 
00161 }
00162 
00163 #endif