PDK API Guide for J721E
pmic_rtc.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  *****************************************************************************/
33 
54 #ifndef PMIC_RTC_H_
55 #define PMIC_RTC_H_
56 
57 /* ========================================================================= */
58 /* Include Files */
59 /* ========================================================================= */
60 
61 #include <pmic_core.h>
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 /* ========================================================================= */
68 /* Macros & Typedefs */
69 /* ========================================================================= */
70 
77 #define PMIC_RTC_SECOND_INTR_PERIOD (0x0U)
78 #define PMIC_RTC_MINUTE_INTR_PERIOD (0x1U)
79 #define PMIC_RTC_HOUR_INTR_PERIOD (0x2U)
80 #define PMIC_RTC_DAY_INTR_PERIOD (0x3U)
81 /* @} */
82 
89 #define PMIC_RTC_ALARM_INTR_ENABLE 1U
90 #define PMIC_RTC_ALARM_INTR_DISABLE 0U
91 /* @} */
92 
99 #define PMIC_RTC_TIMER_INTR_ENABLE 1U
100 #define PMIC_RTC_TIMER_INTR_DISABLE 0U
101 /* @} */
102 
109 #define PMIC_RTC_24_HOUR_MODE (0x0U)
110 #define PMIC_RTC_12_HOUR_MODE (0x1U)
111 /* @} */
112 
119 #define PMIC_RTC_AM_MODE (0x0U)
120 #define PMIC_RTC_PM_MODE (0x1U)
121 /* @} */
122 
129 #define PMIC_RTC_STOP 0U
130 #define PMIC_RTC_START 1U
131 /* @} */
132 
139 #define PMIC_RTC_STATUS_FROZEN 0U
140 #define PMIC_RTC_STATUS_RUNNING 1U
141 /* @} */
142 
150 #define PMIC_RTC_RST_STATUS_RESET_VAL (0x0U)
151 
152 #define PMIC_RTC_RST_STATUS_SET_VAL (0x1U)
153 /* @} */
154 
162 #define PMIC_RTC_POWERUP_STATUS_CLR_VAL (0x0U)
163 
164 #define PMIC_RTC_POWERUP_STATUS_RESET_VAL (0x1U)
165 /* @} */
166 
173 #define PMIC_RTC_WEEKDAY_SUNDAY (1U)
174 #define PMIC_RTC_WEEKDAY_MONDAY (2U)
175 #define PMIC_RTC_WEEKDAY_TUESDAY (3U)
176 #define PMIC_RTC_WEEKDAY_WEDNESDAY (4U)
177 #define PMIC_RTC_WEEKDAY_THURSDAY (5U)
178 #define PMIC_RTC_WEEKDAY_FRIDAY (6U)
179 #define PMIC_RTC_WEEKDAY_SATURDAY (7U)
180 /* @} */
181 
190 #define PMIC_RTC_MONTH_JAN (1U)
191 #define PMIC_RTC_MONTH_FEB (2U)
192 #define PMIC_RTC_MONTH_MAR (3U)
193 #define PMIC_RTC_MONTH_APR (4U)
194 #define PMIC_RTC_MONTH_MAY (5U)
195 #define PMIC_RTC_MONTH_JUN (6U)
196 #define PMIC_RTC_MONTH_JUL (7U)
197 #define PMIC_RTC_MONTH_AUG (8U)
198 #define PMIC_RTC_MONTH_SEP (9U)
199 #define PMIC_RTC_MONTH_OCT (10U)
200 #define PMIC_RTC_MONTH_NOV (11U)
201 #define PMIC_RTC_MONTH_DEC (12U)
202 /* @} */
203 
211 #define PMIC_RTC_32K_COUNTER_COMP_VAL_SET (0x1U)
212 /* @} */
213 
220 #define PMIC_RTC_CRYSTAL_OSC_DISABLE 0U
221 #define PMIC_RTC_CRYSTAL_OSC_ENABLE 1U
222 /* @} */
223 
224 
232 #define PMIC_RTC_ROUND_TIME_SET (0x1U)
233 /* @} */
234 
242 #define PMIC_RTC_DYNAMIC_REG_SEL (0x0U)
243 
244 #define PMIC_RTC_STATIC_SHADOWED_REG_SEL (0x1U)
245 /* @} */
246 
254 #define PMIC_RTC_CRYSTAL_OSC_TYPE_6PF (0x0U)
255 
256 #define PMIC_RTC_CRYSTAL_OSC_TYPE_9PF (0x1U)
257 
258 #define PMIC_RTC_CRYSTAL_OSC_TYPE_12_5PF (0x2U)
259 /* @} */
260 
268 #define PMIC_RTC_RST_STATUS (0x0U)
269 
270 #define PMIC_RTC_POWERUP_STATUS (0x1U)
271 /* @} */
272 
280 #define PMIC_RTC_TIME_CFG_SEC_VALID (0U)
281 
282 #define PMIC_RTC_TIME_CFG_MIN_VALID (1U)
283 
284 #define PMIC_RTC_TIME_CFG_HRS_VALID (2U)
285 
286 #define PMIC_RTC_TIME_CFG_TIMEMODE_VALID (3U)
287 
288 #define PMIC_RTC_TIME_CFG_MERIDIAN_VALID (4U)
289 /* @} */
290 
300 #define PMIC_RTC_TIME_CFG_SEC_VALID_SHIFT \
301  (1U << PMIC_RTC_TIME_CFG_SEC_VALID)
302 #define PMIC_RTC_TIME_CFG_MIN_VALID_SHIFT \
303  (1U << PMIC_RTC_TIME_CFG_MIN_VALID)
304 #define PMIC_RTC_TIME_CFG_HRS_VALID_SHIFT \
305  (1U << PMIC_RTC_TIME_CFG_HRS_VALID)
306 #define PMIC_RTC_TIME_CFG_TIMEMODE_VALID_SHIFT \
307  (1U << PMIC_RTC_TIME_CFG_TIMEMODE_VALID)
308 #define PMIC_RTC_TIME_CFG_MERIDIAN_VALID_SHIFT \
309  (1U << PMIC_RTC_TIME_CFG_MERIDIAN_VALID)
310 /* @} */
311 
319 #define PMIC_RTC_DATE_CFG_DAY_VALID (0U)
320 
321 #define PMIC_RTC_DATE_CFG_MONTH_VALID (1U)
322 
323 #define PMIC_RTC_DATE_CFG_YEAR_VALID (2U)
324 
326 #define PMIC_RTC_DATE_CFG_WEEKDAY_VALID (3U)
327 /* @} */
328 
338 #define PMIC_RTC_DATE_CFG_DAY_VALID_SHIFT \
339  (1U << PMIC_RTC_DATE_CFG_DAY_VALID)
340 #define PMIC_RTC_DATE_CFG_MONTH_VALID_SHIFT \
341  (1U << PMIC_RTC_DATE_CFG_MONTH_VALID)
342 #define PMIC_RTC_DATE_CFG_YEAR_VALID_SHIFT \
343  (1U << PMIC_RTC_DATE_CFG_YEAR_VALID)
344 #define PMIC_RTC_DATE_CFG_WEEKDAY_VALID_SHIFT \
345  (1U << PMIC_RTC_DATE_CFG_WEEKDAY_VALID)
346 /* @} */
347 
355 #define PMIC_RTC_RESET_STATUS_VALID (0U)
356 
357 #define PMIC_RTC_POWERUP_STATUS_VALID (1U)
358 /* @} */
359 
369 #define PMIC_RTC_RESET_STATUS_VALID_SHIFT \
370  (1U << PMIC_RTC_RESET_STATUS_VALID)
371 #define PMIC_RTC_POWERUP_STATUS_VALID_SHIFT \
372  (1U << PMIC_RTC_POWERUP_STATUS_VALID)
373 /* @} */
374 
383 #define PMIC_RTC_CFG_32K_COUNTER_COMP_VAL_SET_VALID (0U)
384 
386 #define PMIC_RTC_CFG_RTC_TIME_ROUND_30S_SET_VALID (1U)
387 
389 #define PMIC_RTC_CFG_CRYSTAL_OSC_EN_VALID (2U)
390 
392 #define PMIC_RTC_CFG_TIME_DATE_REG_SEL_VALID (3U)
393 
395 #define PMIC_RTC_CFG_CRYSTAL_OSC_TYPE_VALID (4U)
396 /* @} */
397 
408 #define PMIC_RTC_CFG_32K_COUNTER_COMP_VAL_SET_VALID_SHIFT \
409  (1U << PMIC_RTC_CFG_32K_COUNTER_COMP_VAL_SET_VALID)
410 #define PMIC_RTC_CFG_RTC_TIME_ROUND_30S_SET_VALID_SHIFT \
411  (1U << PMIC_RTC_CFG_RTC_TIME_ROUND_30S_SET_VALID)
412 #define PMIC_RTC_CFG_CRYSTAL_OSC_EN_VALID_SHIFT \
413  (1U << PMIC_RTC_CFG_CRYSTAL_OSC_EN_VALID)
414 #define PMIC_RTC_CFG_TIME_DATE_REG_SEL_VALID_SHIFT \
415  (1U << PMIC_RTC_CFG_TIME_DATE_REG_SEL_VALID)
416 #define PMIC_RTC_CFG_CRYSTAL_OSC_TYPE_VALID_SHIFT \
417  (1U << PMIC_RTC_CFG_CRYSTAL_OSC_TYPE_VALID)
418 /* @} */
419 
420 /*==========================================================================*/
421 /* Structures and Enums */
422 /*==========================================================================*/
423 
454 typedef struct Pmic_RtcTime_s
455 {
456  uint32_t validParams;
457  uint8_t seconds;
458  uint8_t minutes;
459  uint8_t hour;
460  uint8_t timeMode;
461  uint8_t meridianMode;
463 
489 typedef struct Pmic_RtcDate_s
490 {
491  uint32_t validParams;
492  uint8_t day;
493  uint8_t month;
494  uint16_t year;
495  uint8_t weekday;
497 
521 typedef struct Pmic_RtcRstStatus_s
522 {
523  uint32_t validParams;
527 
576 typedef struct Pmic_RtcCfg_s
577 {
578  uint32_t validParams;
582  uint8_t timeDateRegSel;
583  uint8_t crystalOScType;
585 
586 /*==========================================================================*/
587 /* Function Declarations */
588 /*==========================================================================*/
589 
608 int32_t Pmic_rtcSetAlarmInfo(Pmic_CoreHandle_t *pPmicCoreHandle,
609  const Pmic_RtcTime_t timeCfg,
610  const Pmic_RtcDate_t dateCfg);
611 
630 int32_t Pmic_rtcGetAlarmInfo(Pmic_CoreHandle_t *pPmicCoreHandle,
631  Pmic_RtcTime_t *pTimeCfg,
632  Pmic_RtcDate_t *pDateCfg);
633 
652 int32_t Pmic_rtcSetTimerPeriod(Pmic_CoreHandle_t *pPmicCoreHandle,
653  const uint8_t timerPeriod);
654 
671 int32_t Pmic_rtcGetTimerPeriod(Pmic_CoreHandle_t *pPmicCoreHandle,
672  uint8_t *pTimerPeriod);
673 
692 int32_t Pmic_rtcSetTimeDateInfo(Pmic_CoreHandle_t *pPmicCoreHandle,
693  const Pmic_RtcTime_t timeCfg,
694  const Pmic_RtcDate_t dateCfg);
695 
714 int32_t Pmic_rtcGetTimeDateInfo(Pmic_CoreHandle_t *pPmicCoreHandle,
715  Pmic_RtcTime_t *pTimeCfg,
716  Pmic_RtcDate_t *pDateCfg);
717 
734 int32_t Pmic_rtcSetFreqComp(Pmic_CoreHandle_t *pPmicCoreHandle,
735  const uint16_t compensation);
736 
754 int32_t Pmic_rtcGetFreqComp(Pmic_CoreHandle_t *pPmicCoreHandle,
755  uint16_t *pCompensation);
756 
773 int32_t Pmic_rtcEnable(Pmic_CoreHandle_t *pPmicCoreHandle,
774  const bool enableRtc);
775 
793 int32_t Pmic_rtcGetStatus(Pmic_CoreHandle_t *pPmicCoreHandle,
794  bool *pRtcstatus);
795 
814 int32_t Pmic_rtcEnableTimerIntr(Pmic_CoreHandle_t *pPmicCoreHandle,
815  const bool enableIntr);
816 
835 int32_t Pmic_rtcEnableAlarmIntr(Pmic_CoreHandle_t *pPmicCoreHandle,
836  const bool enableIntr);
837 
855 int32_t Pmic_rtcGetRstStatus(Pmic_CoreHandle_t *pPmicCoreHandle,
856  Pmic_RtcRstStatus_t *pRtcRstStatus);
857 
876 int32_t Pmic_rtcClrRstStatus(Pmic_CoreHandle_t *pPmicCoreHandle,
877  const uint8_t rtcRstStatType);
878 
895 int32_t Pmic_rtcSetConfiguration(Pmic_CoreHandle_t *pPmicCoreHandle,
896  const Pmic_RtcCfg_t rtcCfg);
897 
915 int32_t Pmic_rtcGetConfiguration(Pmic_CoreHandle_t *pPmicCoreHandle,
916  Pmic_RtcCfg_t *pRtcCfg);
917 
918 
919 #ifdef __cplusplus
920 }
921 
922 #endif /* __cplusplus */
923 
924 #endif /* PMIC_RTC_H_ */
925 
926 /* @} */
uint8_t day
Definition: pmic_rtc.h:492
int32_t Pmic_rtcEnable(Pmic_CoreHandle_t *pPmicCoreHandle, const bool enableRtc)
API to Enable/Disable the RTC.
int32_t Pmic_rtcGetConfiguration(Pmic_CoreHandle_t *pPmicCoreHandle, Pmic_RtcCfg_t *pRtcCfg)
API to Get PMIC RTC Configuration.
int32_t Pmic_rtcEnableAlarmIntr(Pmic_CoreHandle_t *pPmicCoreHandle, const bool enableIntr)
API to Enable/Disable the RTC Alarm Interrupt.
uint32_t validParams
Definition: pmic_rtc.h:456
int32_t Pmic_rtcGetTimerPeriod(Pmic_CoreHandle_t *pPmicCoreHandle, uint8_t *pTimerPeriod)
API to Get the timer interrupt period from PMIC RTC.
uint16_t year
Definition: pmic_rtc.h:494
int32_t Pmic_rtcSetAlarmInfo(Pmic_CoreHandle_t *pPmicCoreHandle, const Pmic_RtcTime_t timeCfg, const Pmic_RtcDate_t dateCfg)
API to Set the alarm Time and Date to PMIC RTC.
int32_t Pmic_rtcSetFreqComp(Pmic_CoreHandle_t *pPmicCoreHandle, const uint16_t compensation)
API to Set the RTC frequency compensation value.
uint8_t hour
Definition: pmic_rtc.h:459
int32_t Pmic_rtcSetTimerPeriod(Pmic_CoreHandle_t *pPmicCoreHandle, const uint8_t timerPeriod)
API to Set the timer interrupt Period to PMIC RTC.
int32_t Pmic_rtcGetRstStatus(Pmic_CoreHandle_t *pPmicCoreHandle, Pmic_RtcRstStatus_t *pRtcRstStatus)
API to Get the Reset status of RTC.
uint8_t timeMode
Definition: pmic_rtc.h:460
int32_t Pmic_rtcGetFreqComp(Pmic_CoreHandle_t *pPmicCoreHandle, uint16_t *pCompensation)
API to Get the RTC frequency compensation value.
bool crystalOScEn
Definition: pmic_rtc.h:579
int32_t Pmic_rtcGetAlarmInfo(Pmic_CoreHandle_t *pPmicCoreHandle, Pmic_RtcTime_t *pTimeCfg, Pmic_RtcDate_t *pDateCfg)
API to Get the alarm Time and Date from PMIC RTC function.
uint32_t validParams
Definition: pmic_rtc.h:578
int32_t Pmic_rtcSetTimeDateInfo(Pmic_CoreHandle_t *pPmicCoreHandle, const Pmic_RtcTime_t timeCfg, const Pmic_RtcDate_t dateCfg)
API to Set the RTC Time and Date to PMIC RTC.
uint8_t set32KCounterCompVal
Definition: pmic_rtc.h:580
int32_t Pmic_rtcGetTimeDateInfo(Pmic_CoreHandle_t *pPmicCoreHandle, Pmic_RtcTime_t *pTimeCfg, Pmic_RtcDate_t *pDateCfg)
API to Get the RTC Time and Date from PMIC RTC function.
RTC time configuration. The Pmic_RtcTime_s structure contains set of time parameters to set/get the R...
Definition: pmic_rtc.h:454
uint8_t setRtcTimeRound30s
Definition: pmic_rtc.h:581
PMIC Interface Handle. Contains various PMIC driver instance specific information....
Definition: pmic_types.h:148
bool powerupStatus
Definition: pmic_rtc.h:525
RTC Date configuration. The Pmic_RtcDate_s structure contains set of date parameters to set/get the R...
Definition: pmic_rtc.h:489
RTC Reset Status The Pmic_RtcRstStatus_s structure contains status of RTC Reset and power-up status....
Definition: pmic_rtc.h:521
uint8_t seconds
Definition: pmic_rtc.h:457
int32_t Pmic_rtcEnableTimerIntr(Pmic_CoreHandle_t *pPmicCoreHandle, const bool enableIntr)
API to Enable/Disable the RTC Timer Interrupt.
PMIC Driver Common API/interface file.
uint8_t minutes
Definition: pmic_rtc.h:458
uint8_t meridianMode
Definition: pmic_rtc.h:461
bool rtcRstStatus
Definition: pmic_rtc.h:524
uint8_t crystalOScType
Definition: pmic_rtc.h:583
uint8_t weekday
Definition: pmic_rtc.h:495
int32_t Pmic_rtcGetStatus(Pmic_CoreHandle_t *pPmicCoreHandle, bool *pRtcstatus)
API to read RTC status which defines RTC is started or not.
uint32_t validParams
Definition: pmic_rtc.h:491
int32_t Pmic_rtcSetConfiguration(Pmic_CoreHandle_t *pPmicCoreHandle, const Pmic_RtcCfg_t rtcCfg)
API to Set PMIC RTC Configuration.
int32_t Pmic_rtcClrRstStatus(Pmic_CoreHandle_t *pPmicCoreHandle, const uint8_t rtcRstStatType)
API to clear the Reset status of RTC.
uint32_t validParams
Definition: pmic_rtc.h:523
RTC configuration The Pmic_RtcRstStatus_s structure contains status of RTC Reset and power-up status....
Definition: pmic_rtc.h:576
uint8_t timeDateRegSel
Definition: pmic_rtc.h:582
uint8_t month
Definition: pmic_rtc.h:493