iLLD_TC27xD
1.0
IfxGtm_Atom_Pwm.c
Go to the documentation of this file.
1
/**
2
* \file IfxGtm_Atom_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_Atom_Pwm.h
"
30
31
/******************************************************************************/
32
/*-------------------------Function Implementations---------------------------*/
33
/******************************************************************************/
34
35
boolean
IfxGtm_Atom_Pwm_init
(
IfxGtm_Atom_Pwm_Driver
*driver,
IfxGtm_Atom_Pwm_Config
*config)
36
{
37
boolean
result =
TRUE
;
38
39
driver->
gtm
= config->
gtm
;
40
driver->
atomIndex
= config->
atom
;
41
42
Ifx_GTM_ATOM *atomSFR = &config->
gtm
->ATOM[config->
atom
];
43
driver->
atom
= atomSFR;
44
driver->
atomChannel
= config->
atomChannel
;
45
Ifx_GTM_ATOM_AGC *agc = &atomSFR->AGC;
46
driver->
agc
= agc;
47
48
/* Initialize the timer part */
49
if
(config->
synchronousUpdateEnabled
== 1)
50
{
51
IfxGtm_Atom_Agc_enableChannelUpdate
(agc, config->
atomChannel
,
TRUE
);
52
}
53
54
IfxGtm_Atom_Agc_setChannelForceUpdate
(agc, config->
atomChannel
,
TRUE
,
TRUE
);
55
IfxGtm_Atom_Agc_enableChannel
(agc, config->
atomChannel
,
TRUE
, config->
synchronousUpdateEnabled
== 0 ?
TRUE
:
FALSE
);
56
IfxGtm_Atom_Agc_enableChannelOutput
(agc, config->
atomChannel
,
TRUE
, config->
synchronousUpdateEnabled
== 0 ?
TRUE
: FALSE);
57
58
IfxGtm_Atom_Ch_setSignalLevel
(atomSFR, config->
atomChannel
, config->
signalLevel
);
59
60
IfxGtm_Atom_Ch_setMode
(atomSFR, config->
atomChannel
, config->
mode
);
61
62
if
(config->
pin
.
outputPin
!=
NULL_PTR
)
63
{
64
IfxGtm_PinMap_setAtomTout
(config->
pin
.
outputPin
, config->
pin
.
outputMode
, config->
pin
.
padDriver
);
65
}
66
67
// enable and initialise interrupts if chosen
68
if
((config->
interrupt
.
ccu0Enabled
== 1) || (config->
interrupt
.
ccu1Enabled
== 1))
69
{
70
IfxGtm_Atom_Ch_setNotification
(atomSFR, config->
atomChannel
, config->
interrupt
.
mode
, config->
interrupt
.
ccu0Enabled
, config->
interrupt
.
ccu1Enabled
);
71
72
volatile
Ifx_SRC_SRCR *src;
73
src =
IfxGtm_Atom_Ch_getSrcPointer
(config->
gtm
, config->
atom
, config->
atomChannel
);
74
IfxSrc_init
(src, config->
interrupt
.
isrProvider
, config->
interrupt
.
isrPriority
);
75
IfxSrc_enable
(src);
76
77
IfxCpu_enableInterrupts
();
78
}
79
80
if
(config->
synchronousUpdateEnabled
== 1)
81
{
82
IfxGtm_Atom_Ch_setCompareZeroShadow
(atomSFR, config->
atomChannel
, config->
period
);
83
IfxGtm_Atom_Ch_setCompareOneShadow
(atomSFR, config->
atomChannel
, config->
dutyCycle
);
84
IfxGtm_Atom_Agc_trigger
(driver->
agc
);
85
}
86
else
87
{
88
IfxGtm_Atom_Ch_setCompareZero
(atomSFR, config->
atomChannel
, config->
period
);
89
IfxGtm_Atom_Ch_setCompareOne
(atomSFR, config->
atomChannel
, config->
dutyCycle
);
90
}
91
92
return
result;
93
}
94
95
96
void
IfxGtm_Atom_Pwm_initConfig
(
IfxGtm_Atom_Pwm_Config
*config, Ifx_GTM *gtm)
97
{
98
config->
gtm
= gtm;
99
config->
atom
=
IfxGtm_Atom_0
;
100
config->
atomChannel
=
IfxGtm_Atom_Ch_0
;
101
config->
period
= 20;
102
config->
dutyCycle
= 10;
103
config->
signalLevel
=
Ifx_ActiveState_high
;
104
config->
mode
=
IfxGtm_Atom_Mode_outputPwm
;
105
config->
oneShotModeEnabled
=
FALSE
;
106
config->
synchronousUpdateEnabled
=
FALSE
;
107
config->
interrupt
.
ccu0Enabled
=
FALSE
;
108
config->
interrupt
.
ccu1Enabled
=
FALSE
;
109
config->
interrupt
.
mode
=
IfxGtm_IrqMode_pulseNotify
;
110
config->
interrupt
.
isrProvider
=
IfxSrc_Tos_cpu0
;
111
config->
interrupt
.
isrPriority
= 0;
112
config->
pin
.
outputPin
=
NULL_PTR
;
113
config->
pin
.
outputMode
=
IfxPort_OutputMode_pushPull
;
114
config->
pin
.
padDriver
=
IfxPort_PadDriver_cmosAutomotiveSpeed1
;
115
}
home
mclld
Libraries
release
iLLD_1_0_0_11_0
src
ifx
TC27xD
Gtm
Atom
Pwm
IfxGtm_Atom_Pwm.c
Generated by
1.8.4