1 /** @file het.h
2 *   @brief HET 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 
11 #ifndef __HET_H__
12 #define __HET_H__
13 
14 #include "reg_het.h"
15 #include <string.h>
16 
17 
18 
19 /* USER CODE BEGIN (0) */
20 /* USER CODE END */
21 
22 /** @def pwm0
23 *   @brief Pwm signal 0
24 *
25 *   Alias for pwm signal 0
26 */
27 #define pwm0 0U
28 
29 /** @def pwm1
30 *   @brief Pwm signal 1
31 *
32 *   Alias for pwm signal 1
33 */
34 #define pwm1 1U
35 
36 /** @def pwm2
37 *   @brief Pwm signal 2
38 *
39 *   Alias for pwm signal 2
40 */
41 #define pwm2 2U
42 
43 /** @def pwm3
44 *   @brief Pwm signal 3
45 *
46 *   Alias for pwm signal 3
47 */
48 #define pwm3 3U
49 
50 /** @def pwm4
51 *   @brief Pwm signal 4
52 *
53 *   Alias for pwm signal 4
54 */
55 #define pwm4 4U
56 
57 /** @def pwm5
58 *   @brief Pwm signal 5
59 *
60 *   Alias for pwm signal 5
61 */
62 #define pwm5 5U
63 
64 /** @def pwm6
65 *   @brief Pwm signal 6
66 *
67 *   Alias for pwm signal 6
68 */
69 #define pwm6 6U
70 
71 /** @def pwm7
72 *   @brief Pwm signal 7
73 *
74 *   Alias for pwm signal 7
75 */
76 #define pwm7 7U
77 
78 
79 /** @def edge0
80 *   @brief Edge signal 0
81 *
82 *   Alias for edge signal 0
83 */
84 #define edge0 0U
85 
86 /** @def edge1
87 *   @brief Edge signal 1
88 *
89 *   Alias for edge signal 1
90 */
91 #define edge1 1U
92 
93 /** @def edge2
94 *   @brief Edge signal 2
95 *
96 *   Alias for edge signal 2
97 */
98 #define edge2 2U
99 
100 /** @def edge3
101 *   @brief Edge signal 3
102 *
103 *   Alias for edge signal 3
104 */
105 #define edge3 3U
106 
107 /** @def edge4
108 *   @brief Edge signal 4
109 *
110 *   Alias for edge signal 4
111 */
112 #define edge4 4U
113 
114 /** @def edge5
115 *   @brief Edge signal 5
116 *
117 *   Alias for edge signal 5
118 */
119 #define edge5 5U
120 
121 /** @def edge6
122 *   @brief Edge signal 6
123 *
124 *   Alias for edge signal 6
125 */
126 #define edge6 6U
127 
128 /** @def edge7
129 *   @brief Edge signal 7
130 *
131 *   Alias for edge signal 7
132 */
133 #define edge7 7U
134 
135 
136 /** @def cap0
137 *   @brief Capture signal 0
138 *
139 *   Alias for capture signal 0
140 */
141 #define cap0 0U
142 
143 /** @def cap1
144 *   @brief Capture signal 1
145 *
146 *   Alias for capture signal 1
147 */
148 #define cap1 1U
149 
150 /** @def cap2
151 *   @brief Capture signal 2
152 *
153 *   Alias for capture signal 2
154 */
155 #define cap2 2U
156 
157 /** @def cap3
158 *   @brief Capture signal 3
159 *
160 *   Alias for capture signal 3
161 */
162 #define cap3 3U
163 
164 /** @def cap4
165 *   @brief Capture signal 4
166 *
167 *   Alias for capture signal 4
168 */
169 #define cap4 4U
170 
171 /** @def cap5
172 *   @brief Capture signal 5
173 *
174 *   Alias for capture signal 5
175 */
176 #define cap5 5U
177 
178 /** @def cap6
179 *   @brief Capture signal 6
180 *
181 *   Alias for capture signal 6
182 */
183 #define cap6 6U
184 
185 /** @def cap7
186 *   @brief Capture signal 7
187 *
188 *   Alias for capture signal 7
189 */
190 #define cap7 7U
191 
192 /** @def pwmEND_OF_DUTY
193 *   @brief Pwm end of duty
194 *
195 *   Alias for pwm end of duty notification
196 */
197 #define pwmEND_OF_DUTY 2U
198 
199 /** @def pwmEND_OF_PERIOD
200 *   @brief Pwm end of period
201 *
202 *   Alias for pwm end of period notification
203 */
204 #define pwmEND_OF_PERIOD 4U
205 
206 /** @def pwmEND_OF_BOTH
207 *   @brief Pwm end of duty and period
208 *
209 *   Alias for pwm end of duty and period notification
210 */
211 #define pwmEND_OF_BOTH 6U
212 
213 /* USER CODE BEGIN (1) */
214 /* USER CODE END */
215 
216 /** @struct hetBase
217 *   @brief HET Register Definition
218 *
219 *   This structure is used to access the HET module registers.
220 */
221 /** @typedef hetBASE_t
222 *   @brief HET Register Frame Type Definition
223 *
224 *   This type is used to access the HET Registers.
225 */
226 
227 enum hetPinSelect
228 {
229     PIN_HET_0 = 0U,
230     PIN_HET_1 = 1U,
231     PIN_HET_2 = 2U,
232     PIN_HET_3 = 3U,
233     PIN_HET_4 = 4U,
234     PIN_HET_5 = 5U,
235     PIN_HET_6 = 6U,
236     PIN_HET_7 = 7U,
237     PIN_HET_8 = 8U,
238     PIN_HET_9 = 9U,
239     PIN_HET_10 = 10U,
240     PIN_HET_11 = 11U,
241     PIN_HET_12 = 12U,
242     PIN_HET_13 = 13U,
243     PIN_HET_14 = 14U,
244     PIN_HET_15 = 15U,
245     PIN_HET_16 = 16U,
246     PIN_HET_17 = 17U,
247     PIN_HET_18 = 18U,
248     PIN_HET_19 = 19U,
249     PIN_HET_20 = 20U,
250     PIN_HET_21 = 21U,
251     PIN_HET_22 = 22U,
252     PIN_HET_23 = 23U,
253     PIN_HET_24 = 24U,
254     PIN_HET_25 = 25U,
255     PIN_HET_26 = 26U,
256     PIN_HET_27 = 27U,
257     PIN_HET_28 = 28U,
258     PIN_HET_29 = 29U,
259     PIN_HET_30 = 30U,
260     PIN_HET_31 = 31U
261 };
262 
263 
264 /** @struct hetInstructionBase
265 *   @brief HET Instruction Definition
266 *
267 *   This structure is used to access the HET RAM.
268 */
269 /** @typedef hetINSTRUCTION_t
270 *   @brief HET Instruction Type Definition
271 *
272 *   This type is used to access a HET Instruction.
273 */
274 typedef volatile struct hetInstructionBase
275 {
276     uint32 Program;
277     uint32 Control;
278     uint32 Data;
279     uint32   rsvd1;
280 } hetINSTRUCTION_t;
281 
282 
283 /** @struct hetRamBase
284 *   @brief HET RAM Definition
285 *
286 *   This structure is used to access the HET RAM.
287 */
288 /** @typedef hetRAMBASE_t
289 *   @brief HET RAM Type Definition
290 *
291 *   This type is used to access the HET RAM.
292 */
293 typedef volatile struct het1RamBase
294 {
295     hetINSTRUCTION_t Instruction[160U];
296 } hetRAMBASE_t;
297 
298 
299 /** @struct hetSignal
300 *   @brief HET Signal Definition
301 *
302 *   This structure is used to define a pwm signal.
303 */
304 /** @typedef hetSIGNAL_t
305 *   @brief HET Signal Type Definition
306 *
307 *   This type is used to access HET Signal Information.
308 */
309 typedef struct hetSignal
310 {
311 	uint32 duty;   /**< Duty cycle in % of the period  */
312 	float64   period; /**< Period in us                   */
313 } hetSIGNAL_t;
314 
315 /**
316  *  @defgroup HET HET
317  *  @brief Inter-Integrated Circuit Module.
318  *
319  *  The HET is a software-controlled timer with a dedicated specialized timer micromachine and a set of 30 instructions.
320  *  The HET micromachine is connected to a port of up to 32 input/output (I/O) pins.
321  *
322  *	Related Files
323  *   - reg_het.h
324  *   - het.h
325  *   - het.c
326  *   - reg_htu.h
327  *   - htu.h
328  *   - std_nhet.h
329  *  @addtogroup HET
330  *  @{
331  */
332 
333 /* HET Interface Functions */
334 void hetInit(void);
335 
336 /* PWM Interface Functions */
337 void        pwmStart(hetRAMBASE_t * hetRAM,uint32 pwm);
338 void        pwmStop(hetRAMBASE_t * hetRAM,uint32 pwm);
339 void        pwmSetDuty(hetRAMBASE_t * hetRAM,uint32 pwm, uint32 pwmDuty);
340 void        pwmSetSignal(hetRAMBASE_t * hetRAM,uint32 pwm, hetSIGNAL_t signal);
341 hetSIGNAL_t pwmGetSignal(hetRAMBASE_t * hetRAM,uint32 pwm);
342 void        pwmEnableNotification(hetBASE_t * hetREG,uint32 pwm, uint32 notification);
343 void        pwmDisableNotification(hetBASE_t * hetREG,uint32 pwm, uint32 notification);
344 void        pwmNotification(hetBASE_t * hetREG,uint32 pwm, uint32 notification);
345 
346 /* Edge Interface Functions */
347 void     edgeResetCounter(hetRAMBASE_t * hetRAM,uint32 edge);
348 uint32 edgeGetCounter(hetRAMBASE_t * hetRAM,uint32 edge);
349 void     edgeEnableNotification(hetBASE_t * hetREG,uint32 edge);
350 void     edgeDisableNotification(hetBASE_t * hetREG,uint32 edge);
351 void     edgeNotification(hetBASE_t * hetREG,uint32 edge);
352 
353 /* Captured Signal Interface Functions */
354 hetSIGNAL_t capGetSignal(hetRAMBASE_t * hetRAM,uint32 cap);
355 
356 /* Timestamp Interface Functions */
357 void     hetResetTimestamp(hetRAMBASE_t * hetRAM);
358 uint32 hetGetTimestamp(hetRAMBASE_t * hetRAM);
359 
360 /** @fn void hetNotification(hetBASE_t *het, uint32 offset)
361 *   @brief het interrupt callback
362 *   @param[in] het - Het module base address
363 *              - hetREG1: HET1 module base address pointer
364 *              - hetREG2: HET2 module base address pointer
365 *   @param[in] offset - het interrupt offset / Source number
366 *
367 *   @note This function has to be provide by the user.
368 *
369 * This is a interrupt callback that is provided by the application and is call upon
370 * an het interrupt.  The parameter passed to the callback is a copy of the interrupt
371 * offset register which is used to decode the interrupt source.
372 */
373 void hetNotification(hetBASE_t *het, uint32 offset);
374 
375 /**@}*/
376 /* USER CODE BEGIN (2) */
377 /* USER CODE END */
378 #endif
379