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 
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  {
61  }
62 
63  IfxGtm_Tom_Ch_setClockSource(tomSFR, config->tomChannel, config->clock);
64 
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  {
74  }
75 
76  // enable and initialise interrupts if chosen
77  if ((config->interrupt.ccu0Enabled == 1) || (config->interrupt.ccu1Enabled == 1))
78  {
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 
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 
106 {
107  config->gtm = gtm;
108  config->tom = IfxGtm_Tom_0;
109  config->tomChannel = IfxGtm_Tom_Ch_0;
111  config->period = 20;
112  config->dutyCycle = 10;
114  config->oneShotModeEnabled = FALSE;
116  config->interrupt.ccu0Enabled = FALSE;
117  config->interrupt.ccu1Enabled = FALSE;
120  config->interrupt.isrPriority = 0;
121  config->pin.outputPin = NULL_PTR;
124 }