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モードでの動作が始まります。
参考リンク
- 『雲仙』 オーディオ・フレームワーク
- skeleton_unzen_nucleo_f746 Nucleo F746ZGおよびUI基板を使う場合のスケルトンプログラム。F746を使う方はここから読み始めると良いでしょう。
adau1361.h@1:ea6d442bd68a, 2016-05-08 (annotated)
- Committer:
- shorie
- Date:
- Sun May 08 09:52:42 2016 +0000
- Revision:
- 1:ea6d442bd68a
- Child:
- 2:fba0b8afebf0
Refactored naming conventions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shorie | 1:ea6d442bd68a | 1 | /** |
shorie | 1:ea6d442bd68a | 2 | * \brief header file for the unzen audio frame work |
shorie | 1:ea6d442bd68a | 3 | * \arthur SeiichiHorie |
shorie | 1:ea6d442bd68a | 4 | * \date 8/May/2016 |
shorie | 1:ea6d442bd68a | 5 | */ |
shorie | 1:ea6d442bd68a | 6 | |
shorie | 1:ea6d442bd68a | 7 | #ifndef _Adau1361_h_ |
shorie | 1:ea6d442bd68a | 8 | #define _Adau1361_h_ |
shorie | 1:ea6d442bd68a | 9 | |
shorie | 1:ea6d442bd68a | 10 | #include "baseaudiocodec.h" |
shorie | 1:ea6d442bd68a | 11 | #include "mbed.h" |
shorie | 1:ea6d442bd68a | 12 | |
shorie | 1:ea6d442bd68a | 13 | /** |
shorie | 1:ea6d442bd68a | 14 | \brief audio framework name space. |
shorie | 1:ea6d442bd68a | 15 | */ |
shorie | 1:ea6d442bd68a | 16 | namespace audiocodec |
shorie | 1:ea6d442bd68a | 17 | { |
shorie | 1:ea6d442bd68a | 18 | |
shorie | 1:ea6d442bd68a | 19 | |
shorie | 1:ea6d442bd68a | 20 | |
shorie | 1:ea6d442bd68a | 21 | /** |
shorie | 1:ea6d442bd68a | 22 | * \brief ADAU1361 audio codec controller. |
shorie | 1:ea6d442bd68a | 23 | * \details |
shorie | 1:ea6d442bd68a | 24 | * This class sends a set of command to control an ADAU1361 codec. |
shorie | 1:ea6d442bd68a | 25 | * This class is template for all ADAU1361 based codec board. |
shorie | 1:ea6d442bd68a | 26 | */ |
shorie | 1:ea6d442bd68a | 27 | class Adau1361:public BaseAudioCodec |
shorie | 1:ea6d442bd68a | 28 | { |
shorie | 1:ea6d442bd68a | 29 | public: |
shorie | 1:ea6d442bd68a | 30 | /** |
shorie | 1:ea6d442bd68a | 31 | * \brief constructor. |
shorie | 1:ea6d442bd68a | 32 | * \param controler Pass the I2C controler object. |
shorie | 1:ea6d442bd68a | 33 | * \param Fs Sampling frequency. |
shorie | 1:ea6d442bd68a | 34 | * \param Addr I2C device address. value range is from 0 to 127 |
shorie | 1:ea6d442bd68a | 35 | * \details |
shorie | 1:ea6d442bd68a | 36 | * initialize the internal variables. |
shorie | 1:ea6d442bd68a | 37 | */ |
shorie | 1:ea6d442bd68a | 38 | Adau1361( I2C * controler, Fs_Type Fs, unsigned int Addr ): |
shorie | 1:ea6d442bd68a | 39 | BaseAudioCodec( controler, Fs, Addr ){}; |
shorie | 1:ea6d442bd68a | 40 | virtual void start(void); |
shorie | 1:ea6d442bd68a | 41 | /** |
shorie | 1:ea6d442bd68a | 42 | * \brief Set the line input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 43 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 44 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 45 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 46 | */ |
shorie | 1:ea6d442bd68a | 47 | virtual void set_line_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 48 | /** |
shorie | 1:ea6d442bd68a | 49 | * \brief Set the aux input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 50 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 51 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 52 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 53 | */ |
shorie | 1:ea6d442bd68a | 54 | virtual void set_aux_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 55 | /** |
shorie | 1:ea6d442bd68a | 56 | * \brief Set the line output gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 57 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 58 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 59 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 60 | */ |
shorie | 1:ea6d442bd68a | 61 | virtual void set_line_output_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 62 | /** |
shorie | 1:ea6d442bd68a | 63 | * \brief Set the headphone output gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 64 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 65 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 66 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 67 | */ |
shorie | 1:ea6d442bd68a | 68 | virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 69 | |
shorie | 1:ea6d442bd68a | 70 | protected: |
shorie | 1:ea6d442bd68a | 71 | virtual void configure_pll(void)=0; |
shorie | 1:ea6d442bd68a | 72 | virtual void configure_board(void)=0; |
shorie | 1:ea6d442bd68a | 73 | /** |
shorie | 1:ea6d442bd68a | 74 | * Service function for the ADAu1361 board implementer. |
shorie | 1:ea6d442bd68a | 75 | * |
shorie | 1:ea6d442bd68a | 76 | * \brief send one command to ADAU1361. |
shorie | 1:ea6d442bd68a | 77 | * \param command command data array. It have to have register addess of ADAU1361 in first two bytes. |
shorie | 1:ea6d442bd68a | 78 | * \param size number of bytes in the command, including the regsiter address. |
shorie | 1:ea6d442bd68a | 79 | * \details |
shorie | 1:ea6d442bd68a | 80 | * Send one complete command to ADAU3161 by I2C. |
shorie | 1:ea6d442bd68a | 81 | */ |
shorie | 1:ea6d442bd68a | 82 | virtual void send_command( const char command[], int size ); |
shorie | 1:ea6d442bd68a | 83 | /** |
shorie | 1:ea6d442bd68a | 84 | * \brief send one command to ADAU1361. |
shorie | 1:ea6d442bd68a | 85 | * \param table command table. All commands are stored in one row. Each row has only 1 byte data after reg address. |
shorie | 1:ea6d442bd68a | 86 | * \param rows number of the rows in the table. |
shorie | 1:ea6d442bd68a | 87 | * \details |
shorie | 1:ea6d442bd68a | 88 | * Service function for the ADAu1361 board implementer. |
shorie | 1:ea6d442bd68a | 89 | * |
shorie | 1:ea6d442bd68a | 90 | * Send a list of command to ADAU1361. All commands has 3 bytes length. That mean, after two byte register |
shorie | 1:ea6d442bd68a | 91 | * address, only 1 byte data payload is allowed. Commadns are sent by I2C |
shorie | 1:ea6d442bd68a | 92 | */ |
shorie | 1:ea6d442bd68a | 93 | virtual void send_command_table( const char table[][3], int rows); |
shorie | 1:ea6d442bd68a | 94 | |
shorie | 1:ea6d442bd68a | 95 | /** |
shorie | 1:ea6d442bd68a | 96 | * \brief wait until PLL locks. |
shorie | 1:ea6d442bd68a | 97 | * \details |
shorie | 1:ea6d442bd68a | 98 | * Service function for the ADAu1361 board implementer. |
shorie | 1:ea6d442bd68a | 99 | * |
shorie | 1:ea6d442bd68a | 100 | * Read the PLL status and repeat it until the PLL locks. |
shorie | 1:ea6d442bd68a | 101 | */ |
shorie | 1:ea6d442bd68a | 102 | virtual void wait_pll_lock(void); |
shorie | 1:ea6d442bd68a | 103 | }; |
shorie | 1:ea6d442bd68a | 104 | |
shorie | 1:ea6d442bd68a | 105 | } |
shorie | 1:ea6d442bd68a | 106 | |
shorie | 1:ea6d442bd68a | 107 | #endif |