1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - OS - demos - message-1
3 File: main.c
4
5 Copyright 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-04-02#$
14 $Rev: 5266 $
15 $Author: yada $
16 *---------------------------------------------------------------------------*/
17 #include <nitro.h>
18
19 #define STACK_SIZE 1024
20 #define MESG_DEPTH 1
21 #define THREAD1_PRIO 10
22
23 OSMessage mesgBuffer[MESG_DEPTH];
24 OSMessageQueue mesgQueue;
25
26 OSThread thread1;
27 u64 stack1[STACK_SIZE / sizeof(u64)];
28
29 void proc1(void *arg);
30
31 //================================================================================
32 /*---------------------------------------------------------------------------*
33 Name: NitroMain
34
35 Description: main
36
37 Arguments: None
38
39 Returns: None
40 *---------------------------------------------------------------------------*/
NitroMain(void)41 void NitroMain(void)
42 {
43 s32 n;
44
45 OS_Init();
46 OS_InitThread();
47
48 OS_InitMessageQueue(&mesgQueue, &mesgBuffer[0], MESG_DEPTH);
49
50 OS_CreateThread(&thread1, proc1, NULL, stack1 + STACK_SIZE / sizeof(u64), STACK_SIZE, THREAD1_PRIO);
51 OS_WakeupThreadDirect(&thread1);
52
53 for( n=0; n<5; n++ )
54 {
55 OSMessage message = (OSMessage)0x12345;
56
57 OS_Printf("send message = %x\n", message);
58 (void)OS_SendMessage(&mesgQueue, message, OS_MESSAGE_BLOCK);
59 }
60
61 OS_Printf("==== Finish sample.\n");
62 OS_Terminate();
63 }
64
65 //--------------------------------------------------------------------------------
66 // proc1
67 //
proc1(void * arg)68 void proc1(void *arg)
69 {
70 #pragma unused(arg)
71 while (1)
72 {
73 OSMessage message;
74
75 (void)OS_ReceiveMessage(&mesgQueue, &message, OS_MESSAGE_BLOCK);
76 OS_Printf("recv message = %x\n", message);
77 }
78 }
79
80 /*====== End of main.c ======*/
81