1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - include - snd - common
3   File:     alarm.h
4 
5   Copyright 2004-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 #ifndef NITRO_SND_COMMON_ALARM_H_
19 #define NITRO_SND_COMMON_ALARM_H_
20 
21 #include <nitro/types.h>
22 #include <nitro/os.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /******************************************************************************
29 	macro definition
30  ******************************************************************************/
31 
32 #define SND_ALARM_NUM 8
33 #define SND_ALARM_MIN 0
34 #define SND_ALARM_MAX ( SND_ALARM_NUM - 1 )
35 
36 #define SND_ALARM_PRESCALER 32
37 
38 /******************************************************************************
39 	type definition
40  ******************************************************************************/
41 
42 typedef void (*SNDAlarmHandler) (void *);
43 
44 /******************************************************************************
45 	structure definition
46  ******************************************************************************/
47 
48 typedef struct SNDAlarm
49 {
50     u8      enable;
51     u8      id;
52     u8      count;
53     u8      padding;
54 
55     struct
56     {
57         OSTick  tick;
58         OSTick  period;
59     }
60     setting;
61 
62     OSAlarm alarm;
63 }
64 SNDAlarm;
65 
66 /******************************************************************************
67 	public function declaration
68  ******************************************************************************/
69 
70 void    SND_AlarmInit(void);
71 
72 #ifdef SDK_ARM7
73 
74 void    SND_SetupAlarm(int alarmNo, OSTick tick, OSTick period, int id);
75 
76 void    SND_StartAlarm(int alarmNo);
77 void    SND_StopAlarm(int alarmNo);
78 
79 #endif /* SDK_ARM7 */
80 
81 /******************************************************************************
82 	private function declaration
83  ******************************************************************************/
84 
85 #ifdef SDK_ARM9
86 
87 void    SNDi_IncAlarmId(int alarmNo);
88 
89 u8      SNDi_SetAlarmHandler(int alarmNo, SNDAlarmHandler handler, void *arg);
90 
91 void    SNDi_CallAlarmHandler(int alarmNo);
92 
93 #endif
94 
95 #ifdef __cplusplus
96 } /* extern "C" */
97 #endif
98 
99 #endif /* NITRO_SND_COMMON_ALARM_H_ */
100