iLLD_TC27xD
1.0
IfxGtm_Tom_Pwm.c
Go to the documentation of this file.
1
/**
2
* \file IfxGtm_Tom_Pwm.c
3
* \brief GTM PWM details
4
*
5
* \version iLLD_1_0_0_11_0
6
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
7
*
8
*
9
* IMPORTANT NOTICE
10
*
11
*
12
* Infineon Technologies AG (Infineon) is supplying this file for use
13
* exclusively with Infineon's microcontroller products. This file can be freely
14
* distributed within development tools that are supporting such microcontroller
15
* products.
16
*
17
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20
* INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
21
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22
*
23
*/
24
25
/******************************************************************************/
26
/*----------------------------------Includes----------------------------------*/
27
/******************************************************************************/
28
29
#include "
IfxGtm_Tom_Pwm.h
"
30
31
/******************************************************************************/
32
/*-------------------------Function Implementations---------------------------*/
33
/******************************************************************************/
34
35
boolean
IfxGtm_Tom_Pwm_init
(
IfxGtm_Tom_Pwm_Driver
*driver,
IfxGtm_Tom_Pwm_Config
*config)
36
{
37
boolean
result =
TRUE
;
38
39
driver->
gtm
= config->
gtm
;
40
driver->
tomIndex
= config->
tom
;
41
42
Ifx_GTM_TOM *tomSFR = &config->
gtm
->TOM[config->
tom
];
43
driver->
tom
= tomSFR;
44
driver->
tomChannel
= config->
tomChannel
;
45
46
if
(config->
tomChannel
<= 7)
47
{
48
driver->
tgc
[0] =
IfxGtm_Tom_Ch_getTgcPointer
(driver->
tom
, 0);
49
driver->
tgc
[1] =
IfxGtm_Tom_Ch_getTgcPointer
(driver->
tom
, 1);
50
}
51
else
52
{
53
driver->
tgc
[0] =
IfxGtm_Tom_Ch_getTgcPointer
(driver->
tom
, 1);
54
driver->
tgc
[1] =
NULL_PTR
;
/* NOTE currently no concatenation between TOMs */
55
}
56
57
/* Initialize the timer part */
58
if
(config->
synchronousUpdateEnabled
== 1)
59
{
60
IfxGtm_Tom_Tgc_enableChannelUpdate
(driver->
tgc
[0], config->
tomChannel
,
TRUE
);
61
}
62
63
IfxGtm_Tom_Ch_setClockSource
(tomSFR, config->
tomChannel
, config->
clock
);
64
65
IfxGtm_Tom_Tgc_setChannelForceUpdate
(driver->
tgc
[0], config->
tomChannel
,
TRUE
,
TRUE
);
66
IfxGtm_Tom_Tgc_enableChannel
(driver->
tgc
[0], config->
tomChannel
,
TRUE
, config->
synchronousUpdateEnabled
== 0 ?
TRUE
:
FALSE
);
67
IfxGtm_Tom_Tgc_enableChannelOutput
(driver->
tgc
[0], config->
tomChannel
,
TRUE
, config->
synchronousUpdateEnabled
== 0 ?
TRUE
: FALSE);
68
69
IfxGtm_Tom_Ch_setSignalLevel
(tomSFR, config->
tomChannel
, config->
signalLevel
);
70
71
if
(config->
pin
.
outputPin
!=
NULL_PTR
)
72
{
73
IfxGtm_PinMap_setTomTout
(config->
pin
.
outputPin
, config->
pin
.
outputMode
, config->
pin
.
padDriver
);
74
}
75
76
// enable and initialise interrupts if chosen
77
if
((config->
interrupt
.
ccu0Enabled
== 1) || (config->
interrupt
.
ccu1Enabled
== 1))
78
{
79
IfxGtm_Tom_Ch_setNotification
(tomSFR, config->
tomChannel
, config->
interrupt
.
mode
, config->
interrupt
.
ccu0Enabled
, config->
interrupt
.
ccu1Enabled
);
80
81
volatile
Ifx_SRC_SRCR *src;
82
src =
IfxGtm_Tom_Ch_getSrcPointer
(config->
gtm
, config->
tom
, config->
tomChannel
);
83
IfxSrc_init
(src, config->
interrupt
.
isrProvider
, config->
interrupt
.
isrPriority
);
84
IfxSrc_enable
(src);
85
86
IfxCpu_enableInterrupts
();
87
}
88
89
if
(config->
synchronousUpdateEnabled
== 1)
90
{
91
IfxGtm_Tom_Ch_setCompareZeroShadow
(tomSFR, config->
tomChannel
, config->
period
);
92
IfxGtm_Tom_Ch_setCompareOneShadow
(tomSFR, config->
tomChannel
, config->
dutyCycle
);
93
IfxGtm_Tom_Tgc_trigger
(driver->
tgc
[0]);
94
}
95
else
96
{
97
IfxGtm_Tom_Ch_setCompareZero
(tomSFR, config->
tomChannel
, config->
period
);
98
IfxGtm_Tom_Ch_setCompareOne
(tomSFR, config->
tomChannel
, config->
dutyCycle
);
99
}
100
101
return
result;
102
}
103
104
105
void
IfxGtm_Tom_Pwm_initConfig
(
IfxGtm_Tom_Pwm_Config
*config, Ifx_GTM *gtm)
106
{
107
config->
gtm
= gtm;
108
config->
tom
=
IfxGtm_Tom_0
;
109
config->
tomChannel
=
IfxGtm_Tom_Ch_0
;
110
config->
clock
=
IfxGtm_Tom_Ch_ClkSrc_cmuFxclk0
;
111
config->
period
= 20;
112
config->
dutyCycle
= 10;
113
config->
signalLevel
=
Ifx_ActiveState_high
;
114
config->
oneShotModeEnabled
=
FALSE
;
115
config->
synchronousUpdateEnabled
=
FALSE
;
116
config->
interrupt
.
ccu0Enabled
=
FALSE
;
117
config->
interrupt
.
ccu1Enabled
=
FALSE
;
118
config->
interrupt
.
mode
=
IfxGtm_IrqMode_pulseNotify
;
119
config->
interrupt
.
isrProvider
=
IfxSrc_Tos_cpu0
;
120
config->
interrupt
.
isrPriority
= 0;
121
config->
pin
.
outputPin
=
NULL_PTR
;
122
config->
pin
.
outputMode
=
IfxPort_OutputMode_pushPull
;
123
config->
pin
.
padDriver
=
IfxPort_PadDriver_cmosAutomotiveSpeed1
;
124
}
home
mclld
Libraries
release
iLLD_1_0_0_11_0
src
ifx
TC27xD
Gtm
Tom
Pwm
IfxGtm_Tom_Pwm.c
Generated by
1.8.4