iLLD_TC27xC
1.0
IfxCcu6_Timer.h
Go to the documentation of this file.
1
/**
2
* \file IfxCcu6_Timer.h
3
* \brief CCU6 TIMER details
4
* \ingroup IfxLld_Ccu6
5
*
6
* \version iLLD_0_1_0_10
7
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8
*
9
*
10
* IMPORTANT NOTICE
11
*
12
*
13
* Infineon Technologies AG (Infineon) is supplying this file for use
14
* exclusively with Infineon's microcontroller products. This file can be freely
15
* distributed within development tools that are supporting such microcontroller
16
* products.
17
*
18
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21
* INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23
*
24
*
25
* \defgroup IfxLld_Ccu6_Timer_Usage How to use the CCU6 TIMER Interface driver?
26
* \ingroup IfxLld_Ccu6
27
*
28
* The TIMER interface driver provides a default CCU6 configuration for runnung the selected timer block.
29
*
30
* User can select the various configuration options that hardware allows
31
*
32
* In the following sections it will be described, how to integrate the driver into the application framework.
33
*
34
*
35
* \section IfxLld_Ccu6_Timer_Preparation Preparation
36
*
37
*
38
* \subsection IfxLld_Ccu6_Timer_Include Include Files
39
*
40
* Include following header file into your C code:
41
*
42
* \code
43
* #include <Ccu6/Timer/IfxCcu6_Timer.h>
44
* \endcode
45
*
46
* \subsection IfxLld_Ccu6_Timer_Variables Variables
47
*
48
* Declare the TIMER handle as global variable in your C code:
49
*
50
* \code
51
* // used globally
52
* static IfxCcu6_Timer timer;
53
* \endcode
54
*
55
* \subsection IfxLld_Ccu6_Timer_Interrupt Interrupt Handler Installation
56
*
57
* See also \ref IfxLld_Cpu_Irq_Usage
58
*
59
* Define priority for the Interrrupt handler. This is normally done in the Ifx_IntPrioDef.h file:
60
*
61
* \code
62
* // priorities are normally defined in Ifx_IntPrioDef.h
63
* #define IFX_INTPRIO_CCU6 1
64
* \endcode
65
*
66
* Add the interrupt service routine to your C code.
67
*
68
* \code
69
* IFX_INTERRUPT(ccu60ISR_Timer, 0, IFX_INTPRIO_CCU6)
70
* {
71
* //user code
72
* }
73
* \endcode
74
*
75
* Finally install the interrupt handlers in your initialisation function:
76
*
77
* \code
78
* // install interrupt handlers
79
* IfxCpu_Irq_installInterruptHandler(&ccu60ISR_Timer, IFX_INTPRIO_CCU6);
80
* IfxCpu_enableInterrupts();
81
* \endcode
82
*
83
* \subsection IfxLld_Ccu6_Timer_Init Module Initialisation
84
*
85
* The module initialisation can be done in the same function. Here an example:
86
*
87
* \code
88
* // create configuration
89
* IfxCcu6_Timer_Config timerConfig;
90
* IfxCcu6_Timer_initModuleConfig(&timerConfig, &MODULE_CCU60);
91
*
92
* // configure the frequency of the timer in case of internal start
93
* // this frequency will be set for the timer block selected later
94
* timerConfig.base.frequency = 400000;
95
*
96
* // configure the period of the timer
97
* timerConfig.base.period = 100;
98
*
99
* // configure the waiting time in case of delayed T13 start in sync with T12
100
* timerConfig.base.waitingTime = 0;
101
*
102
* // select the timer that needs to be started
103
* timerConfig.timer = IfxCcu6_TimerId_t12;
104
*
105
* // select the synchronous operation if both timers need to be start at the same time
106
* // previous selection of timer block can be ignored in this mode
107
* timerConfig.synchronousOperation = TRUE;
108
*
109
* // configure the clock for internal mode
110
* timerConfig.clock.t12ExtClockEnabled = FALSE;
111
* timerConfig.clock.t12ExtClockInput = NULL_PTR;
112
* timerConfig.clock.t12countingInputMode = IfxCcu6_CountingInputMode_internal;
113
*
114
* // configure the selcted timer block
115
* timerConfig.timer12.countMode = IfxCcu6_T12CountMode_edgeAligned;
116
* timerConfig.timer12.counterValue = 0;
117
*
118
* // configure the interrupts
119
* timerConfig.interrupt.interruptSource = IfxCcu6_InterruptSource_t12PeriodMatch;
120
* timerConfig.interrupt.serviceRequest = IfxCcu6_ServiceRequest_sR2;
121
* timerConfig.interrupt.priority = IFX_INTRPRIO_CCU6;
122
* timerConfig.interrupt.typeOfService = IfxSrc_Tos_cpu0;
123
*
124
* // configure input and output triggers
125
* timerConfig.trigger.t12ExtInputTrigger = IfxCcu60_T12HRB_P00_7_IN;
126
* timerConfig.trigger.t13ExtInputTrigger = NULL_PTR;
127
* timerConfig.trigger.extInputTriggerMode = IfxCcu6_ExternalTriggerMode_risingEdge;
128
* timerConfig.trigger.t13InSyncWithT12 = FALSE;
129
*
130
* // initialize the module
131
* IfxCcu6_Timer_initModule(&timer, &timerConfig);
132
* \endcode
133
*
134
*
135
* The Timer is ready for use now!
136
*
137
*
138
* \section IfxLld_Ccu6_Timer_Control Control
139
*
140
*
141
* The TIMER driver provides simple to use timer Control functions
142
*
143
* This means: In addition to start and stop a single timer, you can start and stop both the timer blocks at the same time
144
* you can also run the timer in single shot mode and finally you an manually make the timer count each step
145
*
146
* Start the timer
147
*
148
* \code
149
* IfxCcu6_Timer_start(&timer);
150
* \endcode
151
*
152
* Stop the timer
153
*
154
* \code
155
* IfxCcu6_Timer_stop(&timer);
156
* \endcode
157
*
158
* Start both the timers synchronously, when the synchronousOperation mode is selected in the configuration
159
*
160
* \code
161
* IfxCcu6_Timer_synchronousStart(&timer);
162
* \endcode
163
*
164
* Stop both the timers synchronously, when the synchronousOperation mode is selected in the configuration
165
*
166
* \code
167
* IfxCcu6_Timer_synchronousStop(&timer);
168
* \endcode
169
*
170
* Start the selected timer in single shot mode
171
*
172
* \code
173
* IfxCcu6_Timer_startSingleShotMode(&timer);
174
* \endcode
175
*
176
* Make the timer count each step manually
177
*
178
* \code
179
* uint8 i;
180
* for (i=0; i<50; i++)
181
* {
182
* IfxCcu6_Timer_countOneStep(&timer);
183
* }
184
* \endcode
185
*
186
* \defgroup IfxLld_Ccu6_Timer Timer
187
* \ingroup IfxLld_Ccu6
188
* \defgroup IfxLld_Ccu6_Timer_DataStructures Data Structures
189
* \ingroup IfxLld_Ccu6_Timer
190
* \defgroup IfxLld_Ccu6_Timer_Module_Initialize_Functions Module Initialize Functions
191
* \ingroup IfxLld_Ccu6_Timer
192
* \defgroup IfxLld_Ccu6_Timer_Timer_Control_Functions Timer Control Functions
193
* \ingroup IfxLld_Ccu6_Timer
194
*/
195
196
#ifndef IFXCCU6_TIMER_H
197
#define IFXCCU6_TIMER_H 1
198
199
/******************************************************************************/
200
/*----------------------------------Includes----------------------------------*/
201
/******************************************************************************/
202
203
#include "
Ccu6/Std/IfxCcu6.h
"
204
#include "
If/Ccu6If/Timer.h
"
205
206
/******************************************************************************/
207
/*-----------------------------Data Structures--------------------------------*/
208
/******************************************************************************/
209
210
/** \addtogroup IfxLld_Ccu6_Timer_DataStructures
211
* \{ */
212
/** \brief Structure for clock configuration
213
*/
214
typedef
struct
215
{
216
boolean
t12ExtClockEnabled
;
/**< \brief Timer 12 external clock enable / disable selection */
217
IfxCcu6_T12hr_In
*
t12ExtClockInput
;
/**< \brief External input signal selection for timer 12 */
218
IfxCcu6_CountingInputMode
t12countingInputMode
;
/**< \brief Input event leading to a counting action of the timer T12 */
219
boolean
t13ExtClockEnabled
;
/**< \brief Timer 13 external clock enable / disable selection */
220
IfxCcu6_T13hr_In
*
t13ExtClockInput
;
/**< \brief External input signal selection for timer 13 */
221
IfxCcu6_CountingInputMode
t13countingInputMode
;
/**< \brief Input event leading to a counting action of the timer T13 */
222
}
IfxCcu6_Timer_Clock
;
223
224
/** \brief Structure for interrupt configuration
225
*/
226
typedef
struct
227
{
228
IfxCcu6_InterruptSource
interruptSource
;
/**< \brief Interrupt source selection */
229
IfxCcu6_ServiceRequest
serviceRequest
;
/**< \brief Selection of service request outputs */
230
uint16
priority
;
/**< \brief Interrupt priority */
231
IfxSrc_Tos
typeOfService
;
/**< \brief type of interrupt service */
232
}
IfxCcu6_Timer_InterruptConfig
;
233
234
/** \brief Structure for Timer 12
235
*/
236
typedef
struct
237
{
238
IfxCcu6_T12CountMode
countMode
;
/**< \brief Operating mode of Timer 12 */
239
uint16
counterValue
;
/**< \brief 16-bit counter value of Timer12 */
240
}
IfxCcu6_Timer_Timer12
;
241
242
/** \brief Structure for Timer 13
243
*/
244
typedef
struct
245
{
246
uint16
counterValue
;
/**< \brief 16-bit counter value of Timer13 */
247
IfxCcu6_T13TriggerEvent
t12SyncEvent
;
/**< \brief T12 sync trigger event to start T13 */
248
IfxCcu6_T13TriggerDirection
t12SyncDirection
;
/**< \brief Additional information to control trigger event selection */
249
}
IfxCcu6_Timer_Timer13
;
250
251
/** \brief Configuration structure for external triggers
252
*/
253
typedef
struct
254
{
255
IfxCcu6_T12hr_In
*
t12ExtInputTrigger
;
/**< \brief External input signal selection for timer 12 */
256
IfxCcu6_T13hr_In
*
t13ExtInputTrigger
;
/**< \brief External input signal selection for timer 13 */
257
IfxCcu6_ExternalTriggerMode
extInputTriggerMode
;
/**< \brief Event of signal T1xHR that can set the run bit T1xR by HW */
258
boolean
t13InSyncWithT12
;
/**< \brief Selection of Timer 13 start in sync with T12 */
259
}
IfxCcu6_Timer_TriggerConfig
;
260
261
/** \} */
262
263
/** \brief Structure for CCU6 output pin configuration
264
*/
265
typedef
struct
266
{
267
const
IfxCcu6_T12hr_In
*
t12hr
;
/**< \brief T12HR input signal */
268
const
IfxCcu6_T13hr_In
*
t13hr
;
/**< \brief T13HR input signal */
269
IfxPort_InputMode
t1xhrInputMode
;
/**< \brief The T1xHR pin input mode which should be configured */
270
}
IfxCcu6_Timer_Pins
;
271
272
/** \addtogroup IfxLld_Ccu6_Timer_DataStructures
273
* \{ */
274
/** \brief Module handle
275
*/
276
typedef
struct
277
{
278
Timer
base
;
/**< \brief Base Timer object */
279
Ifx_CCU6 *
ccu6
;
/**< \brief Pointer to the base of CCU6 registers */
280
IfxCcu6_TimerId
timer
;
/**< \brief Timer number (T12 / T13) */
281
IfxCcu6_Timer_TriggerConfig
trigger
;
/**< \brief Structure for trigger configuration */
282
}
IfxCcu6_Timer
;
283
284
/** \brief Configuration structure of the module
285
*/
286
typedef
struct
287
{
288
Timer_Config
base
;
/**< \brief Base configuration */
289
Ifx_CCU6 *
ccu6
;
/**< \brief Pointer to the base of CCU6 registers */
290
IfxCcu6_TimerId
timer
;
/**< \brief Timer number (T12 / T13) */
291
boolean
synchronousOperation
;
/**< \brief Synchronous operation selection (starting / stopping both the timers at the same time) */
292
IfxCcu6_Timer_Clock
clock
;
/**< \brief Structure for clock configuration */
293
IfxCcu6_Timer_Timer12
timer12
;
/**< \brief Structure for Timer 12 */
294
IfxCcu6_Timer_Timer13
timer13
;
/**< \brief Structure for Timer 13 */
295
IfxCcu6_Timer_InterruptConfig
interrupt
;
/**< \brief Structure for interrupt configuration */
296
IfxCcu6_Timer_TriggerConfig
trigger
;
/**< \brief Structure for trigger configuration */
297
IfxCcu6_Timer_Pins
*
pins
;
/**< \brief Structure for CCU6 output pin configuration */
298
}
IfxCcu6_Timer_Config
;
299
300
/** \} */
301
302
/** \addtogroup IfxLld_Ccu6_Timer_Module_Initialize_Functions
303
* \{ */
304
305
/******************************************************************************/
306
/*-------------------------Global Function Prototypes-------------------------*/
307
/******************************************************************************/
308
309
/** \brief Initialises the module with default configuration
310
* \param timer Module handle
311
* \param config Configuration structure of the module
312
* \return None
313
*
314
* \code
315
* // create configuration
316
* IfxCcu6_Timer_Config timerConfig;
317
* IfxCcu6_Timer_initModuleConfig(&timerConfig, &MODULE_CCU60);
318
*
319
* // configure the frequency of the timer in case of internal start
320
* // this frequency will be set for the timer block selected later
321
* timerConfig.base.frequency = 400000;
322
*
323
* // configure the period of the timer
324
* timerConfig.base.period = 100;
325
*
326
* // configure the waiting time in case of delayed T13 start in sync with T12
327
* timerConfig.base.waitingTime = 0;
328
*
329
* // select the timer that needs to be started
330
* timerConfig.timer = IfxCcu6_TimerId_t12;
331
*
332
* // select the synchronous operation if both timers need to be start at the same time
333
* // previous selection of timer block can be ignored in this mode
334
* timerConfig.synchronousOperation = TRUE;
335
*
336
* // configure the clock for internal mode
337
* timerConfig.clock.t12ExtClockEnabled = FALSE;
338
* timerConfig.clock.t12ExtClockInput = NULL_PTR;
339
* timerConfig.clock.t12countingInputMode = IfxCcu6_CountingInputMode_internal;
340
*
341
* // configure the selcted timer block
342
* timerConfig.timer12.countMode = IfxCcu6_T12CountMode_edgeAligned;
343
* timerConfig.timer12.counterValue = 0;
344
*
345
* // configure the interrupts
346
* timerConfig.interrupt.interruptSource = IfxCcu6_InterruptSource_t12PeriodMatch;
347
* timerConfig.interrupt.serviceRequest = IfxCcu6_ServiceRequest_sR2;
348
* timerConfig.interrupt.priority = IFX_INTRPRIO_CCU6;
349
* timerConfig.interrupt.typeOfService = IfxSrc_Tos_cpu0;
350
*
351
* // configure input and output triggers
352
* timerConfig.trigger.t12ExtInputTrigger = IfxCcu60_T12HRB_P00_7_IN;
353
* timerConfig.trigger.t13ExtInputTrigger = NULL_PTR;
354
* timerConfig.trigger.extInputTriggerMode = IfxCcu6_ExternalTriggerMode_risingEdge;
355
* timerConfig.trigger.t13InSyncWithT12 = FALSE;
356
*
357
* // initialize the module
358
* IfxCcu6_Timer_initModule(&timer, &timerConfig);
359
* \endcode
360
*
361
*/
362
IFX_EXTERN
void
IfxCcu6_Timer_initModule
(
IfxCcu6_Timer
*timer,
const
IfxCcu6_Timer_Config
*config);
363
364
/** \brief Fills the config structure with default values
365
* \param config Configuration structure of the module
366
* \param ccu6 Pointer to the base of CCU6 registers
367
* \return None
368
*
369
* A coding example can be found in \ref IfxCcu6_Timer_initModule
370
*
371
*/
372
IFX_EXTERN
void
IfxCcu6_Timer_initModuleConfig
(
IfxCcu6_Timer_Config
*config, Ifx_CCU6 *ccu6);
373
374
/** \} */
375
376
/** \addtogroup IfxLld_Ccu6_Timer_Timer_Control_Functions
377
* \{ */
378
379
/******************************************************************************/
380
/*-------------------------Global Function Prototypes-------------------------*/
381
/******************************************************************************/
382
383
/** \brief Counts the timer one step
384
* \param timer Module handle
385
* \return None
386
*
387
* \code
388
* IfxCcu6_Timer_countOneStep(&timer);
389
* \endcode
390
*
391
*/
392
IFX_EXTERN
void
IfxCcu6_Timer_countOneStep
(
IfxCcu6_Timer
*timer);
393
394
/** \brief Starts the timer
395
* \param timer Module handle
396
* \return None
397
*
398
* \code
399
* IfxCcu6_Timer_start(&timer);
400
* \endcode
401
*
402
*/
403
IFX_EXTERN
void
IfxCcu6_Timer_start
(
IfxCcu6_Timer
*timer);
404
405
/** \brief Starts the single shot mode of the timer
406
* \param timer Module handle
407
* \return None
408
*
409
* \code
410
* IfxCcu6_Timer_startSingleShotMode(&timer);
411
* \endcode
412
*
413
*/
414
IFX_EXTERN
void
IfxCcu6_Timer_startSingleShotMode
(
IfxCcu6_Timer
*timer);
415
416
/** \brief Stops the timer
417
* \param timer Module handle
418
* \return None
419
*
420
* \code
421
* IfxCcu6_Timer_stop(&timer);
422
* \endcode
423
*
424
*/
425
IFX_EXTERN
void
IfxCcu6_Timer_stop
(
IfxCcu6_Timer
*timer);
426
427
/** \brief Starts both the timers together
428
* \param timer Module handle
429
* \return None
430
*
431
* \code
432
* IfxCcu6_Timer_synchronousStart(&timer);
433
* \endcode
434
*
435
*/
436
IFX_EXTERN
void
IfxCcu6_Timer_synchronousStart
(
IfxCcu6_Timer
*timer);
437
438
/** \brief Starts both the timers together
439
* \param timer Module handle
440
* \return None
441
*
442
* \code
443
* IfxCcu6_Timer_synchronousStop(&timer);
444
* \endcode
445
*
446
*/
447
IFX_EXTERN
void
IfxCcu6_Timer_synchronousStop
(
IfxCcu6_Timer
*timer);
448
449
/** \} */
450
451
#endif
/* IFXCCU6_TIMER_H */
home
mclld
Libraries
release
iLLD_0_1_0_10
src
ifx
TC27xC
Ccu6
Timer
IfxCcu6_Timer.h
Generated by
1.8.4