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:
1:ea6d442bd68a
Child:
2:fba0b8afebf0
diff -r dc22d60383f0 -r ea6d442bd68a adau1361.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/adau1361.h	Sun May 08 09:52:42 2016 +0000
@@ -0,0 +1,107 @@
+/**
+* \brief header file for the unzen audio frame work 
+* \arthur SeiichiHorie
+* \date 8/May/2016
+*/
+
+#ifndef _Adau1361_h_
+#define _Adau1361_h_
+
+#include "baseaudiocodec.h"
+#include "mbed.h"
+
+/**
+ \brief audio framework name space. 
+*/
+namespace audiocodec 
+{
+
+
+
+/**
+* \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.
+*/
+    class Adau1361:public BaseAudioCodec
+    {
+    public:
+            /**
+            * \brief constructor.
+            * \param controler Pass the I2C controler object.
+            * \param Fs Sampling frequency.
+            * \param Addr I2C device address. value range is from 0 to 127
+            * \details
+            *   initialize the internal variables.
+            */
+        Adau1361( I2C * controler, Fs_Type Fs, unsigned int Addr ):
+            BaseAudioCodec( controler, Fs, Addr ){};
+        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
+            */
+        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
+            */
+        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
+            */
+        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
+            */
+        virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false);
+        
+    protected:
+        virtual void configure_pll(void)=0;
+        virtual void configure_board(void)=0;
+            /**
+            *  Service function for the ADAu1361 board implementer.
+            *
+            * \brief send one command to ADAU1361.
+            * \param command command data array. It have to have register addess of ADAU1361 in first two bytes. 
+            * \param size number of bytes in the command, including the regsiter address. 
+            * \details
+            *   Send one complete command to ADAU3161 by I2C.
+            */
+        virtual void send_command( const char command[], int size );
+            /**
+            * \brief send one command to ADAU1361.
+            * \param table command table. All commands are stored in one row. Each row has only 1 byte data after reg address.
+            * \param rows number of the rows in the table.
+            * \details
+            *   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
+            */
+        virtual void send_command_table( const char table[][3], int rows);
+        
+            /**
+            * \brief wait until PLL locks.
+            * \details
+            *   Service function for the ADAu1361 board implementer.
+            *
+            *   Read the PLL status and repeat it until the PLL locks. 
+            */
+        virtual void wait_pll_lock(void);
+    };
+
+}
+
+#endif
\ No newline at end of file