From af2ed6150a0fbf43a4719d3796ba87e5bc201237 Mon Sep 17 00:00:00 2001 From: kamikawa Date: Fri, 20 Jul 2007 07:16:06 +0000 Subject: [PATCH] Add sample "tp3" git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@199 4ee2a332-4b2b-5046-8439-1ba90f034370 --- build/tests/spi/tp3/ARM7/Makefile | 44 +++++++ build/tests/spi/tp3/ARM7/src/main.c | 180 ++++++++++++++++++++++++++++ build/tests/spi/tp3/ARM9/Makefile | 43 +++++++ build/tests/spi/tp3/ARM9/src/main.c | 108 +++++++++++++++++ build/tests/spi/tp3/Makefile | 32 +++++ 5 files changed, 407 insertions(+) create mode 100644 build/tests/spi/tp3/ARM7/Makefile create mode 100644 build/tests/spi/tp3/ARM7/src/main.c create mode 100644 build/tests/spi/tp3/ARM9/Makefile create mode 100644 build/tests/spi/tp3/ARM9/src/main.c create mode 100644 build/tests/spi/tp3/Makefile diff --git a/build/tests/spi/tp3/ARM7/Makefile b/build/tests/spi/tp3/ARM7/Makefile new file mode 100644 index 0000000..6becf1d --- /dev/null +++ b/build/tests/spi/tp3/ARM7/Makefile @@ -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 = main.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 ===== diff --git a/build/tests/spi/tp3/ARM7/src/main.c b/build/tests/spi/tp3/ARM7/src/main.c new file mode 100644 index 0000000..f14e3aa --- /dev/null +++ b/build/tests/spi/tp3/ARM7/src/main.c @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------* + 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: $ + *---------------------------------------------------------------------------*/ + +#include +#include // for DS mode +#include + +/*---------------------------------------------------------------------------* + 定数定義 + *---------------------------------------------------------------------------*/ +// ===== スレッド優先度 ===== + +#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); + + + // 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) + { + 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 + *---------------------------------------------------------------------------*/ diff --git a/build/tests/spi/tp3/ARM9/Makefile b/build/tests/spi/tp3/ARM9/Makefile new file mode 100644 index 0000000..b3e7032 --- /dev/null +++ b/build/tests/spi/tp3/ARM9/Makefile @@ -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 = main.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 ===== diff --git a/build/tests/spi/tp3/ARM9/src/main.c b/build/tests/spi/tp3/ARM9/src/main.c new file mode 100644 index 0000000..70dfe75 --- /dev/null +++ b/build/tests/spi/tp3/ARM9/src/main.c @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - SND - tests - 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: $ + *---------------------------------------------------------------------------*/ + +#include +#include + +void VBlankIntr(void); +void DrawPos(int x, int y); + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void TwlMain() +{ + TPData raw_point; + + // 初期化 + OS_Init(); + GX_Init(); + TP_Init(); + + // Vブランク割り込み設定 + OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); + (void)OS_EnableIrqMask(OS_IE_V_BLANK); + (void)OS_EnableIrq(); + (void)GX_VBlankIntr(TRUE); + + // Send parameter of revision noise. + if (TP_RequestSetStability(3, 15) != 0) + { + OS_Panic("SetStability request err!\n"); + } + + GX_DispOff(); + GXS_DispOff(); + + //--------------------------------------------------------------------------- + // All VRAM banks to LCDC + //--------------------------------------------------------------------------- + GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); + + //--------------------------------------------------------------------------- + // Clear all LCDC space + //--------------------------------------------------------------------------- + MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); + + //--------------------------------------------------------------------------- + // Set graphics mode VRAM display mode + //--------------------------------------------------------------------------- + GX_SetGraphicsMode(GX_DISPMODE_VRAM_A, // display VRAM-A + (GXBGMode)0, // dummy + (GXBG0As)0); // dummy + + GX_DispOn(); + GXS_DispOn(); + + while (1) + { + OS_WaitVBlankIntr(); + + if (TP_RequestRawSampling(&raw_point) == 0) + { + DrawPos(raw_point.x, raw_point.y); + } + } +} + +//-------------------------------------------------------------------------------- +// Vブランク割り込み処理 +// +void VBlankIntr(void) +{ + OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt +} + +//-------------------------------------------------------------------------------- +// 画面座標描画 +// +void DrawPos(int x, int y) +{ + const int screen_width = 256; + const int screen_height = 191; + const int axis_max = 4096; + int adjust_x = x * screen_width / axis_max; + int adjust_y = y * screen_height / axis_max; + int address = HW_LCDC_VRAM + screen_width*2*adjust_y + 2*adjust_x; + + *(u16 *)(address) = 0x7fff; +} diff --git a/build/tests/spi/tp3/Makefile b/build/tests/spi/tp3/Makefile new file mode 100644 index 0000000..078ec37 --- /dev/null +++ b/build/tests/spi/tp3/Makefile @@ -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 =====