ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_rtc_def.h
1 
13 #ifndef ADI_RTC_DEF_H__
14 #define ADI_RTC_DEF_H__
15 
17 #define ADI_RTC_NUM_INSTANCE 2u
18 
19 
20 
21 #define ADI_RTC_INT_ENA_MASK_CR0 0XF804u
22 
23 #define ADI_RTC_INT_ENA_MASK_CR1 0X1Fu
24 
25 #define ADI_RTC_INT_ENA_MASK_CR2IC 0xF41C
26 #define ADI_RTC_INT_ENA_MASK_CR3SS 0x1FFE
27 #define ADI_RTC_INT_ENA_MASK_CR4SS 0x0E0E
28 #define ADI_RTC_INT_ENA_MASK_CR5SSS 0x0FFF
29 
30 /* Mask to select pend/sync write status bits */
31 #define ADI_RTC_WRITE_STATUS_MASK 0X3F80u
32 
33 
34 #define ADI_RTC_TRIM_MASK (BITM_RTC_TRM_VALUE | BITM_RTC_TRM_ADD|BITM_RTC_TRM_IVL | BITM_RTC_TRM_IVL2EXPMIN )
35 
36 #define ALWAYS_PEND_BEFORE_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=0u)\
37  {\
38  }
39 
40 #define ALWAYS_SYNC_AFTER_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=(mask))\
41  {\
42  }
43 
44 #if (ADI_RTC_CFG_ENABLE_SAFE_WRITE == 1)
45  /* pause on pending writes to CR to avoid data loss */
46 
47 #ifdef __ICCARM__
48 /*
49 * Pm154 (rule 19.10): in the definition of a function-like macro, each instance
50 * of a parameter shall be enclosed in parentheses
51 * Parameter use without parentheses needed for struct field name in register access macro.
52 */
53 #pragma diag_suppress=Pm154
54 #endif /* __ICCARM__ */
55 
56 #define PEND_BEFORE_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=0u)\
57  {\
58  }
59 
60 #define SYNC_AFTER_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=(mask))\
61  {\
62  }
63 
64 #ifdef __ICCARM__
65 #pragma diag_default=Pm154
66 #endif /* __ICCARM__ */
67 
68 #else
69  /* pause on pending writes to CR to avoid data loss */
70 #define PEND_BEFORE_WRITE(reg,mask)
71 #define SYNC_AFTER_WRITE(reg,mask)
72 #endif
73 
74 /*
75  * The following is used for static configuration
76  */
77 typedef struct
78 {
79  uint16_t CR0;
80  uint16_t CR1;
81  uint16_t CNT0;
82  uint16_t CNT1;
84  uint16_t ALM0;
85  uint16_t ALM1;
86  uint16_t ALM2;
87  uint16_t TRIM;
88  uint16_t CR2IC;
89  uint16_t CR3SS;
90  uint16_t CR4SS;
91  uint16_t SSMSK;
92  uint16_t SS1;
93 #if defined(__ADUCM302x__)
94  uint16_t SS1ARL;
95 #elif defined(__ADUCM4x50__)
96  uint16_t SS1LOWDUR;
97  uint16_t SS1HIGHDUR;
98  uint16_t SS2LOWDUR;
99  uint16_t SS2HIGHDUR;
100  uint16_t SS3LOWDUR;
101  uint16_t SS3HIGHDUR;
103  uint16_t CR5SSS;
104  uint16_t CR6SSS;
105  uint16_t CR7SSS;
106 #endif
107  uint16_t GPMUX0;
108  uint16_t GPMUX1;
109 }ADI_RTC_CONFIG;
110 
111 /* Device information structure */
112 typedef struct _ADI_RTC_DEVICE_INFO
113 {
114  volatile ADI_RTC_TypeDef *pRTCRegs; /* Base address of the SPORT registers */
115  const IRQn_Type eIRQn; /* IRQn */
116  ADI_RTC_HANDLE hDevice; /* RTC handle */
117 }ADI_RTC_DEVICE_INFO;
118 
120 typedef struct _ADI_RTC_DEVICE
121 {
122  volatile ADI_RTC_TypeDef *pRTCRegs; /* Pointer to RTC Memory Mapped Registers */
123 
124  ADI_CALLBACK pfCallback; /* Function pointer for callback function. */
125 
126  void *pCBParam; /* Parameter to callback function. */
127  IRQn_Type eIRQn; /* IRQn */
128  uint32_t cbWatch;
129  ADI_RTC_DEVICE_INFO *pDeviceInfo; /* Parameter to callback function. */
130 
131 } ADI_RTC_DEVICE;
132 
133 
134 static void rtc_init(ADI_RTC_DEVICE *pDevice,ADI_RTC_CONFIG *pConfig);
135 
136 #ifdef ADI_DEBUG
137 static ADI_RTC_RESULT ValidateHandle( ADI_RTC_DEVICE *pInDevice);
138 #endif
139 
140 #endif /* ADI_RTC_DEF_H__ */
void * ADI_RTC_HANDLE
Definition: adi_rtc.h:40
ADI_RTC_RESULT
Definition: adi_rtc.h:69