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 umb_adau1361a.h Source File

umb_adau1361a.h

00001 /*
00002 * \brief header file for the UMB-ADAU1361A codec board controler
00003 * \arthur SeiichiHorie
00004 * \date 8/May/2016
00005 */
00006 
00007 #ifndef _UMB_ADAU1361A_H_
00008 #define _UMB_ADAU1361A_H_
00009 
00010 #include "adau1361.h"
00011 #include "mbed.h"
00012 /**
00013  \brief audio framework name space. 
00014 */
00015 namespace shimabara 
00016 {
00017 
00018 
00019 /**
00020 * \brief UMB-ADAU1361-A audio codec board controller.
00021 * \details
00022 *   This class send a set of command to control an UMB-ADAU1361-A codec board.
00023 *
00024 *   The hardware desription is here. http://dsps.shop-pro.jp/?pid=82798273
00025 
00026       
00027       example :
00028       \code
00029 #include "unzen.h"          // audio framework include file
00030 #include "umb_adau1361a.h"     // audio codec contoler include file
00031 #include "mbed.h"
00032 
00033 #define CODEC_I2C_ADDR 0x38
00034 
00035 DigitalOut myled1(LED1);
00036 
00037 
00038     // customer signal processing initialization call back.
00039 void init_callback(
00040             unsigned int block_size     // block size [sample]
00041             )
00042 {
00043         // place initialization code here
00044 }
00045 
00046 
00047     // customer signal processing call back.
00048 void process_callback(
00049             float rx_left_buffer[],     // array of the left input samples
00050             float rx_right_buffer[],    // array of the right input samples
00051             float tx_left_buffer[],     // place to write the left output samples
00052             float tx_right_buffer[],    // place to write the left output samples
00053             unsigned int block_size     // block size [sample]
00054             )
00055 {
00056         // Sample processing
00057     for ( int i=0; i<block_size; i++)   // for all sample
00058     {
00059         tx_left_buffer[i] = rx_left_buffer[i];      // copy from input to output
00060         tx_right_buffer[i] = rx_right_buffer[i];
00061         
00062     }
00063 }
00064 
00065 
00066 
00067 int main() 
00068 {    
00069         // I2C is essential to talk with ADAU1361
00070     I2C i2c(SDA, SCL);
00071 
00072         // create an audio codec contoler
00073     shimabara::UMB_ADAU1361A codec(shimabara::Fs_32, i2c, CODEC_I2C_ADDR ); 
00074 //    shimabara::UMB_ADAU1361A codec(shimabara::Fs_441, i2c, CODEC_I2C_ADDR ); 
00075 //    shimabara::UMB_ADAU1361A codec(shimabara::Fs_48, i2c, CODEC_I2C_ADDR ); 
00076 //    shimabara::UMB_ADAU1361A codec(shimabara::Fs_96, i2c, CODEC_I2C_ADDR ); 
00077 
00078        // create an audio framework by singlton pattern
00079     unzen::Framework audio;
00080  
00081          // Set I3C clock to 10kHz
00082     i2c.frequency( 10000 );
00083 
00084 
00085         // Configure the optional block size of signal processing. By default, it is 1[Sample] 
00086 //    audio.set_block_size(16);
00087 
00088     
00089         // Start the ADAU1361. Audio codec starts to generate the I2C signals 
00090     codec.start();
00091 
00092         // Start the audio framework on ARM processor.  
00093     audio.start( init_callback, process_callback);     // path the initializaiton and process call back to framework 
00094 
00095 
00096         // periodically changing gain for test
00097     while(1)     
00098     {
00099         for ( int i=-15; i<4; i++ )
00100         {
00101             codec.set_hp_output_gain( i, i );
00102             codec.set_line_output_gain( i, i );
00103             myled1 = 1;
00104             wait(0.2);
00105             myled1 = 0;
00106             wait(0.2);
00107         }
00108     }
00109 }
00110 
00111 
00112       \endcode
00113 */
00114     class UMB_ADAU1361A:public Adau1361
00115     {
00116     public:
00117             /**
00118             * \brief constructor.
00119             * \param controler Pass the I2C controler object.
00120             * \param Fs Sampling frequency.
00121             * \param Addr I2C device address. value range is from 0 to 127
00122             * \details
00123             *   initialize the internal variables.
00124             */
00125         UMB_ADAU1361A( Fs_Type Fs, I2C &controler, unsigned int Addr ):
00126             Adau1361( Fs, controler, Addr  ){};
00127     protected:
00128             /**
00129             * \brief configuration of the PLL for the desired Fs.
00130             * \details
00131             *   Configure the PLL based on the given Fs and hardware clock configuration. 
00132             *   Fs is stored in fs member variable already. Hadrware clock have to be given
00133             *   from the circuit designer. For the UMB-ADAU1361-A, the clock is external 
00134             *   12MHz oscillator from the clock input. 
00135             */
00136         virtual void configure_pll(void);
00137             /**
00138             * \brief configuration of the the codec for UMB-ADAU1361-A
00139             * \details
00140             *   Configure Internal signal pass and parameters for UMB-ADAU1361.  
00141             *   The all pass-through signals are shut off. All cross channel signals are shut off. 
00142             *   Monoral output is disabled. 
00143             */
00144         virtual void configure_board(void);
00145     };
00146 
00147 }
00148 
00149 #endif