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
This commit is contained in:
yutaka 2007-07-10 00:54:50 +00:00
parent 305eece949
commit 11e95b591c
9 changed files with 291 additions and 17 deletions

View File

@ -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 <twl/vlink.h>

View File

@ -20,7 +20,8 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = alarm-1
SUBDIRS = alarm-1 \
sleep-1 \
#----------------------------------------------------------------------------

View File

@ -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 =====

View File

@ -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 <twl.h>
#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();
}

View File

@ -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 =====

View File

@ -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 <twl.h>
/*---------------------------------------------------------------------------*
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();
}

View 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 =====

View File

@ -53,6 +53,13 @@ void TwlSpMain(void)
// ヒープ領域設定
heapHandle = InitializeAllocateSystem();
// Š„<C5A0>žÝ‰Â
(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();
// Š„<C5A0>žÝ‰Â
(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);

View File

@ -55,6 +55,13 @@ void TwlSpMain(void)
// ヒープ領域設定
heapHandle = InitializeAllocateSystem();
// Š„<C5A0>žÝ‰Â
(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();
// Š„<C5A0>žÝ‰Â
(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);