1 /*---------------------------------------------------------------------------*
2   Project:    Revolution alarm demo
3   File:       alarm.c
4   Programmer: HIRATSU Daisuke
5 
6   Copyright 2006 Nintendo.  All rights reserved.
7 
8   These coded instructions, statements, and computer programs contain
9   proprietary information of Nintendo of America Inc. and/or Nintendo
10   Company Ltd., and are protected by Federal copyright law.  They may
11   not be disclosed to third parties or copied or duplicated in any form,
12   in whole or in part, without the prior written consent of Nintendo.
13 
14   $Log: alarm.c,v $
15   Revision 1.1  07/04/2006 08:55:21  hiratsu
16   This demo tells how to use OSSet/GetAlarmUserData().
17 
18 
19   $NoKeywords: $
20  *---------------------------------------------------------------------------*/
21 
22 #include <revolution.h>
23 
24 #define ALARMS  3
25 
26 
handler(OSAlarm * alarm,OSContext *)27 static void handler(OSAlarm* alarm, OSContext*)
28 {
29     char *msg = (char*)OSGetAlarmUserData( alarm );
30     OSReport( "Message: %s\n", msg );
31 }
32 
33 
main(void)34 int main(void)
35 {
36     int i = 0;
37     OSAlarm alarm[ALARMS];
38     const char* MSG[ALARMS] = { "1st alarm", "2nd alarm", "last alarm" };
39 
40     for(i = 0; i < ALARMS; ++i)
41     {
42         OSCreateAlarm( &alarm[i] );
43         OSSetAlarmUserData( &alarm[i], (void*)MSG[i] );
44         OSSetAlarm( &alarm[i], OSSecondsToTicks( i+1 ), handler );
45     }
46 
47     while(1)
48       ;
49 
50     return 0;  // Never reach here.
51 }
52