iLLD_TC27xD  1.0
IfxGpt12.c
Go to the documentation of this file.
1 /**
2  * \file IfxGpt12.c
3  * \brief GPT12 basic functionality
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 "IfxGpt12.h"
30 
31 /******************************************************************************/
32 /*-------------------------Function Implementations---------------------------*/
33 /******************************************************************************/
34 
36 {
38 
39  IfxGpt12_Mode mode;
41 
42  IfxGpt12_Gpt1BlockPrescaler bps1 = gpt12->T3CON.B.BPS1;
43 
44  switch (bps1)
45  {
47  freq = freq / 4;
48  break;
50  freq = freq / 8;
51  break;
53  freq = freq / 16;
54  break;
55  default: /* case IfxGpt12_Gpt1BlockPrescaler_32: */
56  freq = freq / 32;
57  break;
58  }
59 
60  mode = IfxGpt12_T2_getMode(gpt12);
61  prescaler = (IfxGpt12_TimerInputPrescaler)gpt12->T2CON.B.T2I;
62 
64  {
65  freq = freq / (1 << prescaler);
66  }
67  else // FIXME:
68  {
69  freq = freq / 2;
70  }
71 
72  return freq;
73 }
74 
75 
77 {
79 
80  IfxGpt12_Mode mode;
82 
83  IfxGpt12_Gpt1BlockPrescaler bps1 = gpt12->T3CON.B.BPS1;
84 
85  switch (bps1)
86  {
88  freq = freq / 4;
89  break;
91  freq = freq / 8;
92  break;
94  freq = freq / 16;
95  break;
96  default: /* case IfxGpt12_Gpt1BlockPrescaler_32: */
97  freq = freq / 32;
98  break;
99  }
100 
101  mode = (IfxGpt12_Mode)gpt12->T3CON.B.T3M;
102  prescaler = (IfxGpt12_TimerInputPrescaler)gpt12->T3CON.B.T3I;
103 
104  if ((mode == IfxGpt12_Mode_timer) || (mode == IfxGpt12_Mode_highGatedTimer) || (mode == IfxGpt12_Mode_lowGatedTimer))
105  {
106  freq = freq / (1 << prescaler);
107  }
108  else // FIXME:
109  {
110  freq = freq / 2;
111  }
112 
113  return freq;
114 }
115 
116 
118 {
119  float32 freq = IfxGpt12_getModuleFrequency(gpt12);
120 
121  IfxGpt12_Mode mode;
123 
124  IfxGpt12_Gpt1BlockPrescaler bps1 = gpt12->T3CON.B.BPS1;
125 
126  switch (bps1)
127  {
129  freq = freq / 4;
130  break;
132  freq = freq / 8;
133  break;
135  freq = freq / 16;
136  break;
137  default: /* case IfxGpt12_Gpt1BlockPrescaler_32: */
138  freq = freq / 32;
139  break;
140  }
141 
142  mode = (IfxGpt12_Mode)gpt12->T4CON.B.T4M;
143  prescaler = (IfxGpt12_TimerInputPrescaler)gpt12->T4CON.B.T4I;
144 
145  if ((mode == IfxGpt12_Mode_timer) || (mode == IfxGpt12_Mode_highGatedTimer) || (mode == IfxGpt12_Mode_lowGatedTimer))
146  {
147  freq = freq / (1 << prescaler);
148  }
149  else // FIXME:
150  {
151  freq = freq / 2;
152  }
153 
154  return freq;
155 }
156 
157 
159 {
160  float32 freq = IfxGpt12_getModuleFrequency(gpt12);
161 
162  IfxGpt12_Mode mode;
164 
165  IfxGpt12_Gpt2BlockPrescaler bps2 = gpt12->T6CON.B.BPS2;
166 
167  switch (bps2)
168  {
170  freq = freq / 2;
171  break;
173  freq = freq / 4;
174  break;
176  freq = freq / 8;
177  break;
178  default: /* case IfxGpt12_Gpt2BlockPrescaler_16: */
179  freq = freq / 16;
180  break;
181  }
182 
183  mode = (IfxGpt12_Mode)gpt12->T5CON.B.T5M;
184  prescaler = (IfxGpt12_TimerInputPrescaler)gpt12->T5CON.B.T5I;
185 
186  if ((mode == IfxGpt12_Mode_timer) || (mode == IfxGpt12_Mode_highGatedTimer) || (mode == IfxGpt12_Mode_lowGatedTimer))
187  {
188  freq = freq / (1 << prescaler);
189  }
190  else // FIXME:
191  {
192  freq = freq / 2;
193  }
194 
195  return freq;
196 }
197 
198 
200 {
201  float32 freq = IfxGpt12_getModuleFrequency(gpt12);
202 
203  IfxGpt12_Mode mode;
205 
206  IfxGpt12_Gpt2BlockPrescaler bps2 = gpt12->T6CON.B.BPS2;
207 
208  switch (bps2)
209  {
211  freq = freq / 2;
212  break;
214  freq = freq / 4;
215  break;
217  freq = freq / 8;
218  break;
219  default: /* case IfxGpt12_Gpt2BlockPrescaler_16: */
220  freq = freq / 16;
221  break;
222  }
223 
224  mode = (IfxGpt12_Mode)gpt12->T6CON.B.T6M;
225  prescaler = (IfxGpt12_TimerInputPrescaler)gpt12->T6CON.B.T6I;
226 
227  if ((mode == IfxGpt12_Mode_timer) || (mode == IfxGpt12_Mode_highGatedTimer) || (mode == IfxGpt12_Mode_lowGatedTimer))
228  {
229  freq = freq / (1 << prescaler);
230  }
231  else // FIXME:
232  {
233  freq = freq / 2;
234  }
235 
236  return freq;
237 }
238 
239 
240 void IfxGpt12_enableModule(Ifx_GPT12 *gpt12)
241 {
244  gpt12->CLC.B.DISR = 0;
246 }
247 
248 
250 {
251  IfxPort_setPinModeInput(txEudIn->pin.port, txEudIn->pin.pinIndex, inputMode);
252 
253  switch (txEudIn->timer)
254  {
255  case 2:
257  break;
258  case 3:
260  break;
261  case 4:
263  break;
264  case 5:
266  break;
267  case 6:
269  break;
270  default:
271  break;
272  }
273 }
274 
275 
277 {
278  IfxPort_setPinModeInput(txIn->pin.port, txIn->pin.pinIndex, inputMode);
279 
280  switch (txIn->timer)
281  {
282  case 2:
284  break;
285  case 3:
287  break;
288  case 4:
290  break;
291  case 5:
293  break;
294  case 6:
296  break;
297  default:
298  break;
299  }
300 }
301 
302 
303 void IfxGpt12_resetModule(Ifx_GPT12 *gpt12)
304 {
306 
308  gpt12->KRST0.B.RST = 1; /* Only if both Kernel reset bits are set a reset is executed */
309  gpt12->KRST1.B.RST = 1;
310  IfxScuWdt_setCpuEndinit(passwd);
311 
312  while (0 == gpt12->KRST0.B.RSTSTAT) /* Wait until reset is executed */
313 
314  {}
315 
317  gpt12->KRSTCLR.B.CLR = 1; /* Clear Kernel reset status bit */
318  IfxScuWdt_setCpuEndinit(passwd);
319 }