From 15e9ec85222a1d5fc93488c7683d89fc9760ca03 Mon Sep 17 00:00:00 2001 From: takemasa Date: Sun, 16 Dec 2012 23:09:47 +0900 Subject: [PATCH] =?utf8?q?AD7999=E3=81=AB=E3=82=88=E3=82=8B=E3=83=9C?= =?utf8?q?=E3=83=AA=E3=83=A5=E3=83=BC=E3=83=A0=E8=AA=AD=E3=81=BF=E5=8F=96?= =?utf8?q?=E3=82=8A=E3=81=AEAPI=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97?= =?utf8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- uzume_prototype/Makefile | 4 ++-- uzume_prototype/Makefile.depend | 21 +++++++++++++++++---- uzume_prototype/configure-project | 2 +- uzume_prototype/kernel_cfg.c | 14 +++++++++----- uzume_prototype/kernel_chk.c | 2 ++ uzume_prototype/kernel_id.h | 2 ++ uzume_prototype/kernel_obj.dat | Bin 3605 -> 4072 bytes uzume_prototype/uzume.c | 8 ++++---- uzume_prototype/uzume.h | 20 ++++++++++++++++++++ uzume_prototype/uzume_callback.c | 9 +++++++-- uzume_prototype/uzume_prototype.c | 3 --- uzume_prototype/uzume_prototype.cfg | 4 ++-- 12 files changed, 66 insertions(+), 23 deletions(-) diff --git a/uzume_prototype/Makefile b/uzume_prototype/Makefile index 3422d7f..829c530 100644 --- a/uzume_prototype/Makefile +++ b/uzume_prototype/Makefile @@ -116,10 +116,10 @@ UTASK_CFG = $(UNAME).cfg UTASK_DIR = $(SRCDIR)/library UTASK_ASMOBJS = ifdef USE_CXX - UTASK_CXXOBJS = $(UNAME).o uzume.o uzume_callback.o + UTASK_CXXOBJS = $(UNAME).o uzume.o uzume_callback.o ad7999.o UTASK_COBJS = else - UTASK_COBJS = $(UNAME).o uzume.o uzume_callback.o + UTASK_COBJS = $(UNAME).o uzume.o uzume_callback.o ad7999.o endif UTASK_CFLAGS = UTASK_LIBS = diff --git a/uzume_prototype/Makefile.depend b/uzume_prototype/Makefile.depend index c2c81b5..cb3e337 100644 --- a/uzume_prototype/Makefile.depend +++ b/uzume_prototype/Makefile.depend @@ -1,7 +1,7 @@ kernel_cfg.c kernel_id.h kernel_chk.c: kernel/systask/logtask.cfg \ kernel/include/kernel.h uzume.cfg \ kernel/config/blackfin/cpu_defs.h \ - kernel/config/blackfin/_common_bf592/chip_defs.h \ + kernel/config/blackfin/_common_bf592/chip_defs.h ad7999.cfg \ kernel/config/blackfin/_common_bf592/sys_rename.h \ kernel/include/t_config.h \ kernel/config/blackfin/tool_config.h uzume_prototype.cfg \ @@ -637,8 +637,9 @@ start.o: kernel/include/kernel.h kernel/config/blackfin/cpu_defs.h \ kernel/config/blackfin/cpu_config.h kernel/include/itron.h \ kernel/config/blackfin/_common_bf592/chip_config.h cpu_crtbegin.o: kernel/config/blackfin/cpu_crtbegin.c -uzume_prototype.o: kernel/include/kernel.h \ - kernel/include/t_services.h \ +uzume_prototype.o: \ + kernel/config/blackfin/amakusa_bf592/i2c_subsystem.h \ + kernel/include/kernel.h kernel/include/t_services.h \ kernel/config/blackfin/cpu_defs.h uzume_prototype.c \ kernel/config/blackfin/_common_bf592/chip_defs.h \ /opt/uClinux2011R1RC4/bfin-elf/bin/../lib/gcc/bfin-elf/4.3.5/include-fixed/limits.h \ @@ -686,6 +687,18 @@ uzume_callback.o: kernel/include/kernel.h \ kernel/include/itron.h \ /opt/uClinux2011R1RC4/bfin-elf/bin/../lib/gcc/bfin-elf/4.3.5/include/stddef.h \ kernel/include/t_stddef.h +ad7999.o: kernel/include/kernel.h ad7999.h \ + kernel/config/blackfin/cpu_defs.h \ + kernel/config/blackfin/_common_bf592/chip_defs.h \ + kernel/include/serial.h kernel/include/t_stddef.h \ + kernel/config/blackfin/amakusa_bf592/i2c_subsystem.h \ + ad7999.c kernel/include/t_services.h \ + /opt/uClinux2011R1RC4/bfin-elf/bin/../lib/gcc/bfin-elf/4.3.5/include-fixed/limits.h \ + uzume.h kernel/config/blackfin/tool_defs.h \ + kernel/include/t_syslog.h \ + kernel/config/blackfin/amakusa_bf592/sys_defs.h \ + /opt/uClinux2011R1RC4/bfin-elf/bin/../lib/gcc/bfin-elf/4.3.5/include/stddef.h \ + kernel/include/itron.h timer.o: \ /opt/uClinux2011R1RC4/bfin-elf/bin/../lib/gcc/bfin-elf/4.3.5/../../../../bfin-elf/include/defBF59x_base.h \ kernel/include/kernel.h kernel/include/timer.h \ @@ -809,7 +822,7 @@ kernel_cfg.o: \ kernel/include/kernel_cfg.h kernel/include/s_services.h \ kernel/config/blackfin/_common_bf592/chip_config.h \ kernel/include/../kernel/task.h kernel/include/kernel.h \ - kernel/include/timer.h \ + ad7999.h kernel/include/timer.h \ /opt/uClinux2011R1RC4/bfin-elf/bin/../lib/gcc/bfin-elf/4.3.5/../../../../bfin-elf/include/stdint.h \ kernel/config/blackfin/_common_bf592/chip_defs.h \ /opt/uClinux2011R1RC4/bfin-elf/bin/../lib/gcc/bfin-elf/4.3.5/../../../../bfin-elf/include/cdef_LPBlackfin.h \ diff --git a/uzume_prototype/configure-project b/uzume_prototype/configure-project index b73c940..f89d814 100755 --- a/uzume_prototype/configure-project +++ b/uzume_prototype/configure-project @@ -1 +1 @@ -kernel/configure -C blackfin -S amakusa_bf592 -A uzume_prototype -U "uzume.o uzume_callback.o" +kernel/configure -C blackfin -S amakusa_bf592 -A uzume_prototype -U "uzume.o uzume_callback.o ad7999.o" diff --git a/uzume_prototype/kernel_cfg.c b/uzume_prototype/kernel_cfg.c index 477624b..fd5911f 100644 --- a/uzume_prototype/kernel_cfg.c +++ b/uzume_prototype/kernel_cfg.c @@ -29,32 +29,35 @@ #include "logtask.h" #include "i2c_subsystem.h" #include "uzume.h" +#include "ad7999.h" /* Object initializer [task] */ -#define TNUM_TSKID 3 +#define TNUM_TSKID 4 const ID _kernel_tmax_tskid = (TMIN_TSKID + TNUM_TSKID - 1); static __STK_UNIT __stack_MAIN_TASK[__TCOUNT_STK_UNIT(1024)]; static __STK_UNIT __stack_LOGTASK[__TCOUNT_STK_UNIT(LOGTASK_STACK_SIZE)]; static __STK_UNIT __stack_CODEC_TASK[__TCOUNT_STK_UNIT(512)]; +static __STK_UNIT __stack_AD7999_TASK[__TCOUNT_STK_UNIT(1024)]; const TINIB _kernel_tinib_table[TNUM_TSKID] = { {0x00u | 0x02u, (VP_INT)(0), (FP)(main_task), INT_PRIORITY(5), __TROUND_STK_UNIT(1024), __stack_MAIN_TASK, TA_NULL, (FP)(NULL)}, {0x00u | 0x02u, (VP_INT)(( VP_INT ) 1), (FP)(logtask), INT_PRIORITY(LOGTASK_PRIORITY), __TROUND_STK_UNIT(LOGTASK_STACK_SIZE), __stack_LOGTASK, TA_NULL, (FP)(NULL)}, - {0x00u | 0x02u, (VP_INT)(0), (FP)(task_audiocodec), INT_PRIORITY(3), __TROUND_STK_UNIT(512), __stack_CODEC_TASK, TA_NULL, (FP)(NULL)} + {0x00u | 0x02u, (VP_INT)(0), (FP)(task_audiocodec), INT_PRIORITY(3), __TROUND_STK_UNIT(512), __stack_CODEC_TASK, TA_NULL, (FP)(NULL)}, + {0x00u | 0x02u, (VP_INT)(40), (FP)(ad7999_task), INT_PRIORITY(AD7999_PRIORITY), __TROUND_STK_UNIT(1024), __stack_AD7999_TASK, TA_NULL, (FP)(NULL)} }; -const ID _kernel_torder_table[TNUM_TSKID] = {1,2,3}; +const ID _kernel_torder_table[TNUM_TSKID] = {1,2,3,4}; TCB _kernel_tcb_table[TNUM_TSKID]; /* Object initializer [semaphore] */ -#define TNUM_SEMID 5 +#define TNUM_SEMID 6 const ID _kernel_tmax_semid = (TMIN_SEMID + TNUM_SEMID - 1); @@ -63,7 +66,8 @@ const SEMINIB _kernel_seminib_table[TNUM_SEMID] = { {1, 1, 1}, {1, 1, 1}, {1, 0, 1}, - {1, 0, 1} + {1, 0, 1}, + {1, 1, 1} }; SEMCB _kernel_semcb_table[TNUM_SEMID]; diff --git a/uzume_prototype/kernel_chk.c b/uzume_prototype/kernel_chk.c index d9e62ab..9b99d77 100644 --- a/uzume_prototype/kernel_chk.c +++ b/uzume_prototype/kernel_chk.c @@ -39,6 +39,7 @@ void checker_function(void) /* task */ + OBJECT(task_4,AD7999_TASK); OBJECT(task_3,CODEC_TASK); OBJECT(task_2,LOGTASK); OBJECT(task_1,MAIN_TASK); @@ -56,6 +57,7 @@ void checker_function(void) /* semaphore */ + OBJECT(semaphore_6,AD7999_SEM); OBJECT(semaphore_3,SEM_I2C0_BLOCK); OBJECT(semaphore_4,SEM_I2C0_SIGNAL); OBJECT(semaphore_1,SERIAL_RCV_SEM1); diff --git a/uzume_prototype/kernel_id.h b/uzume_prototype/kernel_id.h index c9762da..c42e6e1 100644 --- a/uzume_prototype/kernel_id.h +++ b/uzume_prototype/kernel_id.h @@ -3,6 +3,8 @@ /* object identifier deifnition */ +#define AD7999_SEM 6 +#define AD7999_TASK 4 #define CODEC_TASK 3 #define LOGTASK 2 #define MAIN_TASK 1 diff --git a/uzume_prototype/kernel_obj.dat b/uzume_prototype/kernel_obj.dat index c9b52e8e5694f51382766d9b3d2353e60644ee56..3e0a7d0cd1a59d8dc823f35460c4bee44a401400 100644 GIT binary patch delta 272 zcmbO#^Fn??10(0e#{Xi>3=9kg1{NTS3y75xQ_L+bEjL#(I> UZUME_INT_BITS; + rightIn[sample] = RxBuffer[bufRx].data[sample][ADC_R0] >> UZUME_INT_BITS; } // 信号処理 @@ -341,8 +341,8 @@ void task_audiocodec(VP_INT extinf) // 引数データをCODEC用送信バッファにコピー for ( sample = 0; sample < UZUME_BLOCKSIZE; sample++ ){ - TxBuffer[bufRx].data[sample][DAC_L0] = leftOut[sample]; - TxBuffer[bufRx].data[sample][DAC_R0] = rightOut[sample]; + TxBuffer[bufRx].data[sample][DAC_L0] = leftOut[sample] << UZUME_INT_BITS; + TxBuffer[bufRx].data[sample][DAC_R0] = rightOut[sample] << UZUME_INT_BITS; } } diff --git a/uzume_prototype/uzume.h b/uzume_prototype/uzume.h index 3c56556..b072e39 100644 --- a/uzume_prototype/uzume.h +++ b/uzume_prototype/uzume.h @@ -4,15 +4,35 @@ */ #ifndef UZUME_H_ #define UZUME_H_ + +/** + * @brief 汎用固定小数点型。 + * @datails + * Blackfinでは32bitで使用する。整数部のビット長は0である。 + */ +typedef int FX32; + /** * @brief 割り込み1回あたりのサンプル数。ユーザーが変えてもよい。 */ +#define UZUME_INT_BITS 0 +/** + * @brief スケーリング・ファクター + * @details + * AUDIOSAMPLE型の整数部のビット数を指定する。0の場合フォーマットは1.32、 + * 3ならば4.28、7ならば8.24となる。 + */ #define UZUME_BLOCKSIZE 64 /** * @brief サンプルあたりのスロット数。I2Sなら2。 */ #define SLOT_PER_SAMPLE 2 +/** + * @brief オーディオコーデック用データ型。 + * @datails + * Blackfinでは32bitで使用する。整数部のビット長は、 UZUME_INT_BITS で宣言する。 + */ typedef int AUDIOSAMPLE; // CODECのスロット番号 diff --git a/uzume_prototype/uzume_callback.c b/uzume_prototype/uzume_callback.c index 84ed363..8c3b064 100644 --- a/uzume_prototype/uzume_callback.c +++ b/uzume_prototype/uzume_callback.c @@ -6,6 +6,7 @@ #include "t_services.h" #include "kernel_id.h" #include "uzume.h" +#include "ad7999.h" /** * @brief 信号処理初期化関数 * @param count @ref codec_callback()に渡される引数配列のサイズ @@ -44,11 +45,15 @@ void process_audio( { // ループ変数 int sample; + FX32 volume; + + // ch 0 のボリューム値(32bit) + volume = get_volume(0)>>15; // count個のサンプルすべてを処理する for ( sample = 0; sample < UZUME_BLOCKSIZE; sample++ ){ - output_left[sample] = input_left[sample]; - output_right[sample] = input_right[sample]; + output_left[sample] = (input_left[sample]>>16) * volume; + output_right[sample] = (input_right[sample]>>16) * volume; } } diff --git a/uzume_prototype/uzume_prototype.c b/uzume_prototype/uzume_prototype.c index 0f38932..f94c40e 100644 --- a/uzume_prototype/uzume_prototype.c +++ b/uzume_prototype/uzume_prototype.c @@ -4,7 +4,6 @@ #include "uzume_prototype.h" #include -unsigned char adcbuf[8]; #define ADCADDR 0x28 @@ -17,8 +16,6 @@ void main_task(VP_INT exinf) while(1) { - i2c_master_read(0, ADCADDR, adcbuf, 2); - syslog( LOG_NOTICE, "ADC is : %02x%02x ", adcbuf[0], adcbuf[1]); tslp_tsk(200); } } diff --git a/uzume_prototype/uzume_prototype.cfg b/uzume_prototype/uzume_prototype.cfg index ca0f819..cdf60fb 100644 --- a/uzume_prototype/uzume_prototype.cfg +++ b/uzume_prototype/uzume_prototype.cfg @@ -1,5 +1,4 @@ /* - * @(#) $Id: sample1.cfg,v 1.1 2009/01/31 05:27:37 suikan Exp $ */ @@ -14,4 +13,5 @@ CRE_TSK(MAIN_TASK, { TA_HLNG|TA_ACT, 0, main_task, MAIN_PRIORITY, #include "kernel/systask/serial.cfg" #include "kernel/systask/logtask.cfg" #include "i2c0_m.cfg" -#include "uzume.cfg" \ No newline at end of file +#include "uzume.cfg" +#include "ad7999.cfg" -- 2.11.0