1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - OS - demos - cpuSpeed-1 3 File: main.c 4 5 Copyright 2007 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2008-12-09#$ 14 $Rev: 9589 $ 15 $Author: yada $ 16 *---------------------------------------------------------------------------*/ 17 #include <twl.h> 18 19 volatile int vCount = 0; 20 int fCount = 0; 21 22 void VBlankIntr(void); 23 24 25 /*---------------------------------------------------------------------------* 26 Name: TwlMain / NitroMain 27 28 Description: main 29 30 Arguments: None 31 32 Returns: None 33 *---------------------------------------------------------------------------*/ TwlMain(void)34void TwlMain(void) 35 { 36 SCFGCpuSpeed speed = SCFG_GetCpuSpeed(); 37 38 OS_Init(); 39 40 //---- interrupt setting 41 OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); 42 (void)OS_EnableIrqMask(OS_IE_V_BLANK); 43 (void)OS_EnableIrq(); 44 (void)GX_VBlankIntr(TRUE); 45 46 OS_Printf("*** start cpuSpeed-1 demo\n"); 47 48 while( fCount <= 30 ) 49 { 50 int count; 51 int preVCount; 52 53 count = preVCount = vCount = 0; 54 while( vCount <= 60 ) 55 { 56 if ( preVCount != vCount ) 57 { 58 static u16 prevButton = 0; 59 u16 button = PAD_Read(); 60 u16 trigger = (u16)((button ^ prevButton) & button); 61 prevButton = button; 62 63 if ( trigger & PAD_BUTTON_A ) 64 { 65 speed = (speed == SCFG_CPU_SPEED_1X)? SCFG_CPU_SPEED_2X: SCFG_CPU_SPEED_1X; 66 SCFG_SetCpuSpeed( speed ); 67 OS_Printf("speed: %s\n", (speed == SCFG_CPU_SPEED_1X)? "1X": "2X" ); 68 } 69 preVCount = vCount; 70 } 71 72 count ++; 73 } 74 75 OS_Printf( "count= %d\n", count ); 76 77 fCount ++; 78 } 79 80 OS_Printf("***End of demo\n"); 81 OS_Terminate(); 82 } 83 84 85 /*---------------------------------------------------------------------------* 86 Name: VBlankIntr 87 88 Description: main 89 90 Arguments: None 91 92 Returns: None 93 *---------------------------------------------------------------------------*/ VBlankIntr(void)94void VBlankIntr(void) 95 { 96 vCount ++; 97 98 OS_SetIrqCheckFlag(OS_IE_V_BLANK); 99 } 100 101