]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/rpp/include/sys/ti_drv_het.h
Yet another place to fix
[pes-rpp/rpp-test-sw.git] / rpp / lib / rpp / include / sys / ti_drv_het.h
1 /** @file het.h
2 *   @brief HET 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 __HET_H__
12 #define __HET_H__
13
14 #include "base.h"
15 #include "sys/ti_drv_gio.h"
16 #include <string.h>
17
18 /* USER CODE BEGIN (0) */
19 /* USER CODE END */
20
21 /** @def pwm0
22 *   @brief Pwm signal 0
23 *
24 *   Alias for pwm signal 0
25 */
26 #define pwm0 0U
27
28 /** @def pwm1
29 *   @brief Pwm signal 1
30 *
31 *   Alias for pwm signal 1
32 */
33 #define pwm1 1U
34
35 /** @def pwm2
36 *   @brief Pwm signal 2
37 *
38 *   Alias for pwm signal 2
39 */
40 #define pwm2 2U
41
42 /** @def pwm3
43 *   @brief Pwm signal 3
44 *
45 *   Alias for pwm signal 3
46 */
47 #define pwm3 3U
48
49 /** @def pwm4
50 *   @brief Pwm signal 4
51 *
52 *   Alias for pwm signal 4
53 */
54 #define pwm4 4U
55
56 /** @def pwm5
57 *   @brief Pwm signal 5
58 *
59 *   Alias for pwm signal 5
60 */
61 #define pwm5 5U
62
63 /** @def pwm6
64 *   @brief Pwm signal 6
65 *
66 *   Alias for pwm signal 6
67 */
68 #define pwm6 6U
69
70 /** @def pwm7
71 *   @brief Pwm signal 7
72 *
73 *   Alias for pwm signal 7
74 */
75 #define pwm7 7U
76
77
78 /** @def edge0
79 *   @brief Edge signal 0
80 *
81 *   Alias for edge signal 0
82 */
83 #define edge0 0U
84
85 /** @def edge1
86 *   @brief Edge signal 1
87 *
88 *   Alias for edge signal 1
89 */
90 #define edge1 1U
91
92 /** @def edge2
93 *   @brief Edge signal 2
94 *
95 *   Alias for edge signal 2
96 */
97 #define edge2 2U
98
99 /** @def edge3
100 *   @brief Edge signal 3
101 *
102 *   Alias for edge signal 3
103 */
104 #define edge3 3U
105
106 /** @def edge4
107 *   @brief Edge signal 4
108 *
109 *   Alias for edge signal 4
110 */
111 #define edge4 4U
112
113 /** @def edge5
114 *   @brief Edge signal 5
115 *
116 *   Alias for edge signal 5
117 */
118 #define edge5 5U
119
120 /** @def edge6
121 *   @brief Edge signal 6
122 *
123 *   Alias for edge signal 6
124 */
125 #define edge6 6U
126
127 /** @def edge7
128 *   @brief Edge signal 7
129 *
130 *   Alias for edge signal 7
131 */
132 #define edge7 7U
133
134
135 /** @def cap0
136 *   @brief Capture signal 0
137 *
138 *   Alias for capture signal 0
139 */
140 #define cap0 0U
141
142 /** @def cap1
143 *   @brief Capture signal 1
144 *
145 *   Alias for capture signal 1
146 */
147 #define cap1 1U
148
149 /** @def cap2
150 *   @brief Capture signal 2
151 *
152 *   Alias for capture signal 2
153 */
154 #define cap2 2U
155
156 /** @def cap3
157 *   @brief Capture signal 3
158 *
159 *   Alias for capture signal 3
160 */
161 #define cap3 3U
162
163 /** @def cap4
164 *   @brief Capture signal 4
165 *
166 *   Alias for capture signal 4
167 */
168 #define cap4 4U
169
170 /** @def cap5
171 *   @brief Capture signal 5
172 *
173 *   Alias for capture signal 5
174 */
175 #define cap5 5U
176
177 /** @def cap6
178 *   @brief Capture signal 6
179 *
180 *   Alias for capture signal 6
181 */
182 #define cap6 6U
183
184 /** @def cap7
185 *   @brief Capture signal 7
186 *
187 *   Alias for capture signal 7
188 */
189 #define cap7 7U
190
191 /** @def pwmEND_OF_DUTY
192 *   @brief Pwm end of duty
193 *
194 *   Alias for pwm end of duty notification
195 */
196 #define pwmEND_OF_DUTY 2U
197
198 /** @def pwmEND_OF_PERIOD
199 *   @brief Pwm end of period
200 *
201 *   Alias for pwm end of period notification
202 */
203 #define pwmEND_OF_PERIOD 4U
204
205 /** @def pwmEND_OF_BOTH
206 *   @brief Pwm end of duty and period
207 *
208 *   Alias for pwm end of duty and period notification
209 */
210 #define pwmEND_OF_BOTH 6U
211
212 /* USER CODE BEGIN (1) */
213 /* USER CODE END */
214
215 /** @struct hetBase
216 *   @brief HET Register Definition
217 *
218 *   This structure is used to access the HET module egisters.
219 */
220 /** @typedef hetBASE_t
221 *   @brief HET Register Frame Type Definition
222 *
223 *   This type is used to access the HET Registers.
224 */
225
226 enum hetPinSelect
227 {
228     PIN_HET_0 = 0,
229     PIN_HET_1 = 1,
230     PIN_HET_2 = 2,
231     PIN_HET_3 = 3,
232     PIN_HET_4 = 4,
233     PIN_HET_5 = 5,
234     PIN_HET_6 = 6,
235     PIN_HET_7 = 7,
236     PIN_HET_8 = 8,
237     PIN_HET_9 = 9,
238     PIN_HET_10 = 10,
239     PIN_HET_11 = 11,
240     PIN_HET_12 = 12,
241     PIN_HET_13 = 13,
242     PIN_HET_14 = 14,
243     PIN_HET_15 = 15,
244     PIN_HET_16 = 16,
245     PIN_HET_17 = 17,
246     PIN_HET_18 = 18,
247     PIN_HET_19 = 19,
248     PIN_HET_20 = 20,
249     PIN_HET_21 = 21,
250     PIN_HET_22 = 22,
251     PIN_HET_23 = 23,
252     PIN_HET_24 = 24,
253     PIN_HET_25 = 25,
254     PIN_HET_26 = 26,
255     PIN_HET_27 = 27,
256     PIN_HET_28 = 28,
257     PIN_HET_29 = 29,
258     PIN_HET_30 = 30,
259     PIN_HET_31 = 31
260 };
261
262 /** @struct hetBase
263 *   @brief HET Base Register Definition
264 *
265 *   This structure is used to access the HET module egisters.
266 */
267 /** @typedef hetBASE_t
268 *   @brief HET Register Frame Type Definition
269 *
270 *   This type is used to access the HET Registers.
271 */
272
273 typedef volatile struct hetBase
274 {
275     uint32_t GCR;     /**< 0x0000: Global control register              */
276     uint32_t PFR;     /**< 0x0004: Prescale factor register             */
277     uint32_t ADDR;    /**< 0x0008: Current address register             */
278     uint32_t OFF1;    /**< 0x000C: Interrupt offset register 1          */
279     uint32_t OFF2;    /**< 0x0010: Interrupt offset register 2          */
280     uint32_t INTENAS; /**< 0x0014: Interrupt enable set register        */
281     uint32_t INTENAC; /**< 0x0018: Interrupt enable clear register      */
282     uint32_t EXC1;    /**< 0x001C: Exeption control register 1          */
283     uint32_t EXC2;    /**< 0x0020: Exeption control register 2          */
284     uint32_t PRY;     /**< 0x0024: Interrupt priority register          */
285     uint32_t FLG;     /**< 0x0028: Interrupt flag register              */
286     uint32_t AND;     /**< 0x002C: AND share control register         */
287     uint32_t : 32U;   /**< 0x0030: Reserved                             */
288     uint32_t HRSH;    /**< 0x0034: High resoltion share register        */
289     uint32_t XOR;     /**< 0x0038: XOR share register                   */
290     uint32_t REQENS;  /**< 0x003C: Request enable set register          */
291     uint32_t REQENC;  /**< 0x0040: Request enable clear register        */
292     uint32_t REQDS;   /**< 0x0044: Request destination select register  */
293     uint32_t : 32U;   /**< 0x0048: Reserved                             */
294     uint32_t DIR;     /**< 0x004C: Direction register                   */
295     uint32_t DIN;     /**< 0x0050: Data input register                  */
296     uint32_t DOUT;    /**< 0x0054: Data output register                 */
297     uint32_t DSET;    /**< 0x0058: Data output set register             */
298     uint32_t DCLR;    /**< 0x005C: Data output clear register           */
299     uint32_t PDR;     /**< 0x0060: Open drain register                  */
300     uint32_t PULDIS;  /**< 0x0064: Pull disable register                */
301     uint32_t PSL;     /**< 0x0068: Pull select register                 */
302     uint32_t : 32U;   /**< 0x006C: Reserved                             */
303     uint32_t : 32U;   /**< 0x0070: Reserved                             */
304     uint32_t PCREG;   /**< 0x0074: Parity control register              */
305     uint32_t PAR;     /**< 0x0078: Parity address register              */
306     uint32_t PPR;     /**< 0x007C: Parity pin select register           */
307     uint32_t SFPRLD;  /**< 0x0080: Suppression filter preload register  */
308     uint32_t SFENA;   /**< 0x0084: Suppression filter enable register   */
309     uint32_t : 32U;   /**< 0x0088: Reserved                             */
310     uint32_t LBPSEL;  /**< 0x008C: Loop back pair select register       */
311     uint32_t LBPDIR;  /**< 0x0090: Loop back pair direction register    */
312     uint32_t PINDIS;  /**< 0x0094: Pin disable register                 */
313     uint32_t : 32U;   /**< 0x0098: Reserved                             */
314     uint32_t HWAPINSEL;/**< 0x009C: HWAG Pin select register            */
315     uint32_t HWAGCR0;  /**< 0x00A0: HWAG Global control register 0      */
316     uint32_t HWAGCR1;  /**< 0x00A4: HWAG Global control register 1      */
317     uint32_t HWAGCR2;  /**< 0x00A8: HWAG Global control register 2      */
318     uint32_t HWAENASET;/**< 0x00AC: HWAG Interrupt enable set register  */
319     uint32_t HWAENACLR;/**< 0x00B0: HWAG Interrupt enable clear register*/
320     uint32_t HWALVLSET;/**< 0x00B4: HWAG Interrupt level set register   */
321     uint32_t HWALVLCLR;/**< 0x00B8: HWAG Interrupt level clear register */
322     uint32_t HWAFLG;   /**< 0x00BC: HWAG Interrupt flag register        */
323     uint32_t HWAOFF1;  /**< 0x00C0: HWAG Interrupt offset 1 register    */
324     uint32_t HWAOFF2;  /**< 0x00C4: HWAG Interrupt offset 2 register    */
325     uint32_t HWAACNT;  /**< 0x00C8: HWAG Angle value register           */
326     uint32_t HWAPCNT1; /**< 0x00CC: HWAG Period value register 1        */
327     uint32_t HWAPCNT;  /**< 0x00D0: HWAG Period value register          */
328     uint32_t HWASTWD;  /**< 0x00D4: HWAG Step width register            */
329     uint32_t HWATHNB;  /**< 0x00D8: HWAG Teeth number register          */
330     uint32_t HWATHVL;  /**< 0x00DC: HWAG Teeth Value register           */
331     uint32_t HWAFIL;   /**< 0x00E0: HWAG Filter register                */
332     uint32_t : 32U;    /**< 0x00E4: Reserved                            */
333     uint32_t HWAFIL2;  /**< 0x00E8: HWAG Second filter register         */
334     uint32_t : 32U;    /**< 0x00EC: Reserved                            */
335     uint32_t HWAANGI;  /**< 0x00F0: HWAG Angle increment register       */
336 } hetBASE_t;
337
338
339 /** @def hetREG1
340 *   @brief HET Register Frame Pointer
341 *
342 *   This pointer is used by the HET driver to access the het module registers.
343 */
344 #define hetREG1 ((hetBASE_t *)0xFFF7B800U)
345
346
347 /** @def hetPORT1
348 *   @brief HET GIO Port Register Pointer
349 *
350 *   Pointer used by the GIO driver to access I/O PORT of HET1
351 *   (use the GIO drivers to access the port pins).
352 */
353 #define hetPORT1 ((gioPORT_t *)0xFFF7B84CU)
354
355
356 /** @def hetREG2
357 *   @brief HET2 Register Frame Pointer
358 *
359 *   This pointer is used by the HET driver to access the het module registers.
360 */
361 #define hetREG2 ((hetBASE_t *)0xFFF7B900U)
362
363
364 /** @def hetPORT2
365 *   @brief HET2 GIO Port Register Pointer
366 *
367 *   Pointer used by the GIO driver to access I/O PORT of HET2
368 *   (use the GIO drivers to access the port pins).
369 */
370 #define hetPORT2 ((gioPORT_t *)0xFFF7B94CU)
371
372
373
374 /** @struct hetInstructionBase
375 *   @brief HET Instruction Definition
376 *
377 *   This structure is used to access the HET RAM.
378 */
379 /** @typedef hetINSTRUCTION_t
380 *   @brief HET Instruction Type Definition
381 *
382 *   This type is used to access a HET Instruction.
383 */
384 typedef volatile struct hetInstructionBase
385 {
386     uint32_t Program;
387     uint32_t Control;
388     uint32_t Data;
389     uint32_t   rsvd1;
390 } hetINSTRUCTION_t;
391
392
393 /** @struct hetRamBase
394 *   @brief HET RAM Definition
395 *
396 *   This structure is used to access the HET RAM.
397 */
398 /** @typedef hetRAMBASE_t
399 *   @brief HET RAM Type Definition
400 *
401 *   This type is used to access the HET RAM.
402 */
403 typedef volatile struct het1RamBase
404 {
405     hetINSTRUCTION_t Instruction[160U];
406 } hetRAMBASE_t;
407
408
409 #define hetRAM1 ((hetRAMBASE_t *)0xFF460000U)
410
411 #define hetRAM2 ((hetRAMBASE_t *)0xFF440000U)
412
413 #define NHET1RAMPARLOC  (*(unsigned int *)0xFF462000U)
414 #define NHET1RAMLOC     (*(unsigned int *)0xFF460000U)
415
416 #define NHET2RAMPARLOC  (*(unsigned int *)0xFF442000U)
417 #define NHET2RAMLOC     (*(unsigned int *)0xFF440000U)
418
419 /** @struct hetSignal
420 *   @brief HET Signal Definition
421 *
422 *   This structure is used to define a pwm signal.
423 */
424 /** @typedef hetSIGNAL_t
425 *   @brief HET Signal Type Definition
426 *
427 *   This type is used to access HET Signal Information.
428 */
429 typedef struct hetSignal
430 {
431     uint32_t duty;   /**< Duty cycle in % of the period  */
432     double   period; /**< Period in us                   */
433 } hetSIGNAL_t;
434
435
436 /* HET Interface Functions */
437 void hetInit(void);
438
439 /* PWM Interface Functions */
440 void        pwmStart(hetRAMBASE_t * hetRAM,uint32_t pwm);
441 void        pwmStop(hetRAMBASE_t * hetRAM,uint32_t pwm);
442 void        pwmSetDuty(hetRAMBASE_t * hetRAM,uint32_t pwm, uint32_t duty);
443 void        pwmSetSignal(hetRAMBASE_t * hetRAM,uint32_t pwm, hetSIGNAL_t signal);
444 hetSIGNAL_t pwmGetSignal(hetRAMBASE_t * hetRAM,uint32_t pwm);
445 void        pwmEnableNotification(hetBASE_t * hetREG,uint32_t pwm, uint32_t notification);
446 void        pwmDisableNotification(hetBASE_t * hetREG,uint32_t pwm, uint32_t notification);
447 void        pwmNotification(hetBASE_t * hetREG,uint32_t pwm, uint32_t notification);
448
449 /* Edge Interface Functions */
450 void     edgeResetCounter(hetRAMBASE_t * hetRAM,uint32_t edge);
451 uint32_t edgeGetCounter(hetRAMBASE_t * hetRAM,uint32_t edge);
452 void     edgeEnableNotification(hetBASE_t * hetREG,uint32_t edge);
453 void     edgeDisableNotification(hetBASE_t * hetREG,uint32_t edge);
454 void     edgeNotification(hetBASE_t * hetREG,uint32_t edge);
455
456 /* Captured Signal Interface Functions */
457 hetSIGNAL_t capGetSignal(hetRAMBASE_t * hetRAM,uint32_t cap);
458
459 /* Timestamp Interface Functions */
460 void     hetResetTimestamp(hetRAMBASE_t * hetRAM);
461 uint32_t hetGetTimestamp(hetRAMBASE_t * hetRAM);
462
463 /** @fn void hetNotification(hetBASE_t *het, uint32_t offset)
464 *   @brief het interrupt callback
465 *   @param[in] het - Het module base address
466 *              - hetREG1: HET1 module base address pointer
467 *              - hetREG2: HET2 module base address pointer
468 *   @param[in] offset - het interrupt offset / Source number
469 *
470 *   @note This function has to be provide by the user.
471 *
472 * This is a interrupt callback that is provided by the application and is call upon
473 * an het interrupt.  The paramer passed to the callback is a copy of the interrupt
474 * offset register which is used to decode the interrupt source.
475 */
476 void hetNotification(hetBASE_t *het, uint32_t offset);
477
478 /* USER CODE BEGIN (3) */
479 /* USER CODE END */
480
481 #endif