1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - rtc - include
3   File:     type_ex.h
4 
5   Copyright 2007-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-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 #ifndef TWL_RTC_COMMON_TYPE_EX_H_
18 #define TWL_RTC_COMMON_TYPE_EX_H_
19 #ifdef  __cplusplus
20 extern  "C" {
21 #endif
22 /*---------------------------------------------------------------------------*/
23 
24 #include	<twl/types.h>
25 
26 /*---------------------------------------------------------------------------*
27     Constant Definitions
28  *---------------------------------------------------------------------------*/
29 /* FOUT duty definitions */
30 #define     RTC_FOUT_DUTY_1HZ         	0x0001
31 #define     RTC_FOUT_DUTY_2HZ           0x0002
32 #define     RTC_FOUT_DUTY_4HZ           0x0004
33 #define     RTC_FOUT_DUTY_8HZ           0x0008
34 #define     RTC_FOUT_DUTY_16HZ          0x0010
35 #define     RTC_FOUT_DUTY_32HZ          0x0020
36 #define     RTC_FOUT_DUTY_64HZ          0x0040
37 #define     RTC_FOUT_DUTY_128HZ         0x0080
38 #define     RTC_FOUT_DUTY_256HZ         0x0100
39 #define     RTC_FOUT_DUTY_512HZ         0x0200
40 #define     RTC_FOUT_DUTY_1KHZ          0x0400
41 #define     RTC_FOUT_DUTY_2KHZ          0x0800
42 #define     RTC_FOUT_DUTY_4KHZ          0x1000
43 #define     RTC_FOUT_DUTY_8KHZ          0x2000
44 #define     RTC_FOUT_DUTY_16KHZ         0x4000
45 #define     RTC_FOUT_DUTY_32KHZ         0x8000
46 
47 /*---------------------------------------------------------------------------*
48     Structure Definitions
49  *---------------------------------------------------------------------------*/
50 /* Up counter structure */
51 typedef union RTCRawCounter
52 {
53     struct
54     {
55         u32 count:24;   // big-endian
56         u32 dummy:8;
57     };
58 
59     u8  bytes[4];
60 }
61 RTCRawCounter;
62 
63 /* FOUT structure */
64 typedef union RTCRawFout
65 {
66     struct
67     {
68         u16 fout;
69         u16 dummy0;
70     };
71     struct
72     {
73         u8  fout2;
74         u8  fout1;
75         u16 dummy1;
76     };
77 }
78 RTCRawFout;
79 
80 /* Extended alarm structure */
81 typedef union
82 {
83     u32     year:8;            	/* Year ( 00 - 99 ) */
84     u32     month:5;            /* Month ( 01 - 12 ) */
85     u32     dummy0:1;
86     u32     ye:1;               /* Flag enabling year setting */
87     u32     me:1;               /* Flag enabling month setting */
88     u32     day:6;              /* Day ( 01 - 31 ) Month / Upper limit will change with leap year */
89     u32     dummy1:1;
90     u32     de:1;               /* Flag enabling day setting */
91     u32     dummy2:8;
92 }
93 RTCRawAlarmEx;
94 
95 /* ARM9 <-> ARM7 transfer data structure (8 byte union) */
96 typedef union RTCRawDataEx
97 {
98     struct
99     {
100         RTCRawAlarmEx alarmex;      // Extended alarm (1 or 2) register settings
101         union
102         {
103             RTCRawCounter counter;  // Up counter
104             RTCRawFout fout;        // FOUT1/FOUT2 register setting
105         };
106     }
107     a;
108 
109     u32     words[2];              	// For 4-byte access
110     u16     halfs[4];               // For 2-byte access
111     u8      bytes[8];               // For byte access
112 }
113 RTCRawDataEx;
114 
115 
116 /*---------------------------------------------------------------------------*/
117 #ifdef __cplusplus
118 }   /* extern "C" */
119 #endif
120 #endif  /* TWL_RTC_COMMON_TYPE_EX_H_ */
121