From 11e95b591c8538a50ffda09c66d70824bb41abd9 Mon Sep 17 00:00:00 2001 From: yutaka Date: Tue, 10 Jul 2007 00:54:50 +0000 Subject: [PATCH] add a test for OS_Sleep. CDC is using OS_Sleep again and tests are fixed. git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@184 4ee2a332-4b2b-5046-8439-1ba90f034370 --- build/libraries/cdc/ARM7/src/cdc_api.c | 2 - build/tests/os/Makefile | 3 +- build/tests/os/sleep-1/ARM7/Makefile | 44 ++++++++++++ build/tests/os/sleep-1/ARM7/src/main.c | 96 +++++++++++++++++++++++++ build/tests/os/sleep-1/ARM9/Makefile | 43 +++++++++++ build/tests/os/sleep-1/ARM9/src/main.c | 60 ++++++++++++++++ build/tests/os/sleep-1/Makefile | 32 +++++++++ build/tests/snd/capture/ARM7/src/main.c | 14 ++-- build/tests/snd/channel/ARM7/src/main.c | 14 ++-- 9 files changed, 291 insertions(+), 17 deletions(-) create mode 100644 build/tests/os/sleep-1/ARM7/Makefile create mode 100644 build/tests/os/sleep-1/ARM7/src/main.c create mode 100644 build/tests/os/sleep-1/ARM9/Makefile create mode 100644 build/tests/os/sleep-1/ARM9/src/main.c create mode 100644 build/tests/os/sleep-1/Makefile diff --git a/build/libraries/cdc/ARM7/src/cdc_api.c b/build/libraries/cdc/ARM7/src/cdc_api.c index a2dfd39..9e9b77a 100644 --- a/build/libraries/cdc/ARM7/src/cdc_api.c +++ b/build/libraries/cdc/ARM7/src/cdc_api.c @@ -18,8 +18,6 @@ #include "pm_pmic.h" -#define OS_Sleep(msec) OS_SpinWait(((msec)*(HW_CPU_CLOCK/1000))&~3) - //#define MEASUREMENT_BY_TICK #ifdef MEASUREMENT_BY_TICK #include diff --git a/build/tests/os/Makefile b/build/tests/os/Makefile index 224ecec..0b69ebc 100644 --- a/build/tests/os/Makefile +++ b/build/tests/os/Makefile @@ -20,7 +20,8 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs #---------------------------------------------------------------------------- -SUBDIRS = alarm-1 +SUBDIRS = alarm-1 \ + sleep-1 \ #---------------------------------------------------------------------------- diff --git a/build/tests/os/sleep-1/ARM7/Makefile b/build/tests/os/sleep-1/ARM7/Makefile new file mode 100644 index 0000000..927d172 --- /dev/null +++ b/build/tests/os/sleep-1/ARM7/Makefile @@ -0,0 +1,44 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - OS - demos - sleep-1 +# 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/os/sleep-1/ARM7/src/main.c b/build/tests/os/sleep-1/ARM7/src/main.c new file mode 100644 index 0000000..2e9ae17 --- /dev/null +++ b/build/tests/os/sleep-1/ARM7/src/main.c @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - OS - demos - sleep-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 + +#define OSi_IDLE_CHECKNUM_SIZE ( sizeof(u32)*2 ) +#define OSi_IDLE_SVC_SIZE ( sizeof(u32)*16 ) // arm7 svc stacks 14 words +#define OSi_IDLE_THREAD_STACK_SIZE ( OSi_IDLE_CHECKNUM_SIZE + OSi_IDLE_SVC_SIZE ) +extern u32 OSi_IdleThreadStack[OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32)]; +extern OSThread OSi_IdleThread; + +/*---------------------------------------------------------------------------* + Name: OSi_IdleThreadProc + + Description: procedure of idle thread which system creates + + Arguments: None + + Returns: None (never return) + *---------------------------------------------------------------------------*/ +static void OSi_IdleThreadProc(void *) +{ + (void)OS_EnableInterrupts(); + while (1) + { + OS_Halt(); + } + // never return +} + +/*---------------------------------------------------------------------------* + Name: TwlSpMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void TwlSpMain() +{ + u16 trg; + u16 old = 0; + + OS_Init(); + + OS_Printf("ARM7 starts.\n"); + + // create idle thread to sleep in main thread + OS_CreateThread(&OSi_IdleThread, + OSi_IdleThreadProc, + (void *)NULL, + OSi_IdleThreadStack + OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32), + OSi_IDLE_THREAD_STACK_SIZE, + OS_THREAD_PRIORITY_MAX /*pseudo. change at next line. */ ); + OSi_IdleThread.priority = OS_THREAD_PRIORITY_MAX + 1; // lower priority than the lowest (=OS_THREAD_PRIORITY_MAX) + OSi_IdleThread.state = OS_THREAD_STATE_READY; + + OS_InitTick(); + OS_InitAlarm(); + OS_EnableIrq(); + OS_EnableInterrupts(); + + while (1) + { + u16 pad = PAD_Read(); + trg = (u16)(pad & ~old); + old = pad; + if (trg & PAD_BUTTON_A) + { + OS_TPrintf("call OS_Sleep(1000) ..."); + OS_Sleep(1000); + OS_TPrintf(" Done.\n"); + } + if (trg & PAD_BUTTON_START) + { + break; + } + } + + // done + OS_TPrintf("\nARM7 ends.\n"); + OS_Terminate(); +} diff --git a/build/tests/os/sleep-1/ARM9/Makefile b/build/tests/os/sleep-1/ARM9/Makefile new file mode 100644 index 0000000..8ab2e82 --- /dev/null +++ b/build/tests/os/sleep-1/ARM9/Makefile @@ -0,0 +1,43 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - OS - demos - sleep-1 +# 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/os/sleep-1/ARM9/src/main.c b/build/tests/os/sleep-1/ARM9/src/main.c new file mode 100644 index 0000000..f07d693 --- /dev/null +++ b/build/tests/os/sleep-1/ARM9/src/main.c @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - OS - demos - sleep-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 + +/*---------------------------------------------------------------------------* + Name: TwlMain + + Description: main + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void TwlMain() +{ + u16 trg; + u16 old = 0; + + OS_Init(); + + OS_Printf("ARM9 starts.\n"); + + OS_InitTick(); + OS_InitAlarm(); + OS_EnableIrq(); + + while (1) + { + u16 pad = PAD_Read(); + trg = (u16)(pad & ~old); + old = pad; + if (trg & PAD_BUTTON_A) + { + OS_TPrintf("call OS_Sleep(1000) ..."); + OS_Sleep(1000); + OS_TPrintf(" Done.\n"); + } + if (trg & PAD_BUTTON_START) + { + break; + } + } + + // done + OS_TPrintf("\nARM9 ends.\n"); + OS_Terminate(); +} diff --git a/build/tests/os/sleep-1/Makefile b/build/tests/os/sleep-1/Makefile new file mode 100644 index 0000000..078ec37 --- /dev/null +++ b/build/tests/os/sleep-1/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 ===== diff --git a/build/tests/snd/capture/ARM7/src/main.c b/build/tests/snd/capture/ARM7/src/main.c index f8cd4a9..eacd652 100644 --- a/build/tests/snd/capture/ARM7/src/main.c +++ b/build/tests/snd/capture/ARM7/src/main.c @@ -53,6 +53,13 @@ void TwlSpMain(void) // ヒープ領域設定 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); @@ -63,13 +70,6 @@ void TwlSpMain(void) // ボタン入力サーチ初期化 (void)PAD_InitXYButton(); - // 割込み許可 - (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(); - // SPI初期化 SPI_Init(THREAD_PRIO_SPI); diff --git a/build/tests/snd/channel/ARM7/src/main.c b/build/tests/snd/channel/ARM7/src/main.c index a5451b5..f717d7a 100644 --- a/build/tests/snd/channel/ARM7/src/main.c +++ b/build/tests/snd/channel/ARM7/src/main.c @@ -55,6 +55,13 @@ void TwlSpMain(void) // ヒープ領域設定 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); @@ -73,13 +80,6 @@ void TwlSpMain(void) // ボタン入力サーチ初期化 (void)PAD_InitXYButton(); - // 割込み許可 - (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(); - // SPI初期化 SPI_Init(THREAD_PRIO_SPI);