00001 /** \file afw.h 00002 * \brief フレームワーク宣言ファイル 00003 * \author アナログ・デバイセズ株式会社 00004 * \version 1.0 00005 * \date 2006.Sep.8 00006 * 00007 * 各種パラメータの宣言ファイル。パラメータのうち、afw::SAMPLE_PER_INTRはユーザーが変更して 00008 * もよい。メインルーチンからはafw::initとafw::startAudioを呼び出してオーディオ処理を開始する。 00009 */ 00010 #ifndef __Talkthrough_DEFINED 00011 #define __Talkthrough_DEFINED 00012 00013 //--------------------------------------------------------------------------// 00014 // Header files // 00015 //--------------------------------------------------------------------------// 00016 #include <sys\exception.h> 00017 #include <cdefBF533.h> 00018 #include <ccblkfn.h> 00019 #include <sysreg.h> 00020 /** オーディオ・フレームワーク 00021 * 00022 * ADSP-BF537 EZ-KIT Lite上で動作するオーディオフレームワーク関連の関数および変数を含む名前空間。 00023 * プログラマは以下の関数を呼んでオーディオ処理を開始する。 00024 * - afw::init 00025 * - afw::startAudio 00026 */ 00027 namespace afw 00028 { 00029 //--------------------------------------------------------------------------// 00030 // Symbolic constants // 00031 //--------------------------------------------------------------------------// 00032 /** サンプルあたりのスロット数。 00033 * 00034 * AD1836Aのマルチチャンネル・モードでは8。ユーザーが変えてはならない。 00035 */ 00036 const int SLOT_PER_SAMPLE = 8; 00037 /** 割り込み1回あたりに転送する、サンプル数。 00038 * 00039 * ユーザーが変えてよい。 00040 */ 00041 const int SAMPLES_PER_INTR = 8; 00042 /** 過去何回分の割り込みのデータを用意するか。 00043 * 00044 * トリプルバッファなので3 00045 */ 00046 const int INTR_PER_BUFFER = 3; 00047 00048 /// addresse for Port B in Flash A Direction Register 00049 //volatile unsigned char * const pFlashA_PortA_Dir = (unsigned char * )0x20270006; 00050 #define pFlashA_PortA_Dir (volatile unsigned char * )0x20270006 00051 00052 /// addresse for Port B in Flash A Data Register 00053 //volatile unsigned char * const pFlashA_PortA_Data = (unsigned char * )0x20270004; 00054 #define pFlashA_PortA_Data (volatile unsigned char * )0x20270004 00055 00056 00057 // names for codec registers, used for iCodec1836TxRegs[] 00058 const int DAC_CONTROL_1 = 0x0000; 00059 const int DAC_CONTROL_2 = 0x1000; 00060 const int DAC_VOLUME_0 = 0x2000; 00061 const int DAC_VOLUME_1 = 0x3000; 00062 const int DAC_VOLUME_2 = 0x4000; 00063 const int DAC_VOLUME_3 = 0x5000; 00064 const int DAC_VOLUME_4 = 0x6000; 00065 const int DAC_VOLUME_5 = 0x7000; 00066 const int ADC_0_PEAK_LEVEL = 0x8000; 00067 const int ADC_1_PEAK_LEVEL = 0x9000; 00068 const int ADC_2_PEAK_LEVEL = 0xA000; 00069 const int ADC_3_PEAK_LEVEL = 0xB000; 00070 const int ADC_CONTROL_1 = 0xC000; 00071 const int ADC_CONTROL_2 = 0xD000; 00072 const int ADC_CONTROL_3 = 0xE000; 00073 00074 // names for slots in ad1836 audio frame 00075 const int INTERNAL_ADC_L0 = 0; 00076 const int INTERNAL_ADC_L1 = 1; 00077 const int INTERNAL_ADC_R0 = 4; 00078 const int INTERNAL_ADC_R1 = 5; 00079 const int INTERNAL_DAC_L0 = 0; 00080 const int INTERNAL_DAC_L1 = 1; 00081 const int INTERNAL_DAC_L2 = 2; 00082 const int INTERNAL_DAC_R0 = 4; 00083 const int INTERNAL_DAC_R1 = 5; 00084 const int INTERNAL_DAC_R2 = 6; 00085 00086 /// size of array iCodec1836TxRegs and iCodec1836RxRegs 00087 const int CODEC_1836_REGS_LENGTH = 11; 00088 00089 /// SPI transfer mode 00090 const int TIMOD_DMA_TX = 0x0003; 00091 00092 /// SPORT0 word length 00093 const int SLEN_32 = 0x001f; 00094 00095 /// DMA flow mode 00096 const int FLOW_Autobuffer = 0x1000; 00097 00098 //--------------------------------------------------------------------------// 00099 // Global variables // 00100 //--------------------------------------------------------------------------// 00101 00102 extern volatile short sCodec1836TxRegs[]; 00103 extern volatile int iRxBuffer1[][SAMPLES_PER_INTR][SLOT_PER_SAMPLE]; // 00104 extern volatile int iTxBuffer1[][SAMPLES_PER_INTR][SLOT_PER_SAMPLE]; // 00105 00106 //--------------------------------------------------------------------------// 00107 // Prototypes // 00108 //--------------------------------------------------------------------------// 00109 // in afw.cpp 00110 bool ISR(void); 00111 00112 /** オーディオ処理の開始 00113 * 00114 * 設定が終わったSPORTとDMAの両方をイネーブルし、オーディオ処理を開始する。 00115 */ 00116 00117 void start(void); 00118 /** afwの初期化 00119 * 00120 * オーディオ・フレームワークの初期化。初期化関数はこれひとつよべば、残りの関数を 00121 * まとめて呼んでくれる。ただし、 afw::start は呼ばないので、プログラマが明示的に 00122 * 呼ばなければならない。 00123 */ 00124 void init(void); 00125 00126 // in processdata.cpp 00127 void initProcessData( int count ); 00128 void processData( const short leftIn[], const short rightIn[], short leftOut[], short rightOut[], int count); 00129 00130 00131 } // namespace afw 00132 00133 #endif //__Talkthrough_DEFINED