1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - RTC - include 3 File: type.h 4 5 Copyright 2003-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:: $ 14 $Rev:$ 15 $Author:$ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NITRO_RTC_COMMON_TYPE_H_ 19 #define NITRO_RTC_COMMON_TYPE_H_ 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /*===========================================================================*/ 26 27 #include <nitro/types.h> 28 29 /*---------------------------------------------------------------------------* 30 Constant Definitions 31 *---------------------------------------------------------------------------*/ 32 // RTC Interrupt-related Definitions 33 #define RTC_INTERRUPT_MODE_NONE 0x0 // No interrupts 34 #define RTC_INTERRUPT_MODE_32kHz 0x8 // 32 kHz standing wave output 35 #define RTC_INTERRUPT_MODE_PULSE 0x1 // Selected-frequency steady interrupt 36 #define RTC_INTERRUPT_MODE_MINUTE_EDGE 0x2 // Once-a-minute edge interrupt 37 #define RTC_INTERRUPT_MODE_MINUTE_PULSE1 0x3 // Once-a-minute steady interrupt 1 (50% duty) 38 #define RTC_INTERRUPT_MODE_ALARM 0x4 // Alarm interrupt 39 #define RTC_INTERRUPT_MODE_MINUTE_PULSE2 0x7 // Once-a-minute steady interrupt 2 40 41 #define RTC_INTERRUPT_MASK_32kHz 0x8 // Bit mask meaning current 32 kHz standing wave output is being used 42 #define RTC_INTERRUPT_MASK_PULSE 0xb // Bit mask meaning selected-frequency steady interrupt is being used 43 #define RTC_INTERRUPT_MASK_MINUTE_EDGE 0xb // Bit mask meaning once-a-minute edge interrupt is being used 44 45 // Frequency duty definitions 46 #define RTC_PULSE_DUTY_1HZ 0x01 47 #define RTC_PULSE_DUTY_2HZ 0x02 48 #define RTC_PULSE_DUTY_4HZ 0x04 49 #define RTC_PULSE_DUTY_8HZ 0x08 50 #define RTC_PULSE_DUTY_16HZ 0x10 51 /* When configured for more than one, high will be output to the interrupt signal line when all of the specified pulses become high. 52 Low will be output if any of them is low.*/ 53 54 55 /*---------------------------------------------------------------------------* 56 Structure Definitions 57 *---------------------------------------------------------------------------*/ 58 // Date structure 59 typedef struct RTCRawDate 60 { 61 u32 year:8; // Year ( 00 - 99 ) 62 u32 month:5; // Month ( 01 - 12 ) 63 u32 dummy0:3; 64 u32 day:6; // Day ( 01 - 31 ) Month / Upper limit will change with leap year 65 u32 dummy1:2; 66 u32 week:3; // Day of week ( 00 - 06 ) 67 u32 dummy2:5; 68 69 } 70 RTCRawDate; 71 72 // Time structure 73 typedef struct RTCRawTime 74 { 75 u32 hour:6; // Hour ( 00 - 23 or 00 - 11 ) 76 u32 afternoon:1; // P.M. flag in the case of 12-hour notation 77 u32 dummy0:1; 78 u32 minute:7; // Minutes ( 00 - 59 ) 79 u32 dummy1:1; 80 u32 second:7; // Second ( 00 - 59 ) 81 u32 dummy2:9; 82 83 } 84 RTCRawTime; 85 86 // Status 1 structure 87 typedef struct RTCRawStatus1 88 { 89 u16 reset:1; // W: Reset flag 90 u16 format:1; // Flag for R/W time notation (0: 12-hour notation, 1: 24-hour notation) 91 u16 dummy0:2; 92 u16 intr1:1; // R: Interrupt 1 generated flag (low will be output on the interrupt signal line) 93 u16 intr2:1; // R: Interrupt 2 generated flag (low will be output on the interrupt signal line) 94 u16 bld:1; // R: Power source voltage drop detection flag 95 u16 poc:1; // R: Power source turned on detection flag 96 u16 dummy1:8; 97 98 } 99 RTCRawStatus1; 100 101 // Status 2 structure 102 typedef struct RTCRawStatus2 103 { 104 u16 intr_mode:4; // R/W interrupt 1 selection ( RTC_INTERRUPT_MODE_* ) 105 u16 dummy0:2; 106 u16 intr2_mode:1; // R/W interrupt 2 enable flag 107 u16 test:1; // R/W test mode flag 108 u16 dummy1:8; 109 110 } 111 RTCRawStatus2; 112 113 // Alarm structure 114 typedef struct RTCRawAlarm 115 { 116 u32 week:3; // Day of week ( 00 - 06 ) 117 u32 dummy0:4; 118 u32 we:1; // Day of week setting enable flag 119 u32 hour:6; // Time ( 00 - 23 or 00 - 11 ). Hour notation depends on status 1. 120 u32 afternoon:1; // P.M. flag in the case of 12-hour notation 121 u32 he:1; // Hour setting enable flag 122 u32 minute:7; // Minutes ( 00 - 59 ) 123 u32 me:1; // Minute setting enable flag 124 u32 dummy2:8; 125 126 } 127 RTCRawAlarm; 128 129 // Pulse structure 130 typedef struct RTCRawPulse 131 { 132 u32 pulse:5; // Frequency duty flag ( RTC_PULSE_DUTY_* ) 133 u32 dummy:27; 134 135 } 136 RTCRawPulse; 137 138 // Clock adjust register structure 139 typedef struct RTCRawAdjust 140 { 141 u32 adjust:8; // Clock adjustment register ( see other documents for settings ) 142 u32 dummy:24; 143 144 } 145 RTCRawAdjust; 146 147 // Free register structure 148 typedef struct RTCRawFree 149 { 150 u32 free:8; // Free register 151 u32 dummy:24; 152 153 } 154 RTCRawFree; 155 156 // ARM9 <-> ARM7 transfer data structure (8 byte union) 157 typedef union RTCRawData 158 { 159 struct 160 { 161 RTCRawDate date; // Date 162 RTCRawTime time; // Time 163 } 164 t; 165 166 struct 167 { 168 RTCRawStatus1 status1; // Status 1 register 169 RTCRawStatus2 status2; // Status 2 register 170 union 171 { 172 RTCRawPulse pulse; // Register setting for frequency periodic interrupt 173 RTCRawAlarm alarm; // Register setting for alarm ( 1 or 2 ) 174 RTCRawAdjust adjust; // Register setting for clock adjustment 175 RTCRawFree free; // Free register setting 176 }; 177 } 178 a; 179 180 u32 words[2]; // For 4-byte access 181 182 u16 halfs[4]; // For 2-byte access 183 184 u8 bytes[8]; // For byte access 185 186 } 187 RTCRawData; 188 189 190 /*===========================================================================*/ 191 192 #ifdef __cplusplus 193 } /* extern "C" */ 194 #endif 195 196 #endif /* NITRO_RTC_COMMON_TYPE_H_ */ 197 198 /*---------------------------------------------------------------------------* 199 End of file 200 *---------------------------------------------------------------------------*/ 201