dcl_rtc.h
33.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* dcl_rtc.h
*
* Project:
* --------
* Maui
*
* Description:
* ------------
* Header file of DCL (Driver Common Layer) for RTC.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifdef DCL_DEFINITION_STRUCT
#ifndef __DCL_RTC_H_STRUCT__
#define __DCL_RTC_H_STRUCT__
/*******************************************************************************
* DCL_OPTIONS for RTC
*******************************************************************************/
#define RTC_OPTIONS
/*******************************************************************************
* DCL_CONFIGURE_T for RTC
*******************************************************************************/
#define RTC_CONFIGS
/*******************************************************************************
* DCL_EVENT for RTC
*******************************************************************************/
#define RTC_EVENTS \
EVENT_RTC_ALARM = 0x00000001,\
EVENT_RTC_TC = 0x00000002,
/*******************************************************************************
* DCL_CTRL_CMD for RTC
*******************************************************************************/
#ifdef __BUILD_DOM__
/* The RTC Command Values in DCL_CTRL_CMD_T Enum of dcl.h */
typedef enum {
RTC_CMD_BOOTLOADER_POWERON, /* For RTC Bootloader Power On */
RTC_CMD_CLEAR_PDN_BITS, /* To Clear RTC PDN Bits */
RTC_CMD_CONFIG_AL_TC, /* To Configure the RTC Interrupt */
RTC_CMD_DELAY, /* To Delay */
RTC_CMD_FT_POWEROFF, /* For Flash Tool Power Off */
RTC_CMD_GET_ALARM_TIME, /* To Get Alarm Time */
RTC_CMD_GET_TIME, /* To Get Time*/
RTC_CMD_GPIO_GET_INPUT, /* To Get GPIO Input */
RTC_CMD_GPIO_SET_EXPORT_32K, /* To Set Export 32K for GPIO */
RTC_CMD_GPIO_SET_EXPORT_COREDETB, /* To Set Export COREDETB for GPIO */
RTC_CMD_GPIO_SET_INPUT_MODE, /* To Set GPIO Input Mode */
RTC_CMD_GPIO_SET_OUTPUT_MODE, /* To Set GPIO Output Mode */
RTC_CMD_HW_INIT, /* To Initialize RTC HW */
RTC_CMD_INIT, /* To Initialize RTC SW */
RTC_CMD_INIT_TC_AL_INTR, /* To Initialize RTC SW (RTC_TCintr,RTC_ALintr) */
RTC_CMD_IS_CONFIG_VALID, /* To Check If RTC Configure Valid or Not */
RTC_CMD_IS_FIRST_ON, /* To Check If RTC Is First On or Not */
RTC_CMD_IS_MS_FIRSTPOWERON, /* To Check If RTC Is First On or Not (for MMI Only) */
RTC_CMD_IS_TIME_VALID, /* To Check If RTC Time Is Valid or Not */
RTC_CMD_PWIC_CHECK_POWERON, /* To Check RTC Power On (for PWIC Only) */
RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME, /* To Initialize RTC Time When First Power On (for PWIC Only) */
RTC_CMD_PWIC_MASK_AL, /* To Diable All Alarm Mask (for PWIC Only) */
RTC_CMD_PWIC_POWEROFF_RTC_INIT, /* To Do RTC Initalize When Power Off (for PWIC Only) */
RTC_CMD_PWIC_POWERON_RTC_INIT, /* To Do RTC Initalize When Power On (for PWIC Only) */
RTC_CMD_READ_PDN_BITS, /* To Read RTC PDN Bits */
RTC_CMD_READ_SPAR, /* To Read SPAR Register */
RTC_CMD_RELOAD, /* To Do RTC Reload */
RTC_CMD_SET_ALARM_TIME, /* To Set Alarm Time */
RTC_CMD_SET_FIRST_POWERON, /* To Set First Power On */
RTC_CMD_SET_PDN_BITS, /* To Set RTC PDN Bits */
RTC_CMD_SET_PWR_KEY, /* To Set Power Key */
RTC_CMD_SET_TIME, /* To Set Time */
RTC_CMD_SETBBPU, /* To Set BBPU */
RTC_CMD_SETXOSC, /* To Set XOSC */
RTC_CMD_START_CALI, /* To Start Calibration */
RTC_CMD_WAIT_DEBOUNCE, /* To Wait De-bounce */
RTC_CMD_WRITE_PDN_BITS, /* To Write RTC PDN Bits */
RTC_CMD_WRITE_SPAR, /* To Write SPAR Register */
RTC_CMD_WRITE_TRIGGER, /* To Set Write Trigger */
RTC_CMD_WRITE_TRIGGER_WAIT, /* To Set Write Trigger And Wait */
RTC_CMD_PROT_UNLOCK, /* To Unlock RTC PROT */
RTC_CMD_REGISTER_MODULE_TO_SEND_RTCTIME, /* To register ilm infomation by other modules to request RTC time */
} DCL_CTRL_CMD_T;
#else /* __BUILD_DOM__ */
#define RTC_CMDS \
RTC_CMD_BOOTLOADER_POWERON, \
RTC_CMD_CLEAR_PDN_BITS, \
RTC_CMD_CONFIG_AL_TC, \
RTC_CMD_DELAY, \
RTC_CMD_FT_POWEROFF, \
RTC_CMD_GET_ALARM_TIME, \
RTC_CMD_GET_TIME, \
RTC_CMD_GPIO_GET_INPUT, \
RTC_CMD_GPIO_SET_EXPORT_32K, \
RTC_CMD_GPIO_SET_EXPORT_COREDETB, \
RTC_CMD_GPIO_SET_INPUT_MODE, \
RTC_CMD_GPIO_SET_OUTPUT_MODE, \
RTC_CMD_HW_INIT, \
RTC_CMD_INIT, \
RTC_CMD_INIT_TC_AL_INTR, \
RTC_CMD_IS_CONFIG_VALID,\
RTC_CMD_IS_FIRST_ON, \
RTC_CMD_IS_MS_FIRSTPOWERON, \
RTC_CMD_IS_TIME_VALID, \
RTC_CMD_PWIC_CHECK_POWERON, \
RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME, \
RTC_CMD_PWIC_MASK_AL, \
RTC_CMD_PWIC_POWEROFF_RTC_INIT, \
RTC_CMD_PWIC_POWERON_RTC_INIT, \
RTC_CMD_READ_PDN_BITS, \
RTC_CMD_READ_SPAR, \
RTC_CMD_RELOAD, \
RTC_CMD_SET_ALARM_TIME, \
RTC_CMD_SET_FIRST_POWERON, \
RTC_CMD_SET_PDN_BITS, \
RTC_CMD_SET_PWR_KEY, \
RTC_CMD_SET_TIME, \
RTC_CMD_SETBBPU, \
RTC_CMD_SETXOSC, \
RTC_CMD_START_CALI, \
RTC_CMD_WAIT_DEBOUNCE, \
RTC_CMD_WRITE_PDN_BITS, \
RTC_CMD_WRITE_SPAR, \
RTC_CMD_WRITE_TRIGGER, \
RTC_CMD_WRITE_TRIGGER_WAIT, \
RTC_CMD_PROT_UNLOCK, \
RTC_CMD_REGISTER_MODULE_TO_SEND_RTCTIME,
#endif /* __BUILD_DOM__ */
/*******************************************************************************
* Define the Data and Time Interrupt Control Bit
*******************************************************************************/
/* Y:Year, M:Month, W:DOW, D:DOM, H:Hour, M:Min, S:SEC */
/* Alarm Enable None */
#define AL_EN_None 0
/* Alarm Enable Check Sec */
#define AL_EN_ChkS 1
/* Alarm Enable Check Min & Sec */
#define AL_EN_ChkMS 2
/* Alarm Enable Check Hour, Min & Sec */
#define AL_EN_ChkHMS 3
/* Alarm Enable Check DOM, Hour, Min & Sec */
#define AL_EN_ChkDHMS 4
/* Alarm Enable Check DOW, Hour, Min & Sec */
#define AL_EN_ChkWHMS 5
/* Alarm Enable Check Month, DOM, Hour, Min & Sec */
#define AL_EN_ChkMDHMS 6
/* Alarm Enable Check Year, Month, DOM, Hour, Min & Sec */
#define AL_EN_ChkYMDHMS 7
/* Alarm Enable No Change */
#define AL_EN_NoChange 8
/* Time Counter Enable None */
#define TC_EN_None 0
/* Time Counter Enable Check Sec */
#define TC_EN_ChkS 1
/* Time Counter Enable Check Min & Sec */
#define TC_EN_ChkM 2
/* Time Counter Enable Check Hour, Min & Sec */
#define TC_EN_ChkH 3
/* Time Counter Enable Check DOM, Hour, Min & Sec */
#define TC_EN_ChkD 4
/* Time Counter Enable Check DOW, Hour, Min & Sec */
#define TC_EN_ChkW 5
/* Time Counter Enable Check Month, DOM, Hour, Min & Sec */
#define TC_EN_ChkMon 6
/* Time Counter Enable Check Year, Month, DOM, Hour, Min & Sec */
#define TC_EN_ChkY 7
/* Time Counter Enable No Change */
#define TC_EN_NoChange 8
/*******************************************************************************
* RTC PDN Bits Definitions
*******************************************************************************/
/* PDN 1 Bit[7], META Reset RTC */
#define DRV_COMM_REG1_META_RESET_RTC 0x0080
/* PDN 2 Bit[7], Normal Reset */
#define DRV_COMM_REG2_NORMAL_RESET 0x0080
/* PDN 2 Bit[6], Charge Power On */
#define DRV_COMM_REG2_CHRPWRON 0x0040
/* PDN 2 Bit[5], USB Mass Storage Power On */
#define DRV_COMM_REG2_USBMS_PWRON 0x0020
/* PDN 2 Bit[4], RTC Power On */
#define DRV_COMM_REG2_RTCPWRON 0x0010
/* PDN 2 Bit[3], USB Mass Storage Power Off */
#define DRV_COMM_REG2_USBMS_PWROFF 0x0008
/* PDN 2 Bit[2], RTC NVRAM Valid */
#define DRV_COMM_REG2_RTC_NVRAM 0x0004
/* PDN 2 Bit[1], Swich To IDLE Power On */
#define DRV_COMM_REG2_SWITCH2IDLE_PWRON 0x0002
/* PDN 2 Bit[0], BTMT Watchdog Reset Power On */
#define DRV_COMM_REG2_BTMT_WDTRET_PWRON 0x0001
/* Reserved for bootrom security, support it after 6227 */
#if defined(DRV_RTC_COMM_REG1_SECURITY)
/* Bootrom Security 1 */
#define DRV_COMM_REG1_BOOTROM_SECURITY1 0x0001
/* Bootrom Security 2 */
#define DRV_COMM_REG1_BOOTROM_SECURITY2 0x0010
/* Bootrom Security 3 */
#define DRV_COMM_REG1_BOOTROM_SECURITY3 0x0020
/* Bootrom Security 4 */
#define DRV_COMM_REG1_BOOTROM_SECURITY4 0x0040
#endif
/* RTC PDN1, use RTC INFO1 as DRV_COMM_REG1 */
#define DRV_COMM_REG1 (RTC_base+0x0058)
/* RTC PDN1, use RTC INFO2 as DRV_COMM_REG2 */
#define DRV_COMM_REG2 (RTC_base+0x005c)
/*******************************************************************************
* DCL_CTRL_DATA_T: Define the Control data structure for each module's command
*******************************************************************************/
/* RTC Data Stucture for Save Information Only (Cannot be used for function's parameter) */
typedef struct
{
DCL_UINT8 rtc_sec; /* Seconds after the minute - [0,59] */
DCL_UINT8 rtc_min; /* Minutes after the hour - [0,59] */
DCL_UINT8 rtc_hour; /* Hours after the midnight - [0,23] */
DCL_UINT8 rtc_day; /* Day of the month - [1,31] */
DCL_UINT8 rtc_mon; /* Months - [1,12] */
DCL_UINT8 rtc_wday; /* Days in a week - [1,7] */
DCL_UINT8 rtc_year; /* Years - [0,127] */
}DCL_RTC_DATA_T;
/* For RTC_CMD_BOOTLOADER_POWERON command. */
typedef struct
{
DCL_BOOLEAN fgBootloaderPowerOn; /* Output : TRUE: Indicate Device Is First On; FALSE: Device Is Not First On */
}RTC_CTRL_BOOTLOADER_POWERON_T;
/* Enum of PDN Registers */
typedef enum
{
DCL_RTC_PDN1 = 0, /* PDN1 */
DCL_RTC_PDN2, /* PDN2 */
DCL_RTC_MAX_INDEX /* Maximum PDN Register */
}DCL_RTC_PDN_INDEX_T;
/* For RTC_CMD_CLEAR_PDN_BITS, RTC_CMD_READ_PDN_BITS, RTC_CMD_SET_PDN_BITS, RTC_CMD_WRITE_PDN_BITS commands. */
typedef struct
{
DCL_RTC_PDN_INDEX_T PDNIndex; /* Input : Number of PDN Register */
DCL_UINT16 fgConfigBit; /* Input : PDN Bit for Configuration */
DCL_UINT16 PDNValue; /* Output : Value of PDN Register */
}RTC_CTRL_CONFIG_PDN_BIT_T;
/* For RTC_CMD_CONFIG_AL_TC command. */
typedef struct
{
DCL_UINT8 u1ALEn; /* Input : Alarm Enable */
DCL_UINT8 u1TCEn; /* Input : Time Counter Enable */
}RTC_CTRL_CONFIG_AL_TC_T;
/* For RTC_CMD_DELAY command. */
// RTC_CMD_DELAY does NOT need parameters
/* For RTC_CMD_FT_POWEROFF command. */
typedef struct
{
DCL_BOOLEAN fgMetaReset; /* Output : If DRV_COMM_REG1_META_RESET_RTC set or not*/
}RTC_CTRL_FT_POWEROFF_T;
/* For RTC_CMD_GET_ALARM_TIME command. */
typedef struct
{
DCL_UINT8 u1Sec; /* Output : Seconds after the minute - [0,59] */
DCL_UINT8 u1Min; /* Output : Minutes after the hour - [0,59] */
DCL_UINT8 u1Hour; /* Output : Hours after the midnight - [0,23] */
DCL_UINT8 u1Day; /* Output : Day of the month - [1,31] */
DCL_UINT8 u1Mon; /* Output : Months - [1,12] */
DCL_UINT8 u1WDay; /* Output : Days in a week - [1,7] */
DCL_UINT8 u1Year; /* Output : Years - [0,127] */
DCL_BOOLEAN ALEnBit; /* Output : The status of AL enable bit of RTC_IRQ_EN */
}RTC_CTRL_GET_ALARM_TIME_T;
/* For RTC_CMD_GET_TIME command. */
typedef struct
{
DCL_UINT8 u1Sec; /* Output : Seconds after the minute - [0,59] */
DCL_UINT8 u1Min; /* Output : Minutes after the hour - [0,59] */
DCL_UINT8 u1Hour; /* Output : Hours after the midnight - [0,23] */
DCL_UINT8 u1Day; /* Output : Day of the month - [1,31] */
DCL_UINT8 u1Mon; /* Output : Months - [1,12] */
DCL_UINT8 u1WDay; /* Output : Days in a week - [1,7] */
DCL_UINT8 u1Year; /* Output : Years - [0,127] */
}RTC_CTRL_GET_TIME_T;
/* For RTC GPIO Pulling Type */
typedef enum {
DCL_RTC_GPIO_NO_PULL = 0, /* No Pull */
DCL_RTC_GPIO_PULL_DOWN, /* Pull Down */
DCL_RTC_GPIO_PULL_UP /* Pull Up */
}DCL_RTC_GPIO_PULL_TYPE_T;
/* For RTC GPIO Driving Strength */
typedef enum {
DCL_RTC_GPIO_DS_4mA = 0, /* 4mA */
DCL_RTC_GPIO_DS_8mA, /* 8mA */
DCL_RTC_GPIO_DS_12mA, /* 12mA */
DCL_RTC_GPIO_DS_16mA /* 16mA */
}DCL_RTC_GPIO_DRIVING_STRENGTH_T;
/* For RTC_CMD_GPIO_CONFIG_MODE command. */
typedef struct
{
DCL_RTC_GPIO_PULL_TYPE_T rPullType; /* Input : Pull Type */
DCL_RTC_GPIO_DRIVING_STRENGTH_T rPullStrength; /* Input : Drving Strength */
DCL_BOOLEAN InputValue; /* Output : Value of GPIO Input */
DCL_BOOLEAN OutputValue; /* Input : Value of GPIO Output */
DCL_BOOLEAN is_SmithTrigger; /* Input : Is Smith Triggter Or Not */
DCL_BOOLEAN is_SlewRateControl; /* Input : Is Slew Rate Control Or Not */
}RTC_CTRL_GPIO_TIME_T;
/* For RTC_CMD_HW_INIT command. */
// RTC_CMD_HW_INIT does NOT need parameters
/* For RTC_CMD_INIT command. */
typedef struct
{
void (*RTC_TCCallback)(void); /* Input : Callback Function for Timer Count */
void (*RTC_ALCallback)(void); /* Input : Callback Function for Alarm */
}RTC_CTRL_INIT_T;
/* For RTC_CMD_INIT_TC_AL_INTR command. */
// RTC_CMD_INIT_TC_AL_INTR does NOT need parameters
/* For RTC_CMD_IS_CONFIG_VALID command. */
typedef struct
{
DCL_BOOLEAN fgIsValid; /* Output : RTC Config Is Valid Or Not */
}RTC_CTRL_IS_CONFIG_VALID_T;
/* For RTC_CMD_IS_FIRST_ON command. */
typedef struct
{
DCL_BOOLEAN fgFirstOn; /* Output : TRUE: Indicate Device Is First On; FALSE: Device Is Not First On */
}RTC_CTRL_IS_FIRST_ON_T;
/* For RTC_CMD_IS_MS_FIRSTPOWERON command. */
typedef struct
{
DCL_BOOLEAN fgMSFirstPowerOn; /* Output : TRUE: Indicate Device Is First On; FALSE: Device Is Not First On */
}RTC_CTRL_IS_MS_FIRSTPOWERON_T;
/* For RTC_CMD_IS_TIME_VALID command. */
typedef struct
{
DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
DCL_UINT8 u1Year; /* Input : Years - [0,127] */
DCL_BOOLEAN isTimeValid; /* Output: If time is valid */
}RTC_CTRL_IS_TIME_VALID_T;
/* For RTC_CMD_PWIC_CHECK_POWERON command. */
typedef struct
{
DCL_BOOLEAN fgIsPowerOn; /* Output : If Power On Or Not */
}RTC_CTRL_PWIC_CHECK_POWERON_T;
/* For RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME command. */
typedef struct
{
DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
DCL_UINT8 u1Year; /* Input : Years - [0,127] */
}RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T;
/* For RTC_CMD_PWIC_MASK_AL command. */
// RTC_CMD_PWIC_MASK_AL does NOT need parameters
/* For RTC_CMD_PWIC_POWEROFF_RTC_INIT command. */
// RTC_CMD_PWIC_POWEROFF_RTC_INIT does NOT need parameters
/* For RTC_CMD_PWIC_POWERON_RTC_INIT command. */
// RTC_CMD_PWIC_POWERON_RTC_INIT does NOT need parameters
/* Enum of SPAR Registers */
typedef enum
{
DCL_RTC_SPAR0 = 0, /* SPAR0 */
DCL_RTC_SPAR1, /* SPAR1 */
DCL_RTC_NEW_SPAR0,
DCL_RTC_NEW_SPAR1,
DCL_RTC_NEW_SPAR2,
DCL_RTC_NEW_SPAR3,
DCL_RTC_NEW_SPAR4,
DCL_RTC_SPAR_MAX_INDEX /* Maximum SPAR Register */
}DCL_RTC_SPAR_INDEX_T;
/* For RTC_CMD_READ_SPAR, RTC_CMD_WRITE_SPAR commands. */
typedef struct
{
DCL_RTC_SPAR_INDEX_T SPARIndex; /* Input : Number of SPAR Register */
DCL_UINT16 WriteValue; /* Input : Value of SPAR for Configuration */
DCL_UINT16 ReadValue; /* Output : Value of SPAR Register */
}RTC_CTRL_CONFIG_SPAR_T;
/* For RTC_CMD_RELOAD command. */
// RTC_CMD_RELOAD does NOT need parameters
/* For RTC_CMD_SET_ALARM_TIME command. */
typedef struct
{
DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
DCL_UINT8 u1Year; /* Input : Years - [0,127] */
}RTC_CTRL_SET_ALARM_TIME_T;
/* For RTC_CMD_SET_FIRST_POWERON command. */
typedef struct
{
DCL_BOOLEAN fgPowerOn; /* Input : Set First Power On */
}RTC_CTRL_SET_FIRST_POWERON_T;
/* For RTC_CMD_SET_PWR_KEY command. */
// RTC_CMD_SET_PWR_KEY does NOT need parameters
/* For RTC_CMD_SET_TIME command. */
typedef struct
{
DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
DCL_UINT8 u1Year; /* Input : Years - [0,127] */
}RTC_CTRL_SET_TIME_T;
/* For RTC_CMD_SETBBPU command. */
typedef struct
{
DCL_UINT16 BBPUReg; /* Input : Set BBPU Register */
}RTC_CTRL_SETBBPU_T;
/* For RTC_CMD_SETXOSC command. */
// RTC_CMD_SETXOSC does NOT need parameters
/* For RTC_CMD_START_CALI command. */
// RTC_CMD_START_CALI does NOT need parameters
/* For RTC_CMD_WAIT_DEBOUNCE command. */
// RTC_CMD_WAIT_DEBOUNCE does NOT need parameters
/* For RTC_CMD_WRITE_TRIGGER command. */
// RTC_CMD_WRITE_TRIGGER does NOT need parameters
/* For RTC_CMD_WRITE_TRIGGER_WAIT command. */
// RTC_CMD_WRITE_TRIGGER_WAIT does NOT need parameters
typedef struct
{
DCL_UINT32 dest_mod_id;
DCL_UINT32 sap_id;
DCL_UINT32 msg_id;
DCL_BOOLEAN fgRegisterILM;
}RTC_CTRL_REGISTER_MODULE_ILM_INFO_T;
#ifdef __BUILD_DOM__
/* The RTC Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */
typedef struct
{
RTC_CTRL_BOOTLOADER_POWERON_T rBootloaderPowerOn; /* Data Structure for RTC_CMD_BOOTLOADER_POWERON */
RTC_CTRL_CONFIG_AL_TC_T rConfigALTC; /* Data Structure for RTC_CMD_CONFIG_AL_TC */
RTC_CTRL_CONFIG_PDN_BIT_T rConfigPDNBit; /* Data Structure for RTC_CMD_CLEAR_PDN_BITS, RTC_CMD_READ_PDN_BITS, RTC_CMD_SET_PDN_BITS, and RTC_CMD_WRITE_PDN_BITS */
RTC_CTRL_FT_POWEROFF_T rFTPowerOff; /* Data Structure for RTC_CMD_FT_POWEROFF */
RTC_CTRL_GET_ALARM_TIME_T rGetAlarmTime; /* Data Structure for RTC_CMD_GET_ALARM_TIME */
RTC_CTRL_GET_TIME_T rGetTime; /* Data Structure for RTC_CMD_GET_TIME */
RTC_CTRL_GPIO_TIME_T rGPIO; /* Data Structure for RTC_CMD_GPIO_GET_INPUT, RTC_CMD_GPIO_SET_INPUT_MODE, and RTC_CMD_GPIO_SET_OUTPUT_MODE */
RTC_CTRL_INIT_T rInit; /* Data Structure for RTC_CMD_INIT */
RTC_CTRL_IS_CONFIG_VALID_T rIsConfigValid; /* Data Structure for RTC_CMD_IS_CONFIG_VALID */
RTC_CTRL_IS_FIRST_ON_T rIsFirstOn; /* Data Structure for RTC_CMD_IS_FIRST_ON */
RTC_CTRL_IS_MS_FIRSTPOWERON_T rIsMSFirstPowerOn; /* Data Structure for RTC_CMD_IS_MS_FIRSTPOWERON */
RTC_CTRL_IS_TIME_VALID_T rIsTimeValid; /* Data Structure for RTC_CMD_IS_TIME_VALID */
RTC_CTRL_PWIC_CHECK_POWERON_T rPwicCheckPowerOn; /* Data Structure for RTC_CMD_PWIC_CHECK_POWERON */
RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T rPwicFirstPowerOnInitRTCTime; /* Data Structure for RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME */
RTC_CTRL_CONFIG_SPAR_T rConfigSPARReg; /* Data Structure for RTC_CMD_READ_SPAR, and RTC_CMD_WRITE_SPAR */
RTC_CTRL_SET_ALARM_TIME_T rSetAlarmTime; /* Data Structure for RTC_CMD_SET_ALARM_TIME */
RTC_CTRL_SET_FIRST_POWERON_T rSetFirstPowerOn; /* Data Structure for RTC_CMD_SET_FIRST_POWERON */
RTC_CTRL_SET_TIME_T rSetTime; /* Data Structure for RTC_CMD_SET_TIME */
RTC_CTRL_SETBBPU_T rSetBBPU; /* Data Structure for RTC_CMD_SETBBPU */
RTC_CTRL_REGISTER_MODULE_ILM_INFO_T rRegisterModILMInfo; /* Data Structure for ilm to send to other modules */
}DCL_CTRL_DATA_T;
#else /* __BUILD_DOM__ */
#define RTC_CTRLS \
RTC_CTRL_BOOTLOADER_POWERON_T rBootloaderPowerOn; \
RTC_CTRL_CONFIG_AL_TC_T rConfigALTC; \
RTC_CTRL_CONFIG_PDN_BIT_T rConfigPDNBit; \
RTC_CTRL_FT_POWEROFF_T rFTPowerOff; \
RTC_CTRL_GET_ALARM_TIME_T rGetAlarmTime; \
RTC_CTRL_GET_TIME_T rGetTime; \
RTC_CTRL_GPIO_TIME_T rGPIO; \
RTC_CTRL_INIT_T rInit; \
RTC_CTRL_IS_CONFIG_VALID_T rIsConfigValid; \
RTC_CTRL_IS_FIRST_ON_T rIsFirstOn; \
RTC_CTRL_IS_MS_FIRSTPOWERON_T rIsMSFirstPowerOn; \
RTC_CTRL_IS_TIME_VALID_T rIsTimeValid; \
RTC_CTRL_PWIC_CHECK_POWERON_T rPwicCheckPowerOn; \
RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T rPwicFirstPowerOnInitRTCTime; \
RTC_CTRL_CONFIG_SPAR_T rConfigSPARReg; \
RTC_CTRL_SET_ALARM_TIME_T rSetAlarmTime; \
RTC_CTRL_SET_FIRST_POWERON_T rSetFirstPowerOn; \
RTC_CTRL_SET_TIME_T rSetTime; \
RTC_CTRL_SETBBPU_T rSetBBPU; \
RTC_CTRL_REGISTER_MODULE_ILM_INFO_T rRegisterModILMInfo;
#endif /* __BUILD_DOM__ */
#endif // #ifndef __DCL_RTC_H_STRUCT__
#endif // #ifdef DCL_DEFINITION_STRUCT
#ifdef DCL_DEFINITION_PROTOTYPE
#ifndef __DCL_RTC_H_PROTOTYPE__
#define __DCL_RTC_H_PROTOTYPE__
/*************************************************************************
* FUNCTION
* DclRTC_Initialize
*
* DESCRIPTION
* This function is to initialize RTC module
*
* PARAMETERS
* None
*
* RETURNS
* Return the status of DclRTC_Initialize
*
* RETURN VALUES
* STATUS_OK: Initialize Finished
*
*************************************************************************/
extern DCL_STATUS DclRTC_Initialize(void);
/*************************************************************************
* FUNCTION
* DclRTC_Open
*
* DESCRIPTION
* This function is to open the RTC module and return a handle
*
* PARAMETERS
* dev: [IN] Only valid for DCL_RTC
* flags: [IN] No sepcial flags is needed. Please use FLAGS_NONE
*
* RETURNS
* Return DCL_HANDLE of RTC
*
* RETURN VALUES
* DCL_HANDLE_INVALID : Open failed
* Other value : A valid handle
*
*************************************************************************/
extern DCL_HANDLE DclRTC_Open(DCL_DEV dev, DCL_FLAGS flags);
/*************************************************************************
* FUNCTION
* DclRTC_ReadData
*
* DESCRIPTION
* This function is not supported for the RTC module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclRTC_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclRTC_WriteData
*
* DESCRIPTION
* This function is not supported for the RTC module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclRTC_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclRTC_Configure
*
* DESCRIPTION
* This function is not supported for the RTC module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclRTC_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
/*************************************************************************
* FUNCTION
* DclRTC_RegisterCallback
*
* DESCRIPTION
* This function is to set callback function for the RTC module.
*
* PARAMETERS
* handle: [IN] The returned handle value of DclRTC_Open
* event: [IN] Supported events:
* 1.EVENT_RTC_ALARM: RTC alarm interrupt
* 2.EVENT_RTC_TC: RTC tick interrupt
* callback: [IN] the callback function for registered events
*
* RETURNS
* Return the status of DclRTC_RegisterCallback
*
* RETURN VALUES
* STATUS_OK: Successfully register the callback function.
* STATUS_INVALID_DCL_HANDLE: It's a invalid handle.
* STATUS_NOT_OPENED: The module has not been opened.
* STATUS_INVALID_EVENT: The event parameter is invalid.
*
*************************************************************************/
extern DCL_STATUS DclRTC_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
/*************************************************************************
* FUNCTION
* DclRTC_Control
*
* DESCRIPTION
* This function is to send command to control the RTC module.
*
* PARAMETERS
* handle: [IN] The handle value returned from DclRTC_Open
* cmd: [IN] A control command for RTC module
* 1. RTC_CMD_BOOTLOADER_POWERON: to check RTC Power On in bootloader
* 2. RTC_CMD_CLEAR_PDN_BITS: to clear RTC PDN bits
* 3. RTC_CMD_CONFIG_AL_TC: to set alarm mask and tick mask
* 4. RTC_CMD_DELAY: to Delay 2000 counts
* 5. RTC_CMD_FT_POWEROFF: to Power Off for FlashTool
* 6. RTC_CMD_GET_ALARM_TIME: to get alarm time
* 7. RTC_CMD_GET_TIME: to get time
* 8. RTC_CMD_GPIO_GET_INPUT: to get RTC_GPIO_GPI register value
* 9. RTC_CMD_GPIO_SET_EXPORT_32K: to export 32.768KHz clock on RTC_GPIO
* 10. RTC_CMD_GPIO_SET_EXPORT_COREDETB: to export COREDETB on RTC_GPIO
* 11. RTC_CMD_GPIO_SET_INPUT_MODE: to set RTC_GPIO input mode
* 12. RTC_CMD_GPIO_SET_OUTPUT_MODE: to set RTC_GPIO output mode
* 13. RTC_CMD_HW_INIT: to initialize RTC hardware
* 14. RTC_CMD_INIT: to initialize RTC software
* 15. RTC_CMD_INIT_TC_AL_INTR: to initialize RTC TC & AL INTR
* 16. RTC_CMD_IS_CONFIG_VALID: to check if RTC time and Alarm are valid
* 17. RTC_CMD_IS_FIRST_ON: to check if device is first on
* 18. RTC_CMD_IS_MS_FIRSTPOWERON: to check whether RTC is first power on(for MMI)
* 19. RTC_CMD_IS_TIME_VALID: to check if time are valid
* 20. RTC_CMD_PWIC_CHECK_POWERON: to check if power on (for PWIC)
* 21. RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME: to init RTC time at first power on (for PWIC)
* 22. RTC_CMD_PWIC_MASK_AL: to control RTC Alarm mask (for PWIC)
* 23. RTC_CMD_PWIC_POWEROFF_RTC_INIT: to init RTC at power off (for PWIC)
* 24. RTC_CMD_PWIC_POWERON_RTC_INIT: to init RTC at power on (for PWIC)
* 25. RTC_CMD_READ_PDN_BITS: to read RTC PDN bits
* 26. RTC_CMD_READ_SPAR: to read RTC SPAR Register
* 28. RTC_CMD_RELOAD: to load RTC whole register info from RTC module
* 29. RTC_CMD_SET_ALARM_TIME: to set alarm time
* 30. RTC_CMD_SET_FIRST_POWERON: to set first power on
* 31. RTC_CMD_SET_PDN_BITS: to set RTC PDN bits
* 32. RTC_CMD_SET_PWR_KEY: to set PWR KEY
* 33. RTC_CMD_SET_TIME: to set time
* 34. RTC_CMD_SETBBPU: to set RTC_BBPU
* 35. RTC_CMD_SETXOSC: to set RTC XOSCCALI register
* 36. RTC_CMD_START_CALI: to start calibration process
* 37. RTC_CMD_WAIT_DEBOUNCE: to wait until debounce bit becomes 0
* 38. RTC_CMD_WRITE_PDN_BITS: to write RTC PDN bits
* 39. RTC_CMD_WRITE_SPAR: to write RTC SPAR Register
* 40. RTC_CMD_WRITE_TRIGGER: to set write trigger
* 41. RTC_CMD_WRITE_TRIGGER_WAIT: to set write trigger and wait until BUSY bit becomes 0
*
* data: The data of the control command
* 1. RTC_CMD_BOOTLOADER_POWERON: pointer to a RTC_CTRL_BOOTLOADER_POWERON_T structure
* 2. RTC_CMD_CLEAR_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
* 3. RTC_CMD_CONFIG_AL_TC: pointer to a RTC_CTRL_CONFIG_AL_TC_T structure
* 4. RTC_CMD_DELAY: A null pointer
* 5. RTC_CMD_FT_POWEROFF: A null pointer
* 6. RTC_CMD_GET_ALARM_TIME: pointer to a RTC_CTRL_GET_ALARM_TIME_T structure
* 7. RTC_CMD_GET_TIME: pointer to a RTC_CTRL_GET_TIME_T structure
* 8. RTC_CMD_GPIO_GET_INPUT: pointer to a RTC_CTRL_GPIO_TIME_T structure
* 9. RTC_CMD_GPIO_SET_EXPORT_32K: pointer to a RTC_CTRL_GPIO_TIME_T structure
* 10. RTC_CMD_GPIO_SET_EXPORT_COREDETB: pointer to a RTC_CTRL_GPIO_TIME_T structure
* 11. RTC_CMD_GPIO_SET_INPUT_MODE: pointer to a RTC_CTRL_GPIO_TIME_T structure
* 12. RTC_CMD_GPIO_SET_OUTPUT_MODE: pointer to a RTC_CTRL_GPIO_TIME_T structure
* 13. RTC_CMD_HW_INIT: A null pointer
* 14. RTC_CMD_INIT: pointer to a RTC_CTRL_INIT_T structure
* 15. RTC_CMD_INIT_TC_AL_INTR: A null pointer
* 16. RTC_CMD_IS_CONFIG_VALID: pointer to a RTC_CTRL_IS_CONFIG_VALID_T structure
* 17. RTC_CMD_IS_FIRST_ON: pointer to a RTC_CTRL_IS_FIRST_ON_T structure
* 18. RTC_CMD_IS_MS_FIRSTPOWERON: pointer to a RTC_CTRL_IS_MS_FIRSTPOWERON_T structure
* 19. RTC_CMD_IS_TIME_VALID: pointer to a RTC_CTRL_IS_TIME_VALID_T structure
* 20. RTC_CMD_PWIC_CHECK_POWERON: pointer to a RTC_CTRL_PWIC_CHECK_POWERON_T structure
* 21. RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME: pointer to a RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T structure
* 22. RTC_CMD_PWIC_MASK_AL: A null pointer
* 23. RTC_CMD_PWIC_POWEROFF_RTC_INIT: A null pointer
* 24. RTC_CMD_PWIC_POWERON_RTC_INIT: A null pointer
* 25. RTC_CMD_READ_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
* 26. RTC_CMD_READ_SPAR: pointer to a RTC_CTRL_CONFIG_SPAR_T structure
* 28. RTC_CMD_RELOAD: A null pointer
* 29. RTC_CMD_SET_ALARM_TIME: pointer to a RTC_CTRL_SET_ALARM_TIME_T structure
* 30. RTC_CMD_SET_FIRST_POWERON: pointer to a RTC_CTRL_SET_FIRST_POWERON_T structure
* 31. RTC_CMD_SET_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
* 32. RTC_CMD_SET_PWR_KEY: A null pointer
* 33. RTC_CMD_SET_TIME: pointer to a RTC_CTRL_SET_TIME_T structure
* 34. RTC_CMD_SETBBPU: pointer to a RTC_CTRL_SETBBPU_T structure
* 35. RTC_CMD_SETXOSC: A null pointer
* 36. RTC_CMD_START_CALI: A null pointer
* 37. RTC_CMD_WAIT_DEBOUNCE: A null pointer
* 38. RTC_CMD_WRITE_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
* 39. RTC_CMD_WRITE_SPAR: pointer to a RTC_CTRL_CONFIG_SPAR_T structure
* 40. RTC_CMD_WRITE_TRIGGER: A null pointer
* 41. RTC_CMD_WRITE_TRIGGER_WAIT: A null pointer
*
* RETURNS
* Return the status of DclRTC_Control
*
* RETURN VALUES
* STATUS_OK: Command is executed successfully.
* STATUS_FAIL: Command is failed.
* STATUS_INVALID_CMD: It's a invalid command.
*
*************************************************************************/
extern DCL_STATUS DclRTC_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
/*************************************************************************
* FUNCTION
* DclRTC_Close
*
* DESCRIPTION
* This function is to close the RTC module.
*
* PARAMETERS
* handle: [IN] The returned handle value of DclRTC_Open
*
* RETURNS
* Return the status of DclRTC_Close
*
* RETURN VALUES
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclRTC_Close(DCL_HANDLE handle);
#endif // #ifndef __DCL_RTC_H_PROTOTYPE__
#endif // #ifdef DCL_DEFINITION_PROTOTYPE