mirror of
https://github.com/rvtr/twl_wrapsdk.git
synced 2025-10-31 06:11:10 -04:00
add mic.
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@95 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
parent
ea28219429
commit
0cee338ff1
@ -43,7 +43,8 @@ SRCS = \
|
|||||||
snd_alarm.c \
|
snd_alarm.c \
|
||||||
snd_command.c \
|
snd_command.c \
|
||||||
snd_data.c \
|
snd_data.c \
|
||||||
snd_i2s.c
|
snd_i2s.c \
|
||||||
|
snd_mic.c \
|
||||||
|
|
||||||
|
|
||||||
TARGET_LIB = libsnd_sp$(TWL_LIBSUFFIX).a
|
TARGET_LIB = libsnd_sp$(TWL_LIBSUFFIX).a
|
||||||
|
|||||||
178
build/libraries/snd/ARM7/snd_mic.c
Normal file
178
build/libraries/snd/ARM7/snd_mic.c
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: CtrSDK - MIC
|
||||||
|
File: mic.c
|
||||||
|
|
||||||
|
Copyright 2006 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <twl.h>
|
||||||
|
#include <twl/snd/ARM7/snd_mic.h>
|
||||||
|
|
||||||
|
|
||||||
|
static void MICi_ExDmaRecvAsync( u32 dmaNo, void *dest, s32 size );
|
||||||
|
void MICi_ExDmaInterruptHandler( void );
|
||||||
|
|
||||||
|
void MICi_DmaInterruptHandler( void );
|
||||||
|
void MICi_FifoInterruptHandler( void );
|
||||||
|
|
||||||
|
static MICWork micWork;
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: MICi_Start
|
||||||
|
|
||||||
|
Description: start MIC
|
||||||
|
|
||||||
|
Arguments: dtc : enable DTC or not
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void MICi_Start( MICSampleRate smp, u32 dmaNo, void *dest, s32 size )
|
||||||
|
{
|
||||||
|
MICWork *wp = &micWork;
|
||||||
|
|
||||||
|
OSIntrMode enabled;
|
||||||
|
|
||||||
|
wp->dmaNo = dmaNo;
|
||||||
|
wp->buf = dest;
|
||||||
|
wp->bufSize = size;
|
||||||
|
|
||||||
|
MICi_Stop();
|
||||||
|
|
||||||
|
enabled = OS_DisableInterrupts();
|
||||||
|
|
||||||
|
if ( dest != NULL )
|
||||||
|
{
|
||||||
|
if ( MI_EXDMA_CH_MIN <= dmaNo && dmaNo <= MI_EXDMA_CH_MAX )
|
||||||
|
{
|
||||||
|
u32 ch = dmaNo + MI_EXDMA_CH_MIN;
|
||||||
|
|
||||||
|
MIi_StopExDma( dmaNo );
|
||||||
|
|
||||||
|
MICi_ExDmaRecvAsync( dmaNo, dest, size );
|
||||||
|
|
||||||
|
OS_SetIrqFunction( OS_IE_DMA4 + ch, MICi_ExDmaInterruptHandler );
|
||||||
|
|
||||||
|
reg_OS_IF = (OS_IE_DMA4 << ch);
|
||||||
|
reg_OS_IE |= (OS_IE_DMA4 << ch); // enable mic dma interrupt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SND_Enable();
|
||||||
|
|
||||||
|
// start monoral sampling
|
||||||
|
reg_SND_MICCNT = (u8)REG_SND_MICCNT_FIFO_CLR_MASK;
|
||||||
|
reg_SND_MICCNT = (u8)(REG_SND_MICCNT_E_MASK | REG_SND_MICCNT_NR_MASK | MIC_INTR_OVERFLOW
|
||||||
|
| smp);
|
||||||
|
|
||||||
|
(void)OS_RestoreInterrupts(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: MICi_Stop
|
||||||
|
|
||||||
|
Description: stop MIC
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void MICi_Stop( void )
|
||||||
|
{
|
||||||
|
MICWork *wp = &micWork;
|
||||||
|
|
||||||
|
OSIntrMode enabled = OS_DisableInterrupts();
|
||||||
|
|
||||||
|
if ( reg_SND_MICCNT & REG_SND_MICCNT_E_MASK )
|
||||||
|
{
|
||||||
|
u32 dmaNo = wp->dmaNo;
|
||||||
|
|
||||||
|
reg_SND_MICCNT &= ~REG_SND_MICCNT_E_MASK;
|
||||||
|
|
||||||
|
if ( MI_EXDMA_CH_MIN <= dmaNo && dmaNo <= MI_EXDMA_CH_MAX )
|
||||||
|
{
|
||||||
|
u32 ch = dmaNo + MI_EXDMA_CH_MIN;
|
||||||
|
|
||||||
|
MIi_StopExDma( dmaNo );
|
||||||
|
|
||||||
|
reg_OS_IE &= ~(OS_IE_DMA4 << ch); // disable mic dma interrupt
|
||||||
|
reg_OS_IF = (OS_IE_DMA4 << ch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reg_OS_IE2 &= ~(OS_IE_MIC >> 32); // disable mic fifo interrupt
|
||||||
|
reg_OS_IF2 = (OS_IE_MIC >> 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)OS_RestoreInterrupts(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: MICi_ExDmaRecvAsync
|
||||||
|
|
||||||
|
Description: receive data with DMA
|
||||||
|
async version
|
||||||
|
|
||||||
|
Arguments: dmaNo : DMA channel No.
|
||||||
|
dest : destination address
|
||||||
|
size : size (byte)
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static void MICi_ExDmaRecvAsync( u32 dmaNo, void *dest, s32 size )
|
||||||
|
{
|
||||||
|
u32 interval = (0x2C0 * 16) - 16;
|
||||||
|
MIExDmaPrescaler prescale = MI_EXDMA_PRESCALER_1;
|
||||||
|
|
||||||
|
MIi_ExDmaRecvAsyncCore( dmaNo, (void*)REG_MIC_FIFO_ADDR, dest,
|
||||||
|
(u32)size, (u32)size,
|
||||||
|
MI_EXDMA_BLOCK_32B, interval, prescale,
|
||||||
|
MI_EXDMA_CONTINUOUS_ON, MI_EXDMA_SRC_RLD_ON, MI_EXDMA_DEST_RLD_ON,
|
||||||
|
MI_EXDMA_TIMING_MIC );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: MICi_ExDmaInterruptHandler
|
||||||
|
|
||||||
|
Description: interrupt handler
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void MICi_ExDmaInterruptHandler( void )
|
||||||
|
{
|
||||||
|
// MICWork *wp = &micWork;
|
||||||
|
|
||||||
|
// OS_TPrintf( "*" );
|
||||||
|
|
||||||
|
// MICi_ExDmaRecvAsync( wp->dmaNo, wp->buf, wp->bufSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: MICi_FifoInterruptHandler
|
||||||
|
|
||||||
|
Description: interrupt handler
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void MICi_FifoInterruptHandler( void )
|
||||||
|
{
|
||||||
|
MICWork *wp = &micWork;
|
||||||
|
|
||||||
|
MIi_CpuSend32( (void*)REG_MIC_FIFO_ADDR, wp->buf, (u32)wp->bufSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -22,6 +22,8 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
|||||||
|
|
||||||
SUBDIRS = channel \
|
SUBDIRS = channel \
|
||||||
capture \
|
capture \
|
||||||
|
mic-1 \
|
||||||
|
mic-2 \
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|||||||
44
build/tests/snd/mic-1/ARM7/Makefile
Normal file
44
build/tests/snd/mic-1/ARM7/Makefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
TWL_PROC = ARM7
|
||||||
|
|
||||||
|
TARGET_BIN = mic7_1.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
63
build/tests/snd/mic-1/ARM7/src/main.c
Normal file
63
build/tests/snd/mic-1/ARM7/src/main.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - tests - snd - mic-1
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <twl_sp.h>
|
||||||
|
#include <twl/mic.h>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
// ===== スレッド優先度 =====
|
||||||
|
|
||||||
|
#define THREAD_PRIO_SND 6
|
||||||
|
|
||||||
|
#define MY_MIC_BUF_LEN 0x100
|
||||||
|
|
||||||
|
u16 micBuf[MY_MIC_BUF_LEN] __attribute__ ((aligned (32)));
|
||||||
|
|
||||||
|
void TwlSpMain(void)
|
||||||
|
{
|
||||||
|
int i, ii;
|
||||||
|
|
||||||
|
OS_Init();
|
||||||
|
OS_InitThread();
|
||||||
|
|
||||||
|
// サウンド初期化
|
||||||
|
SND_Init(THREAD_PRIO_SND);
|
||||||
|
|
||||||
|
OS_TPrintf("\nARM7 starts.\n");
|
||||||
|
|
||||||
|
MICi_Start( MIC_SMP_ALL, MIC_DEFAULT_DMA_NO, micBuf, sizeof(micBuf) );
|
||||||
|
OS_TPrintf( "\nMIC starts.\n");
|
||||||
|
|
||||||
|
OS_SpinWait( OS_MSEC_TO_CPUCYC( 60 ) );
|
||||||
|
|
||||||
|
MICi_Stop();
|
||||||
|
OS_TPrintf( "\nMIC stops.\n");
|
||||||
|
|
||||||
|
OS_TPrintf( "\nDump mic buffer.\n" );
|
||||||
|
for (i=0; i<MY_MIC_BUF_LEN/16; i++)
|
||||||
|
{
|
||||||
|
for (ii=0; ii<16; ii++)
|
||||||
|
{
|
||||||
|
OS_TPrintf( "%4.4x ", micBuf[i*16+ii] );
|
||||||
|
}
|
||||||
|
OS_TPrintf( "\n" );
|
||||||
|
}
|
||||||
|
OS_TPrintf( "\n" );
|
||||||
|
|
||||||
|
OS_TPrintf("\nARM7 ends.\n");
|
||||||
|
OS_Terminate();
|
||||||
|
}
|
||||||
43
build/tests/snd/mic-1/ARM9/Makefile
Normal file
43
build/tests/snd/mic-1/ARM9/Makefile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
|
||||||
|
TARGET_BIN = mic9_1.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
35
build/tests/snd/mic-1/ARM9/src/main.c
Normal file
35
build/tests/snd/mic-1/ARM9/src/main.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - SND - tests - mic-1
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#include <twl.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlMain
|
||||||
|
|
||||||
|
Description: main
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlMain()
|
||||||
|
{
|
||||||
|
OS_Init();
|
||||||
|
|
||||||
|
OS_TPrintf("\nARM9 starts.\n");
|
||||||
|
OS_TPrintf("\nARM9 ends.\n");
|
||||||
|
OS_Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
32
build/tests/snd/mic-1/Makefile
Normal file
32
build/tests/snd/mic-1/Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - build
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS = \
|
||||||
|
ARM7 \
|
||||||
|
ARM9 \
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
44
build/tests/snd/mic-2/ARM7/Makefile
Normal file
44
build/tests/snd/mic-2/ARM7/Makefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
TWL_PROC = ARM7
|
||||||
|
|
||||||
|
TARGET_BIN = mic7_2.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
207
build/tests/snd/mic-2/ARM7/src/main.c
Normal file
207
build/tests/snd/mic-2/ARM7/src/main.c
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - tests - snd - mic-2
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <twl_sp.h>
|
||||||
|
#include <twl/mic.h>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define ENABLE_PSG
|
||||||
|
|
||||||
|
#define MY_MIC_BUF_LEN 0x100
|
||||||
|
|
||||||
|
#define MPI 3.14159265358979323846
|
||||||
|
|
||||||
|
#define MY_SND_16
|
||||||
|
|
||||||
|
#ifdef MY_SND_16
|
||||||
|
#define MY_SND_BYTES 2
|
||||||
|
#define MY_SND_DATA_MAX 0x7fff
|
||||||
|
#define MY_SND_WAVE_FMT SND_WAVE_FORMAT_PCM16
|
||||||
|
#define MY_SND_CAP_FMT SND_CAPTURE_FORMAT_PCM16
|
||||||
|
typedef s16 mySndType;
|
||||||
|
#else
|
||||||
|
#define MY_SND_BYTES 1
|
||||||
|
#define MY_SND_DATA_MAX 0x7f
|
||||||
|
#define MY_SND_WAVE_FMT SND_WAVE_FORMAT_PCM8
|
||||||
|
#define MY_SND_CAP_FMT SND_CAPTURE_FORMAT_PCM8
|
||||||
|
typedef s8 mySndType;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MY_SND_FREQ 0x160 // 0x200
|
||||||
|
|
||||||
|
#define MY_SND_BUF_LEN (0x0400/MY_SND_BYTES)
|
||||||
|
#define MY_SND_CAPTURE_LEN (0x1000/MY_SND_BYTES)
|
||||||
|
|
||||||
|
u16 micBuf[MY_MIC_BUF_LEN] __attribute__ ((aligned (32)));
|
||||||
|
|
||||||
|
mySndType wavBuf[2][MY_SND_BUF_LEN] __attribute__ ((aligned (32)));
|
||||||
|
mySndType capBuf[2][MY_SND_CAPTURE_LEN] __attribute__ ((aligned (32)));
|
||||||
|
|
||||||
|
|
||||||
|
static void MY_SndInit( void )
|
||||||
|
{
|
||||||
|
OSIntrMode enabled;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i<MY_SND_BUF_LEN; i++)
|
||||||
|
{
|
||||||
|
wavBuf[0][i] = (mySndType)(sin( 2 * MPI * i / MY_SND_BUF_LEN ) * MY_SND_DATA_MAX);
|
||||||
|
}
|
||||||
|
for (i=0; i<MY_SND_BUF_LEN-1; i++)
|
||||||
|
{
|
||||||
|
wavBuf[1][i] = wavBuf[0][i+1];
|
||||||
|
}
|
||||||
|
wavBuf[1][MY_SND_BUF_LEN-1] = wavBuf[0][0];
|
||||||
|
|
||||||
|
enabled = OS_DisableInterrupts();
|
||||||
|
|
||||||
|
SND_Enable();
|
||||||
|
SND_SetMasterVolume( SND_MASTER_VOLUME_MAX );
|
||||||
|
SND_SetOutputSelector( SND_OUTPUT_MIXER, SND_OUTPUT_MIXER, SND_CHANNEL_OUT_BYPASS, SND_CHANNEL_OUT_BYPASS );
|
||||||
|
|
||||||
|
SND_SetupCapture( SND_CAPTURE_0, MY_SND_CAP_FMT, &capBuf[0], sizeof(capBuf[0])/4, TRUE,
|
||||||
|
SND_CAPTURE_IN_MIXER, SND_CAPTURE_OUT_NORMAL );
|
||||||
|
|
||||||
|
SND_SetupCapture( SND_CAPTURE_1, MY_SND_CAP_FMT, &capBuf[1], sizeof(capBuf[1])/4, TRUE,
|
||||||
|
SND_CAPTURE_IN_MIXER, SND_CAPTURE_OUT_NORMAL );
|
||||||
|
SND_StartCaptureBoth();
|
||||||
|
|
||||||
|
#ifdef ENABLE_PSG
|
||||||
|
|
||||||
|
SND_SetupChannelPsg( 8, SND_DUTY_4_8, SND_CHANNEL_VOLUME_MAX, SND_CHANNEL_DATASHIFT_1BIT, 0x0000, SND_CHANNEL_PAN_CENTER );
|
||||||
|
|
||||||
|
SND_StartChannel( 8 );
|
||||||
|
|
||||||
|
#else // ENABLE_PCM
|
||||||
|
|
||||||
|
SND_SetupChannelPcm( 1, &capBuf[0], MY_SND_WAVE_FMT, SND_CHANNEL_LOOP_REPEAT, 0, sizeof(capBuf[0])/4,
|
||||||
|
SND_CHANNEL_VOLUME_MAX, SND_CHANNEL_DATASHIFT_NONE, MY_SND_FREQ, SND_CHANNEL_PAN_MIN );
|
||||||
|
SND_SetupChannelPcm( 3, &capBuf[1], MY_SND_WAVE_FMT, SND_CHANNEL_LOOP_REPEAT, 0, sizeof(capBuf[1])/4,
|
||||||
|
SND_CHANNEL_VOLUME_MAX, SND_CHANNEL_DATASHIFT_NONE, MY_SND_FREQ, SND_CHANNEL_PAN_MAX );
|
||||||
|
|
||||||
|
SND_SetupChannelPcm( 0, &wavBuf[0], MY_SND_WAVE_FMT, SND_CHANNEL_LOOP_REPEAT, 0, sizeof(wavBuf[0])/4,
|
||||||
|
SND_CHANNEL_VOLUME_MAX, SND_CHANNEL_DATASHIFT_NONE, MY_SND_FREQ, SND_CHANNEL_PAN_MIN );
|
||||||
|
SND_SetupChannelPcm( 2, &wavBuf[1], MY_SND_WAVE_FMT, SND_CHANNEL_LOOP_REPEAT, 0, sizeof(wavBuf[1])/4,
|
||||||
|
SND_CHANNEL_VOLUME_MAX, SND_CHANNEL_DATASHIFT_NONE, MY_SND_FREQ, SND_CHANNEL_PAN_MAX );
|
||||||
|
|
||||||
|
SND_StartChannel( 1 );
|
||||||
|
SND_StartChannel( 3 );
|
||||||
|
|
||||||
|
SND_StartChannel( 0 );
|
||||||
|
SND_StartChannel( 2 );
|
||||||
|
|
||||||
|
#endif // ENABLE_PCM
|
||||||
|
|
||||||
|
(void)OS_RestoreInterrupts(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void MY_SndTerminate( void )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
OSIntrMode enabled = OS_DisableInterrupts();
|
||||||
|
|
||||||
|
SND_StopCapture( SND_CAPTURE_0 );
|
||||||
|
SND_StopCapture( SND_CAPTURE_1 );
|
||||||
|
|
||||||
|
for (i=0; i<16; i++)
|
||||||
|
{
|
||||||
|
SND_StopChannel( i, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)OS_RestoreInterrupts(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintfCaptureBuf( int startIdx )
|
||||||
|
{
|
||||||
|
int i, ii;
|
||||||
|
|
||||||
|
for (i=0; i<2; i++)
|
||||||
|
{
|
||||||
|
OS_TPrintf( "%s : ", i ==0 ? "L" : "R" );
|
||||||
|
for (ii=0; ii<16; ii++)
|
||||||
|
{
|
||||||
|
OS_TPrintf( MY_SND_BYTES == 2 ? "%4.4x " : "%2.2x ", (u16)capBuf[i][startIdx + ii] );
|
||||||
|
}
|
||||||
|
OS_TPrintf( "\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CheckSound( void )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
OS_TPrintf( "\nDump reverb buffer.\n" );
|
||||||
|
OS_TPrintf( "[Top]\n" );
|
||||||
|
PrintfCaptureBuf( 0 );
|
||||||
|
OS_TPrintf( "[Bottom]\n" );
|
||||||
|
PrintfCaptureBuf( MY_SND_CAPTURE_LEN - 16 );
|
||||||
|
|
||||||
|
OS_TPrintf( "\nDump mic buffer.\n" );
|
||||||
|
for (i=0; i<16; i++)
|
||||||
|
{
|
||||||
|
OS_TPrintf( "%4.4x ", micBuf[i] );
|
||||||
|
}
|
||||||
|
OS_TPrintf( "\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TestFunc( void )
|
||||||
|
{
|
||||||
|
MY_SndInit();
|
||||||
|
OS_TPrintf( "\nSound starts.\n" );
|
||||||
|
|
||||||
|
MICi_Start( MIC_SMP_ALL, MIC_DEFAULT_DMA_NO, micBuf, sizeof(micBuf) );
|
||||||
|
OS_TPrintf( "\nMIC starts.\n");
|
||||||
|
|
||||||
|
OS_SpinWait( OS_MSEC_TO_CPUCYC( 60 ) );
|
||||||
|
|
||||||
|
MICi_Stop();
|
||||||
|
OS_TPrintf( "\nMIC stops.\n");
|
||||||
|
|
||||||
|
MY_SndTerminate();
|
||||||
|
OS_TPrintf( "\nSound stops.\n" );
|
||||||
|
|
||||||
|
CheckSound();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwlSpMain(void)
|
||||||
|
{
|
||||||
|
OS_Init();
|
||||||
|
|
||||||
|
OS_TPrintf("\nARM7 starts.\n");
|
||||||
|
|
||||||
|
// round robin dma test
|
||||||
|
OS_TPrintf( "\nChange Round Robin Mode.\n" );
|
||||||
|
|
||||||
|
MIi_SetExDmaArbitration( MI_EXDMAGBL_ARB_PRIORITY );
|
||||||
|
|
||||||
|
TestFunc();
|
||||||
|
|
||||||
|
OS_SpinWait( OS_MSEC_TO_CPUCYC( 60 ) );
|
||||||
|
|
||||||
|
// priority dma test
|
||||||
|
OS_TPrintf( "\nChange Priority Mode.\n" );
|
||||||
|
|
||||||
|
MIi_SetExDmaArbitration( MI_EXDMAGBL_ARB_ROUND_ROBIN );
|
||||||
|
MIi_SetExDmaYieldCycles( MI_EXDMAGBL_YLD_CYCLE_DEFAULT );
|
||||||
|
|
||||||
|
TestFunc();
|
||||||
|
|
||||||
|
OS_TPrintf("\nARM7 ends.\n");
|
||||||
|
OS_Terminate();
|
||||||
|
}
|
||||||
43
build/tests/snd/mic-2/ARM9/Makefile
Normal file
43
build/tests/snd/mic-2/ARM9/Makefile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - SND - demos - channel
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#TWL_CODEGEN = THUMB
|
||||||
|
|
||||||
|
TARGET_BIN = mic9_2.axf
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
#SRCDIR = # using default
|
||||||
|
#LCFILE = # using default
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
do-build: $(TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
35
build/tests/snd/mic-2/ARM9/src/main.c
Normal file
35
build/tests/snd/mic-2/ARM9/src/main.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - SND - tests - mic-2
|
||||||
|
File: main.c
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: main.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#include <twl.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: TwlMain
|
||||||
|
|
||||||
|
Description: main
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void TwlMain()
|
||||||
|
{
|
||||||
|
OS_Init();
|
||||||
|
|
||||||
|
OS_TPrintf("\nARM9 starts.\n");
|
||||||
|
OS_TPrintf("\nARM9 ends.\n");
|
||||||
|
OS_Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
32
build/tests/snd/mic-2/Makefile
Normal file
32
build/tests/snd/mic-2/Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#! make -f
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: TwlSDK - build
|
||||||
|
# File: Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Log: $
|
||||||
|
# $NoKeywords: $
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SUBDIRS = \
|
||||||
|
ARM7 \
|
||||||
|
ARM9 \
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||||
|
|
||||||
|
|
||||||
|
#===== End of Makefile =====
|
||||||
@ -21,6 +21,7 @@
|
|||||||
#include <twl/os.h>
|
#include <twl/os.h>
|
||||||
#include <twl/mi.h>
|
#include <twl/mi.h>
|
||||||
#include <twl/aes.h>
|
#include <twl/aes.h>
|
||||||
|
#include <twl/mic.h>
|
||||||
#ifdef SDK_DEBUGGER_KMC
|
#ifdef SDK_DEBUGGER_KMC
|
||||||
#include <twl/vlink.h>
|
#include <twl/vlink.h>
|
||||||
#endif // SDK_DEBUGGER_KMC
|
#endif // SDK_DEBUGGER_KMC
|
||||||
|
|||||||
25
include/twl/mic.h
Normal file
25
include/twl/mic.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - include - MIC
|
||||||
|
File: mic.h
|
||||||
|
|
||||||
|
Copyright 2007 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef TWL_MIC_H_
|
||||||
|
#define TWL_MIC_H_
|
||||||
|
|
||||||
|
#ifdef SDK_ARM7
|
||||||
|
#include <twl/snd/ARM7/snd_mic.h>
|
||||||
|
#endif // SDK_ARM7
|
||||||
|
|
||||||
|
/* TWL_MIC_H_ */
|
||||||
|
#endif
|
||||||
@ -35,6 +35,25 @@ typedef enum
|
|||||||
}
|
}
|
||||||
OSChipType;
|
OSChipType;
|
||||||
|
|
||||||
|
typedef u32 OSCpuCycle;
|
||||||
|
|
||||||
|
#define OS_CPU_CLOCK HW_CPU_CLOCK
|
||||||
|
|
||||||
|
//---- sec to cpu cycle
|
||||||
|
// 150nsec - 30sec
|
||||||
|
#define OS_SEC_TO_CPUCYC( sec ) ((OSCpuCycle)( ( OS_CPU_CLOCK * (u32)(sec)) ))
|
||||||
|
#define OS_MSEC_TO_CPUCYC( msec ) ((OSCpuCycle)( ((OS_CPU_CLOCK/1000) * (u32)(msec)) ))
|
||||||
|
#define OS_USEC_TO_CPUCYC( usec ) ((OSCpuCycle)( ((OS_CPU_CLOCK/1000) * (u32)(usec)) / 1000 ))
|
||||||
|
#define OS_NSEC_TO_CPUCYC( nsec ) ((OSCpuCycle)( ((OS_CPU_CLOCK/1000) * (u32)(nsec)) / (1000 * 1000) ))
|
||||||
|
|
||||||
|
//---- cpu cycle to sec
|
||||||
|
// 150nsec - 30sec
|
||||||
|
#define OS_CPUCYC_TO_SEC( cyc ) ( ((u32)(cyc) ) / OS_CPU_CLOCK )
|
||||||
|
#define OS_CPUCYC_TO_MSEC( cyc ) ( ((u32)(cyc) ) / (OS_CPU_CLOCK/1000) )
|
||||||
|
#define OS_CPUCYC_TO_USEC( cyc ) ( ((u32)(cyc) * 1000) / (OS_CPU_CLOCK/1000) )
|
||||||
|
#define OS_CPUCYC_TO_NSEC( cyc ) ( ((u32)(cyc) * 1000 * 1000) / (OS_CPU_CLOCK/1000) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
86
include/twl/snd/ARM7/snd_mic.h
Normal file
86
include/twl/snd/ARM7/snd_mic.h
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: CtrSDK - MIC - include
|
||||||
|
File: snd_mic.h
|
||||||
|
|
||||||
|
Copyright 2006 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Log: $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#ifndef TWL_SND_MIC_H_
|
||||||
|
#define TWL_SND_MIC_H_
|
||||||
|
|
||||||
|
#include <twl/types.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MIC_INTR_DISABLE = (0x0UL << REG_SND_MICCNT_IM_SHIFT),
|
||||||
|
MIC_INTR_HALF = (0x1UL << REG_SND_MICCNT_IM_SHIFT),
|
||||||
|
MIC_INTR_OVERFLOW = (0x2UL << REG_SND_MICCNT_IM_SHIFT),
|
||||||
|
MIC_INTR_HALF_OVERFLOW = (0x3UL << REG_SND_MICCNT_IM_SHIFT)
|
||||||
|
}
|
||||||
|
MICIntrCond;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MIC_SMP_ALL = (0x0UL << REG_SND_MICCNT_FIFO_SMP_SHIFT),
|
||||||
|
MIC_SMP_1_2 = (0x1UL << REG_SND_MICCNT_FIFO_SMP_SHIFT),
|
||||||
|
MIC_SMP_1_3 = (0x2UL << REG_SND_MICCNT_FIFO_SMP_SHIFT),
|
||||||
|
MIC_SMP_1_4 = (0x3UL << REG_SND_MICCNT_FIFO_SMP_SHIFT)
|
||||||
|
}
|
||||||
|
MICSampleRate;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u32 dmaNo; // DMA No
|
||||||
|
void* buf;
|
||||||
|
s32 bufSize;
|
||||||
|
}
|
||||||
|
MICWork;
|
||||||
|
|
||||||
|
|
||||||
|
#define MIC_DEFAULT_DMA_NO 6
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: MICi_Start
|
||||||
|
|
||||||
|
Description: start MIC
|
||||||
|
|
||||||
|
Arguments: id : slave id
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void MICi_Start( MICSampleRate smp, u32 dmaNo, void *dest, s32 size );
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: MICi_Stop
|
||||||
|
|
||||||
|
Description: stop MIC
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void MICi_Stop( void );
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* TWL_SND_MIC_H_ */
|
||||||
|
#endif
|
||||||
Loading…
Reference in New Issue
Block a user