iLLD_TC27xC
1.0
IfxCcu6_Icu.h
Go to the documentation of this file.
1
/**
2
* \file IfxCcu6_Icu.h
3
* \brief CCU6 ICU 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_Icu_Usage How to use the CCU6 ICU Interface driver?
26
* \ingroup IfxLld_Ccu6
27
*
28
* The ICU interface driver provides a default CCU6 configuration for capturing the input from the selected channel
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_Icu_Preparation Preparation
36
*
37
*
38
* \subsection IfxLld_Ccu6_Icu_Include Include Files
39
*
40
* Include following header file into your C code:
41
*
42
* \code
43
* #include <Ccu6/Icu/IfxCcu6_Icu.h>
44
* \endcode
45
*
46
* \subsection IfxLld_Ccu6_Icu_Variables Variables
47
*
48
* Declare the ICU handle and channel handle as global variables in your C code:
49
*
50
* \code
51
* // used globally
52
* static IfxCcu6_Icu icu;
53
* static IfxCcu6_IcuChannel icuChannel;
54
* \endcode
55
*
56
* \subsection IfxLld_Ccu6_Icu_Interrupt Interrupt Handler Installation
57
*
58
* See also \ref IfxLld_Cpu_Irq_Usage
59
*
60
* Define priority for the Interrrupt handler. This is normally done in the Ifx_IntPrioDef.h file:
61
*
62
* \code
63
* // priorities are normally defined in Ifx_IntPrioDef.h
64
* #define IFX_INTPRIO_CCU6 1
65
* \endcode
66
*
67
* Add the interrupt service routine to your C code.
68
*
69
* \code
70
* IFX_INTERRUPT(ccu60ISR_Icu, 0, IFX_INTPRIO_CCU6)
71
* {
72
* //user code
73
* }
74
* \endcode
75
*
76
* Finally install the interrupt handlers in your initialisation function:
77
*
78
* \code
79
* // install interrupt handlers
80
* IfxCpu_Irq_installInterruptHandler(&ccu60ISR_Icu, IFX_INTPRIO_CCU6);
81
* IfxCpu_enableInterrupts();
82
* \endcode
83
*
84
* \subsection IfxLld_Ccu6_Icu_Init Module Initialisation
85
*
86
* The module can be initialised in two ways, as a stand alone driver or in conjunction with Timer driver
87
* The module initialisation can be done in the same function. Here an example:
88
*
89
* \code
90
* // ---- when not using inconjunction with Timer driver ---- //
91
* // create configuration
92
* IfxCcu6_Icu_Config icuConfig;
93
* IfxCcu6_Icu_initModuleConfig(&icuConfig, &MODULE_CCU60);
94
*
95
* // configure the frequency of the timer in case of internal start
96
* icuConfig.frequency = 400000;
97
*
98
* // configure the period of the timer
99
* icuConfig.period = 100;
100
*
101
* // configure the clock for internal mode
102
* icuConfig.clock.extClockEnabled = FALSE;
103
* icuConfig.clock.extClockInput = NULL_PTR;
104
* icuConfig.clock.countingInputMode = IfxCcu6_CountingInputMode_internal;
105
*
106
* // configure count operation
107
* icuConfig.countMode = IfxCcu6_T12CountMode_edgeAligned;
108
* icuConfig.counterValue = 0;
109
*
110
* // initialize the module
111
* IfxCcu6_Icu_initModule(&icu, &icuConfig);
112
* // -------------------------------------------------------- //
113
*
114
* // ---- when not using inconjunction with Timer driver ---- //
115
* // after initialising the timer
116
* IfxCcu6_Timer timer;
117
* IfxCcu6_TimerConfig timerConfig;
118
* IfxCcu6_Timer_initModule(&timer, &timerConfig); // e.g. Timer 12 is specified previously in timerConfig.
119
* // -------------------------------------------------------- //
120
*
121
* // create Icu channel config
122
* IfxCcu6_Icu_channelConfig icuChannelConfig;
123
* IfxCcu6_Icu_initChannelConfig(&icuChannelConfig, &MODULE_CCU60);
124
*
125
* // ---- when using inconjunction with Timer driver ---- //
126
* icuChannelConfig.timer = (Timer*)&timer;
127
* // ---------------------------------------------------- //
128
*
129
* // configure the channel
130
* icuChannelConfig.channelNumber = IfxCcu6_T12Channel_0;
131
* icuChannelConfig.channelMode = IfxCcu6_T12ChannelMode_doubleRegisterCaptureRising;
132
*
133
* // configure the interrupts
134
* icuChannelConfig.interrupt.interruptSource = IfxCcu6_InterruptSource_cc60RisingEdge;
135
* icuChannelConfig.interrupt.serviceRequest = IfxCcu6_ServiceRequest_sR2;
136
* icuChannelConfig.interrupt.priority = IFX_INTRPRIO_CCU6;
137
* icuChannelConfig.interrupt.typeOfService = IfxSrc_Tos_cpu0;
138
*
139
* // ---- when not using inconjunction with Timer driver ---- //
140
* // configure input and output triggers
141
* icuChannelConfig.trigger.extInputTrigger = IfxCcu60_T12HRB_P00_7_IN;
142
* icuChannelConfig.trigger.extInputTriggerMode = IfxCcu6_ExternalTriggerMode_risingEdge;
143
* // -------------------------------------------------------- //
144
*
145
* // pin configuration, in case of multi input capture mode select the respective CC6xIn and CCPOSxIn pins of the selected channel
146
* const IfxCcu6_Icu_Pins pins = {
147
* IfxCcu60_CC60INA_P02_0_IN, // CC60In pin
148
* NULL, // CC61In pin not used
149
* NULL, // CC62In pin not used
150
* NULL, // CCPOS0In pin not used
151
* NULL, // CCPOS1In pin not used
152
* NULL, // CCPOS2In pin not used
153
* IfxPort_InputMode_pullUp,
154
* IfxPort_InputMode_pullUp
155
* };
156
* IcuConfig.pins = &pins;
157
*
158
* // configure multi input capture mode
159
* icuChannelConfig->multiInputCaptureEnabled = FALSE;
160
*
161
* // initialize the channel
162
* IfxCcu6_Icu_initChannel(&icuChannel, &icuChannelConfig);
163
* \endcode
164
*
165
*
166
* The Icu is ready for use now!
167
*
168
*
169
* \section IfxLld_Ccu6_Icu_Control Control
170
*
171
*
172
* The ICU driver provides simple to use Capture Control functions
173
*
174
* This means: you can start and stop the capture process, and you can also get a time stamp at any point of time during the capture process
175
*
176
* Start Capture
177
*
178
* \code
179
* IfxCcu6_Icu_startCapture(&icuChannel);
180
* \endcode
181
*
182
* Stop Capture
183
*
184
* \code
185
* IfxCcu6_Icu_stopCapture(&icuChannel);
186
* \endcode
187
*
188
* Get time stamp at any point of time during the capture process
189
* (can also be used in ISR)
190
*
191
* \code
192
* // assumed to be declared globally
193
* // uint32 timeStamp[100] = 0;
194
*
195
* // store the time stamp in an array
196
* timeStamp[i] = IfxCcu6_Icu_getTimeStamp(&icuChannel);
197
* \endcode
198
*
199
* \defgroup IfxLld_Ccu6_Icu Icu
200
* \ingroup IfxLld_Ccu6
201
* \defgroup IfxLld_Ccu6_Icu_DataStructures Data Structures
202
* \ingroup IfxLld_Ccu6_Icu
203
* \defgroup IfxLld_Ccu6_Icu_Module_Initialize_Functions Module Initialize Functions
204
* \ingroup IfxLld_Ccu6_Icu
205
* \defgroup IfxLld_Ccu6_Icu_Capture_Control_Functions Capture Control Functions
206
* \ingroup IfxLld_Ccu6_Icu
207
* \defgroup IfxLld_Ccu6_Icu_Channel_Initialize_Functions Channel Initialize Functions
208
* \ingroup IfxLld_Ccu6_Icu
209
*/
210
211
#ifndef IFXCCU6_ICU_H
212
#define IFXCCU6_ICU_H 1
213
214
/******************************************************************************/
215
/*----------------------------------Includes----------------------------------*/
216
/******************************************************************************/
217
218
#include "
Ccu6/Std/IfxCcu6.h
"
219
#include "
If/Ccu6If/Icu.h
"
220
#include "
Ccu6/Timer/IfxCcu6_Timer.h
"
221
222
/******************************************************************************/
223
/*-----------------------------Data Structures--------------------------------*/
224
/******************************************************************************/
225
226
/** \addtogroup IfxLld_Ccu6_Icu_DataStructures
227
* \{ */
228
/** \brief Structure for clock configuration
229
*/
230
typedef
struct
231
{
232
boolean
extClockEnabled
;
/**< \brief external clock enable / disable selection */
233
IfxCcu6_T12hr_In
*
extClockInput
;
/**< \brief External input signal selection for timer 12 */
234
IfxCcu6_CountingInputMode
countingInputMode
;
/**< \brief Input event leading to a counting action of the timer T12 */
235
}
IfxCcu6_Icu_Clock
;
236
237
/** \brief Structure for interrupt configuration
238
*/
239
typedef
struct
240
{
241
IfxCcu6_InterruptSource
interruptSource
;
/**< \brief Interrupt source selection */
242
IfxCcu6_ServiceRequest
serviceRequest
;
/**< \brief Selection of service request outputs */
243
uint16
priority
;
/**< \brief Interrupt priority */
244
IfxSrc_Tos
typeOfService
;
/**< \brief type of interrupt service */
245
}
IfxCcu6_Icu_InterruptConfig
;
246
247
/** \brief Structure for capture input pins
248
*/
249
typedef
struct
250
{
251
const
IfxCcu6_Cc60in_In
*
cc60In
;
/**< \brief CC60 input signal */
252
const
IfxCcu6_Cc61in_In
*
cc61In
;
/**< \brief CC61 input signal */
253
const
IfxCcu6_Cc62in_In
*
cc62In
;
/**< \brief CC62 input signal */
254
const
IfxCcu6_Ccpos0_In
*
ccpos0
;
/**< \brief CCPOS0 input signal */
255
const
IfxCcu6_Ccpos1_In
*
ccpos1
;
/**< \brief CCPOS2 input signal */
256
const
IfxCcu6_Ccpos2_In
*
ccpos2
;
/**< \brief CCPOS2 input signal */
257
IfxPort_InputMode
cc6xInputMode
;
/**< \brief The CC6x pin input mode which should be configured */
258
IfxPort_InputMode
ccposxInputMode
;
/**< \brief The CCPOSx pin input mode which should be configured */
259
const
IfxCcu6_T12hr_In
*
t12hr
;
/**< \brief T12HR input signal */
260
const
IfxCcu6_T13hr_In
*
t13hr
;
/**< \brief T13HR input signal */
261
IfxPort_InputMode
t1xhrInputMode
;
/**< \brief The T1xHR pin input mode which should be configured */
262
}
IfxCcu6_Icu_Pins
;
263
264
/** \brief Configuration structure for external triggers
265
*/
266
typedef
struct
267
{
268
IfxCcu6_T12hr_In
*
extInputTrigger
;
/**< \brief External input signal selection for timer */
269
IfxCcu6_ExternalTriggerMode
extInputTriggerMode
;
/**< \brief Event of signal T12HR that can set the run bit T12R by HW */
270
}
IfxCcu6_Icu_TriggerConfig
;
271
272
/** \} */
273
274
/** \addtogroup IfxLld_Ccu6_Icu_DataStructures
275
* \{ */
276
/** \brief Module handle
277
*/
278
typedef
struct
279
{
280
Ifx_CCU6 *
ccu6
;
/**< \brief Pointer to the base of CCU6 registers */
281
}
IfxCcu6_Icu
;
282
283
/** \brief Channel handle
284
*/
285
typedef
struct
286
{
287
Icu
base
;
/**< \brief Base ICU object */
288
Ifx_CCU6 *
ccu6
;
/**< \brief Pointer to the base of CCU6 registers */
289
IfxCcu6_Icu_TriggerConfig
trigger
;
/**< \brief Structure for trigger configuration */
290
IfxCcu6_T12Channel
channelId
;
/**< \brief Capture compare channel of the Timer12 */
291
IfxCcu6_T12ChannelMode
channelMode
;
/**< \brief The operating mode for the T12 channel */
292
IfxCcu6_Icu_InterruptConfig
interrupt
;
/**< \brief Structure for interrupt configuration */
293
}
IfxCcu6_Icu_Channel
;
294
295
/** \brief Configuration structure of the channel
296
*/
297
typedef
struct
298
{
299
Icu_Config
base
;
/**< \brief Base configuration */
300
Ifx_CCU6 *
ccu6
;
/**< \brief Pointer to the base of CCU6 registers */
301
IfxCcu6_T12Channel
channelId
;
/**< \brief Capture compare channel of the Timer12 */
302
IfxCcu6_T12ChannelMode
channelMode
;
/**< \brief The operating mode for the T12 channel */
303
IfxCcu6_Icu_InterruptConfig
interrupt
;
/**< \brief Structure for interrupt configuration */
304
IfxCcu6_Icu_TriggerConfig
trigger
;
/**< \brief Structure for trigger configuration */
305
IfxCcu6_Icu_Pins
*
pins
;
/**< \brief Structure for capture input pins */
306
boolean
multiInputCaptureEnabled
;
/**< \brief Choice of multi input capture */
307
IfxCcu6_Timer
timer
;
/**< \brief Timer handle */
308
}
IfxCcu6_Icu_ChannelConfig
;
309
310
/** \brief Configuration structure of the module
311
*/
312
typedef
struct
313
{
314
Ifx_CCU6 *
ccu6
;
/**< \brief Pointer to the base of CCU6 registers */
315
float32
frequency
;
/**< \brief Specify expected PWM frequency in Hertz */
316
Ifx_TimerValue
period
;
/**< \brief PWM period in ticks */
317
IfxCcu6_Icu_Clock
clock
;
/**< \brief Structure for clock configuration */
318
IfxCcu6_T12CountMode
countMode
;
/**< \brief Operating mode of Timer 12 */
319
uint16
counterValue
;
/**< \brief 16-bit counter value of Timer12 */
320
}
IfxCcu6_Icu_Config
;
321
322
/** \} */
323
324
/** \addtogroup IfxLld_Ccu6_Icu_Module_Initialize_Functions
325
* \{ */
326
327
/******************************************************************************/
328
/*-------------------------Global Function Prototypes-------------------------*/
329
/******************************************************************************/
330
331
/** \brief Initialises the module with default configuration
332
* \param icu Module handle
333
* \param config Configuration structure of the module
334
* \return None
335
*
336
* \code
337
* // create configuration
338
* IfxCcu6_Icu_Config icuConfig;
339
* IfxCcu6_Icu_initModuleConfig(&icuConfig, &MODULE_CCU60);
340
*
341
* // configure the frequency of the timer 12 in case of internal start
342
* icuConfig.frequency = 400000;
343
*
344
* // configure the period of the timer 12
345
* icuConfig.period = 100;
346
*
347
* // configure the clock for internal mode
348
* icuConfig.clock.extClockEnabled = FALSE;
349
* icuConfig.clock.extClockInput = NULL_PTR;
350
* icuConfig.clock.countingInputMode = IfxCcu6_CountingInputMode_internal;
351
*
352
* // configure count operation
353
* icuConfig.countMode = IfxCcu6_T12CountMode_edgeAligned;
354
* icuConfig.counterValue = 0;
355
*
356
* // initialize the module
357
* IfxCcu6_Icu_initModule(&icu, &icuConfig);
358
* \endcode
359
*
360
*/
361
IFX_EXTERN
void
IfxCcu6_Icu_initModule
(
IfxCcu6_Icu
*icu,
const
IfxCcu6_Icu_Config
*config);
362
363
/** \brief Fills the config structure with default values
364
* \param config Configuration structure of the module
365
* \param ccu6 Pointer to the base of CCU6 registers
366
* \return None
367
*
368
* A coding example can be found in \ref IfxCcu6_Icu_initModule
369
*
370
*/
371
IFX_EXTERN
void
IfxCcu6_Icu_initModuleConfig
(
IfxCcu6_Icu_Config
*config, Ifx_CCU6 *ccu6);
372
373
/** \} */
374
375
/** \addtogroup IfxLld_Ccu6_Icu_Capture_Control_Functions
376
* \{ */
377
378
/******************************************************************************/
379
/*-------------------------Global Function Prototypes-------------------------*/
380
/******************************************************************************/
381
382
/** \brief Returns the cuurent value stored in the Compare Shadow register (current time stamp)
383
* \param channel Channel handle
384
* \return timeStamp (cuurent CC6xSR register value)
385
*
386
* \code
387
* // assumed to be declared globally
388
* uint32 timeStamp[100] = 0;
389
*
390
* // store the time stamp in an array
391
* timeStamp[i] = IfxCcu6_Icu_getTimeStamp(&icuChannel);
392
* \endcode
393
*
394
*/
395
IFX_EXTERN
uint32
IfxCcu6_Icu_getTimeStamp
(
IfxCcu6_Icu_Channel
*channel);
396
397
/** \brief Starts the input capture
398
* \param channel Channel handle
399
* \return None
400
*
401
* \code
402
* IfxCcu6_Icu_startCapture(&icuChannel);
403
* \endcode
404
*
405
*/
406
IFX_EXTERN
void
IfxCcu6_Icu_startCapture
(
IfxCcu6_Icu_Channel
*channel);
407
408
/** \brief Stops the input capture
409
* \param channel Channel handle
410
* \return None
411
*
412
* \code
413
* IfxCcu6_Icu_stopCapture(&icuChannel);
414
* \endcode
415
*
416
*/
417
IFX_EXTERN
void
IfxCcu6_Icu_stopCapture
(
IfxCcu6_Icu_Channel
*channel);
418
419
/** \} */
420
421
/** \addtogroup IfxLld_Ccu6_Icu_Channel_Initialize_Functions
422
* \{ */
423
424
/******************************************************************************/
425
/*-------------------------Global Function Prototypes-------------------------*/
426
/******************************************************************************/
427
428
/** \brief Initialises the channel
429
* \param channel Channel handle
430
* \param channelConfig Configuration structure of the channel
431
* \return None
432
*
433
* \code
434
* //---- when using inconjunction with Timer driver ----//
435
* // after initialising the timer
436
* IfxCcu6_Timer timer;
437
* IfxCcu6_TimerConfig timerConfig;
438
* IfxCcu6_Timer_initModule(&timer, &timerConfig); // e.g. Timer 12 is specified previously in timerConfig.
439
* //----------------------------------------------------//
440
*
441
* // create Icu channel config
442
* IfxCcu6_Icu_channelConfig icuChannelConfig;
443
* IfxCcu6_Icu_initChannelConfig(&icuChannelConfig, &MODULE_CCU60);
444
*
445
* //---- when using inconjunction with Timer driver ----//
446
* icuChannelConfig.timer = (Timer*)&timer;
447
* //----------------------------------------------------//
448
*
449
* // configure the channel
450
* icuChannelConfig.channelNumber = IfxCcu6_T12Channel_0;
451
* icuChannelConfig.channelMode = IfxCcu6_T12ChannelMode_doubleRegisterCaptureRising;
452
*
453
* // configure the interrupts
454
* icuChannelConfig.interrupt.interruptSource = IfxCcu6_InterruptSource_cc60RisingEdge;
455
* icuChannelConfig.interrupt.serviceRequest = IfxCcu6_ServiceRequest_sR2;
456
* icuChannelConfig.interrupt.priority = IFX_INTRPRIO_CCU6;
457
* icuChannelConfig.interrupt.ypeOfService = IfxSrc_Tos_cpu0;
458
*
459
* //---- when not using inconjunction with Timer driver ----//
460
* // configure input and output triggers
461
* icuChannelConfig.trigger.extInputTrigger = IfxCcu60_T12HRB_P00_7_IN;
462
* icuChannelConfig.trigger.extInputTriggerMode = IfxCcu6_ExternalTriggerMode_risingEdge;
463
* //--------------------------------------------------------//
464
*
465
* // pin configuration, in case of multi input capture mode select the respective CC6xIn and CCPOSxIn pins of the selected channel
466
* const IfxCcu6_Icu_Pins pins = {
467
* IfxCcu60_CC60INA_P02_0_IN, // CC60In pin
468
* NULL, // CC61In pin not used
469
* NULL, // CC62In pin not used
470
* NULL, // CCPOS0In pin not used
471
* NULL, // CCPOS1In pin not used
472
* NULL, // CCPOS2In pin not used
473
* IfxPort_InputMode_pullUp,
474
* IfxPort_InputMode_pullUp
475
* };
476
* IcuConfig.pins = &pins;
477
*
478
* // configure multi input capture mode
479
* icuChannelConfig->multiInputCaptureEnabled = FALSE;
480
*
481
* // initialize the channel
482
* IfxCcu6_Icu_initChannel(&icuChannel, &icuChannelConfig);
483
* \endcode
484
*
485
*/
486
IFX_EXTERN
void
IfxCcu6_Icu_initChannel
(
IfxCcu6_Icu_Channel
*channel,
const
IfxCcu6_Icu_ChannelConfig
*channelConfig);
487
488
/** \brief Fills the channel config structure with default values
489
* \param channelConfig Configuration structure of the channel
490
* \param ccu6 Pointer to the base of CCU6 registers
491
* \return None
492
*
493
* A coding example can be found in \ref IfxCcu6_Icu_initChannel
494
*
495
*/
496
IFX_EXTERN
void
IfxCcu6_Icu_initChannelConfig
(
IfxCcu6_Icu_ChannelConfig
*channelConfig, Ifx_CCU6 *ccu6);
497
498
/** \} */
499
500
#endif
/* IFXCCU6_ICU_H */
home
mclld
Libraries
release
iLLD_0_1_0_10
src
ifx
TC27xC
Ccu6
Icu
IfxCcu6_Icu.h
Generated by
1.8.4