ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_rtc_def.h
1 
48 #ifndef ADI_RTC_DEF_H__
49 #define ADI_RTC_DEF_H__
50 
52 #define ADI_RTC_NUM_INSTANCE 2u
53 
54 
55 
56 #define ADI_RTC_INT_ENA_MASK_CR0 0XF804u
57 
58 #define ADI_RTC_INT_ENA_MASK_CR1 0X1Fu
59 
60 #define ADI_RTC_INT_ENA_MASK_CR2IC 0xF41C
61 #define ADI_RTC_INT_ENA_MASK_CR3SS 0x1FFE
62 #define ADI_RTC_INT_ENA_MASK_CR4SS 0x0E0E
63 #define ADI_RTC_INT_ENA_MASK_CR5SSS 0x0FFF
64 
65 /* Mask to select pend/sync write status bits */
66 #define ADI_RTC_WRITE_STATUS_MASK 0X3F80u
67 
68 
69 #define ADI_RTC_TRIM_MASK (BITM_RTC_TRM_VALUE | BITM_RTC_TRM_ADD|BITM_RTC_TRM_IVL | BITM_RTC_TRM_IVL2EXPMIN )
70 
71 #define ALWAYS_PEND_BEFORE_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=0u)\
72  {\
73  }
74 
75 #define ALWAYS_SYNC_AFTER_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=(mask))\
76  {\
77  }
78 
79 #if (ADI_RTC_CFG_ENABLE_SAFE_WRITE == 1)
80  /* pause on pending writes to CR to avoid data loss */
81 
82 #ifdef __ICCARM__
83 /*
84 * Pm154 (rule 19.10): in the definition of a function-like macro, each instance
85 * of a parameter shall be enclosed in parentheses
86 * Parameter use without parentheses needed for struct field name in register access macro.
87 */
88 #pragma diag_suppress=Pm154
89 #endif /* __ICCARM__ */
90 
91 #define PEND_BEFORE_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=0u)\
92  {\
93  }
94 
95 #define SYNC_AFTER_WRITE(reg,mask) while((pDevice->pRTCRegs->reg&(mask))!=(mask))\
96  {\
97  }
98 
99 #ifdef __ICCARM__
100 #pragma diag_default=Pm154
101 #endif /* __ICCARM__ */
102 
103 #else
104  /* pause on pending writes to CR to avoid data loss */
105 #define PEND_BEFORE_WRITE(reg,mask)
106 #define SYNC_AFTER_WRITE(reg,mask)
107 #endif
108 
109 /*
110  * The following is used for static configuration
111  */
112 typedef struct
113 {
114  uint16_t CR0;
115  uint16_t CR1;
116  uint16_t CNT0;
117  uint16_t CNT1;
119  uint16_t ALM0;
120  uint16_t ALM1;
121  uint16_t ALM2;
122  uint16_t TRIM;
123  uint16_t CR2IC;
124  uint16_t CR3SS;
125  uint16_t CR4SS;
126  uint16_t SSMSK;
127  uint16_t SS1;
128 #if defined(__ADUCM302x__)
129  uint16_t SS1ARL;
130 #elif defined(__ADUCM4x50__)
131  uint16_t SS1LOWDUR;
132  uint16_t SS1HIGHDUR;
133  uint16_t SS2LOWDUR;
134  uint16_t SS2HIGHDUR;
135  uint16_t SS3LOWDUR;
136  uint16_t SS3HIGHDUR;
138  uint16_t CR5SSS;
139  uint16_t CR6SSS;
140  uint16_t CR7SSS;
141 #endif
142  uint16_t GPMUX0;
143  uint16_t GPMUX1;
144 }ADI_RTC_CONFIG;
145 
146 /* Device information structure */
147 typedef struct _ADI_RTC_DEVICE_INFO
148 {
149  volatile ADI_RTC_TypeDef *pRTCRegs; /* Base address of the SPORT registers */
150  const IRQn_Type eIRQn; /* IRQn */
151  ADI_RTC_HANDLE hDevice; /* RTC handle */
152 }ADI_RTC_DEVICE_INFO;
153 
155 typedef struct _ADI_RTC_DEVICE
156 {
157  volatile ADI_RTC_TypeDef *pRTCRegs; /* Pointer to RTC Memory Mapped Registers */
158 
159  ADI_CALLBACK pfCallback; /* Function pointer for callback function. */
160 
161  void *pCBParam; /* Parameter to callback function. */
162  IRQn_Type eIRQn; /* IRQn */
163  uint32_t cbWatch;
164  ADI_RTC_DEVICE_INFO *pDeviceInfo; /* Parameter to callback function. */
165 
166 } ADI_RTC_DEVICE;
167 
168 
169 static void rtc_init(ADI_RTC_DEVICE *pDevice,ADI_RTC_CONFIG *pConfig);
170 
171 #ifdef ADI_DEBUG
172 static ADI_RTC_RESULT ValidateHandle( ADI_RTC_DEVICE *pInDevice);
173 #endif
174 
175 #endif /* ADI_RTC_DEF_H__ */
void * ADI_RTC_HANDLE
Definition: adi_rtc.h:74
ADI_RTC_RESULT
Definition: adi_rtc.h:103