1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - WM - demos - wireless-all 3 File: main.c 4 5 Copyright 2006-2008 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-09-17#$ 14 $Rev: 8556 $ 15 $Author: okubata_ryoma $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifdef SDK_TWL 19 #include <twl.h> 20 #else 21 #include <nitro.h> 22 #endif 23 24 #include "common.h" 25 26 /* 27 * This sample application implements all of the following wireless features. 28 * 29 * - DS Download Play clone booting 30 * - Data sharing 31 * - Using a file system via a wireless connection 32 * 33 * Because the MB library samples use the multiboot functionality, multiple development units with the same communications environment (wired or wireless) are required. 34 * 35 * The mb_child.bin program in the directory $NitroSDK/bin/ARM9-TS/Release/ is a sample providing the same features as the multiboot child in the final commercial unit. Load this binary into other development units using the same method as for sample programs, and execute them together. 36 * 37 * 38 * 39 * 40 * 41 */ 42 43 /******************************************************************************/ 44 /* Functions */ 45 46 /*---------------------------------------------------------------------------* 47 Name: NitroMain / TwlMain 48 49 Description: Main routine. 50 51 Arguments: None. 52 53 Returns: None. 54 *---------------------------------------------------------------------------*/ 55 #ifdef SDK_TWL TwlMain(void)56void TwlMain(void) 57 #else 58 void NitroMain(void) 59 #endif 60 { 61 /* Common system initialization process */ 62 InitCommon(); 63 64 /* Overall state transition */ 65 for (;;) 66 { 67 /* DS Download Play process, if parent */ 68 if (!MB_IsMultiBootChild()) 69 { 70 ExecuteDownloadServer(); 71 } 72 /* Wireless initialization and separate parent/child startup processes */ 73 if (!MB_IsMultiBootChild()) 74 { 75 #if !defined(MBP_USING_MB_EX) 76 if (!WH_Initialize()) 77 { 78 OS_Panic("WH_Initialize failed."); 79 } 80 #endif 81 WaitWHState(WH_SYSSTATE_IDLE); 82 StartWirelessParent(); 83 } 84 else 85 { 86 if (!WH_Initialize()) 87 { 88 OS_Panic("WH_Initialize failed."); 89 } 90 WaitWHState(WH_SYSSTATE_IDLE); 91 StartWirelessChild(); 92 } 93 /* Main process for data sharing */ 94 ExecuteDataSharing(); 95 (void)WH_End(); 96 WaitWHState(WH_SYSSTATE_STOP); 97 } 98 99 /* Control should not arrive here */ 100 OS_Terminate(); 101 } 102