1 /** @file dcc.h
2 *   @brief DCC Driver Definition File
3 *   @date 29.May.2013
4 *   @version 03.05.02
5 *
6 */
7 
8 /* (c) Texas Instruments 2009-2013, All rights reserved. */
9 
10 #ifndef __DCC_H__
11 #define __DCC_H__
12 
13 #include "reg_dcc.h"
14 
15 
16 
17 /* DCC General Definitions */
18 
19 /** @def dcc1CNT0_CLKSRC_HFLPO
20 *   @brief Alias name for DCC1 Counter 0 Clock Source HFLPO
21 *
22 *   This is an alias name for the Clock Source HFLPO for DCC1 Counter 0.
23 *
24 *   @note This value should be used for API argument @a cnt0_Clock_Source
25 */
26 #define dcc1CNT0_CLKSRC_HFLPO 0x00000005U
27 
28 /** @def dcc1CNT0_CLKSRC_TCK
29 *   @brief Alias name for DCC1 Counter 0 Clock Source TCK
30 *
31 *   This is an alias name for the Clock Source TCK for DCC1 Counter 0.
32 *
33 *   @note This value should be used for API argument @a cnt0_Clock_Source
34 */
35 #define dcc1CNT0_CLKSRC_TCK 0x0000000AU
36 
37 /** @def dcc1CNT0_CLKSRC_OSCIN
38 *   @brief Alias name for DCC1 Counter 0 Clock Source OSCIN
39 *
40 *   This is an alias name for the Clock Source OSCIN for DCC1 Counter 0.
41 *
42 *   @note This value should be used for API argument @a cnt0_Clock_Source
43 */
44 #define dcc1CNT0_CLKSRC_OSCIN 0x0000000FU
45 
46 /** @def dcc1CNT1_CLKSRC_PLL1
47 *   @brief Alias name for DCC1 Counter 1 Clock Source PLL1
48 *
49 *   This is an alias name for the Clock Source PLL for DCC1 Counter 1.
50 *
51 *   @note This value should be used for API argument @a cnt1_Clock_Source
52 */
53 #define dcc1CNT1_CLKSRC_PLL1 0x0000A0000U
54 
55 /** @def dcc1CNT1_CLKSRC_PLL2
56 *   @brief Alias name for DCC1 Counter 1 Clock Source PLL2
57 *
58 *   This is an alias name for the Clock Source OSCIN for DCC1 Counter 1.
59 *
60 *   @note This value should be used for API argument @a cnt1_Clock_Source
61 */
62 #define dcc1CNT1_CLKSRC_PLL2 0x0000A0001U
63 
64 /** @def dcc1CNT1_CLKSRC_LFLPO
65 *   @brief Alias name for DCC1 Counter 1 Clock Source LFLPO
66 *
67 *   This is an alias name for the Clock Source LFLPO for DCC1 Counter 1.
68 *
69 *   @note This value should be used for API argument @a cnt1_Clock_Source
70 */
71 #define dcc1CNT1_CLKSRC_LFLPO 0x0000A0002U
72 
73 /** @def dcc1CNT1_CLKSRC_HFLPO
74 *   @brief Alias name for DCC1 Counter 1 Clock Source HFLPO
75 *
76 *   This is an alias name for the Clock Source HFLPO for DCC1 Counter 1.
77 *
78 *   @note This value should be used for API argument @a cnt1_Clock_Source
79 */
80 #define dcc1CNT1_CLKSRC_HFLPO 0x0000A0003U
81 
82 /** @def dcc1CNT1_CLKSRC_EXTCLKIN1
83 *   @brief Alias name for DCC1 Counter 1 Clock Source EXTCLKIN1
84 *
85 *   This is an alias name for the Clock Source EXTCLKIN1 for DCC1 Counter 1.
86 *
87 *   @note This value should be used for API argument @a cnt1_Clock_Source
88 */
89 #define dcc1CNT1_CLKSRC_EXTCLKIN1 0x0000A0005U
90 
91 /** @def dcc1CNT1_CLKSRC_EXTCLKIN2
92 *   @brief Alias name for DCC1 Counter 1 Clock Source EXTCLKIN2
93 *
94 *   This is an alias name for the Clock Source EXTCLKIN2 for DCC1 Counter 1.
95 *
96 *   @note This value should be used for API argument @a cnt1_Clock_Source
97 */
98 #define dcc1CNT1_CLKSRC_EXTCLKIN2 0x0000A0006U
99 
100 /** @def dcc1CNT1_CLKSRC_VCLK
101 *   @brief Alias name for DCC1 Counter 1 Clock Source VCLK
102 *
103 *   This is an alias name for the Clock Source VCLK for DCC1 Counter 1.
104 *
105 *   @note This value should be used for API argument @a cnt1_Clock_Source
106 */
107 #define dcc1CNT1_CLKSRC_VCLK 0x0000A0008U
108 
109 /** @def dcc1CNT1_CLKSRC_N2HET1_31
110 *   @brief Alias name for DCC1 Counter 1 Clock Source N2HET1_31
111 *
112 *   This is an alias name for the Clock Source N2HET1_31 for DCC1 Counter 1.
113 *
114 *   @note This value should be used for API argument @a cnt1_Clock_Source
115 */
116 #define dcc1CNT1_CLKSRC_N2HET1_31 0x00005000FU
117 
118 /** @def dcc2CNT0_CLKSRC_TCK
119 *   @brief Alias name for DCC2 Counter 0 Clock Source TCK
120 *
121 *   This is an alias name for the Clock Source TCK for DCC2 Counter 0.
122 *
123 *   @note This value should be used for API argument @a cnt0_Clock_Source
124 */
125 #define dcc2CNT0_CLKSRC_TCK 0x0000000AU
126 
127 /** @def dcc1CNT0_CLKSRC_OSCIN
128 *   @brief Alias name for DCC1 Counter 0 Clock Source OSCIN
129 *
130 *   This is an alias name for the Clock Source OSCIN for DCC2 Counter 0.
131 *
132 *   @note This value should be used for API argument @a cnt0_Clock_Source
133 */
134 #define dcc2CNT0_CLKSRC_OSCIN 0x0000000FU
135 
136 /** @def dcc2CNT1_CLKSRC_VCLK
137 *   @brief Alias name for DCC2 Counter 1 Clock Source VCLK
138 *
139 *   This is an alias name for the Clock Source VCLK for DCC2 Counter 1.
140 *
141 *   @note This value should be used for API argument @a cnt1_Clock_Source
142 */
143 #define dcc2CNT1_CLKSRC_VCLK 0x0000A0008U
144 
145 /** @def dcc2CNT1_CLKSRC_N2HET1_0
146 *   @brief Alias name for DCC2 Counter 1 Clock Source N2HET2_0
147 *
148 *   This is an alias name for the Clock Source N2HET2_0 for DCC2 Counter 1.
149 *
150 *   @note This value should be used for API argument @a cnt1_Clock_Source
151 */
152 #define dcc2CNT1_CLKSRC_N2HET1_0 0x00005000FU
153 
154 /** @def dccNOTIFICATION_DONE
155 *   @brief Alias name for DCC Done notification
156 *
157 *   This is an alias name for the DCC Done notification.
158 *
159 *   @note This value should be used for API argument @a notification
160 */
161 #define dccNOTIFICATION_DONE 0x0000A000U
162 
163 /** @def dccNOTIFICATION_ERROR
164 *   @brief Alias name for DCC Error notification
165 *
166 *   This is an alias name for the DCC Error notification.
167 *
168 *   @note This value should be used for API argument @a notification
169 */
170 #define dccNOTIFICATION_ERROR 0x000000A0U
171 
172 
173 /** @enum dcc1clocksource
174 *   @brief Alias names for dcc clock sources
175 *
176 *   This enumeration is used to provide alias names for the clock sources:
177 */
178 enum dcc1clocksource
179 {
180     DCC1_CNT0_HF_LPO	= 0x5U,	/**< Alias for DCC1 CNT 0 CLOCK SOURCE 0*/
181 	DCC1_CNT0_TCK		= 0xAU,	/**< Alias for DCC1 CNT 0 CLOCK SOURCE 1*/
182 	DCC1_CNT0_OSCIN		= 0xFU,	/**< Alias for DCC1 CNT 0 CLOCK SOURCE 2*/
183 
184     DCC1_CNT1_PLL1		= 0x0U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 0*/
185     DCC1_CNT1_PLL2		= 0x1U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 1*/
186 	DCC1_CNT1_LF_LPO	= 0x2U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 2*/
187 	DCC1_CNT1_HF_LPO	= 0x3U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 3*/
188 	DCC1_CNT1_EXTCLKIN1 = 0x5U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 4*/
189 	DCC1_CNT1_EXTCLKIN2 = 0x6U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 6*/
190 	DCC1_CNT1_VCLK		= 0x8U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 8*/
191 	DCC1_CNT1_N2HET1_31	= 0xAU	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 9*/
192 };
193 
194 /** @enum dcc2clocksource
195 *   @brief Alias names for dcc clock sources
196 *
197 *   This enumeration is used to provide alias names for the clock sources:
198 */
199 enum dcc2clocksource
200 {
201     DCC2_CNT0_OSCIN		= 0xFU,	/**< Alias for DCC1 CNT 0 CLOCK SOURCE 0*/
202     DCC2_CNT0_TCK		= 0xAU,	/**< Alias for DCC1 CNT 0 CLOCK SOURCE 2*/
203 
204    	DCC2_CNT1_VCLK		= 0x8U,	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 8*/
205 	DCC2_CNT1_N2HET2_0	= 0xAU	/**< Alias for DCC1 CNT 1 CLOCK SOURCE 9*/
206 };
207 
208 /* Configuration registers */
209 typedef struct dcc_config_reg
210 {
211     uint32 CONFIG_GCTRL;
212     uint32 CONFIG_CNT0SEED;
213     uint32 CONFIG_VALID0SEED;
214     uint32 CONFIG_CNT1SEED;
215     uint32 CONFIG_CLKSRC1;
216     uint32 CONFIG_CLKSRC0;
217 } dcc_config_reg_t;
218 
219 /* Configuration registers initial value */
220 #define DCC1_GCTRL_CONFIGVALUE		0xAU | (0xAU << 4U) | (0x5U << 8U) | (0xAU << 12U)
221 #define DCC1_CNT0SEED_CONFIGVALUE	39204U
222 #define DCC1_VALID0SEED_CONFIGVALUE	792U
223 #define DCC1_CNT1SEED_CONFIGVALUE	495000U
224 #define DCC1_CLKSRC1_CONFIGVALUE	(10U << 12U) | DCC1_CNT1_PLL1
225 /*SAFETYMCUSW 79 S MR:19.4 <REVIEWED> "Macro filled using GUI parameter cannot be avoided" */
226 #define DCC1_CLKSRC0_CONFIGVALUE	DCC1_CNT0_OSCIN
227 
228 #define DCC2_GCTRL_CONFIGVALUE		0xAU | (0xAU << 4U) | (0x5U << 8U) | (0xAU << 12U)
229 #define DCC2_CNT0SEED_CONFIGVALUE	0U
230 #define DCC2_VALID0SEED_CONFIGVALUE	0U
231 #define DCC2_CNT1SEED_CONFIGVALUE	0U
232 #define DCC2_CLKSRC1_CONFIGVALUE	(0x5U << 12U) | DCC2_CNT1_VCLK
233 /*SAFETYMCUSW 79 S MR:19.4 <REVIEWED> "Macro filled using GUI parameter cannot be avoided" */
234 #define DCC2_CLKSRC0_CONFIGVALUE		DCC2_CNT0_OSCIN
235 
236 /**
237  *  @defgroup DCC DCC
238  *  @brief Dual-Clock Comparator Module
239  *
240  *  The primary purpose of a DCC module is to measure the frequency of a clock signal using a second
241  *  known clock signal as a reference. This capability can be used to ensure the correct frequency range for
242  *  several different device clock sources, thereby enhancing the system safety metrics.
243  *
244  *	Related Files
245  *   - reg_dcc.h
246  *   - dcc.h
247  *   - dcc.c
248  *  @addtogroup DCC
249  *  @{
250  */
251 
252 /* DCC Interface Functions */
253 void dccInit(void);
254 void dccSetCounter0Seed(dccBASE_t  *dcc, uint32 cnt0seed);
255 void dccSetTolerance(dccBASE_t  *dcc, uint32 valid0seed);
256 void dccSetCounter1Seed(dccBASE_t  *dcc, uint32 cnt1seed);
257 void dccSetSeed(dccBASE_t  *dcc, uint32 cnt0seed, uint32 valid0seed, uint32 cnt1seed);
258 void dccSelectClockSource(dccBASE_t  *dcc, uint32 cnt0_Clock_Source, uint32 cnt1_Clock_Source);
259 void dccEnable(dccBASE_t  *dcc);
260 void dccDisable(dccBASE_t  *dcc);
261 uint32 dccGetErrStatus(dccBASE_t  *dcc);
262 
263 void dccEnableNotification(dccBASE_t  *dcc, uint32 notification);
264 void dccDisableNotification(dccBASE_t  *dcc, uint32 notification);
265 void dcc1GetConfigValue(dcc_config_reg_t *config_reg, config_value_type_t type);
266 void dcc2GetConfigValue(dcc_config_reg_t *config_reg, config_value_type_t type);
267 /** @fn void dccNotification(dccBASE_t  *dcc,uint32 flags)
268 *   @brief Interrupt callback
269 *   @param[in] dcc   - dcc module base address
270 *   @param[in] flags - status flags
271 *
272 * This is a callback function provided by the application.  It is call when
273 * a dcc is complete or detected error.
274 */
275 void dccNotification(dccBASE_t  *dcc,uint32 flags);
276 
277 /**@}*/
278 #endif
279