]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/rpp/include/sys/ti_drv_dcc.h
9f6c72e932bd781ad887bacaf5a570d7ede93b16
[pes-rpp/rpp-test-sw.git] / rpp / lib / rpp / include / sys / ti_drv_dcc.h
1 /** @file dcc.h
2 *   @brief DCC Driver Definition File
3 *   @date 15.Mar.2012
4 *   @version 03.01.00
5 *
6 */
7
8 /* (c) Texas Instruments 2009-2012, All rights reserved. */
9
10
11 #ifndef __DCC_H__
12 #define __DCC_H__
13
14 #include "base.h"
15
16 /* DCC General Definitions */
17
18 /** @def dcc1CNT0_CLKSRC_HFLPO
19 *   @brief Alias name for DCC1 Counter 0 Clock Source HFLPO
20 *
21 *   This is an alias name for the Clock Source HFLPO for DCC1 Counter 0.
22 *
23 *   @note This value should be used for API argument @a cnt0_Clock_Source
24 */
25 #define dcc1CNT0_CLKSRC_HFLPO 0x00000005U
26
27 /** @def dcc1CNT0_CLKSRC_TCK
28 *   @brief Alias name for DCC1 Counter 0 Clock Source TCK
29 *
30 *   This is an alias name for the Clock Source TCK for DCC1 Counter 0.
31 *
32 *   @note This value should be used for API argument @a cnt0_Clock_Source
33 */
34 #define dcc1CNT0_CLKSRC_TCK 0x0000000AU
35
36 /** @def dcc1CNT0_CLKSRC_OSCIN
37 *   @brief Alias name for DCC1 Counter 0 Clock Source OSCIN
38 *
39 *   This is an alias name for the Clock Source OSCIN for DCC1 Counter 0.
40 *
41 *   @note This value should be used for API argument @a cnt0_Clock_Source
42 */
43 #define dcc1CNT0_CLKSRC_OSCIN 0x0000000FU
44
45 /** @def dcc1CNT1_CLKSRC_PLL1
46 *   @brief Alias name for DCC1 Counter 1 Clock Source PLL1
47 *
48 *   This is an alias name for the Clock Source PLL for DCC1 Counter 1.
49 *
50 *   @note This value should be used for API argument @a cnt1_Clock_Source
51 */
52 #define dcc1CNT1_CLKSRC_PLL1 0x0000A0000U
53
54 /** @def dcc1CNT1_CLKSRC_PLL2
55 *   @brief Alias name for DCC1 Counter 1 Clock Source PLL2
56 *
57 *   This is an alias name for the Clock Source OSCIN for DCC1 Counter 1.
58 *
59 *   @note This value should be used for API argument @a cnt1_Clock_Source
60 */
61 #define dcc1CNT1_CLKSRC_PLL2 0x0000A0001U
62
63 /** @def dcc1CNT1_CLKSRC_LFLPO
64 *   @brief Alias name for DCC1 Counter 1 Clock Source LFLPO
65 *
66 *   This is an alias name for the Clock Source LFLPO for DCC1 Counter 1.
67 *
68 *   @note This value should be used for API argument @a cnt1_Clock_Source
69 */
70 #define dcc1CNT1_CLKSRC_LFLPO 0x0000A0002U
71
72 /** @def dcc1CNT1_CLKSRC_HFLPO
73 *   @brief Alias name for DCC1 Counter 1 Clock Source HFLPO
74 *
75 *   This is an alias name for the Clock Source HFLPO for DCC1 Counter 1.
76 *
77 *   @note This value should be used for API argument @a cnt1_Clock_Source
78 */
79 #define dcc1CNT1_CLKSRC_HFLPO 0x0000A0003U
80
81 /** @def dcc1CNT1_CLKSRC_EXTCLKIN1
82 *   @brief Alias name for DCC1 Counter 1 Clock Source EXTCLKIN1
83 *
84 *   This is an alias name for the Clock Source EXTCLKIN1 for DCC1 Counter 1.
85 *
86 *   @note This value should be used for API argument @a cnt1_Clock_Source
87 */
88 #define dcc1CNT1_CLKSRC_EXTCLKIN1 0x0000A0005U
89
90 /** @def dcc1CNT1_CLKSRC_EXTCLKIN2
91 *   @brief Alias name for DCC1 Counter 1 Clock Source EXTCLKIN2
92 *
93 *   This is an alias name for the Clock Source EXTCLKIN2 for DCC1 Counter 1.
94 *
95 *   @note This value should be used for API argument @a cnt1_Clock_Source
96 */
97 #define dcc1CNT1_CLKSRC_EXTCLKIN2 0x0000A0006U
98
99 /** @def dcc1CNT1_CLKSRC_VCLK
100 *   @brief Alias name for DCC1 Counter 1 Clock Source VCLK
101 *
102 *   This is an alias name for the Clock Source VCLK for DCC1 Counter 1.
103 *
104 *   @note This value should be used for API argument @a cnt1_Clock_Source
105 */
106 #define dcc1CNT1_CLKSRC_VCLK 0x0000A0008U
107
108 /** @def dcc1CNT1_CLKSRC_N2HET1_31
109 *   @brief Alias name for DCC1 Counter 1 Clock Source N2HET1_31
110 *
111 *   This is an alias name for the Clock Source N2HET1_31 for DCC1 Counter 1.
112 *
113 *   @note This value should be used for API argument @a cnt1_Clock_Source
114 */
115 #define dcc1CNT1_CLKSRC_N2HET1_31 0x00005000FU
116
117 /** @def dcc2CNT0_CLKSRC_TCK
118 *   @brief Alias name for DCC2 Counter 0 Clock Source TCK
119 *
120 *   This is an alias name for the Clock Source TCK for DCC2 Counter 0.
121 *
122 *   @note This value should be used for API argument @a cnt0_Clock_Source
123 */
124 #define dcc2CNT0_CLKSRC_TCK 0x0000000AU
125
126 /** @def dcc1CNT0_CLKSRC_OSCIN
127 *   @brief Alias name for DCC1 Counter 0 Clock Source OSCIN
128 *
129 *   This is an alias name for the Clock Source OSCIN for DCC2 Counter 0.
130 *
131 *   @note This value should be used for API argument @a cnt0_Clock_Source
132 */
133 #define dcc2CNT0_CLKSRC_OSCIN 0x0000000FU
134
135 /** @def dcc2CNT1_CLKSRC_VCLK
136 *   @brief Alias name for DCC2 Counter 1 Clock Source VCLK
137 *
138 *   This is an alias name for the Clock Source VCLK for DCC2 Counter 1.
139 *
140 *   @note This value should be used for API argument @a cnt1_Clock_Source
141 */
142 #define dcc2CNT1_CLKSRC_VCLK 0x0000A0008U
143
144 /** @def dcc2CNT1_CLKSRC_N2HET1_0
145 *   @brief Alias name for DCC2 Counter 1 Clock Source N2HET2_0
146 *
147 *   This is an alias name for the Clock Source N2HET2_0 for DCC2 Counter 1.
148 *
149 *   @note This value should be used for API argument @a cnt1_Clock_Source
150 */
151 #define dcc2CNT1_CLKSRC_N2HET1_0 0x00005000FU
152
153 /** @def dccNOTIFICATION_DONE
154 *   @brief Alias name for DCC Done notification
155 *
156 *   This is an alias name for the DCC Done notification.
157 *
158 *   @note This value should be used for API argument @a notification
159 */
160 #define dccNOTIFICATION_DONE 0x0000A000U
161
162 /** @def dccNOTIFICATION_ERROR
163 *   @brief Alias name for DCC Error notification
164 *
165 *   This is an alias name for the DCC Error notification.
166 *
167 *   @note This value should be used for API argument @a notification
168 */
169 #define dccNOTIFICATION_ERROR 0x000000A0U
170
171
172 /** @enum dcc1clocksource
173 *   @brief Alias names for dcc clock sources
174 *
175 *   This enumeration is used to provide alias names for the clock sources:
176 */
177 enum dcc1clocksource
178 {
179     DCC1_CNT0_HF_LPO    = 0x5,  /**< Alias for DCC1 CNT 0 CLOCK SOURCE 0*/
180     DCC1_CNT0_TCK       = 0xA,  /**< Alias for DCC1 CNT 0 CLOCK SOURCE 1*/
181     DCC1_CNT0_OSCIN     = 0xF,  /**< Alias for DCC1 CNT 0 CLOCK SOURCE 2*/
182
183     DCC1_CNT1_PLL1      = 0x0,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 0*/
184     DCC1_CNT1_PLL2      = 0x1,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 1*/
185     DCC1_CNT1_LF_LPO    = 0x2,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 2*/
186     DCC1_CNT1_HF_LPO    = 0x3,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 3*/
187     DCC1_CNT1_EXTCLKIN1 = 0x5,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 4*/
188     DCC1_CNT1_EXTCLKIN2 = 0x6,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 6*/
189     DCC1_CNT1_VCLK      = 0x8,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 8*/
190     DCC1_CNT1_N2HET1_31 = 0xA   /**< Alias for DCC1 CNT 1 CLOCK SOURCE 9*/
191 };
192
193 /** @enum dcc2clocksource
194 *   @brief Alias names for dcc clock sources
195 *
196 *   This enumeration is used to provide alias names for the clock sources:
197 */
198 enum dcc2clocksource
199 {
200     DCC2_CNT0_OSCIN     = 0xF,  /**< Alias for DCC1 CNT 0 CLOCK SOURCE 0*/
201     DCC2_CNT0_TCK       = 0xA,  /**< Alias for DCC1 CNT 0 CLOCK SOURCE 2*/
202
203     DCC2_CNT1_VCLK      = 0x8,  /**< Alias for DCC1 CNT 1 CLOCK SOURCE 8*/
204     DCC2_CNT1_N2HET2_0  = 0xA   /**< Alias for DCC1 CNT 1 CLOCK SOURCE 9*/
205 };
206
207 /** @struct dccBase
208 *   @brief DCC Base Register Definition
209 *
210 *   This structure is used to access the DCC module egisters.
211 */
212 /** @typedef dccBASE_t
213 *   @brief DCC Register Frame Type Definition
214 *
215 *   This type is used to access the DCC Registers.
216 */
217 typedef volatile struct dccBase
218 {
219     uint32_t GCTRL;         /**< 0x0000: DCC Control Register       */
220     uint32_t REV;           /**< 0x0004: DCC Revision Id Register   */
221     uint32_t CNT0SEED;      /**< 0x0008: DCC Counter0 Seed Register */
222     uint32_t VALID0SEED;    /**< 0x000C: DCC Valid0 Seed Register   */
223     uint32_t CNT1SEED;      /**< 0x0010: DCC Counter1 Seed Register     */
224     uint32_t STAT;          /**< 0x0014: DCC Status Register        */
225     uint32_t CNT0;          /**< 0x0018: DCC Counter0 Value Register    */
226     uint32_t VALID0;        /**< 0x001C: DCC Valid0 Value Register  */
227     uint32_t CNT1;          /**< 0x0020: DCC Counter1 Value Register    */
228     uint32_t CLKSRC1;       /**< 0x0024: DCC Counter1 Clock Source Selection Register   */
229     uint32_t CLKSRC0;       /**< 0x0028: DCC Counter0 Clock Source Selection Register   */
230 } dccBASE_t;
231
232
233 /** @def dccREG1
234 *   @brief DCC1 Register Frame Pointer
235 *
236 *   This pointer is used by the DCC driver to access the dcc2 module registers.
237 */
238 #define dccREG1   ((dccBASE_t *)0xFFFFEC00U)
239
240
241 /** @def dccREG2
242 *   @brief DCC2 Register Frame Pointer
243 *
244 *   This pointer is used by the DCC driver to access the dcc2 module registers.
245 */
246 #define dccREG2   ((dccBASE_t *)0xFFFFF400U)
247
248
249 /* DCC Interface Functions */
250 void dccInit(void);
251 void dccSetCounter0Seed(dccBASE_t  *dcc, uint32_t cnt0seed);
252 void dccSetTolerance(dccBASE_t  *dcc, uint32_t valid0seed);
253 void dccSetCounter1Seed(dccBASE_t  *dcc, uint32_t cnt1seed);
254 void dccSetSeed(dccBASE_t  *dcc, uint32_t cnt0seed, uint32_t valid0seed, uint32_t cn1seed);
255 void dccSelectClockSource(dccBASE_t  *dcc, uint32_t cnt0_Clock_Source, uint32_t cnt1_Clock_Source);
256 void dccEnable(dccBASE_t  *dcc);
257 void dccDisable(dccBASE_t  *dcc);
258 uint32_t dccGetErrStatus(dccBASE_t  *dcc);
259
260 void dccEnableNotification(dccBASE_t  *dcc, uint32_t notification);
261 void dccDisableNotification(dccBASE_t  *dcc, uint32_t notification);
262
263 /** @fn void dccNotification(dccBASE_t  *dcc,uint32_t flags)
264 *   @brief Interrupt callback
265 *   @param[in] dcc   - dcc module base address
266 *   @param[in] flags - status flags
267 *
268 * This is a callback function provided by the application.  It is call when
269 * a dcc is complete or detected error.
270 */
271 void dccNotification(dccBASE_t  *dcc,uint32_t flags);
272
273 #endif