mirror of
https://github.com/rvtr/twl_wrapsdk.git
synced 2025-10-31 06:11:10 -04:00
sparate TWL additions to snd_i2s.c
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@82 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
parent
e342d61547
commit
c86ca86027
@ -33,16 +33,17 @@ SRCS = \
|
|||||||
snd_global.c \
|
snd_global.c \
|
||||||
snd_channel.c \
|
snd_channel.c \
|
||||||
snd_util.c \
|
snd_util.c \
|
||||||
snd_main.c \
|
snd_main.c \
|
||||||
snd_capture.c \
|
snd_capture.c \
|
||||||
snd_exchannel.c \
|
snd_exchannel.c \
|
||||||
snd_seq.c \
|
snd_seq.c \
|
||||||
snd_midiplayer.c \
|
snd_midiplayer.c \
|
||||||
snd_bank.c \
|
snd_bank.c \
|
||||||
snd_work.c \
|
snd_work.c \
|
||||||
snd_alarm.c \
|
snd_alarm.c \
|
||||||
snd_command.c \
|
snd_command.c \
|
||||||
snd_data.c
|
snd_data.c \
|
||||||
|
snd_i2s.c
|
||||||
|
|
||||||
|
|
||||||
TARGET_LIB = libsnd_sp$(TWL_LIBSUFFIX).a
|
TARGET_LIB = libsnd_sp$(TWL_LIBSUFFIX).a
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#include <twl/os.h>
|
#include <twl/os.h>
|
||||||
#include <twl/misc.h>
|
#include <twl/misc.h>
|
||||||
#include <twl/cdc.h>
|
#include <twl/cdc.h>
|
||||||
|
#include <twl/snd/ARM7/i2s.h>
|
||||||
#include <nitro/hw/ARM7/ioreg_SND.h>
|
#include <nitro/hw/ARM7/ioreg_SND.h>
|
||||||
#include <nitro/spi/common/pm_common.h>
|
#include <nitro/spi/common/pm_common.h>
|
||||||
#include <nitro/snd/common/channel.h>
|
#include <nitro/snd/common/channel.h>
|
||||||
@ -54,21 +55,8 @@ extern void PMi_ResetControl(u8 sw);
|
|||||||
void SND_Enable(void)
|
void SND_Enable(void)
|
||||||
{
|
{
|
||||||
OSIntrMode enabled = OS_DisableInterrupts();
|
OSIntrMode enabled = OS_DisableInterrupts();
|
||||||
|
SND_I2SEnable();
|
||||||
reg_SND_POWCNT |= REG_SND_POWCNT_SPE_MASK;
|
|
||||||
reg_CFG_TWL_EX |= REG_CFG_TWL_EX_I2S_MASK;
|
|
||||||
|
|
||||||
if ((reg_CFG_CLK & REG_CFG_CLK_SND_MASK) == 0)
|
|
||||||
{
|
|
||||||
CDC_Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
reg_SND_I2SCNT |= REG_SND_I2SCNT_E_MASK
|
|
||||||
| REG_SND_I2SCNT_MIX_RATIO_MASK;
|
|
||||||
reg_SND_I2SCNT &= ~REG_SND_I2SCNT_MUTE_MASK;
|
|
||||||
|
|
||||||
reg_SND_SOUNDCNT_8 |= REG_SND_SOUNDCNT_8_E_MASK;
|
reg_SND_SOUNDCNT_8 |= REG_SND_SOUNDCNT_8_E_MASK;
|
||||||
|
|
||||||
(void)OS_RestoreInterrupts(enabled);
|
(void)OS_RestoreInterrupts(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +72,8 @@ void SND_Enable(void)
|
|||||||
void SND_Disable(void)
|
void SND_Disable(void)
|
||||||
{
|
{
|
||||||
OSIntrMode enabled = OS_DisableInterrupts();
|
OSIntrMode enabled = OS_DisableInterrupts();
|
||||||
|
SND_I2SDisable();
|
||||||
reg_SND_I2SCNT &= REG_SND_I2SCNT_E_MASK;
|
|
||||||
reg_SND_SOUNDCNT_8 &= ~REG_SND_SOUNDCNT_8_E_MASK;
|
reg_SND_SOUNDCNT_8 &= ~REG_SND_SOUNDCNT_8_E_MASK;
|
||||||
|
|
||||||
(void)OS_RestoreInterrupts(enabled);
|
(void)OS_RestoreInterrupts(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +111,9 @@ void SND_Shutdown(void)
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
void SND_BeginSleep(void)
|
void SND_BeginSleep(void)
|
||||||
{
|
{
|
||||||
|
// adding process for TWL
|
||||||
|
SND_I2SBeginSleep();
|
||||||
|
|
||||||
// stop all sound
|
// stop all sound
|
||||||
SND_Disable();
|
SND_Disable();
|
||||||
|
|
||||||
@ -164,6 +153,9 @@ void SND_EndSleep(void)
|
|||||||
|
|
||||||
// sound enable
|
// sound enable
|
||||||
SND_Enable();
|
SND_Enable();
|
||||||
|
|
||||||
|
// adding process for TWL
|
||||||
|
SND_I2SEndSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
|
|||||||
188
build/libraries/snd/ARM7/snd_i2s.c
Normal file
188
build/libraries/snd/ARM7/snd_i2s.c
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - SND - libraries
|
||||||
|
File: snd_i2s.c
|
||||||
|
|
||||||
|
Copyright 2004-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: snd_i2s.c,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#include <twl/snd/ARM7/i2s.h>
|
||||||
|
|
||||||
|
#include <twl/os.h>
|
||||||
|
#include <twl/misc.h>
|
||||||
|
#include <twl/cdc.h>
|
||||||
|
#include <nitro/hw/ARM7/ioreg_SND.h>
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
static typedef declaration
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
static variables
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
static u8 state;
|
||||||
|
static BOOL isTwl = FALSE;
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
static functions
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
static void SNDi_I2SInit(void)
|
||||||
|
{
|
||||||
|
static BOOL isInitialized = FALSE;
|
||||||
|
if (isInitialized == FALSE)
|
||||||
|
{
|
||||||
|
isInitialized = TRUE;
|
||||||
|
reg_SND_POWCNT |= REG_SND_POWCNT_SPE_MASK;
|
||||||
|
reg_CFG_TWL_EX |= REG_CFG_TWL_EX_I2S_MASK;
|
||||||
|
if (reg_CFG_TWL_EX & REG_CFG_TWL_EX_I2S_MASK)
|
||||||
|
{
|
||||||
|
isTwl = TRUE;
|
||||||
|
reg_SND_I2SCNT |= REG_SND_I2SCNT_MIX_RATIO_MASK;
|
||||||
|
reg_SND_I2SCNT &= ~REG_SND_I2SCNT_MUTE_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
public functions
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SND_I2SEnable
|
||||||
|
|
||||||
|
Description: Enable sound master control
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void SND_I2SEnable(void)
|
||||||
|
{
|
||||||
|
SNDi_I2SInit();
|
||||||
|
|
||||||
|
if (isTwl)
|
||||||
|
{
|
||||||
|
reg_SND_I2SCNT |= REG_SND_I2SCNT_E_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SND_I2SDisable
|
||||||
|
|
||||||
|
Description: Disable sound master control
|
||||||
|
|
||||||
|
Arguments: None
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void SND_I2SDisable(void)
|
||||||
|
{
|
||||||
|
if (isTwl)
|
||||||
|
{
|
||||||
|
reg_SND_I2SCNT &= ~REG_SND_I2SCNT_E_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SND_I2SShutdown
|
||||||
|
|
||||||
|
Description: shutdown sound system
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void SND_I2SShutdown(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SND_BeginSleep
|
||||||
|
|
||||||
|
Description: Begin sleep
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void SND_I2SBeginSleep(void)
|
||||||
|
{
|
||||||
|
if (isTwl)
|
||||||
|
{
|
||||||
|
state = reg_SND_I2SCNT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SND_EndSleep
|
||||||
|
|
||||||
|
Description: End sleep
|
||||||
|
|
||||||
|
Arguments: None.
|
||||||
|
|
||||||
|
Returns: None.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void SND_I2SEndSleep(void)
|
||||||
|
{
|
||||||
|
if (isTwl)
|
||||||
|
{
|
||||||
|
reg_SND_I2SCNT = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SND_I2SMute
|
||||||
|
|
||||||
|
Description: Set mute status
|
||||||
|
|
||||||
|
Arguments: isMute : TRUE if mute
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void SND_I2SMute(BOOL isMute)
|
||||||
|
{
|
||||||
|
if (isTwl)
|
||||||
|
{
|
||||||
|
if (isMute)
|
||||||
|
{
|
||||||
|
reg_SND_I2SCNT |= REG_SND_I2SCNT_MUTE_MASK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reg_SND_I2SCNT &= ~REG_SND_I2SCNT_MUTE_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: SND_I2SSetMixingRatio
|
||||||
|
|
||||||
|
Description: Set output selector
|
||||||
|
|
||||||
|
Arguments: nitroRatio : NITRO / (NITRO + DSP) ratio. (0-8)
|
||||||
|
if 8, nitro sound is all.
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void SND_I2SSetMixingRatio(int nitroRatio)
|
||||||
|
{
|
||||||
|
if (isTwl)
|
||||||
|
{
|
||||||
|
if (nitroRatio >= 0 && nitroRatio <= 8)
|
||||||
|
{
|
||||||
|
reg_SND_I2SCNT &= ~REG_SND_I2SCNT_MIX_RATIO_MASK;
|
||||||
|
reg_SND_I2SCNT = (u8)((reg_SND_I2SCNT & ~REG_SND_I2SCNT_MIX_RATIO_MASK) | nitroRatio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*====== End of snd_i2s.c ======*/
|
||||||
57
include/twl/snd/ARM7/i2s.h
Normal file
57
include/twl/snd/ARM7/i2s.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - SND - include
|
||||||
|
File: i2s.h
|
||||||
|
|
||||||
|
Copyright 2004-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: i2s.h,v $
|
||||||
|
$NoKeywords: $
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef TWL_SND_COMMON_I2S_H_
|
||||||
|
#define TWL_SND_COMMON_I2S_H_
|
||||||
|
|
||||||
|
#include <twl/types.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/******************************************************************************
|
||||||
|
public macro variables
|
||||||
|
******************************************************************************/
|
||||||
|
#define SND_I2S_MIXING_NITRO_MAX 8
|
||||||
|
#define SND_I2S_MIXING_NITRO_MIN 0
|
||||||
|
#define SND_I2S_MIXING_DSP_MAX 0
|
||||||
|
#define SND_I2S_MIXING_DSP_MIN 8
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
public function declaration
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifdef SDK_ARM7
|
||||||
|
|
||||||
|
void SND_I2SEnable(void);
|
||||||
|
void SND_I2SDisable(void);
|
||||||
|
|
||||||
|
void SND_I2SShutdown(void);
|
||||||
|
|
||||||
|
void SND_I2SBeginSleep(void);
|
||||||
|
void SND_I2SEndSleep(void);
|
||||||
|
|
||||||
|
void SND_I2SMute(BOOL isMute);
|
||||||
|
|
||||||
|
void SND_I2SSetMixingRatio(int nitroRatio);
|
||||||
|
|
||||||
|
#endif /* SDK_ARM7 */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* TWL_SND_COMMON_I2S_H_ */
|
||||||
Loading…
Reference in New Issue
Block a user