• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 *
3 *  Copyright (c) 2011, ARM Limited. All rights reserved.
4 *  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
5 *  Copyright (c) 2015, Linaro Limited. All rights reserved.
6 *
7 *  This program and the accompanying materials
8 *  are licensed and made available under the terms and conditions of the BSD License
9 *  which accompanies this distribution.  The full text of the license may be found at
10 *  http://opensource.org/licenses/bsd-license.php
11 *
12 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 *
15 *  Based on the files under ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
16 **/
17 
18 
19 #ifndef __DS3231_REAL_TIME_CLOCK_H__
20 #define __DS3231_REAL_TIME_CLOCK_H__
21 
22 #define DS3231_REGADDR_SECONDS      0x00
23 #define DS3231_REGADDR_MIUTES       0x01
24 #define DS3231_REGADDR_HOURS        0x02
25 #define DS3231_REGADDR_DAY          0x03
26 #define DS3231_REGADDR_DATE         0x04
27 #define DS3231_REGADDR_MONTH        0x05
28 #define DS3231_REGADDR_YEAR         0x06
29 #define DS3231_REGADDR_ALARM1SEC    0x07
30 #define DS3231_REGADDR_ALARM1MIN    0x08
31 #define DS3231_REGADDR_ALARM1HOUR   0x09
32 #define DS3231_REGADDR_ALARM1DAY    0x0A
33 #define DS3231_REGADDR_ALARM2MIN    0x0B
34 #define DS3231_REGADDR_ALARM2HOUR   0x0C
35 #define DS3231_REGADDR_ALARM2DAY    0x0D
36 #define DS3231_REGADDR_CONTROL      0x0E
37 #define DS3231_REGADDR_STATUS       0x0F
38 #define DS3231_REGADDR_AGOFFSET     0x10
39 #define DS3231_REGADDR_TEMPMSB      0x11
40 #define DS3231_REGADDR_TEMPLSB      0x12
41 
42 
43 typedef union {
44   struct{
45     UINT8 A1IE:1;
46     UINT8 A2IE:1;
47     UINT8 INTCN:1;
48     UINT8 RSV:2;
49     UINT8 CONV:1;
50     UINT8 BBSQW:1;
51     UINT8 EOSC_N:1;
52   }bits;
53   UINT8 u8;
54 }RTC_DS3231_CONTROL;
55 
56 typedef union {
57   struct{
58     UINT8 A1F:1;
59     UINT8 A2F:1;
60     UINT8 BSY:1;
61     UINT8 EN32KHZ:2;
62     UINT8 Rsv:3;
63     UINT8 OSF:1;
64   }bits;
65   UINT8 u8;
66 }RTC_DS3231_STATUS;
67 
68 
69 typedef union {
70   struct{
71     UINT8 Data:7;
72     UINT8 Sign:1;
73   }bits;
74   UINT8 u8;
75 }RTC_DS3231_AGOFFSET;
76 
77 typedef union {
78   struct{
79     UINT8 Data:7;
80     UINT8 Sign:1;
81   }bits;
82   UINT8 u8;
83 }RTC_DS3231_TEMPMSB;
84 
85 
86 typedef union {
87   struct{
88     UINT8 Rsv:6;
89     UINT8 Data:2;
90   }bits;
91   UINT8 u8;
92 }RTC_DS3231_TEMPLSB;
93 
94 typedef union {
95   struct{
96     UINT8 Seconds:4;
97     UINT8 Seconds10:3;
98     UINT8 Rsv:1;
99   }bits;
100   UINT8 u8;
101 }RTC_DS3231_SECONDS;
102 
103 typedef union {
104   struct{
105     UINT8 Minutes:4;
106     UINT8 Minutes10:3;
107     UINT8 Rsv:1;
108   }bits;
109   UINT8 u8;
110 }RTC_DS3231_MINUTES;
111 
112 typedef union {
113   struct{
114     UINT8 Hour:4;
115     UINT8 Hours10:1;
116     UINT8 PM_20Hours:1;
117     UINT8 Hour24_n:1;
118     UINT8 Rsv:1;
119   }bits;
120   UINT8 u8;
121 }RTC_DS3231_HOURS;
122 
123 typedef union {
124   struct{
125     UINT8 Day:3;
126     UINT8 Rsv:5;
127   }bits;
128   UINT8 u8;
129 }RTC_DS3231_DAY;
130 
131 typedef union {
132   struct{
133     UINT8 Month:4;
134     UINT8 Month10:1;
135     UINT8 Rsv:2;
136     UINT8 Century:1;
137   }bits;
138   UINT8 u8;
139 }RTC_DS3231_MONTH;
140 
141 typedef union {
142   struct{
143     UINT8 Year:4;
144     UINT8 Year10:4;
145   }bits;
146   UINT8 u8;
147 }RTC_DS3231_YEAR;
148 
149 typedef union {
150   struct{
151     UINT8 Seconds:4;
152     UINT8 Seconds10:3;
153     UINT8 A1M1:1;
154   }bits;
155   UINT8 u8;
156 }RTC_DS3231_ALARM1SEC;
157 
158 typedef union {
159   struct{
160     UINT8 Minutes:4;
161     UINT8 Minutes10:3;
162     UINT8 A1M2:1;
163   }bits;
164   UINT8 u8;
165 }RTC_DS3231_ALARM1MIN;
166 
167 typedef union {
168   struct{
169     UINT8 Hour:4;
170     UINT8 Hours10:1;
171     UINT8 PM_20Hours:1;
172     UINT8 Hours24:1;
173     UINT8 A1M3:1;
174   }bits;
175   UINT8 u8;
176 }RTC_DS3231_ALARM1HOUR;
177 
178 #endif
179