First Publish. Works fine.

Dependents:   unzen_sample_lpcxpresso_4337_callbacks

Revision:
2:6613e62da521
Parent:
1:9710fb328a08
Child:
3:707608830793
--- a/unzen.h	Tue Apr 12 05:51:45 2016 +0000
+++ b/unzen.h	Tue May 03 01:10:32 2016 +0000
@@ -76,10 +76,11 @@
                 \li length   length of above buffers.
                 
                 The call back is called for each time interrupt comes n times. Where n is the value which is specified by \ref set_block_size() 
-                function. This n is also passed to call back as above length parameter.
+                function. This n is also passed to call back as above length parameter. By default, n is 1.
                 
                 Note that the call back is called at interrupt context. Not the thread level context.
-                That mean, it is better to avoid to call mbed API except the mbed-RTOS API for interrupt handler. 
+                That mean, it is better to avoid to call mbed API except the mbed-RTOS API for interrupt handler.
+                 
             */
         void set_process_callback( void (* cb ) (float[], float[], float[], float[], unsigned int));
         
@@ -167,14 +168,17 @@
         
         void (* process_callback )( float left_in[], float right_in[], float left_out[], float right_out[], unsigned int length );
         
-            // Size of the blocks ( interval of interrupt to call process_callback )
+            // Size of the blocks ( interval of interrupt to call process_callback. 1 means every interrupt. 2 means every 2 interrupt )
         int block_size;
         
-            // Index for indentifying the buffer. 0 or 1. 
-        int buffer_index, process_index;
+            // Index for indentifying the buffer for interrupt. 0 or 1. 
+        int buffer_index;
         
-            // Index of the position data in the buffer. 
-        int tx_sample_index, rx_sample_index;
+            // Index for indentifying the buffer for processing. 0 or 1. 
+        int process_index;
+        
+            // next transfer position in buffer
+        int sample_index;
         
             // buffer for interrupt handler.
             // data format is LRLR... 
@@ -194,13 +198,59 @@
         static void process_irq_handler();        
     };
 
+        // Sampling Frequency of the umb_adau1361
+    enum Fs_Type 
+    {
+        Fs_441, Fs_48, Fs_96
+    } ;
+
+        // mbed I2C class needs the address as "left justified" value. Then, the ADAU1361's address 0x38 is 
+        // shifted right by 1 bit
+    enum Addr_Type
+    {
+        addr_h70 = 0x70, 
+        addr_h71,
+        addr_h72, 
+        addr_h73 
+    } ;
+
     class umb_adau1361
     {
     public:
-        umb_adau1361( I2C * );
+            /**
+            * \brief constructor.
+            * \param controler Pass the I2C controler object.
+            * \param Fs Sampling frequency.
+            * \param Addr I2C device address. 
+            * \details
+            *   initialize the internal variables.
+            */
+        umb_adau1361( I2C * controler, Fs_Type Fs= unzen::Fs_48, Addr_Type Addr = unzen::addr_h70 );
+        
+            /**
+            * \brief Actual initializer. 
+            * \details
+            *   Initialize the ADUC1603 as reset state, and then, configure for the UMB-ADAU1361.
+            *   http://dsps.shop-pro.jp/?pid=82798273 
+            *   and configure for given parameter. 
+            *
+            *   Finally, set the input gain to 0dB.
+            */
         void start(void);
+        
+            /**
+            * \brief Set the input gain and enable the relevant mixer.
+            * \param left_gain
+            * \param right_gain
+            * \param mute
+            */
+        void set_line_input_gain(float left_gain, float right_gain, bool mute=false);
+        void set_line_output_gain(float left_gain, float right_gain, bool mute=false);
+        void set_hp_output_gain(float left_gain, float right_gain, bool mute=false);
     private:
         I2C *i2c;
+        Addr_Type addr;
+        Fs_Type fs;
     };
 
 }