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

shimabaraは、mbedからオーディオ・コーデックのハードウェアを操作するクラス・ライブラリです。このライブラリは雲仙オーディオ・フレームワークと共に使うことを想定して開発しましたが、独立して使うことも可能です。

使い方

shimabaraは BaseAudioCodec, ADAU1361, UMB_ADAU1361Aの三つのクラスを定義しています。いずれのクラスも名前空間simabaraに属しています。実際のアプリケーションで使用するのはshimabara::UMB_ADAU1361Aだけで、このクラスはアクアシグナルのUMB-ADAU1361-Aに対応しています。ヘッダーファイルは umb_adau1361a.hです。

shimabara::UMB_ADAU1361Aのコンストラクタは三つの引数を受け取ります。

  • Fs はサンプル周波数です。これはenum Fs_type型の引数で、やはり名前空間shimabaraに属しています。
  • controller はADAU1361Aが接続されているI2Cポートに対応するI2Cオブジェクトを与えます。shimabaraはこのポートを通してCODECと通信します。
  • Addrには、コーデックのI2Cアドレスを与えます。現時点ではこの引数は0x38固定です。

コンストラクタでオブジェクトを初期化したら、start()メソッドを呼んでください。これでshimabaraはコーデックと通信し、I2Sモードでの動作が始まります。

参考リンク

Revision:
2:fba0b8afebf0
Parent:
1:ea6d442bd68a
Child:
3:c0f834049ee2
diff -r ea6d442bd68a -r fba0b8afebf0 adau1361.h
--- a/adau1361.h	Sun May 08 09:52:42 2016 +0000
+++ b/adau1361.h	Thu May 12 22:13:12 2016 +0000
@@ -1,7 +1,6 @@
 /**
-* \brief header file for the unzen audio frame work 
-* \arthur SeiichiHorie
-* \date 8/May/2016
+* \file adau1361.h
+* \brief header file for the ADAU1361 codec controler abstract class
 */
 
 #ifndef _Adau1361_h_
@@ -13,7 +12,7 @@
 /**
  \brief audio framework name space. 
 */
-namespace audiocodec 
+namespace shimabara 
 {
 
 
@@ -21,8 +20,9 @@
 /**
 * \brief ADAU1361 audio codec controller.
 * \details
-*   This class sends a set of command to control an ADAU1361 codec.
-*   This class is template for all ADAU1361 based codec board.
+*   This class sends a set of command to control an ADAU1361 codec. This class is template for all ADAU1361 based codec board.
+*  
+*   To implement the real board, you must override the configure_pll() method and configure_board method.
 */
     class Adau1361:public BaseAudioCodec
     {
@@ -35,40 +35,96 @@
             * \details
             *   initialize the internal variables.
             */
-        Adau1361( I2C * controler, Fs_Type Fs, unsigned int Addr ):
-            BaseAudioCodec( controler, Fs, Addr ){};
+        Adau1361( Fs_Type Fs, I2C * controler, unsigned int Addr  );
+
+            /**
+            * \brief Set up the ADAU1361 codec,  and then, start the codec. 
+            * \details
+            *   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.
+            */
         virtual void start(void);
+
             /**
             * \brief Set the line input gain and enable the relevant mixer.
             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param mute set true to mute
+            * \details
+            *   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.
             */
         virtual void set_line_input_gain(float left_gain, float right_gain, bool mute=false);
+
             /**
             * \brief Set the aux input gain and enable the relevant mixer.
             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param mute set true to mute
+            * \details
+            *   Other input lines are not killed. To kill it, user have to mute them explicitly.
             */
         virtual void set_aux_input_gain(float left_gain, float right_gain, bool mute=false);
+
             /**
             * \brief Set the line output gain and enable the relevant mixer.
             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param mute set true to mute
+            * \details
+            *   Other output lines are not killed. To kill it, user have to mute them explicitly.
+            *
             */
         virtual void set_line_output_gain(float left_gain, float right_gain, bool mute=false);
+
             /**
             * \brief Set the headphone output gain and enable the relevant mixer.
             * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
             * \param mute set true to mute
+            * \details
+            *   Other out line like line in are not killed. To kill it, user have to mute them explicitly.
             */
         virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false);
         
     protected:
+            I2C *i2c;
+            unsigned int addr;
+
+            /**
+            * \brief configuration of PLL for the desired core clock
+            * \details
+            * A pure virutal function. 
+            *
+            * This member function must be overriden by inherited class. Before the call of this function,
+            * R0 is initialized as 0 and then, set the clock source is PLL.
+            *
+            * This member funciton must configure the PLL correctly, confirm the PLL lock status. And then
+            * set the SRC. 
+            *
+            * Note that the setting SRC before PLL lock may fail. 
+            */
         virtual void configure_pll(void)=0;
+        
+            /**
+            * \brief configuration of the ADAU1361 for the codec board
+            * \details
+            * A pure virutal function. 
+            *
+            * This member function must be overriden by inherited class. Before the calling of this function,
+            * the codec is initialized as default state except PLL. PLL is set by configure_pll() method 
+            * before calling this function.
+            *
+            * This member funciton must configure the ADAU1361 registered based on the board circuit. For example,
+            * internal signal pass or bias. 
+            *
+            */
         virtual void configure_board(void)=0;
             /**
             *  Service function for the ADAu1361 board implementer.