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 
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  {
52  }
53 
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  {
65  }
66 
67  // enable and initialise interrupts if chosen
68  if ((config->interrupt.ccu0Enabled == 1) || (config->interrupt.ccu1Enabled == 1))
69  {
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 
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);
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 
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;
105  config->oneShotModeEnabled = FALSE;
107  config->interrupt.ccu0Enabled = FALSE;
108  config->interrupt.ccu1Enabled = FALSE;
111  config->interrupt.isrPriority = 0;
112  config->pin.outputPin = NULL_PTR;
115 }