twl_wrapsdk/build/tests/spi/tp-auto-sampling-twl-mode/ARM7/src/main.c
kamikawa 78993181c6 CODECがTWLモードでのタッチパネルデータの取得に初対応。
ライブラリ及びサンプルを追加・更新。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@241 4ee2a332-4b2b-5046-8439-1ba90f034370
2007-08-10 02:27:15 +00:00

197 lines
5.5 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*---------------------------------------------------------------------------*
Project: TwlSDK - tests - snd - channel
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: $
*---------------------------------------------------------------------------*/
/*
TP_RequestAutoSamplingStart のテストプログラムです。
最初にキャリブレーションの処理を入れています。
画面に表示される2点をタッチしてください。
tp-auto-sampling と
tp-auto-sampling-twlmode の違いは、
  ARM7側のコードで CDC_GoDsMode() を呼ぶかどうかの違いだけです。
*/
#include <twl_sp.h>
#include <twl/cdc.h> // for DS mode
#include <twl/snd/ARM7/i2s.h>
/*---------------------------------------------------------------------------*
定数定義
*---------------------------------------------------------------------------*/
// ===== スレッド優先度 =====
#define THREAD_PRIO_SPI 2
#define THREAD_PRIO_SND 6
/*---------------------------------------------------------------------------*
内部関数定義
*---------------------------------------------------------------------------*/
static OSHeapHandle InitializeAllocateSystem(void);
static void VBlankIntr(void);
/*---------------------------------------------------------------------------*
Name: TwlSpMain
Description: Initialize and do main
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void TwlSpMain(void)
{
OSHeapHandle heapHandle;
// OS初期化
OS_Init();
OS_InitThread();
// PXI初期化、ARM9と同期
PXI_Init();
// ヒープ領域設定
heapHandle = InitializeAllocateSystem();
// 割込み許可
(void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
// サウンド初期化
SND_Init(THREAD_PRIO_SND);
/////////////////
SND_Disable();
SND_StopIntervalTimer();
//////////////////
// DS mode
// SND_Disable();
// SND_I2SSetSamplingRatio(FALSE); // 32kHz
// CDC_GoDsMode();
// SND_Enable();
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SND_MASK; // SOUND回路バグ修正 (default: off)
// reg_CFG_DS_MDFY |= REG_CFG_DS_MDFY_SDMA_MASK; // SOUND-DMAバグ修正 (default: off)
// reg_CFG_DS_EX &= ~REG_CFG_DS_EX_SDMA2_MASK; // SOUND-DMA新回路 (default: on)
// ボタン入力サーチ初期化
(void)PAD_InitXYButton();
// SPI初期化
SPI_Init(THREAD_PRIO_SPI);
while (TRUE)
{
// int i;
OS_Halt();
//---- check reset
if (OS_IsResetOccurred())
{
OS_ResetSystem();
}
}
}
/*---------------------------------------------------------------------------*
Name: InitializeAllocateSystem
Description: メモリ割当てシステムを初期化する。
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static OSHeapHandle InitializeAllocateSystem(void)
{
void *tempLo;
OSHeapHandle hh;
OS_TPrintf("OS_GetWramSubPrivArenaLo() = %p\n", OS_GetWramSubPrivArenaLo());
OS_TPrintf("OS_GetWramSubPrivArenaHi() = %p\n", OS_GetWramSubPrivArenaHi());
OS_TPrintf("OS_GetWramSubArenaLo() = %p\n", OS_GetWramSubArenaLo());
OS_TPrintf("OS_GetWramSubArenaHi() = %p\n", OS_GetWramSubArenaHi());
OS_TPrintf("OS_GetSubPrivArenaLo() = %p\n", OS_GetSubPrivArenaLo());
OS_TPrintf("OS_GetSubPrivArenaHi() = %p\n", OS_GetSubPrivArenaHi());
OS_TPrintf("call OS_SetWramSubPrivArenaHi(0x0380f980); to fix arena.\n");
OS_SetWramSubPrivArenaHi((void*)0x0380f980);
// メモリ割当て初期化
tempLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV,
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi(), 1);
// アリーナを0クリア
MI_CpuClear8(tempLo, (u32)OS_GetWramSubPrivArenaHi() - (u32)tempLo);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, tempLo);
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV,
OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaHi());
if (hh < 0)
{
OS_Panic("ARM7: Fail to create heap.\n");
}
// カレントヒープに設定
(void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh);
return hh;
}
/*---------------------------------------------------------------------------*
Name: VBlankIntr
Description: VBlank interrupt handler
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
#ifndef SDK_TEG
extern BOOL PMi_Initialized;
void PM_SelfBlinkProc(void);
static void VBlankIntr(void)
{
//---- LED blink system
if (PMi_Initialized)
{
PM_SelfBlinkProc();
}
}
#else
static void VBlankIntr(void)
{
}
#endif
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/