comparison g23m/condat/com/src/driver/rtc_obsolete.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : DRV_RTC
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This Module defines the real time clock
18 | driver interface for the G23 protocol stack.
19 MC SPR 1725, re-wrote for new driver
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef DRV_RTC_C
24 #define DRV_RTC_C
25
26 #define ENTITY_CST
27 /*==== INCLUDES ===================================================*/
28
29 #include <string.h>
30 #include "typedefs.h"
31 #include "vsi.h"
32 #include "custom.h"
33 #include "prim.h"
34 #include "gsm.h"
35 #include "tok.h"
36 #include "cst/cst.h"
37 #include "gdi.h"
38 #include "rtc.h"
39
40 #ifdef _SIMULATION_
41 #define _WINDOWS
42 #endif
43
44 #include "rvf/rvf_api.h"
45
46 #ifndef _SIMULATION_
47 #include "rtc/rtc_api.h"
48 #endif
49 #include "rtcdrv.h"
50 /*==== EXPORT =====================================================*/
51 /*==== VARIABLES ==================================================*/
52
53
54
55 /*
56 +--------------------------------------------------------------------+
57 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
58 | STATE : code ROUTINE : rtc_clock_cleared |
59 +--------------------------------------------------------------------+
60
61 PURPOSE : returns true if clcok has been reset
62
63
64 */
65 BOOL rtc_clock_cleared()
66 {
67 #ifndef _SIMULATION_
68 return RTC_RtcReset();
69 #endif /* _SIMULATION_ */
70 }
71 /*
72 +--------------------------------------------------------------------+
73 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
74 | STATE : code ROUTINE : rtc_set_time_date |
75 +--------------------------------------------------------------------+
76
77 PURPOSE : set the time and date
78
79
80 */
81 UBYTE rtc_set_time_date(T_RTC_DATE* date, T_RTC_TIME* time )
82 {
83 #ifndef _SIMULATION_
84 T_RTC_DATE_TIME time_and_date;
85
86 time_and_date.second = 0;
87 time_and_date.minute = time->minute;
88 if (time->format== RTC_TIME_FORMAT_12HOUR)
89 time_and_date.hour = (time->hour)% 12;
90 else
91 time_and_date.hour = time->hour;
92 time_and_date.second= time->second;
93 time_and_date.day = date->day;
94 time_and_date.month = date->month;
95 time_and_date.wday = 3;
96 time_and_date.year = (date->year - 2000) %100;
97 if (time->format== RTC_TIME_FORMAT_12HOUR)
98 time_and_date.mode_12_hour = TRUE;
99 else
100 time_and_date.mode_12_hour = FALSE;
101
102 time_and_date.PM_flag = time->PM_flag % 2;
103
104
105 return RTC_SetDateTime(time_and_date);
106 #endif /* _SIMULATION_ */
107
108 }
109 /*
110 +--------------------------------------------------------------------+
111 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
112 | STATE : code ROUTINE : rtc_get_time_date |
113 +--------------------------------------------------------------------+
114
115 PURPOSE : get the time and date
116
117
118 */
119 UBYTE rtc_get_time_date(T_RTC_DATE* date , T_RTC_TIME* time)
120 {
121 #ifndef _SIMULATION_
122 T_RTC_DATE_TIME time_and_date;
123
124 if (RTC_GetDateTime(&time_and_date) != RVF_OK)
125 DRV_INTERNAL_ERROR; /*error*/
126 date->year = 2000+ time_and_date.year;
127 date->month = time_and_date.month;
128 date->day = time_and_date.day;
129
130 time->minute = time_and_date.minute;
131 time->hour = time_and_date.hour;
132 time->second = time_and_date.second;
133 if ( time_and_date.mode_12_hour == TRUE)
134 time->format = RTC_TIME_FORMAT_12HOUR;
135 else
136 time->format = RTC_TIME_FORMAT_24HOUR;
137 time->PM_flag = time_and_date.PM_flag;
138 return DRV_OK;
139 #endif /* _SIMULATION_ */
140 }
141
142 void empty_callback_func(void* data)
143 {
144 TRACE_EVENT("empty_callback_func");
145
146 }
147
148 /*
149 +--------------------------------------------------------------------+
150 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
151 | STATE : code ROUTINE : rtc_set_alarm |
152 +--------------------------------------------------------------------+
153
154 PURPOSE : set the alarm
155
156
157 */
158 UBYTE rtc_set_alarm(T_RTC_DATE* date , T_RTC_TIME* time, RtcCallback callback_func )
159 {
160 #ifndef _SIMULATION_
161 T_RTC_DATE_TIME time_and_date;
162 T_RV_RETURN return_path;
163
164 memset(&return_path, 0, sizeof(T_RV_RETURN));
165
166
167 time_and_date.second = time->second;
168 time_and_date.minute = time->minute;
169 if (time->format== RTC_TIME_FORMAT_12HOUR)
170 time_and_date.hour = (time->hour)% 12;
171 else
172 time_and_date.hour = time->hour;
173 time_and_date.day = date->day;
174 time_and_date.month = date->month;
175 time_and_date.wday = 3;
176 time_and_date.year = (date->year - 2000) %100;
177 if (time->format== RTC_TIME_FORMAT_12HOUR)
178 time_and_date.mode_12_hour = TRUE;
179 else
180 time_and_date.mode_12_hour = FALSE;
181
182 time_and_date.PM_flag = time->PM_flag % 2;
183 return_path.addr_id = RVF_INVALID_ADDR_ID;
184 return_path.callback_func = (RtcCallback)callback_func;
185 return RTC_SetAlarm(time_and_date, return_path);
186 #endif /* _SIMULATION_ */
187 }
188 /*
189 +--------------------------------------------------------------------+
190 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
191 | STATE : code ROUTINE : rtc_get_alarm |
192 +--------------------------------------------------------------------+
193
194 PURPOSE : retrieve alarm setting
195
196
197 */
198 UBYTE rtc_get_alarm(T_RTC_DATE* date, T_RTC_TIME* time )
199 {
200 #ifndef _SIMULATION_
201 T_RTC_DATE_TIME time_and_date;
202
203 if (RTC_GetAlarm(&time_and_date) != RVF_OK)
204 DRV_INTERNAL_ERROR; /*ERROR*/
205 date->year = 2000+ time_and_date.year;
206 date->month = time_and_date.month;
207 date->day = time_and_date.day;
208
209 time->second = time_and_date.second;
210 time->minute = time_and_date.minute;
211 time->hour = time_and_date.hour;
212 if ( time_and_date.PM_flag == TRUE)
213 time->format = RTC_TIME_FORMAT_12HOUR;
214 else
215 time->format = RTC_TIME_FORMAT_24HOUR;
216 time->PM_flag = time_and_date.PM_flag;
217 return DRV_OK;
218 #endif /* _SIMULATION_ */
219 }
220
221 /*
222 +--------------------------------------------------------------------+
223 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
224 | STATE : code ROUTINE : rtc_unset_alarm |
225 +--------------------------------------------------------------------+
226
227 PURPOSE : unset alarm
228
229
230 */
231 UBYTE rtc_unset_alarm()
232 {
233 #ifndef _SIMULATION_
234 return RTC_UnsetAlarm();
235 #endif /* _SIMULATION_ */
236 }
237 /*
238 +--------------------------------------------------------------------+
239 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
240 | STATE : code ROUTINE : rtc_set_time_format |
241 +--------------------------------------------------------------------+
242
243 PURPOSE : unset alarm
244
245
246 */
247 UBYTE rtc_set_time_format(T_RTC_TIME_FORMAT format)
248 { BOOL twelve_hour;
249
250 #ifndef _SIMULATION_
251 if (format == RTC_TIME_FORMAT_12HOUR)
252 twelve_hour = TRUE;
253 else
254 twelve_hour = FALSE;
255
256 RTC_Set12HourMode(twelve_hour);
257 #endif /* _SIMULATION_ */
258
259 return DRV_OK;
260 }
261
262 /*
263 +--------------------------------------------------------------------+
264 | PROJECT : GSM-PS (6103) MODULE : DRV_RTC |
265 | STATE : code ROUTINE : vmd_primitive |
266 +--------------------------------------------------------------------+
267
268 PURPOSE : This function get the date and time.
269 and is backawrd compatible
270 if year >= 70 then 19year
271 if year < 70 then 20year
272 */
273
274 GLOBAL UBYTE rtc_read_time ( rtc_time_type *rtc_time )
275 {
276 #ifndef _SIMULATION_
277 T_RTC_DATE_TIME time_and_date;
278 if ( rtc_time EQ NULL )
279 return ( FALSE );
280
281
282
283 if (RTC_GetDateTime(&time_and_date) != RVF_OK)
284 return FALSE;
285 rtc_time->year = time_and_date.year;
286 rtc_time->month = time_and_date.month;
287 rtc_time->day = time_and_date.day;
288
289 rtc_time->minute = time_and_date.minute;
290 rtc_time->hour = time_and_date.hour;
291 rtc_time->second = time_and_date.second;
292
293 #endif /* _SIMULATION_ */
294
295 return ( TRUE );
296 }
297
298 #endif /* #ifndef DRV_RTC_C */